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

@@ -23,11 +23,13 @@ public class MapController : ControllerBase
private readonly IGameTeamService _teamService;
private readonly IGameMonsterService _monsterService;
private readonly IGameFightService _fightService;
private readonly IOnHookService _hookService;
public MapController(IUnitUserService userService, IGameMapService mapService, IGameChatService chatService,
IUnitUserAttrService attrService, IMessageService messageService, IUnitUserWeight weightService,
IUnitUserAccService accService, IGameSkillService skillService, IGameGoodsService goodsService,
IGameTeamService teamService, IGameMonsterService monsterService, IGameFightService fightService)
IGameTeamService teamService, IGameMonsterService monsterService, IGameFightService fightService,
IOnHookService hookService)
{
_userService = userService;
_mapService = mapService;
@@ -41,6 +43,7 @@ public class MapController : ControllerBase
_teamService = teamService;
_monsterService = monsterService;
_fightService = fightService;
_hookService = hookService;
}
#region
@@ -150,6 +153,10 @@ public class MapController : ControllerBase
var mapGoods = await _fightService.GetMapFightGoods(mapInfo.mapId);
mapGoods = mapGoods.FindAll(it => it.userId == "0" || it.userId == userId).Take(3).ToList();
int isHook = 0; //挂机处理
var onHook = await _hookService.GetUserOnHook(userId);
isHook = (int)onHook.status;
object ret = new
{
mapInfo,
@@ -165,9 +172,11 @@ public class MapController : ControllerBase
broadcast,
monster = monsterData,
fightId,
gameTips
gameTips,
isHook
};
return PoAction.Ok(ret);
}

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
}

View File

@@ -130,6 +130,21 @@ public class UserController : ControllerBase
return PoAction.Ok(model);
}
/// <summary>
/// 获取个人特性
/// </summary>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> GetUserBaseAttrData()
{
string userId = StateHelper.userId;
var model = await _attrService.GetUserAttrModel(userId);
var unitExp = await _attrService.GetUserStateDataTotal(userId, nameof(MapEnum.MapCode.DEF_MAP));
var dupExp = await _attrService.GetUserStateDataTotal(userId, nameof(MapEnum.MapCode.Dup_Map));
return PoAction.Ok(new { data = model, unitExp, dupExp });
}
/// <summary>
/// 获取用户资料
/// </summary>
@@ -405,7 +420,7 @@ public class UserController : ControllerBase
temp.id = StringAssist.NewGuid;
temp.goodsId = goodsId;
temp.name = myGoods.goodsName;
temp.code =Convert.ToString(_drugConfig.cls);
temp.code = Convert.ToString(_drugConfig.cls);
temp.count = count;
myDrug.drug.Add(temp);
}