增加修炼功能

This commit is contained in:
LN
2026-07-04 14:09:22 +08:00
147 changed files with 7790 additions and 693 deletions

View File

@@ -280,6 +280,34 @@ namespace Application.Web.Controllers.Login
return PoAction.Ok(new
{ token = token, refToken = userInfo.token, userId = userInfo.userId });
}
[HttpPost]
public async Task<IPoAction> RefreshTokenByBook([FromBody] RefreshTokenParms parms)
{
if (string.IsNullOrEmpty(parms.refToken))
{
return PoAction.Message("刷新失败");
}
string Key = App.Configuration["JwtTokenOptions:SecurityKey"].ToString();
string Issuer = App.Configuration["JwtTokenOptions:Issuer"].ToString();
string Audience = App.Configuration["JwtTokenOptions:Audience"].ToString();
var userInfo = await _userService.GetUserInfoByToken(parms.refToken);
if (userInfo == null)
{
return PoAction.Message("刷新失败,用户不存在!");
}
Dictionary<string, object> loadData = new Dictionary<string, object>();
loadData.Add("userId", userInfo.userId);
loadData.Add("accId", userInfo.accId);
loadData.Add("areaId", userInfo.areaId);
string token = JwtHelper.CreateToken(Key, Issuer, Audience, loadData, TokenConfig.TokenTime);
return PoAction.Ok(new
{ token = token, refToken = userInfo.token, userId = userInfo.userId });
}
/// <summary>
/// 注册角色信息

View File

