121212
This commit is contained in:
134
Service/Application.Web/Controllers/Pub/BusinessController.cs
Normal file
134
Service/Application.Web/Controllers/Pub/BusinessController.cs
Normal file
@@ -0,0 +1,134 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Application.Web.Controllers.Pub;
|
||||
|
||||
/// <summary>
|
||||
/// 业务操作接口
|
||||
/// </summary>
|
||||
[Route("[controller]/[action]")]
|
||||
[ApiController]
|
||||
[Authorize]
|
||||
public class BusinessController : ControllerBase
|
||||
{
|
||||
private readonly IGameMapService _mapService;
|
||||
private readonly IGameEquService _equService;
|
||||
private readonly IGameGoodsService _goodsService;
|
||||
|
||||
public BusinessController(IGameEquService equService, IGameGoodsService goodsService, IGameMapService mapService)
|
||||
{
|
||||
_equService = equService;
|
||||
_goodsService = goodsService;
|
||||
_mapService = mapService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取打造图纸
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> GetEquPaper()
|
||||
{
|
||||
string userId = StateHelper.userId;
|
||||
var data = await _goodsService.GetUserGoodsData(userId, nameof(GoodsEnum.Code.Paper));
|
||||
List<MakePaperView> result = new List<MakePaperView>();
|
||||
foreach (var item in data)
|
||||
{
|
||||
MakePaperView temp = new MakePaperView();
|
||||
temp.goods = await _goodsService.GetGoodsInfo((int)item.goodsId);
|
||||
temp.count = (long)item.count;
|
||||
result.Add(temp);
|
||||
}
|
||||
|
||||
return PoAction.Ok(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打造装备
|
||||
/// </summary>
|
||||
/// <param name="npcId"></param>
|
||||
/// <param name="goodsId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> HandleEquPaper(int npcId, int goodsId)
|
||||
{
|
||||
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.Make)))
|
||||
{
|
||||
return PoAction.Message("业务不可用!");
|
||||
}
|
||||
|
||||
var onMap = await _mapService.GetUserOnMapId(userId);
|
||||
if (npcInfo.mapId != onMap)
|
||||
{
|
||||
return PoAction.Message("Npc不存在!");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
var myGoods = await _goodsService.GetUserGoodsInfo(userId, goodsId);
|
||||
if (myGoods == null)
|
||||
{
|
||||
return PoAction.Message("暂无图纸!");
|
||||
}
|
||||
|
||||
if (myGoods.count < 1)
|
||||
{
|
||||
return PoAction.Message("暂无图纸!");
|
||||
}
|
||||
|
||||
if (myGoods.code != nameof(GoodsEnum.Code.Paper))
|
||||
{
|
||||
return PoAction.Message("非图纸材料,无法打造!");
|
||||
}
|
||||
|
||||
string needstr = await _goodsService.GetGoodsContent(goodsId);
|
||||
var needs = JsonConvert.DeserializeObject<List<TowerNeed>>(needstr);
|
||||
var check = await GameBus.CheckNeed(userId, needs);
|
||||
if (check.result)
|
||||
{
|
||||
if (await GameBus.UpdateBag(userId, 0, needs, "装备打造"))
|
||||
{
|
||||
var onEqu = await _equService.GetMakeEquByGoodsId(goodsId);
|
||||
if (onEqu == null)
|
||||
{
|
||||
return PoAction.Message("打造失败,请联系客服!");
|
||||
}
|
||||
|
||||
//发放装备
|
||||
bool isRd = onEqu.rdAttr != 0;
|
||||
var getEqu = await _equService.AddUserEqu(userId, (int)onEqu.equId, isRd, "打造装备");
|
||||
if (getEqu != null)
|
||||
{
|
||||
return PoAction.Ok(getEqu.ueId, $"打造成功,获得装备[{onEqu.equName}]");
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("打造失败,请稍后尝试!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("打造失败,请稍后尝试!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("材料不足!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,15 +16,17 @@ public class EquController : ControllerBase
|
||||
private readonly IUnitUserService _userService;
|
||||
private readonly IGameDicService _dicService;
|
||||
private readonly IMessageService _messageService;
|
||||
private readonly IGameGoodsService _goodsService;
|
||||
|
||||
public EquController(IGameEquService equService, IUnitUserAttrService attrService, IUnitUserService userService,
|
||||
IGameDicService dicService, IMessageService messageService)
|
||||
IGameDicService dicService, IMessageService messageService, IGameGoodsService goodsService)
|
||||
{
|
||||
_equService = equService;
|
||||
_attrService = attrService;
|
||||
_userService = userService;
|
||||
_dicService = dicService;
|
||||
_messageService = messageService;
|
||||
_goodsService = goodsService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -142,6 +144,71 @@ public class EquController : ControllerBase
|
||||
return PoAction.Ok(new { data, suit });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 鉴定装备
|
||||
/// </summary>
|
||||
/// <param name="ueId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> ApprEqu(string ueId)
|
||||
{
|
||||
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.isAppr == 1)
|
||||
{
|
||||
return PoAction.Message("装备已鉴定!");
|
||||
}
|
||||
|
||||
var resEqu = await _equService.GetEquInfo((int)equInfo.equId);
|
||||
if (resEqu.isAppr == 0)
|
||||
{
|
||||
return PoAction.Message("装备数据异常,联系客服!");
|
||||
}
|
||||
|
||||
var myGoods = await _goodsService.GetUserGoodsCount(userId, GameConfig.GameEquApprGoods);
|
||||
if (myGoods < 1)
|
||||
{
|
||||
return PoAction.Message("暂无装备鉴定符!");
|
||||
}
|
||||
|
||||
if (await _goodsService.UpdateUserGoods(userId, 0, GameConfig.GameEquApprGoods, 1, "鉴定装备"))
|
||||
{
|
||||
equInfo.minAtk = RandomAssist.GetFormatedNumeric((int)resEqu.minAtk, (int)resEqu.maxAtk);
|
||||
equInfo.maxAtk = RandomAssist.GetFormatedNumeric((int)equInfo.minAtk, (int)resEqu.maxAtk);
|
||||
string[] def = resEqu.defense.Split('-');
|
||||
equInfo.Defense = RandomAssist.GetFormatedNumeric(Convert.ToInt32(def[0]), Convert.ToInt32(def[1]));
|
||||
string[] agi = resEqu.agility.Split('-');
|
||||
equInfo.Agility = RandomAssist.GetFormatedNumeric(Convert.ToInt32(agi[0]), Convert.ToInt32(agi[1]));
|
||||
string[] mor = resEqu.morale.Split('-');
|
||||
equInfo.Morale = RandomAssist.GetFormatedNumeric(Convert.ToInt32(mor[0]), Convert.ToInt32(mor[1]));
|
||||
string[] blo = resEqu.blood.Split('-');
|
||||
equInfo.Blood = RandomAssist.GetFormatedNumeric(Convert.ToInt32(blo[0]), Convert.ToInt32(blo[1]));
|
||||
equInfo.isAppr = 1;
|
||||
if (await _equService.UpdateUserEquInfo(equInfo))
|
||||
{
|
||||
return PoAction.Ok(true, "装备鉴定成功!");
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("鉴定失败,请稍后尝试!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("鉴定失败,请稍后尝试!");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 穿/卸装备
|
||||
/// </summary>
|
||||
@@ -680,7 +747,7 @@ public class EquController : ControllerBase
|
||||
}
|
||||
|
||||
var nextNeeds = await _equService.GetUserEquUpData((int)equInfo.intensifyLev + 1);
|
||||
if (needs == null)
|
||||
if (nextNeeds == null)
|
||||
{
|
||||
isMax = true;
|
||||
}
|
||||
@@ -693,7 +760,7 @@ public class EquController : ControllerBase
|
||||
if (equInfo.intensifyLev >= 60)
|
||||
{
|
||||
string msg = $"[{equInfo.equName}]装备强化至{equInfo.intensifyLev}级!";
|
||||
await _messageService.SendBroadcast(userId, nameof(MessageEnum.BroadcastCode.Promote), msg);
|
||||
await _messageService.SendBroadcast(userId, nameof(MessageEnum.BroadcastCode.Promote), msg);
|
||||
}
|
||||
}
|
||||
else //执行材料返还
|
||||
@@ -708,7 +775,7 @@ public class EquController : ControllerBase
|
||||
code = item.code,
|
||||
name = item.name,
|
||||
parameter = item.parameter,
|
||||
count = item.count
|
||||
count = item.retCount
|
||||
};
|
||||
retProp.Add(temp);
|
||||
}
|
||||
@@ -736,4 +803,122 @@ public class EquController : ControllerBase
|
||||
return PoAction.Message("强化错误,请稍后尝试!");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取洗练装备属性
|
||||
/// </summary>
|
||||
/// <param name="ueId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> GetEquQualityInfo(string ueId)
|
||||
{
|
||||
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.isAppr == 0)
|
||||
{
|
||||
return PoAction.Message("装备未鉴定!");
|
||||
}
|
||||
|
||||
long time = TimeExtend.GetTimeStampSeconds;
|
||||
if (equInfo.useEndTime < time)
|
||||
{
|
||||
return PoAction.Message("装备已过期!");
|
||||
}
|
||||
|
||||
List<string> CanOp = new List<string>()
|
||||
{ "Hold", "Vice", "Head", "Wear", "Waist", "Foot", "Ornaments" };
|
||||
if (!CanOp.Contains(equInfo.code))
|
||||
{
|
||||
return PoAction.Message("该部件不可洗练!");
|
||||
}
|
||||
|
||||
var dicConfig = await _dicService.GetDicInfo(nameof(GameEnum.DicCode.Quality));
|
||||
List<TowerNeed> need = JsonConvert.DeserializeObject<List<TowerNeed>>(dicConfig.sign);
|
||||
CheckTowerNeed result = await GameBus.CheckNeed(userId, need);
|
||||
|
||||
return PoAction.Ok(new
|
||||
{
|
||||
equData = equInfo,
|
||||
result
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 洗练装备
|
||||
/// </summary>
|
||||
/// <param name="ueId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> HandleEquQuality(string ueId)
|
||||
{
|
||||
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.isAppr == 0)
|
||||
{
|
||||
return PoAction.Message("装备未鉴定!");
|
||||
}
|
||||
|
||||
long time = TimeExtend.GetTimeStampSeconds;
|
||||
if (equInfo.useEndTime < time)
|
||||
{
|
||||
return PoAction.Message("装备已过期!");
|
||||
}
|
||||
|
||||
List<string> CanOp = new List<string>()
|
||||
{ "Hold", "Vice", "Head", "Wear", "Waist", "Foot", "Ornaments" };
|
||||
if (!CanOp.Contains(equInfo.code))
|
||||
{
|
||||
return PoAction.Message("该部件不可洗练!");
|
||||
}
|
||||
|
||||
var dicConfig = await _dicService.GetDicInfo(nameof(GameEnum.DicCode.Quality));
|
||||
List<TowerNeed> need = JsonConvert.DeserializeObject<List<TowerNeed>>(dicConfig.sign);
|
||||
CheckTowerNeed result = await GameBus.CheckNeed(userId, need);
|
||||
if (result.result)
|
||||
{
|
||||
if (await GameBus.UpdateBag(userId, 0, need, "洗练装备"))
|
||||
{
|
||||
var attr = await _equService.GetRandomEquAttr(equInfo.code, (int)equInfo.lev);
|
||||
equInfo.quality = attr.Count;
|
||||
equInfo.qualityName = GameTool.GetEquQualityName(attr.Count);
|
||||
equInfo.EquAttr = attr;
|
||||
if (await _equService.UpdateUserEquInfo(equInfo, true, "洗练装备", "洗练装备"))
|
||||
{
|
||||
return PoAction.Ok(true, "洗练成功!");
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("洗练失败,请稍后尝试!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("洗练失败,请稍后尝试!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("洗练失败,请稍后尝试!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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