1212
This commit is contained in:
@@ -19,10 +19,12 @@ public class FightController : ControllerBase
|
||||
private readonly IGameGoodsService _goodsService;
|
||||
private readonly IUnitUserService _userService;
|
||||
private readonly IOnHookService _hookService;
|
||||
private readonly IUnitUserRelationService _relationService;
|
||||
|
||||
public FightController(IGameFightService fightService, IGameMonsterService monsterService,
|
||||
IUnitUserAttrService attrService, IGameMapService mapService, IUnitUserAccService accService,
|
||||
IGameGoodsService goodsService, IUnitUserService userService,IOnHookService hookService)
|
||||
IGameGoodsService goodsService, IUnitUserService userService, IOnHookService hookService,
|
||||
IUnitUserRelationService relationService)
|
||||
{
|
||||
_fightService = fightService;
|
||||
_monsterService = monsterService;
|
||||
@@ -32,6 +34,7 @@ public class FightController : ControllerBase
|
||||
_goodsService = goodsService;
|
||||
_userService = userService;
|
||||
_hookService = hookService;
|
||||
_relationService = relationService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -110,6 +113,77 @@ public class FightController : ControllerBase
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 角色战斗生成
|
||||
/// </summary>
|
||||
/// <param name="no"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> FightPerson(string? no)
|
||||
{
|
||||
string userId = StateHelper.userId;
|
||||
var onMapInfo = await _mapService.GetUserOnToMapInfo(userId);
|
||||
var otUser = await _userService.GetUserInfoByUserNo(no);
|
||||
if (otUser == null)
|
||||
{
|
||||
return PoAction.Message("玩家不存在!");
|
||||
}
|
||||
|
||||
if (onMapInfo.isPk == 0)
|
||||
{
|
||||
if (onMapInfo.retMap != onMapInfo.mapId)
|
||||
{
|
||||
if (await _relationService.CheckUserEnemy(userId, otUser.userId) == false)
|
||||
{
|
||||
return PoAction.Message("该场景不允许PK!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("该场景不允许PK!");
|
||||
}
|
||||
}
|
||||
|
||||
var otUserOnMap = await _mapService.GetUserOnMapInfo(otUser.userId);
|
||||
if (onMapInfo.mapId != otUserOnMap.mapId)
|
||||
{
|
||||
return PoAction.Message("玩家不存在!");
|
||||
}
|
||||
|
||||
if (otUserOnMap.isOnline == 0)
|
||||
{
|
||||
return PoAction.Message("玩家已下线!");
|
||||
}
|
||||
|
||||
if (onMapInfo.lookArea == 1)
|
||||
{
|
||||
if (otUser.areaId != StateHelper.areaId)
|
||||
{
|
||||
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);
|
||||
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,
|
||||
copper, petExp, award, pars);
|
||||
if (result)
|
||||
{
|
||||
await _hookService.StopOnHook(userId);
|
||||
return PoAction.Ok(fightId);
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("战斗生成错误!");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 战斗接口
|
||||
/// </summary>
|
||||
@@ -194,7 +268,6 @@ public class FightController : ControllerBase
|
||||
//结束战斗都此处直接返回
|
||||
if (otAttr.blood < 1 || myAttr.blood < 1)
|
||||
{
|
||||
await _fightService.RemoveUserFight(userId, fightId);
|
||||
if (otAttr.blood < 1)
|
||||
{
|
||||
await _fightService.SetFightWin(fight, userId);
|
||||
@@ -343,13 +416,11 @@ public class FightController : ControllerBase
|
||||
var fight = await _fightService.GetFightInfo(fightId);
|
||||
if (fight == null)
|
||||
{
|
||||
await _fightService.RemoveUserFight(userId, fightId);
|
||||
return PoAction.Message("战斗不存在!");
|
||||
}
|
||||
|
||||
if (fight.state == 1)
|
||||
{
|
||||
await _fightService.RemoveUserFight(userId, fightId);
|
||||
return PoAction.Message("战斗结束!");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user