@@ -21,9 +21,13 @@ public class MapController : ControllerBase
private readonly IGameSkillService _skillService;
private readonly IGameGoodsService _goodsService;
private readonly IGameTeamService _teamService;
private readonly IGameMonsterService _monsterService;
private readonly IGameFightService _fightService;
public MapController(IUnitUserService userService, IGameMapService mapService, IGameChatService chatService,
IUnitUserAttrService attrService, IMessageService messageService, IUnitUserWeight weightService,
IUnitUserAccService accService, IGameSkillService skillService,IGameGoodsService goodsService,IGameTeamService teamService)
IUnitUserAccService accService, IGameSkillService skillService, IGameGoodsService goodsService,
IGameTeamService teamService, IGameMonsterService monsterService,IGameFightService fightService)
{
_userService = userService;
_mapService = mapService;
@@ -35,6 +39,8 @@ public class MapController : ControllerBase
_skillService = skillService;
_goodsService = goodsService;
_teamService = teamService;
_monsterService = monsterService;
_fightService = fightService;
}
#region
@@ -89,14 +95,17 @@ public class MapController : ControllerBase
#endregion
//公聊信息
var myTeam = await _teamService.GetUserTeamData(userId);
string teamId =myTeam.teamId ;
var myTeam = await _teamService.GetUserTeamData(userId);
string teamId = myTeam.teamId;
string groupId = "";
var chatData = await _chatService.GetChatTop(userId, area, 2, teamId, groupId);
var npcData = await _mapService.GetMapNpc(mapInfo.mapId); //NPC信息
npcData = npcData.FindAll(it => GameTool.AreaVerify(StateHelper.areaId, it.areaId));
//获取怪物
var monsterData = await _monsterService.GetMapMonster(userId, mapInfo.mapId, teamId);
var nearUser =
await _mapService.GetMapUser(mapInfo.mapId, area, (int)mapInfo.lookArea, [userId],
3); //获取附近的人
@@ -132,7 +141,11 @@ public class MapController : ControllerBase
#endregion
var broadcast = await _messageService.GetBroadcastData(area);
var userFight = await _fightService.GetUserFight(userId);
string fightId = userFight.Count > 0 ? userFight[0] : "";
object ret = new
{
mapInfo,
@@ -143,7 +156,10 @@ public class MapController : ControllerBase
nearUser,
noReadMsg = noReadMsg[3],
business,
mapRes
mapRes,
broadcast,
monster = monsterData,
fightId
};
return PoAction.Ok(ret);
@@ -684,7 +700,6 @@ public class MapController : ControllerBase
}
var myVigour = await _attrService.GetUserVigourInfo(userId);
Console.WriteLine($"{myVigour.vitality }-{resInfo.needVigour}");
if (myVigour.vitality < resInfo.needVigour)
{
return PoAction.Message("活力不足!");

View File

@@ -51,6 +51,11 @@ public class StoreController : ControllerBase
return PoAction.Message("Npc不存在!");
}
if (!npcInfo.bus.Any(it => it.code == nameof(GameEnum.NpcBusCode.Store)))
{
return PoAction.Message("业务不可用!");
}
var onMap = await _mapService.GetUserOnMapId(userId);
if (npcInfo.mapId != onMap)
{
@@ -85,6 +90,11 @@ public class StoreController : ControllerBase
return PoAction.Message("Npc不存在!");
}
if (!npcInfo.bus.Any(it => it.code == nameof(GameEnum.NpcBusCode.Store)))
{
return PoAction.Message("业务不可用!");
}
var onMap = await _mapService.GetUserOnMapId(userId);
if (npcInfo.mapId != onMap)
{
@@ -158,6 +168,11 @@ public class StoreController : ControllerBase
return PoAction.Message("Npc不存在!");
}
if (!npcInfo.bus.Any(it => it.code == nameof(GameEnum.NpcBusCode.Store)))
{
return PoAction.Message("业务不可用!");
}
var onMap = await _mapService.GetUserOnMapId(userId);
if (npcInfo.mapId != onMap)
{
@@ -168,25 +183,25 @@ public class StoreController : ControllerBase
if (type == 0)
{
var data = await _equService.GetUserEquData(userId, 0, query, page, 10, total, true);
return PoAction.Ok(new { data, total.Value });
var data = await _equService.GetUserEquData(userId, 0, query, page, 10, total, true, true);
return PoAction.Ok(new { data, total = total.Value });
}
else if (type == 1)
{
List<string> code = new List<string>() { nameof(GoodsEnum.Code.Drug) };
var data = await _goodsService.GetUserGoodsData(userId, code, new List<string>(), query, page, 10, total);
return PoAction.Ok(new { data, total.Value });
return PoAction.Ok(new { data, total = total.Value });
}
else if (type == 2)
{
List<string> code = new List<string>();
List<string> noCode = new List<string>() { nameof(GoodsEnum.Code.Drug) };
var data = await _goodsService.GetUserGoodsData(userId, code, noCode, query, page, 10, total);
return PoAction.Ok(new { data, total.Value });
return PoAction.Ok(new { data, total = total.Value });
}
else
{
return PoAction.Ok(new { data = new List<string>(), total.Value });
return PoAction.Ok(new { data = new List<string>(), total = total.Value });
}
}
@@ -218,7 +233,7 @@ public class StoreController : ControllerBase
return PoAction.Message("Npc不存在!");
}
if (parms.type == 0)//装备
if (parms.type == 0) //装备
{
var equInfo = await _equService.GetUserEquInfo(parms.id);
if (equInfo == null)
@@ -248,7 +263,7 @@ public class StoreController : ControllerBase
}
else
{
return PoAction.Message("出售失败,请稍后尝试!");
return PoAction.Message("出售失败,请稍后尝试!");
}
}
else //物品
@@ -277,7 +292,7 @@ public class StoreController : ControllerBase
}
else
{
return PoAction.Message("出售失败,请稍后尝试!");
return PoAction.Message("出售失败,请稍后尝试!");
}
}
}

View 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("材料不足!");
}
}
}

View File

@@ -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("洗练失败,请稍后尝试!");
}
}
}

View 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);
}
}

View File

@@ -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("使用失败,请稍后尝试!");
}
}
}

View File

@@ -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);
}

View File

@@ -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)

View File

@@ -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
}
}
}
}
}

View File

