增加修炼功能
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("材料不足!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Application.Web.Controllers.Pub;
|
||||
|
||||
@@ -13,12 +14,19 @@ public class EquController : ControllerBase
|
||||
private readonly IGameEquService _equService;
|
||||
private readonly IUnitUserAttrService _attrService;
|
||||
private readonly IUnitUserService _userService;
|
||||
private readonly IGameDicService _dicService;
|
||||
private readonly IMessageService _messageService;
|
||||
private readonly IGameGoodsService _goodsService;
|
||||
|
||||
public EquController(IGameEquService equService, IUnitUserAttrService attrService, IUnitUserService userService)
|
||||
public EquController(IGameEquService equService, IUnitUserAttrService attrService, IUnitUserService userService,
|
||||
IGameDicService dicService, IMessageService messageService, IGameGoodsService goodsService)
|
||||
{
|
||||
_equService = equService;
|
||||
_attrService = attrService;
|
||||
_userService = userService;
|
||||
_dicService = dicService;
|
||||
_messageService = messageService;
|
||||
_goodsService = goodsService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -66,6 +74,7 @@ public class EquController : ControllerBase
|
||||
suit = await _equService.GetEuqSuitInfo(ueInfo.suitCode);
|
||||
}
|
||||
|
||||
ueInfo = EquTool.GetUserEquByIntensify(ueInfo);
|
||||
user = await UserModelTool.GetUserView(ueInfo.owerId);
|
||||
}
|
||||
|
||||
@@ -109,12 +118,6 @@ public class EquController : ControllerBase
|
||||
return PoAction.Message("装备不存在!");
|
||||
}
|
||||
|
||||
if (equInfo.isAppr == 0)
|
||||
{
|
||||
return PoAction.Message("装备未鉴定!");
|
||||
}
|
||||
|
||||
|
||||
equInfo.isLock = equInfo.isLock == 0 ? 1 : 0;
|
||||
|
||||
bool result = await _equService.UpdateUserEquInfo(equInfo);
|
||||
@@ -138,7 +141,73 @@ public class EquController : ControllerBase
|
||||
{
|
||||
string userId = StateHelper.userId;
|
||||
var data = await _equService.GetUserOnEqu(userId);
|
||||
return PoAction.Ok(data);
|
||||
var suit = await _equService.GetUserEquSuit(userId);
|
||||
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>
|
||||
@@ -200,6 +269,7 @@ public class EquController : ControllerBase
|
||||
return PoAction.Message($"该装备最多穿戴{equInfo.canEqualUp}件!");
|
||||
}
|
||||
}
|
||||
|
||||
bool isOk = true;
|
||||
if (string.IsNullOrEmpty(de))
|
||||
{
|
||||
@@ -222,6 +292,7 @@ public class EquController : ControllerBase
|
||||
{
|
||||
return PoAction.Message("装备未穿戴!");
|
||||
}
|
||||
|
||||
if (DownOnEqu.code != equInfo.code)
|
||||
{
|
||||
return PoAction.Message("装备部位不一致!");
|
||||
@@ -260,6 +331,595 @@ public class EquController : ControllerBase
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取可穿戴装备
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> GetCanOnEqu(int type)
|
||||
{
|
||||
string code = nameof(EquEnum.EquPlace.Hold);
|
||||
switch (type)
|
||||
{
|
||||
case 1:
|
||||
code = nameof(EquEnum.EquPlace.Hold);
|
||||
break;
|
||||
case 2:
|
||||
code = nameof(EquEnum.EquPlace.Vice);
|
||||
break;
|
||||
case 3:
|
||||
code = nameof(EquEnum.EquPlace.Head);
|
||||
break;
|
||||
case 4:
|
||||
code = nameof(EquEnum.EquPlace.Wear);
|
||||
break;
|
||||
case 5:
|
||||
code = nameof(EquEnum.EquPlace.Waist);
|
||||
break;
|
||||
case 6:
|
||||
code = nameof(EquEnum.EquPlace.Foot);
|
||||
break;
|
||||
case 7:
|
||||
code = nameof(EquEnum.EquPlace.Ornaments);
|
||||
break;
|
||||
case 8:
|
||||
code = nameof(EquEnum.EquPlace.Fashion);
|
||||
break;
|
||||
case 9:
|
||||
code = nameof(EquEnum.EquPlace.Wing);
|
||||
break;
|
||||
case 10:
|
||||
code = nameof(EquEnum.EquPlace.Decorate);
|
||||
break;
|
||||
}
|
||||
|
||||
string userId = StateHelper.userId;
|
||||
var userOnEqu = await _equService.GetUserOnEqu(userId);
|
||||
var NoEqu = userOnEqu.FindAll(it => it.code == code).Select(it => it.ueId).ToList();
|
||||
var CanEqu = await _equService.GetUserEquData(userId, code, NoEqu);
|
||||
long onTime = TimeExtend.GetTimeStampSeconds;
|
||||
CanEqu = CanEqu.FindAll(it => it.isAppr == 1 && it.useEndTime > onTime);
|
||||
CanEqu = CanEqu.OrderByDescending(it => it.lev).ToList();
|
||||
return PoAction.Ok(CanEqu);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取激活套装属性
|
||||
/// </summary>
|
||||
/// <param name="suitCode"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> GetUserOnSuitInfo(string suitCode)
|
||||
{
|
||||
var userId = StateHelper.userId;
|
||||
var onSuit = await _equService.GetUserEquSuit(userId);
|
||||
var suit = onSuit.Find(it => it.suitCode == suitCode);
|
||||
if (suit == null)
|
||||
{
|
||||
return PoAction.Message("套装不存在!");
|
||||
}
|
||||
|
||||
var data = await _equService.GetEuqSuitInfo(suitCode);
|
||||
if (data == null)
|
||||
{
|
||||
return PoAction.Message("套装不存在!");
|
||||
}
|
||||
|
||||
return PoAction.Ok(new { data, suit });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取装备觉醒所需
|
||||
/// </summary>
|
||||
/// <param name="ue"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> GetEquAwakenInfo(string ue)
|
||||
{
|
||||
string userId = StateHelper.userId;
|
||||
var equData = await _equService.GetUserEquInfo(ue);
|
||||
if (equData == null)
|
||||
{
|
||||
return PoAction.Message("装备不存在!");
|
||||
}
|
||||
|
||||
if (equData.userId != userId)
|
||||
{
|
||||
return PoAction.Message("装备不存在!");
|
||||
}
|
||||
|
||||
if (equData.isAppr == 0)
|
||||
{
|
||||
return PoAction.Message("装备未鉴定!");
|
||||
}
|
||||
|
||||
if (equData.useEndTime < TimeExtend.GetTimeStampSeconds)
|
||||
{
|
||||
return PoAction.Message("装备已过期!");
|
||||
}
|
||||
|
||||
CheckTowerNeed result = new CheckTowerNeed();
|
||||
if (equData.EquAwaken.Count == 0)
|
||||
{
|
||||
var dicConfig = await _dicService.GetDicInfo(nameof(GameEnum.DicCode.Awaken));
|
||||
List<TowerNeed> need = JsonConvert.DeserializeObject<List<TowerNeed>>(dicConfig.sign);
|
||||
result = await GameBus.CheckNeed(userId, need);
|
||||
}
|
||||
else
|
||||
{
|
||||
var upAwaken =
|
||||
await _equService.GetEquAwakenInfoByLev(equData.EquAwaken[0].atId, equData.EquAwaken[0].lev + 1);
|
||||
if (upAwaken == null)
|
||||
{
|
||||
return PoAction.Message("觉醒已达到上限!");
|
||||
}
|
||||
|
||||
result = await GameBus.CheckNeed(userId, upAwaken.need);
|
||||
}
|
||||
|
||||
return PoAction.Ok(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 觉醒装备
|
||||
/// </summary>
|
||||
/// <param name="ue"></param>
|
||||
/// <param name="type">0重置,1正常觉醒</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> HandleEquAwaken(string ue, int type)
|
||||
{
|
||||
string userId = StateHelper.userId;
|
||||
var equData = await _equService.GetUserEquInfo(ue);
|
||||
if (equData == null)
|
||||
{
|
||||
return PoAction.Message("装备不存在!");
|
||||
}
|
||||
|
||||
if (equData.userId != userId)
|
||||
{
|
||||
return PoAction.Message("装备不存在!");
|
||||
}
|
||||
|
||||
if (equData.isAppr == 0)
|
||||
{
|
||||
return PoAction.Message("装备未鉴定!");
|
||||
}
|
||||
|
||||
if (equData.useEndTime < TimeExtend.GetTimeStampSeconds)
|
||||
{
|
||||
return PoAction.Message("装备已过期!");
|
||||
}
|
||||
|
||||
EquAwakenData onAwaken = new EquAwakenData();
|
||||
game_equ_awaken newAwaken = new game_equ_awaken();
|
||||
CheckTowerNeed result = new CheckTowerNeed();
|
||||
if (type == 0) //重置
|
||||
{
|
||||
newAwaken = await _equService.GetRandomOneAwakenByCode(equData.code);
|
||||
if (newAwaken == null)
|
||||
{
|
||||
return PoAction.Message("该部件装备不可觉醒!");
|
||||
}
|
||||
|
||||
onAwaken = newAwaken.levAttr.Find(it => it.lev == 1);
|
||||
var dicConfig = await _dicService.GetDicInfo(nameof(GameEnum.DicCode.Awaken));
|
||||
List<TowerNeed> need = JsonConvert.DeserializeObject<List<TowerNeed>>(dicConfig.sign);
|
||||
result = await GameBus.CheckNeed(userId, need);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (equData.EquAwaken.Count == 0)
|
||||
{
|
||||
newAwaken = await _equService.GetRandomOneAwakenByCode(equData.code);
|
||||
if (newAwaken == null)
|
||||
{
|
||||
return PoAction.Message("该部件装备不可觉醒!");
|
||||
}
|
||||
|
||||
onAwaken = newAwaken.levAttr.Find(it => it.lev == 1);
|
||||
var dicConfig = await _dicService.GetDicInfo(nameof(GameEnum.DicCode.Awaken));
|
||||
List<TowerNeed> need = JsonConvert.DeserializeObject<List<TowerNeed>>(dicConfig.sign);
|
||||
result = await GameBus.CheckNeed(userId, need);
|
||||
}
|
||||
else
|
||||
{
|
||||
var upAwaken =
|
||||
await _equService.GetEquAwakenInfoByLev(equData.EquAwaken[0].atId, equData.EquAwaken[0].lev + 1);
|
||||
if (upAwaken == null)
|
||||
{
|
||||
return PoAction.Message("觉醒已达到上限!");
|
||||
}
|
||||
|
||||
newAwaken = await _equService.GetEquAwakenInfo(equData.EquAwaken[0].atId);
|
||||
onAwaken = upAwaken;
|
||||
result = await GameBus.CheckNeed(userId, upAwaken.need);
|
||||
}
|
||||
}
|
||||
|
||||
if (result.result == false)
|
||||
{
|
||||
return PoAction.Message("不满足觉醒条件!");
|
||||
}
|
||||
|
||||
if (await GameBus.UpdateBag(userId, 0, result.Needs, "觉醒装备"))
|
||||
{
|
||||
if (RandomAssist.CheakRandom(onAwaken.success))
|
||||
{
|
||||
EquAwaken awaken = new EquAwaken();
|
||||
awaken.atId = newAwaken.atId;
|
||||
awaken.name = newAwaken.name;
|
||||
awaken.lev = onAwaken.lev;
|
||||
awaken.awaken = onAwaken.attr;
|
||||
equData.EquAwaken = [awaken];
|
||||
if (await _equService.UpdateUserEquInfo(equData, true, "觉醒", "装备觉醒"))
|
||||
{
|
||||
string msg = $"[{equData.equName}]装备的特性【{awaken.name}】升至{awaken.lev}级!";
|
||||
await _messageService.SendBroadcast(userId, nameof(MessageEnum.BroadcastCode.Promote), msg);
|
||||
//此处为觉醒成功,返回相关数据
|
||||
var nextAwaken =
|
||||
await _equService.GetEquAwakenInfoByLev(equData.EquAwaken[0].atId,
|
||||
equData.EquAwaken[0].lev + 1);
|
||||
var nextResult = new CheckTowerNeed()
|
||||
{
|
||||
result = false,
|
||||
Needs = new List<TowerNeed>()
|
||||
};
|
||||
if (nextAwaken != null)
|
||||
{
|
||||
nextResult = await GameBus.CheckNeed(userId, nextAwaken.need);
|
||||
}
|
||||
|
||||
return PoAction.Ok(new { state = 1, awaken = equData.EquAwaken, result = nextResult }, "觉醒成功!");
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("觉醒异常,请稍后尝试!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//此处为觉醒成功,返回相关数据
|
||||
var nextAwaken =
|
||||
await _equService.GetEquAwakenInfoByLev(equData.EquAwaken[0].atId,
|
||||
equData.EquAwaken[0].lev + 1);
|
||||
var nextResult = new CheckTowerNeed()
|
||||
{
|
||||
result = false,
|
||||
Needs = new List<TowerNeed>()
|
||||
};
|
||||
if (nextAwaken != null)
|
||||
{
|
||||
nextResult = await GameBus.CheckNeed(userId, nextAwaken.need);
|
||||
}
|
||||
|
||||
return PoAction.Ok(new { state = 0, awaken = equData.EquAwaken, result = nextResult }, "觉醒失败!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("觉醒异常,请稍后尝试!");
|
||||
}
|
||||
|
||||
return PoAction.Ok(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取强化信息
|
||||
/// </summary>
|
||||
/// <param name="ueId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> GetEquUpInfo(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("装备已过期!");
|
||||
}
|
||||
|
||||
if (equInfo.isIntensify == 0)
|
||||
{
|
||||
return PoAction.Message("装备不可强化!");
|
||||
}
|
||||
|
||||
bool isMax = false;
|
||||
int upLev = (int)equInfo.intensifyLev + 1;
|
||||
var needs = await _equService.GetUserEquUpData(upLev);
|
||||
if (needs == null)
|
||||
{
|
||||
isMax = true;
|
||||
}
|
||||
|
||||
CheckTowerNeeds result = new CheckTowerNeeds();
|
||||
result.result = false;
|
||||
result.Needs = new List<TowerNeeds>();
|
||||
if (!isMax)
|
||||
{
|
||||
result = await GameBus.CheckNeeds(userId, needs.needData);
|
||||
}
|
||||
|
||||
return PoAction.Ok(new
|
||||
{
|
||||
equData = equInfo,
|
||||
isMax,
|
||||
result
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 强化装备
|
||||
/// </summary>
|
||||
/// <param name="parms"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<IPoAction> HandleEquUp([FromBody] EquUpParms parms)
|
||||
{
|
||||
string ueId = parms.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("装备已过期!");
|
||||
}
|
||||
|
||||
if (equInfo.isIntensify == 0)
|
||||
{
|
||||
return PoAction.Message("装备不可强化!");
|
||||
}
|
||||
|
||||
int upLev = (int)equInfo.intensifyLev + 1;
|
||||
var needs = await _equService.GetUserEquUpData(upLev);
|
||||
if (needs == null)
|
||||
{
|
||||
return PoAction.Message("已达到最大强化等级!");
|
||||
}
|
||||
|
||||
List<TowerNeeds> reqNeeds = JsonConvert.DeserializeObject<List<TowerNeeds>>(parms.needs);
|
||||
//验证材料
|
||||
foreach (var item in needs.needData)
|
||||
{
|
||||
var onNeed = reqNeeds.Find(it => it.Id == item.Id);
|
||||
if (item.NeedItem.Any(it => it.code == onNeed.code && it.parameter == onNeed.parameter) == false &&
|
||||
item.code != onNeed.code && item.parameter != onNeed.parameter)
|
||||
{
|
||||
return PoAction.Message("材料错误!");
|
||||
}
|
||||
}
|
||||
|
||||
var result = await GameBus.CheckNeeds(userId, reqNeeds);
|
||||
if (result.result == false)
|
||||
{
|
||||
return PoAction.Message("材料不足!");
|
||||
}
|
||||
|
||||
if (await GameBus.UpdateBag(userId, 0, reqNeeds, $"强化装备:{ueId}"))
|
||||
{
|
||||
CheckTowerNeeds nexResult = new CheckTowerNeeds();
|
||||
nexResult.result = false;
|
||||
nexResult.Needs = new List<TowerNeeds>();
|
||||
bool isMax = false;
|
||||
int state = 0;
|
||||
int okNum = (int)needs.okChance;
|
||||
if (RandomAssist.CheakRandom(okNum))
|
||||
{
|
||||
state = 1;
|
||||
equInfo.intensifyLev = upLev;
|
||||
equInfo.isDeal = result.isDeal;
|
||||
equInfo.isGive = result.isGive;
|
||||
if (await _equService.UpdateUserEquInfo(equInfo, true, "强化", "强化装备") == false)
|
||||
{
|
||||
return PoAction.Message("强化异常,请联系客服!");
|
||||
}
|
||||
|
||||
var nextNeeds = await _equService.GetUserEquUpData((int)equInfo.intensifyLev + 1);
|
||||
if (nextNeeds == null)
|
||||
{
|
||||
isMax = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
var nexts = nextNeeds.euId == needs.euId ? reqNeeds : nextNeeds.needData;
|
||||
nexResult = await GameBus.CheckNeeds(userId, nexts);
|
||||
}
|
||||
|
||||
if (equInfo.intensifyLev >= 60)
|
||||
{
|
||||
string msg = $"[{equInfo.equName}]装备强化至{equInfo.intensifyLev}级!";
|
||||
await _messageService.SendBroadcast(userId, nameof(MessageEnum.BroadcastCode.Promote), msg);
|
||||
}
|
||||
}
|
||||
else //执行材料返还
|
||||
{
|
||||
List<TowerGet> retProp = new List<TowerGet>();
|
||||
foreach (var item in reqNeeds)
|
||||
{
|
||||
if (item.retCount > 0 && item.isOp == 1)
|
||||
{
|
||||
TowerGet temp = new TowerGet()
|
||||
{
|
||||
code = item.code,
|
||||
name = item.name,
|
||||
parameter = item.parameter,
|
||||
count = item.retCount
|
||||
};
|
||||
retProp.Add(temp);
|
||||
}
|
||||
}
|
||||
|
||||
if (retProp.Count > 0)
|
||||
{
|
||||
await GameBus.UpdateBag(userId, 1, retProp, "强化失败,返还");
|
||||
}
|
||||
|
||||
nexResult = await GameBus.CheckNeeds(userId, reqNeeds);
|
||||
}
|
||||
|
||||
|
||||
return PoAction.Ok(new
|
||||
{
|
||||
state,
|
||||
equData = equInfo,
|
||||
isMax,
|
||||
result = nexResult
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
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("洗练失败,请稍后尝试!");
|
||||
}
|
||||
}
|
||||
}
|
||||
107
Service/Application.Web/Controllers/Pub/FightController.cs
Normal file
107
Service/Application.Web/Controllers/Pub/FightController.cs
Normal file
@@ -0,0 +1,107 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Application.Web.Controllers.Pub;
|
||||
|
||||
/// <summary>
|
||||
/// 战斗接口
|
||||
/// </summary>
|
||||
[Route("[controller]/[action]")]
|
||||
[ApiController]
|
||||
[Authorize]
|
||||
public class FightController : ControllerBase
|
||||
{
|
||||
private readonly IGameFightService _fightService;
|
||||
private readonly IGameMonsterService _monsterService;
|
||||
private readonly IUnitUserAttrService _attrService;
|
||||
private readonly IGameMapService _mapService;
|
||||
|
||||
public FightController(IGameFightService fightService, IGameMonsterService monsterService,
|
||||
IUnitUserAttrService attrService, IGameMapService mapService)
|
||||
{
|
||||
_fightService = fightService;
|
||||
_monsterService = monsterService;
|
||||
_attrService = attrService;
|
||||
_mapService = mapService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加怪物战斗
|
||||
/// </summary>
|
||||
/// <param name="parms"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<IPoAction> FightMonster([FromBody] FightMonsterParms parms)
|
||||
{
|
||||
string userId = StateHelper.userId;
|
||||
if (await UserKeyTool.CheckUserThickenData(userId, parms.sign, parms.type.ToString(), parms.monsterId) == false)
|
||||
{
|
||||
return PoAction.Message("怪物不存在!", -1);
|
||||
}
|
||||
|
||||
var mapInfo = await _mapService.GetUserOnToMapInfo(userId);
|
||||
|
||||
//添加怪物战斗
|
||||
string fightId = StringAssist.NewGuid;
|
||||
string areaCode = nameof(GameEnum.AreaCode.Own);
|
||||
string keyId = fightId;
|
||||
string mainId = string.Empty;
|
||||
string code = nameof(GameEnum.FightCode.PVE);
|
||||
string scene = mapInfo.code;
|
||||
string mapId = mapInfo.mapId;
|
||||
long exp = 0;
|
||||
long copper = 0;
|
||||
long petExp = 0;
|
||||
string award = string.Empty;
|
||||
string pars = "";
|
||||
if (parms.type == 0)
|
||||
{
|
||||
var monster = await _monsterService.GetMapMonsterInfo(parms.monsterId);
|
||||
mainId = monster.monsterId;
|
||||
pars = JsonConvert.SerializeObject(new { type = "Default" });
|
||||
}
|
||||
else
|
||||
{
|
||||
var monster = await _monsterService.GetCreateMonsterInfo(parms.monsterId);
|
||||
keyId = monster.umId;
|
||||
mainId = monster.monsterId;
|
||||
areaCode = monster.areaCode;
|
||||
pars = JsonConvert.SerializeObject(new { type = "Create", code = monster.code, par = monster.par });
|
||||
}
|
||||
var monsterInfo = await _monsterService.GetMonsterInfo(mainId);
|
||||
if (monsterInfo != null)
|
||||
{
|
||||
var userAttr = await _attrService.GetUserAttrModel(userId, scene);
|
||||
//处理奖励和资源
|
||||
exp = Convert.ToInt64(monsterInfo.exp * (1.0m + userAttr.addExp)) ;
|
||||
copper = Convert.ToInt64(monsterInfo.copper * (1.0m + userAttr.addGold));
|
||||
petExp = (long)monsterInfo.petExp;
|
||||
if (!string.IsNullOrEmpty(monsterInfo.award))//生成奖励
|
||||
{
|
||||
var awardModel = JsonConvert.DeserializeObject<MonsterAwardModel>(monsterInfo.award);
|
||||
if (awardModel.type == nameof(MonsterEnum.AwardCode.Default))
|
||||
{
|
||||
var getAward = GameBus.GetRandomGoods(awardModel.award, 1,userAttr.burst);
|
||||
award = JsonConvert.SerializeObject(new FightAwardModel() { code = "Default", award = getAward });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool result = await _fightService.AddFight(fightId, areaCode, keyId, mainId, code, scene, mapId, userId, exp,
|
||||
copper, petExp, award, pars);
|
||||
if (result)
|
||||
{
|
||||
return PoAction.Ok(fightId);
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("战斗生成错误!");
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IPoAction> Fight([FromBody] FightParms parms)
|
||||
{
|
||||
return PoAction.Ok(true);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Application.Web.Controllers.Pub;
|
||||
|
||||
@@ -11,10 +12,17 @@ namespace Application.Web.Controllers.Pub;
|
||||
public class GoodsController : ControllerBase
|
||||
{
|
||||
private readonly IGameGoodsService _goodsService;
|
||||
private readonly IUnitUserAttrService _attrService;
|
||||
private readonly IMessageService _messageService;
|
||||
private readonly IUnitUserWeight _weightService;
|
||||
|
||||
public GoodsController(IGameGoodsService goodsService)
|
||||
public GoodsController(IGameGoodsService goodsService, IUnitUserAttrService attrService,
|
||||
IMessageService messageService, IUnitUserWeight weightService)
|
||||
{
|
||||
_goodsService = goodsService;
|
||||
_attrService = attrService;
|
||||
_messageService = messageService;
|
||||
_weightService = weightService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -33,7 +41,205 @@ public class GoodsController : ControllerBase
|
||||
|
||||
string userId = StateHelper.userId;
|
||||
int count = await _goodsService.GetUserGoodsCount(userId, goodsId);
|
||||
int UseState = 0;
|
||||
string[] ShowViewNum = ["Pack", "Weight", "State"]; //显示带数量窗口
|
||||
string[] ShowView = ["Ship","Drug"]; //显示只能使用1个的窗口
|
||||
if (ShowViewNum.Any(it => it == goodsInfo.code))
|
||||
{
|
||||
UseState = 1;
|
||||
}
|
||||
else if (ShowView.Any(it => it == goodsInfo.code))
|
||||
{
|
||||
UseState = 2;
|
||||
}
|
||||
else if (goodsInfo.code == nameof(GoodsEnum.Code.ChoicePack))
|
||||
{
|
||||
UseState = 3;
|
||||
}
|
||||
|
||||
return PoAction.Ok(new { goods = goodsInfo, count });
|
||||
return PoAction.Ok(new { goods = goodsInfo, count, use = UseState });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 使用物品
|
||||
/// </summary>
|
||||
/// <param name="goodsId"></param>
|
||||
/// <param name="count"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> UseGoods(int goodsId, int count)
|
||||
{
|
||||
count = count < 1 ? 1 : count;
|
||||
string userId = StateHelper.userId;
|
||||
var goodsInfo = await _goodsService.GetGoodsInfo(goodsId);
|
||||
if (goodsInfo == null)
|
||||
{
|
||||
return PoAction.Message("物品不存在!");
|
||||
}
|
||||
|
||||
var MyGoods = await _goodsService.GetUserGoodsCount(userId, goodsId);
|
||||
if (MyGoods < count)
|
||||
{
|
||||
return PoAction.Message("物品不足!");
|
||||
}
|
||||
|
||||
var myLev = await _attrService.GetUserLev(userId);
|
||||
if (myLev < (int)goodsInfo.lev)
|
||||
{
|
||||
return PoAction.Message($"该物品{goodsInfo.lev}级才可使用!");
|
||||
}
|
||||
|
||||
#region 必要判定
|
||||
|
||||
if (goodsInfo.code == nameof(GoodsEnum.Code.Ship))
|
||||
{
|
||||
var myShip = await _weightService.GetUserShip(userId);
|
||||
if (myShip.Count >= 5)
|
||||
{
|
||||
return PoAction.Message($"每人最多拥有5个船只,您已达到上限!");
|
||||
}
|
||||
}
|
||||
|
||||
if (goodsInfo.code == nameof(GoodsEnum.Code.Drug))
|
||||
{
|
||||
var ck = await _goodsService.CheckUseDrug(userId, goodsId, goodsInfo.content);
|
||||
if (!string.IsNullOrEmpty(ck))
|
||||
{
|
||||
return PoAction.Message(ck);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
if (await _goodsService.UpdateUserGoods(userId, 0, goodsId, count, "使用物品"))
|
||||
{
|
||||
string message = "";
|
||||
if (goodsInfo.code == nameof(GoodsEnum.Code.Pack)) //使用礼包
|
||||
{
|
||||
var park = JsonConvert.DeserializeObject<RandomModel>(goodsInfo.content);
|
||||
var award = GameBus.GetRandomGoods(park, count);
|
||||
if (award.Count > 0)
|
||||
{
|
||||
message = $"打开[{goodsInfo.goodsName}]×{count},获得:";
|
||||
foreach (var item in award)
|
||||
{
|
||||
message += $"{item.name}+{item.count},";
|
||||
}
|
||||
|
||||
message = message.TrimEnd(',');
|
||||
await GameBus.UpdateBag(userId, 1, award, $"打开礼包:{goodsInfo.goodsName}×{count}获得");
|
||||
|
||||
await _messageService.SendBroadcast(userId, nameof(MessageEnum.BroadcastCode.Award), message);
|
||||
}
|
||||
else
|
||||
{
|
||||
message = "空空如也,什么也没有得到!";
|
||||
}
|
||||
}
|
||||
else if (goodsInfo.code == nameof(GoodsEnum.Code.Weight))
|
||||
{
|
||||
int unitWeight = Convert.ToInt32(goodsInfo.content);
|
||||
await _weightService.UpdateUserMaxWeight(userId, 1, unitWeight, count, goodsInfo.goodsId,
|
||||
goodsInfo.goodsName);
|
||||
message = $"使用[{goodsInfo.goodsName}]×{count},负重+{unitWeight * count}";
|
||||
}
|
||||
else if (goodsInfo.code == nameof(GoodsEnum.Code.State))
|
||||
{
|
||||
UserStateModel stateConfig = JsonConvert.DeserializeObject<UserStateModel>(goodsInfo.content);
|
||||
await _attrService.AddUserState(userId, goodsInfo.goodsId.ToString(), stateConfig.name,
|
||||
stateConfig.scene, stateConfig.tips, stateConfig.attr, stateConfig.time, count);
|
||||
message = $"使用[{goodsInfo.goodsName}]×{count},状态时间+{stateConfig.time * count}分钟";
|
||||
}
|
||||
else if (goodsInfo.code == nameof(GoodsEnum.Code.Ship))
|
||||
{
|
||||
dynamic shipInfo = JsonConvert.DeserializeObject<dynamic>(goodsInfo.content);
|
||||
string name = shipInfo.name;
|
||||
int speed = shipInfo.speed;
|
||||
int weight = shipInfo.weight;
|
||||
int copper = shipInfo.copper;
|
||||
long sale = shipInfo.sale;
|
||||
string remark = shipInfo.remark;
|
||||
|
||||
await _weightService.AddUserShip(userId, name, goodsId, speed, weight, copper, sale, remark);
|
||||
message = $"使用[{goodsInfo.goodsName}],获得{name}+1";
|
||||
}
|
||||
if (goodsInfo.code == nameof(GoodsEnum.Code.Drug))
|
||||
{
|
||||
message = "使用成功!";
|
||||
await _goodsService.UseDrug(userId, goodsId, goodsInfo.content);
|
||||
}
|
||||
return PoAction.Ok(true, message);
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("使用失败,请稍后尝试!");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 使用选择物品礼包
|
||||
/// </summary>
|
||||
/// <param name="goodsId"></param>
|
||||
/// <param name="count"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> UseChoiceGoods(int goodsId, int num)
|
||||
{
|
||||
string userId = StateHelper.userId;
|
||||
var goodsInfo = await _goodsService.GetGoodsInfo(goodsId);
|
||||
if (goodsInfo == null)
|
||||
{
|
||||
return PoAction.Message("物品不存在!");
|
||||
}
|
||||
|
||||
var MyGoods = await _goodsService.GetUserGoodsCount(userId, goodsId);
|
||||
if (MyGoods < 1)
|
||||
{
|
||||
return PoAction.Message("物品不足!");
|
||||
}
|
||||
|
||||
var myLev = await _attrService.GetUserLev(userId);
|
||||
if (myLev < (int)goodsInfo.lev)
|
||||
{
|
||||
return PoAction.Message($"该物品{goodsInfo.lev}级才可使用!");
|
||||
}
|
||||
|
||||
if (goodsInfo.code != nameof(GoodsEnum.Code.ChoicePack))
|
||||
{
|
||||
return PoAction.Message("无法使用该物品!");
|
||||
}
|
||||
|
||||
List<ChoiceGoods> choiceGoods = JsonConvert.DeserializeObject<List<ChoiceGoods>>(goodsInfo.content);
|
||||
var onAward = choiceGoods.Find(it => it.id == num);
|
||||
if (onAward == null)
|
||||
{
|
||||
return PoAction.Message("物品中不包含该选择!");
|
||||
}
|
||||
|
||||
|
||||
if (await _goodsService.UpdateUserGoods(userId, 0, goodsId, 1, "使用物品"))
|
||||
{
|
||||
if (await GameBus.UpdateBag(userId, 1, onAward.award, "打开礼包获取"))
|
||||
{
|
||||
string message = $"打开[{goodsInfo.goodsName}],获得:";
|
||||
foreach (var item in onAward.award)
|
||||
{
|
||||
message += $"{item.name}+{item.count},";
|
||||
}
|
||||
|
||||
message = message.TrimEnd(',');
|
||||
|
||||
await _messageService.SendBroadcast(userId, nameof(MessageEnum.BroadcastCode.Award), message);
|
||||
return PoAction.Ok(true, message);
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("使用失败,请稍后尝试!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("使用失败,请稍后尝试!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,6 +39,11 @@ namespace Application.Web.Controllers.Pub
|
||||
account = await _accountService.GetAccInfoByToken(sid);
|
||||
if (account != null)
|
||||
{
|
||||
account.pwd = "";
|
||||
account.npwd = "";
|
||||
account.token = "";
|
||||
account.openId = "";
|
||||
|
||||
isOnline = true;
|
||||
userData = await _userService.GetUserDataByAccId(account.accId);
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -10,14 +10,14 @@ namespace Application.Web.Controllers.Pub
|
||||
[Authorize]
|
||||
public class ShipController : ControllerBase
|
||||
{
|
||||
private readonly IUnitUserWeight weightService;
|
||||
private readonly IGameGoodsService goodsService;
|
||||
private readonly IUnitUserAccService accService;
|
||||
public ShipController(IUnitUserWeight _weightService, IGameGoodsService _goodsService, IUnitUserAccService _accService)
|
||||
private readonly IUnitUserWeight _weightService;
|
||||
private readonly IUnitUserAccService _accService;
|
||||
|
||||
public ShipController(IUnitUserWeight weightService,
|
||||
IUnitUserAccService accService)
|
||||
{
|
||||
accService = _accService;
|
||||
goodsService = _goodsService;
|
||||
weightService = _weightService;
|
||||
_accService = accService;
|
||||
_weightService = weightService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -28,27 +28,11 @@ namespace Application.Web.Controllers.Pub
|
||||
public async Task<IPoAction> GetUserShip()
|
||||
{
|
||||
string userId = StateHelper.userId;
|
||||
var data = await weightService.GetUserShip(userId);
|
||||
var data = await _weightService.GetUserShip(userId);
|
||||
//个人负重
|
||||
var weightInfo = await weightService.GetUserWeightInfo(userId);
|
||||
return PoAction.Ok(new { data, weightInfo });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取船只详情
|
||||
/// </summary>
|
||||
/// <param name="shipId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> GetShipInfo(int shipId)
|
||||
{
|
||||
var data = await goodsService.GetShipInfo(shipId);
|
||||
if (data == null)
|
||||
{
|
||||
return PoAction.Message("船只详情不存在!");
|
||||
}
|
||||
|
||||
return PoAction.Ok(new { data });
|
||||
var weightInfo = await _weightService.GetUserWeightInfo(userId);
|
||||
var maxShipWeight = await _weightService.GetUserShipMaxWeight(userId);
|
||||
return PoAction.Ok(new { data, onShip = weightInfo.shipOnWeight, maxShip = maxShipWeight });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -57,46 +41,25 @@ namespace Application.Web.Controllers.Pub
|
||||
/// <param name="usId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<IPoAction> BuyShip([FromBody] BuyShipParms parms)
|
||||
public async Task<IPoAction> SaleShip([FromBody] BuyShipParms parms)
|
||||
{
|
||||
var userShip = await weightService.GetUserShipInfo(parms.usId);
|
||||
var userShip = await _weightService.GetUserShipInfo(parms.usId);
|
||||
if (userShip == null)
|
||||
{
|
||||
return PoAction.Message("船只不存在!");
|
||||
}
|
||||
|
||||
string userId = StateHelper.userId;
|
||||
if (userShip.userId != userId)
|
||||
{
|
||||
return PoAction.Message("船只不存在!");
|
||||
}
|
||||
var shipInfo = await goodsService.GetShipInfo((int)userShip.goodsId);
|
||||
if (shipInfo == null)
|
||||
|
||||
if (await _weightService.DeleteUserShip(userShip.usId, userId))
|
||||
{
|
||||
return PoAction.Message("船只信息不存在!");
|
||||
}
|
||||
if (await weightService.DeleteUserShip(userShip.usId, userId))
|
||||
{
|
||||
if (shipInfo.payType == AccEnum.AccType.copper.ToString())
|
||||
if (await _accService.UpdateUserCopper(userId, 1, Convert.ToInt64(userShip.sale), "出售船只获得!"))
|
||||
{
|
||||
if (await accService.UpdateUserCopper(userId, 1, Convert.ToInt64(shipInfo.salePrice), "出售船只获得!"))
|
||||
{
|
||||
return PoAction.Ok(new { price = shipInfo.salePrice });
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("出售失败!");
|
||||
}
|
||||
}
|
||||
else if (shipInfo.payType == AccEnum.AccType.gold.ToString())
|
||||
{
|
||||
if (await accService.UpdateUserAcc(userId, 1, AccEnum.AccType.gold.ToString(), Convert.ToInt64(shipInfo.salePrice)))
|
||||
{
|
||||
return PoAction.Ok(new { price = shipInfo.salePrice });
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("出售失败!");
|
||||
}
|
||||
return PoAction.Ok(new { price = userShip.sale });
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -109,4 +72,4 @@ namespace Application.Web.Controllers.Pub
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user