121212
This commit is contained in:
@@ -20,11 +20,12 @@ public class FightController : ControllerBase
|
||||
private readonly IUnitUserService _userService;
|
||||
private readonly IOnHookService _hookService;
|
||||
private readonly IUnitUserRelationService _relationService;
|
||||
private readonly IGameTaskService _taskService;
|
||||
|
||||
public FightController(IGameFightService fightService, IGameMonsterService monsterService,
|
||||
IUnitUserAttrService attrService, IGameMapService mapService, IUnitUserAccService accService,
|
||||
IGameGoodsService goodsService, IUnitUserService userService, IOnHookService hookService,
|
||||
IUnitUserRelationService relationService)
|
||||
IUnitUserRelationService relationService, IGameTaskService taskService)
|
||||
{
|
||||
_fightService = fightService;
|
||||
_monsterService = monsterService;
|
||||
@@ -35,6 +36,7 @@ public class FightController : ControllerBase
|
||||
_userService = userService;
|
||||
_hookService = hookService;
|
||||
_relationService = relationService;
|
||||
_taskService = taskService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -162,16 +164,18 @@ public class FightController : ControllerBase
|
||||
return PoAction.Message("该地图不允许跨服战斗!");
|
||||
}
|
||||
}
|
||||
|
||||
string fightId = StringAssist.NewGuid;
|
||||
string areaCode = nameof(GameEnum.AreaCode.Own);
|
||||
string code = nameof(GameEnum.FightCode.PVP);
|
||||
string keyId = StringAssist.GetSortKey(userId,otUser.userId);
|
||||
string keyId = StringAssist.GetSortKey(userId, otUser.userId);
|
||||
long exp = 0;
|
||||
long copper = 0;
|
||||
long petExp = 0;
|
||||
string award = string.Empty;
|
||||
string pars = "";
|
||||
bool result = await _fightService.AddFight(fightId, areaCode, keyId, otUser.userId, code, onMapInfo.code, onMapInfo.mapId, userId, exp,
|
||||
bool result = await _fightService.AddFight(fightId, areaCode, keyId, otUser.userId, code, onMapInfo.code,
|
||||
onMapInfo.mapId, userId, exp,
|
||||
copper, petExp, award, pars);
|
||||
if (result)
|
||||
{
|
||||
@@ -229,17 +233,6 @@ public class FightController : ControllerBase
|
||||
#endregion
|
||||
|
||||
//更新攻击
|
||||
if (fightResult.result == 0)
|
||||
{
|
||||
myHarm = fightResult.myHarm;
|
||||
myHarm += await _fightService.GetUserFightHarm(userId);
|
||||
otHarm = fightResult.otHarm;
|
||||
await _attrService.UpdateUserBlood(userId, 1, fightResult.myHarm);
|
||||
await _attrService.AddUserLoadState(userId, fightResult.myStateData);
|
||||
await _fightService.HandelFightEnd(userId, fightResult.myRemData);
|
||||
}
|
||||
|
||||
var myAttr = await _attrService.GetUserAttrModel(userId, fight.scene);
|
||||
UserAttrModel otAttr = new UserAttrModel();
|
||||
if (fight.code == nameof(GameEnum.FightCode.PVE))
|
||||
{
|
||||
@@ -264,6 +257,20 @@ public class FightController : ControllerBase
|
||||
|
||||
otAttr = await _attrService.GetUserAttrModel(fight.mainId, fight.scene);
|
||||
}
|
||||
if (fightResult.result == 0)
|
||||
{
|
||||
if (otAttr.blood >0)
|
||||
{
|
||||
myHarm = fightResult.myHarm;
|
||||
myHarm += await _fightService.GetUserFightHarm(userId);
|
||||
otHarm = fightResult.otHarm;
|
||||
await _attrService.UpdateUserBlood(userId, 1, fightResult.myHarm);
|
||||
await _attrService.AddUserLoadState(userId, fightResult.myStateData);
|
||||
await _fightService.HandelFightEnd(userId, fightResult.myRemData);
|
||||
}
|
||||
}
|
||||
|
||||
var myAttr = await _attrService.GetUserAttrModel(userId, fight.scene);
|
||||
|
||||
//结束战斗都此处直接返回
|
||||
if (otAttr.blood < 1 || myAttr.blood < 1)
|
||||
@@ -545,10 +552,26 @@ public class FightController : ControllerBase
|
||||
}
|
||||
}
|
||||
|
||||
string figArea = nameof(MonsterEnum.MonsterCode.Default);
|
||||
var myAttr = await _attrService.GetUserAttrModel(userId, fight.scene);
|
||||
var parsData = JsonConvert.DeserializeObject<dynamic>(fight.pars);
|
||||
object figResult = new object();
|
||||
if (Convert.ToString(parsData.type) == "Create")
|
||||
{
|
||||
if (Convert.ToString(parsData.code) == nameof(MonsterEnum.MonsterCode.Task))
|
||||
{
|
||||
int itemId = Convert.ToInt32(parsData.par);
|
||||
var taskInfo = await _taskService.GetTaskItemInfo(itemId);
|
||||
if (taskInfo != null)
|
||||
{
|
||||
figArea = nameof(MonsterEnum.MonsterCode.Task);
|
||||
figResult = await _taskService.GetUserTaskModel(userId, taskInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return PoAction.Ok(new { isWin, otName, blood = myAttr.blood, upBlood = myAttr.upBlood, fight, isCopy });
|
||||
return PoAction.Ok(new
|
||||
{ isWin, otName, blood = myAttr.blood, upBlood = myAttr.upBlood, fight, isCopy, figArea, figResult });
|
||||
}
|
||||
|
||||
#region 挂机相关
|
||||
|
||||
Reference in New Issue
Block a user