@@ -24,7 +24,7 @@ public class BagController : ControllerBase
_equService = equService;
_accService = accService;
}
/// <summary>
/// 获取背包信息
/// </summary>
@@ -33,7 +33,6 @@ public class BagController : ControllerBase
public async Task<IPoAction> GetUserBagData()
{
string userId = StateHelper.userId;
var accInfo = await _accService.GetUserAccInfo(userId);
long gold = (long)accInfo.gold;
long cowry = (long)accInfo.cowry;
@@ -76,13 +75,13 @@ public class BagController : ControllerBase
}
var data = await _equService.GetUserEquData(userId, _t, query, page, 10, total);
return PoAction.Ok(new { data, total.Value });
return PoAction.Ok(new { data, total = total.Value});
}
else if (type == 1)
{
List<string> code = new List<string>() { nameof(GoodsEnum.Code.Drug) };
var data = await _goodsService.GetUserGoodsData(userId, code, new List<string>(), query, page, 10, total);
return PoAction.Ok(new { data, total.Value });
return PoAction.Ok(new { data, total = total.Value });
}
else if (type == 2)
{
@@ -101,6 +100,7 @@ public class BagController : ControllerBase
break;
case 4:
code.Add(nameof(GoodsEnum.Code.Pack));
code.Add(nameof(GoodsEnum.Code.ChoicePack));
break;
case 5:
code.Add(nameof(GoodsEnum.Code.Mak));
@@ -120,11 +120,35 @@ public class BagController : ControllerBase
}
var data = await _goodsService.GetUserGoodsData(userId, code, noCode, query, page, 10, total);
return PoAction.Ok(new { data, total.Value });
return PoAction.Ok(new { data, total = total.Value });
}
else
{
return PoAction.Ok(new { data = new List<string>(), total.Value });
return PoAction.Ok(new { data = new List<string>(), total = total.Value });
}
}
/// <summary>
/// 验证用户道具
/// </summary>
/// <param name="parms"></param>
/// <returns></returns>
[HttpPost]
public async Task<IPoAction> CheckUserProp([FromBody] CheckUserPropParms parms)
{
string userId = StateHelper.userId;
parms.count = parms.count < 1 ? 1 : parms.count;
if (parms.type == 0)
{
List<TowerNeed> needs = JsonConvert.DeserializeObject<List<TowerNeed>>(parms.needs);
var result = await GameBus.CheckNeed(userId, needs, parms.count);
return PoAction.Ok(result);
}
else
{
List<TowerNeeds> needs = JsonConvert.DeserializeObject<List<TowerNeeds>>(parms.needs);
var result = await GameBus.CheckNeeds(userId, needs, parms.count);
return PoAction.Ok(result);
}
}
}

View File

