121212
This commit is contained in:
@@ -12,11 +12,15 @@ public class RecoverController : ControllerBase
|
||||
{
|
||||
private readonly IUnitUserAttrService _attrService;
|
||||
private readonly IGameMapService _mapService;
|
||||
private readonly IUnitUserAccService _accService;
|
||||
private readonly IGameEquService _equService;
|
||||
|
||||
public RecoverController(IUnitUserAttrService attrService, IGameMapService mapService)
|
||||
public RecoverController(IUnitUserAttrService attrService, IGameMapService mapService,IUnitUserAccService accService,IGameEquService equService)
|
||||
{
|
||||
_attrService = attrService;
|
||||
_mapService = mapService;
|
||||
_accService = accService;
|
||||
_equService = equService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -179,6 +183,194 @@ public class RecoverController : ControllerBase
|
||||
|
||||
#endregion
|
||||
|
||||
var data = await _attrService.GetUserVigourInfo(userId);
|
||||
string time = TimeAssist.GetDateTimeYMDString(0);
|
||||
if (data.upTime == time)
|
||||
{
|
||||
return PoAction.Message("今天已恢复过活力啦!");
|
||||
}
|
||||
if (data.vitality >= data.upVitality)
|
||||
{
|
||||
return PoAction.Message("活力满满,无需恢复!");
|
||||
}
|
||||
|
||||
bool result = await _attrService.UpdateUserVigour(userId, 2, (long)data.upVitality,time);
|
||||
if (result)
|
||||
{
|
||||
return PoAction.Ok(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("恢复失败,请稍后尝试!");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取恢复耐久的装备
|
||||
/// </summary>
|
||||
/// <param name="npcId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> GetUserRecoverEqu(int npcId)
|
||||
{
|
||||
string userId = StateHelper.userId;
|
||||
|
||||
#region NPC验证
|
||||
|
||||
var npcInfo = await _mapService.GetNpcInfo(npcId);
|
||||
if (npcInfo == null)
|
||||
{
|
||||
return PoAction.Message("Npc不存在!");
|
||||
}
|
||||
|
||||
if (npcInfo.status != 1)
|
||||
{
|
||||
return PoAction.Message("Npc不存在!");
|
||||
}
|
||||
|
||||
if (!npcInfo.bus.Any(it => it.code == nameof(GameEnum.NpcBusCode.RetEqu)))
|
||||
{
|
||||
return PoAction.Message("业务不可用!");
|
||||
}
|
||||
|
||||
var onMap = await _mapService.GetUserOnMapId(userId);
|
||||
if (npcInfo.mapId != onMap)
|
||||
{
|
||||
return PoAction.Message("Npc不存在!");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
int need = 0;
|
||||
var data = await _equService.GetUserOnEqu(userId);
|
||||
var needData = data.FindAll(it =>
|
||||
it.isAppr == 1 && it.durability < it.maxdurability && it.useEndTime > TimeExtend.GetTimeStampSeconds);
|
||||
need = needData.Sum(it => (int)it.maxdurability - (int)it.durability);
|
||||
return PoAction.Ok(new { data, need });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 恢复装备耐久
|
||||
/// </summary>
|
||||
/// <param name="npcId"></param>
|
||||
/// <param name="ueId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> RecoverEqu(int npcId,string? ueId)
|
||||
{
|
||||
string userId = StateHelper.userId;
|
||||
|
||||
#region NPC验证
|
||||
|
||||
var npcInfo = await _mapService.GetNpcInfo(npcId);
|
||||
if (npcInfo == null)
|
||||
{
|
||||
return PoAction.Message("Npc不存在!");
|
||||
}
|
||||
|
||||
if (npcInfo.status != 1)
|
||||
{
|
||||
return PoAction.Message("Npc不存在!");
|
||||
}
|
||||
|
||||
if (!npcInfo.bus.Any(it => it.code == nameof(GameEnum.NpcBusCode.RetEqu)))
|
||||
{
|
||||
return PoAction.Message("业务不可用!");
|
||||
}
|
||||
|
||||
var onMap = await _mapService.GetUserOnMapId(userId);
|
||||
if (npcInfo.mapId != onMap)
|
||||
{
|
||||
return PoAction.Message("Npc不存在!");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
if (string.IsNullOrEmpty(ueId))
|
||||
{
|
||||
var myEqu = await _equService.GetUserOnEqu(userId);
|
||||
myEqu = myEqu.FindAll(it =>
|
||||
it.isAppr == 1 && it.durability < it.maxdurability && it.useEndTime > TimeExtend.GetTimeStampSeconds);
|
||||
int need = myEqu.Sum(it => (int)it.maxdurability - (int)it.durability);
|
||||
if (need < 1)
|
||||
{
|
||||
return PoAction.Message("耐久已满,无需恢复!");
|
||||
}
|
||||
|
||||
var myAcc = await _accService.GetUserAccInfo(userId, nameof(AccEnum.AccType.copper));
|
||||
if (need > myAcc)
|
||||
{
|
||||
return PoAction.Message("铜贝不足!");
|
||||
}
|
||||
|
||||
if (await _accService.UpdateUserCopper(userId, 0, need, "修复装备"))
|
||||
{
|
||||
foreach (var item in myEqu)
|
||||
{
|
||||
item.durability = item.maxdurability;
|
||||
await _equService.UpdateUserEquInfo(item);
|
||||
}
|
||||
return PoAction.Ok(true, $"恢复成功,花费{need}铜贝!");
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("恢复失败,请稍后尝试!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var equInfo = await _equService.GetUserEquInfo(ueId);
|
||||
if (equInfo == null)
|
||||
{
|
||||
return PoAction.Message("装备不存在!");
|
||||
}
|
||||
|
||||
if (equInfo.userId != userId)
|
||||
{
|
||||
return PoAction.Message("装备不存在!");
|
||||
}
|
||||
|
||||
if (equInfo.isAppr != 1)
|
||||
{
|
||||
return PoAction.Message("装备未鉴定!");
|
||||
}
|
||||
|
||||
if (equInfo.useEndTime < TimeExtend.GetTimeStampSeconds)
|
||||
{
|
||||
return PoAction.Message("装备已过期!");
|
||||
}
|
||||
|
||||
if (equInfo.durability >= equInfo.maxdurability)
|
||||
{
|
||||
return PoAction.Message("耐久已满,无需恢复!");
|
||||
}
|
||||
|
||||
int need = (int)equInfo.maxdurability - (int)equInfo.durability;
|
||||
var myAcc = await _accService.GetUserAccInfo(userId, nameof(AccEnum.AccType.copper));
|
||||
if (need > myAcc)
|
||||
{
|
||||
return PoAction.Message("铜贝不足!");
|
||||
}
|
||||
|
||||
if (await _accService.UpdateUserCopper(userId, 0, need, "修复装备"))
|
||||
{
|
||||
equInfo.durability = equInfo.maxdurability;
|
||||
if (await _equService.UpdateUserEquInfo(equInfo))
|
||||
{
|
||||
return PoAction.Ok(true, $"恢复成功,花费{need}铜贝!");
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("恢复失败,请稍后尝试!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("恢复失败,请稍后尝试!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var data = await _attrService.GetUserVigourInfo(userId);
|
||||
string time = TimeAssist.GetDateTimeYMDString(0);
|
||||
if (data.upTime == time)
|
||||
|
||||
Reference in New Issue
Block a user