1233
This commit is contained in:
71
Service/Application.Web/Controllers/Pub/EquController.cs
Normal file
71
Service/Application.Web/Controllers/Pub/EquController.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Application.Web.Controllers.Pub;
|
||||
|
||||
/// <summary>
|
||||
/// 装备接口
|
||||
/// </summary>
|
||||
[Route("[controller]/[action]")]
|
||||
[ApiController]
|
||||
[Authorize]
|
||||
public class EquController : ControllerBase
|
||||
{
|
||||
private readonly IGameEquService _equService;
|
||||
|
||||
public EquController(IGameEquService equService)
|
||||
{
|
||||
_equService = equService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取装备信息
|
||||
/// </summary>
|
||||
/// <param name="equId"></param>
|
||||
/// <param name="ueId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> GetEquInfo(int? equId, string? ueId)
|
||||
{
|
||||
game_equ equInfo = new game_equ();
|
||||
game_equ_suit suit = new game_equ_suit();
|
||||
unit_user_equ ueInfo = new unit_user_equ();
|
||||
UserModel user = new UserModel();
|
||||
if (equId != 0)
|
||||
{
|
||||
equInfo = await _equService.GetEquInfo((int)equId);
|
||||
if (equInfo == null)
|
||||
{
|
||||
return PoAction.Message("装备不存在!");
|
||||
}
|
||||
|
||||
if (equInfo.suitCode != "0" && !string.IsNullOrEmpty(equInfo.suitCode))
|
||||
{
|
||||
suit = await _equService.GetEuqSuitInfo(equInfo.suitCode);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ueInfo = await _equService.GetUserEquInfo(ueId);
|
||||
if (ueInfo == null)
|
||||
{
|
||||
return PoAction.Message("装备不存在!");
|
||||
}
|
||||
|
||||
equInfo = await _equService.GetEquInfo((int)ueInfo.equId);
|
||||
if (equInfo == null)
|
||||
{
|
||||
return PoAction.Message("装备不存在!");
|
||||
}
|
||||
|
||||
if (equInfo.suitCode != "0" && !string.IsNullOrEmpty(equInfo.suitCode))
|
||||
{
|
||||
suit = await _equService.GetEuqSuitInfo(equInfo.suitCode);
|
||||
}
|
||||
|
||||
user = await UserModelTool.GetUserView(ueInfo.owerId);
|
||||
}
|
||||
|
||||
return PoAction.Ok(new { equ = equInfo, suit, equData = ueInfo,user });
|
||||
}
|
||||
|
||||
}
|
||||
39
Service/Application.Web/Controllers/Pub/GoodsController.cs
Normal file
39
Service/Application.Web/Controllers/Pub/GoodsController.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Application.Web.Controllers.Pub;
|
||||
|
||||
/// <summary>
|
||||
/// 物品接口
|
||||
/// </summary>
|
||||
[Route("[controller]/[action]")]
|
||||
[ApiController]
|
||||
[Authorize]
|
||||
public class GoodsController : ControllerBase
|
||||
{
|
||||
private readonly IGameGoodsService _goodsService;
|
||||
|
||||
public GoodsController(IGameGoodsService goodsService)
|
||||
{
|
||||
_goodsService = goodsService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取物品信息
|
||||
/// </summary>
|
||||
/// <param name="goodsId">物品ID</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> GetGoodsInfo(int goodsId)
|
||||
{
|
||||
var goodsInfo = await _goodsService.GetGoodsInfo(goodsId);
|
||||
if (goodsInfo == null)
|
||||
{
|
||||
return PoAction.Message("物品不存在!");
|
||||
}
|
||||
|
||||
string userId = StateHelper.userId;
|
||||
int count = await _goodsService.GetUserGoodsCount(userId, goodsId);
|
||||
|
||||
return PoAction.Ok(new { goods = goodsInfo, count });
|
||||
}
|
||||
}
|
||||
@@ -115,6 +115,12 @@ public class MessageController : ControllerBase
|
||||
string userId = StateHelper.userId;
|
||||
int areaId = StateHelper.areaId;
|
||||
|
||||
var msgRole = await _userService.GetUserConfigInfo(userId, nameof(UserEnum.ConfigCode.MsgRole));
|
||||
if (msgRole != 1)
|
||||
{
|
||||
return PoAction.Message("消息权限已被封禁!");
|
||||
}
|
||||
|
||||
var toUser = await _userService.GetUserInfoByUserNo(parms.no.ToString());
|
||||
if (toUser == null)
|
||||
{
|
||||
|
||||
203
Service/Application.Web/Controllers/Pub/RecoverController.cs
Normal file
203
Service/Application.Web/Controllers/Pub/RecoverController.cs
Normal file
@@ -0,0 +1,203 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Application.Web.Controllers.Pub;
|
||||
|
||||
/// <summary>
|
||||
/// 恢复接口
|
||||
/// </summary>
|
||||
[Route("[controller]/[action]")]
|
||||
[ApiController]
|
||||
[Authorize]
|
||||
public class RecoverController : ControllerBase
|
||||
{
|
||||
private readonly IUnitUserAttrService _attrService;
|
||||
private readonly IGameMapService _mapService;
|
||||
|
||||
public RecoverController(IUnitUserAttrService attrService, IGameMapService mapService)
|
||||
{
|
||||
_attrService = attrService;
|
||||
_mapService = mapService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 恢复体力
|
||||
/// </summary>
|
||||
/// <param name="npcId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> RecoverBlood(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.RetBlood)))
|
||||
{
|
||||
return PoAction.Message("业务不可用!");
|
||||
}
|
||||
|
||||
var onMap = await _mapService.GetUserOnMapId(userId);
|
||||
if (npcInfo.mapId != onMap)
|
||||
{
|
||||
return PoAction.Message("Npc不存在!");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
var userAttr = await _attrService.GetUserAttrModel(userId);
|
||||
if (userAttr.blood >= userAttr.upBlood)
|
||||
{
|
||||
return PoAction.Message("体力满满,无需恢复!");
|
||||
}
|
||||
|
||||
bool result = await _attrService.UpdateUserBlood(userId, 2, userAttr.upBlood, true);
|
||||
if (result)
|
||||
{
|
||||
return PoAction.Ok(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("恢复失败,请稍后尝试!");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 恢复士气
|
||||
/// </summary>
|
||||
/// <param name="npcId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> RecoverMorale(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.RetMorale)))
|
||||
{
|
||||
return PoAction.Message("业务不可用!");
|
||||
}
|
||||
|
||||
var onMap = await _mapService.GetUserOnMapId(userId);
|
||||
if (npcInfo.mapId != onMap)
|
||||
{
|
||||
return PoAction.Message("Npc不存在!");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
if (await _attrService.CheackRecoverMorale(userId))
|
||||
{
|
||||
return PoAction.Message("今天已恢复过士气啦!");
|
||||
}
|
||||
|
||||
var userAttr = await _attrService.GetUserAttrModel(userId);
|
||||
if (userAttr.morale >= userAttr.upMorale)
|
||||
{
|
||||
return PoAction.Message("士气满满,无需恢复!");
|
||||
}
|
||||
|
||||
bool result = await _attrService.UpdateUserMorale(userId, 2, userAttr.upMorale);
|
||||
if (result)
|
||||
{
|
||||
await _attrService.LockRecoverMorale(userId);
|
||||
return PoAction.Ok(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("恢复失败,请稍后尝试!");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取个人活力
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> GetUserVigour()
|
||||
{
|
||||
string userId = StateHelper.userId;
|
||||
var data = await _attrService.GetUserVigourInfo(userId);
|
||||
return PoAction.Ok(data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 恢复活力
|
||||
/// </summary>
|
||||
/// <param name="npcId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> RecoverVigour(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.RetVigour)))
|
||||
{
|
||||
return PoAction.Message("业务不可用!");
|
||||
}
|
||||
|
||||
var onMap = await _mapService.GetUserOnMapId(userId);
|
||||
if (npcInfo.mapId != onMap)
|
||||
{
|
||||
return PoAction.Message("Npc不存在!");
|
||||
}
|
||||
|
||||
#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("恢复失败,请稍后尝试!");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user