This commit is contained in:
Putoo
2026-07-07 18:43:01 +08:00
parent 7f29fd46b8
commit 037e845622
37 changed files with 854 additions and 106 deletions

View File

@@ -18,10 +18,11 @@ public class FightController : ControllerBase
private readonly IUnitUserAccService _accService;
private readonly IGameGoodsService _goodsService;
private readonly IUnitUserService _userService;
private readonly IOnHookService _hookService;
public FightController(IGameFightService fightService, IGameMonsterService monsterService,
IUnitUserAttrService attrService, IGameMapService mapService, IUnitUserAccService accService,
IGameGoodsService goodsService, IUnitUserService userService)
IGameGoodsService goodsService, IUnitUserService userService,IOnHookService hookService)
{
_fightService = fightService;
_monsterService = monsterService;
@@ -30,6 +31,7 @@ public class FightController : ControllerBase
_accService = accService;
_goodsService = goodsService;
_userService = userService;
_hookService = hookService;
}
/// <summary>
@@ -99,6 +101,7 @@ public class FightController : ControllerBase
copper, petExp, award, pars);
if (result)
{
await _hookService.StopOnHook(userId);
return PoAction.Ok(fightId);
}
else
@@ -398,8 +401,6 @@ public class FightController : ControllerBase
public async Task<IPoAction> GetFightMsg(string fightId)
{
string userId = StateHelper.userId;
var myFight = await _fightService.GetUserFight(userId);
var fight = await _fightService.GetFightInfo(fightId);
if (fight == null)
{
@@ -430,6 +431,7 @@ public class FightController : ControllerBase
isWin = 2;
}
int isCopy = 0;
string otName = string.Empty;
if (isWin == 0)
{
@@ -455,6 +457,7 @@ public class FightController : ControllerBase
{
var monsterInfo = await _monsterService.GetMonsterInfo(fight.mainId);
otName = monsterInfo.name;
isCopy = (int)monsterInfo.isCopy;
}
}
else
@@ -474,6 +477,104 @@ public class FightController : ControllerBase
var myAttr = await _attrService.GetUserAttrModel(userId, fight.scene);
return PoAction.Ok(new { isWin, otName, blood = myAttr.blood, upBlood = myAttr.upBlood, fight });
return PoAction.Ok(new { isWin, otName, blood = myAttr.blood, upBlood = myAttr.upBlood, fight, isCopy });
}
#region
/// <summary>
/// 个人挂机信息
/// </summary>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> GetUserHook()
{
string userId = StateHelper.userId;
var onHook = await _hookService.GetUserOnHook(userId);
decimal expAdd = 0;
decimal copperAdd = 0;
if (onHook.status == 1)
{
var myAttr = await _attrService.GetUserAttrModel(userId, onHook.scene);
expAdd = myAttr.addExp;
copperAdd = myAttr.addGold;
onHook.exp = Convert.ToInt32(onHook.exp * (1.0M + expAdd));
onHook.copper = Convert.ToInt32(onHook.copper * (1.0M + copperAdd));
}
return PoAction.Ok(new { data = onHook, expAdd, copperAdd });
}
/// <summary>
/// 挂机
/// </summary>
/// <param name="fightId"></param>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> OnHook(string fightId)
{
string userId = StateHelper.userId;
var fight = await _fightService.GetFightInfo(fightId);
if (fight == null)
{
return PoAction.Message("战斗不存在!");
}
if (fight.userId != userId)
{
return PoAction.Message("战斗不存在!");
}
if (fight.code != nameof(GameEnum.FightCode.PVE))
{
return PoAction.Message("该战斗不可复刻挂机!");
}
var monster = await _monsterService.GetMonsterInfo(fight.mainId);
if (monster == null)
{
return PoAction.Message("该战斗不可复刻挂机!");
}
if (monster.isCopy == 0)
{
return PoAction.Message("该战斗不可复刻挂机!");
}
var myAttr = await _attrService.GetUserAttrModel(userId, fight.scene);
int diffTime = Convert.ToInt32(fight.okTime - fight.addTime);
decimal score = myAttr.score * 0.7M;
bool result = await _hookService.StartOnHook(userId, fight.scene, (long)monster.copper, (long)monster.exp,
monster.name,
monster.award, score, diffTime, 6);
if (result)
{
return PoAction.Ok("挂机成功!");
}
else
{
return PoAction.Message("挂机失败,请稍后尝试!");
}
}
/// <summary>
/// 结束挂机
/// </summary>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> StopOnHook()
{
string userId = StateHelper.userId;
bool result = await _hookService.StopOnHook(userId);
if (result)
{
return PoAction.Ok(true);
}
else
{
return PoAction.Message("操作失败,请稍后尝试!");
}
}
#endregion
}