111
This commit is contained in:
@@ -11,10 +11,14 @@ namespace Application.Web.Controllers.Pub;
|
||||
public class EquController : ControllerBase
|
||||
{
|
||||
private readonly IGameEquService _equService;
|
||||
private readonly IUnitUserAttrService _attrService;
|
||||
private readonly IUnitUserService _userService;
|
||||
|
||||
public EquController(IGameEquService equService)
|
||||
public EquController(IGameEquService equService, IUnitUserAttrService attrService, IUnitUserService userService)
|
||||
{
|
||||
_equService = equService;
|
||||
_attrService = attrService;
|
||||
_userService = userService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -65,7 +69,7 @@ public class EquController : ControllerBase
|
||||
user = await UserModelTool.GetUserView(ueInfo.owerId);
|
||||
}
|
||||
|
||||
return PoAction.Ok(new { equ = equInfo, suit, equData = ueInfo,user });
|
||||
return PoAction.Ok(new { equ = equInfo, suit, equData = ueInfo, user });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -99,10 +103,12 @@ public class EquController : ControllerBase
|
||||
{
|
||||
return PoAction.Message("装备不存在!");
|
||||
}
|
||||
|
||||
if (equInfo.userId != userId)
|
||||
{
|
||||
return PoAction.Message("装备不存在!");
|
||||
}
|
||||
|
||||
if (equInfo.isAppr == 0)
|
||||
{
|
||||
return PoAction.Message("装备未鉴定!");
|
||||
@@ -129,8 +135,117 @@ public class EquController : ControllerBase
|
||||
/// <param name="ueId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> DownOrUpEqu(string ueId)
|
||||
public async Task<IPoAction> DownOrUpEqu(string ueId, string? de)
|
||||
{
|
||||
return PoAction.Ok(true);
|
||||
string userId = StateHelper.userId;
|
||||
var equInfo = await _equService.GetUserEquInfo(ueId);
|
||||
if (equInfo == null)
|
||||
{
|
||||
return PoAction.Message("装备不存在!");
|
||||
}
|
||||
|
||||
if (equInfo.userId != userId)
|
||||
{
|
||||
return PoAction.Message("装备不存在!");
|
||||
}
|
||||
|
||||
if (equInfo.isOn == 0) //穿装
|
||||
{
|
||||
if (equInfo.isAppr == 0)
|
||||
{
|
||||
return PoAction.Message("装备未鉴定!");
|
||||
}
|
||||
|
||||
if (equInfo.useEndTime < TimeExtend.GetTimeStampSeconds)
|
||||
{
|
||||
return PoAction.Message("装备已过期!");
|
||||
}
|
||||
|
||||
int myLev = await _attrService.GetUserLev(userId);
|
||||
if (equInfo.lev > myLev)
|
||||
{
|
||||
return PoAction.Message($"等级达到{equInfo.lev}级可穿戴!");
|
||||
}
|
||||
|
||||
if (equInfo.sex != nameof(EquEnum.Sex.Default))
|
||||
{
|
||||
var userInfo = await _userService.GetUserInfoByUserId(userId);
|
||||
string needSex = equInfo.sex == nameof(EquEnum.Sex.Girl)
|
||||
? nameof(GameEnum.Sex.女)
|
||||
: nameof(GameEnum.Sex.男);
|
||||
if (userInfo.sex != needSex)
|
||||
{
|
||||
return PoAction.Message($"该装备只允许{needSex}性角色穿戴!");
|
||||
}
|
||||
}
|
||||
|
||||
var userOnEqu = await _equService.GetUserOnEqu(userId);
|
||||
if (equInfo.canEqualUp > 0)
|
||||
{
|
||||
int onCount = userOnEqu.Count(it => it.equId == equInfo.equId);
|
||||
if (onCount >= equInfo.canEqualUp)
|
||||
{
|
||||
return PoAction.Message($"该装备最多穿戴{equInfo.canEqualUp}件!");
|
||||
}
|
||||
}
|
||||
bool isOk = true;
|
||||
if (string.IsNullOrEmpty(de))
|
||||
{
|
||||
int MaxCount = GameTool.GetEquPlaceCount(equInfo.code);
|
||||
int OnCount = userOnEqu.Count(it => it.code == equInfo.code) + 1;
|
||||
if (OnCount > MaxCount)
|
||||
{
|
||||
return PoAction.Message($"该部位装备最多穿戴{MaxCount}件!", 100);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var DownOnEqu = await _equService.GetUserEquInfo(de);
|
||||
if (DownOnEqu == null)
|
||||
{
|
||||
return PoAction.Message("装备不存在!");
|
||||
}
|
||||
|
||||
if (userOnEqu.Any(it => it.ueId == de) == false)
|
||||
{
|
||||
return PoAction.Message("装备未穿戴!");
|
||||
}
|
||||
if (DownOnEqu.code != equInfo.code)
|
||||
{
|
||||
return PoAction.Message("装备部位不一致!");
|
||||
}
|
||||
|
||||
isOk = await _equService.EquOnOrDown(DownOnEqu, 0);
|
||||
}
|
||||
|
||||
if (isOk)
|
||||
{
|
||||
bool result = await _equService.EquOnOrDown(equInfo, 1);
|
||||
if (result)
|
||||
{
|
||||
return PoAction.Ok(true, "穿装成功!");
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("穿装失败,请稍后尝试");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("穿装失败,请稍后尝试");
|
||||
}
|
||||
}
|
||||
else //卸装
|
||||
{
|
||||
bool result = await _equService.EquOnOrDown(equInfo, 0);
|
||||
if (result)
|
||||
{
|
||||
return PoAction.Ok(true, "卸装成功!");
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("卸装失败,请稍后尝试");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user