@@ -17,9 +17,12 @@ public class UserController : ControllerBase
private readonly IGameChatService _chatService;
private readonly IGameSkillService _skillService;
private readonly IGameTeamService _teamService;
private readonly IGameEquService _equService;
public UserController(IUnitUserService userService, IUnitUserAttrService attrService,
IUnitUserAccService accService, IGameMapService mapService, IUnitUserRelationService relationService,
IGameGoodsService goodsService, IGameChatService chatService,IGameSkillService skillService,IGameTeamService teamService)
IGameGoodsService goodsService, IGameChatService chatService, IGameSkillService skillService,
IGameTeamService teamService, IGameEquService equService)
{
_userService = userService;
_attrService = attrService;
@@ -30,6 +33,7 @@ public class UserController : ControllerBase
_chatService = chatService;
_skillService = skillService;
_teamService = teamService;
_equService = equService;
}
@@ -50,7 +54,10 @@ public class UserController : ControllerBase
var vigourInfo = await _attrService.GetUserVigourInfo(userId);
var accInfo = await _accService.GetUserAccInfo(userId);
object acc = new { accInfo.gold, accInfo.cowry, accInfo.teach, accInfo.renown };
object result = new { user, attr = attrInfo, exp, vigourInfo.vitality, acc };
var buff = await _attrService.GetUserStateData(userId, "ALL");
var stock = await _attrService.GetUserStock(userId);
object result = new { user, attr = attrInfo, exp, vigourInfo.vitality, acc, buff, stock };
return PoAction.Ok(result);
}
@@ -87,7 +94,7 @@ public class UserController : ControllerBase
var model = await UserModelTool.GetUserView(userId);
return PoAction.Ok(model);
}
/// <summary>
/// 获取基础属性信息
/// </summary>
@@ -163,7 +170,13 @@ public class UserController : ControllerBase
bool isFriend = await _relationService.CheckIsFriend(userId, userInfo.userId);
bool isEnemy = await _relationService.CheckUserEnemy(userId, userInfo.userId);
var team = await _teamService.GetUserTeamInfo(userInfo.userId);
object result = new { user, attr = new { attrInfo.lev }, acc, isOnline, onMapName, isFriend, isEnemy ,team};
var equ = await _equService.GetUserOnEqu(userInfo.userId);
var suit = await _equService.GetUserEquSuit(userInfo.userId);
object result = new
{
user, attr = new { attrInfo.lev }, acc, isOnline, onMapName, isFriend, isEnemy, team, equ, suit
};
return PoAction.Ok(result);
}
@@ -284,16 +297,134 @@ public class UserController : ControllerBase
return PoAction.Message("操作失败,请稍后尝试!");
}
}
/// <summary>
/// 获取用户技能
/// </summary>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction>GetUserSkill()
public async Task<IPoAction> GetUserSkill()
{
var userId = StateHelper.userId;
var data = await _skillService.GetUserSkill(userId);
return PoAction.Ok(data);
}
/// <summary>
/// 获取个人药品栏
/// </summary>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> GetUserDrugColumn()
{
string userId = StateHelper.userId;
var data = await _attrService.GetUserDrug(userId);
return PoAction.Ok(data.drug);
}
/// <summary>
/// 移除药品栏药品
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> RemoverUserDrug(string id)
{
string userId = StateHelper.userId;
var data = await _attrService.GetUserDrug(userId);
var onDrug = data.drug.Find(it => it.id == id);
if (onDrug == null)
{
return PoAction.Message("药品栏无此药品!");
}
data.drug.Remove(onDrug);
if (await _attrService.UpdateUserDrug(data))
{
if (onDrug.count > 0)
{
await _goodsService.UpdateUserGoods(userId, 1, onDrug.goodsId, onDrug.count, "药品栏移除,退回背包");
}
return PoAction.Ok(true);
}
else
{
return PoAction.Message("移除失败!");
}
}
/// <summary>
/// 添加到药品栏
/// </summary>
/// <param name="goodsId"></param>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> AddUserDrug(int goodsId, int count)
{
count = count < 1 ? 1 : count;
count = count > 999 ? 999 : count;
string userId = StateHelper.userId;
var myGoods = await _goodsService.GetUserGoodsInfo(userId, goodsId);
if (myGoods == null)
{
return PoAction.Message("暂无该物品!");
}
if (myGoods.count < count)
{
return PoAction.Message("物品数量不足!");
}
if (myGoods.code != nameof(GoodsEnum.Code.Drug))
{
return PoAction.Message("该物品无法置放到药品栏!");
}
bool isAdd = false;
var myDrug = await _attrService.GetUserDrug(userId);
var onDrug = myDrug.drug.Find(it => it.goodsId == goodsId);
if (onDrug == null)
{
if (myDrug.drug.Count >= 5)
{
return PoAction.Message("药品栏最多添加5个药品!");
}
isAdd = true;
}
if (await _goodsService.UpdateUserGoods(userId, 0, goodsId, count, "放置到药品栏"))
{
if (isAdd)
{
UserDrugModel temp = new UserDrugModel();
temp.id = StringAssist.NewGuid;
temp.goodsId = goodsId;
temp.name = myGoods.goodsName;
temp.code = "Blood";
temp.count = count;
myDrug.drug.Add(temp);
}
else
{
myDrug.drug.Remove(onDrug);
onDrug.count += count;
myDrug.drug.Add(onDrug);
}
if (await _attrService.UpdateUserDrug(myDrug))
{
return PoAction.Ok(true);
}
else
{
return PoAction.Message("添加失败,请稍后尝试!");
}
}
else
{
return PoAction.Message("添加失败,请稍后尝试!");
}
}
}

View File

@@ -13,5 +13,4 @@ global using Microsoft.AspNetCore.Authorization;
global using Microsoft.AspNetCore.Mvc;
global using Application.Web;

View File

@@ -0,0 +1,7 @@
namespace Application.Web;
public class EquUpParms
{
public string ueId { get; set; }
public string needs { get; set; }
}

View File

@@ -0,0 +1,8 @@
namespace Application.Web;
public class FightMonsterParms
{
public int type { get; set; }
public string monsterId { get; set; }
public string sign { get; set; }
}

View File

@@ -0,0 +1,6 @@
namespace Application.Web;
public class FightParms
{
public string fightId { get; set; }
}

View File

@@ -0,0 +1,8 @@
namespace Application.Web;
public class CheckUserPropParms
{
public int type { get; set; }
public int count { get; set; }
public string needs { get; set; }
}