diff --git a/Kx.SeaTime.sln.DotSettings.user b/Kx.SeaTime.sln.DotSettings.user index f1f5bbe..b8201f6 100644 --- a/Kx.SeaTime.sln.DotSettings.user +++ b/Kx.SeaTime.sln.DotSettings.user @@ -5,6 +5,7 @@ ForceIncluded ForceIncluded ForceIncluded + ForceIncluded ForceIncluded ForceIncluded ForceIncluded diff --git a/Service/Application.Domain.Entity/model/RandomDataBase.cs b/Service/Application.Domain.Entity/model/RandomDataBase.cs new file mode 100644 index 0000000..cdfbea9 --- /dev/null +++ b/Service/Application.Domain.Entity/model/RandomDataBase.cs @@ -0,0 +1,7 @@ +namespace Application.Domain.Entity; + +public class RandomDataBase +{ + public double random { get; set; } + public object data { get; set; } +} \ No newline at end of file diff --git a/Service/Application.Domain.Entity/resource/game/game_equ_attr.cs b/Service/Application.Domain.Entity/resource/game/game_equ_attr.cs new file mode 100644 index 0000000..145b8f2 --- /dev/null +++ b/Service/Application.Domain.Entity/resource/game/game_equ_attr.cs @@ -0,0 +1,81 @@ +using SqlSugar; +using System; + +namespace Application.Domain.Entity +{ + [Tenant("Kg.SeaTime.Resource")] + public class game_equ_attr + { + /// + /// erId + /// + [SugarColumn(IsPrimaryKey = true, Length = 50)] + public string erId { get; set; } + + /// + /// equCode + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? equCode { get; set; } + + /// + /// minLev + /// + [SugarColumn(IsNullable = true)] + public int? minLev { get; set; } + + /// + /// maxLev + /// + [SugarColumn(IsNullable = true)] + public int? maxLev { get; set; } + + /// + /// 权重 + /// + [SugarColumn(IsNullable = true)] + public int? random { get; set; } + + /// + /// 属性类型:Number 数值 float 百分比 + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? nt { get; set; } + + /// + /// 属性 + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? code { get; set; } + + /// + /// compute + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? compute { get; set; } + + /// + /// min_v + /// + [SugarColumn(Length = 18, IsNullable = true)] + public decimal? min_v { get; set; } + + /// + /// max_v + /// + [SugarColumn(Length = 18, IsNullable = true)] + public decimal? max_v { get; set; } + + /// + /// tips + /// + [SugarColumn(Length = 255, IsNullable = true)] + public string? tips { get; set; } + + /// + /// remark + /// + [SugarColumn(Length = 255, IsNullable = true)] + public string? remark { get; set; } + } +} diff --git a/Service/Application.Domain.Entity/resource/game/game_equ_make.cs b/Service/Application.Domain.Entity/resource/game/game_equ_make.cs new file mode 100644 index 0000000..035b685 --- /dev/null +++ b/Service/Application.Domain.Entity/resource/game/game_equ_make.cs @@ -0,0 +1,45 @@ +using SqlSugar; +using System; + +namespace Application.Domain.Entity +{ + [Tenant("Kg.SeaTime.Resource")] + public class game_equ_make + { + /// + /// mkId + /// + [SugarColumn(IsPrimaryKey = true, Length = 50)] + public string mkId { get; set; } + + /// + /// goodsId + /// + [SugarColumn(IsNullable = true)] + public int? goodsId { get; set; } + + /// + /// equId + /// + [SugarColumn(IsNullable = true)] + public int? equId { get; set; } + + /// + /// equName + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? equName { get; set; } + + /// + /// random + /// + [SugarColumn(IsNullable = true)] + public int? random { get; set; } + + /// + /// 是否随机特性 + /// + [SugarColumn(IsNullable = true)] + public int? rdAttr { get; set; } + } +} \ No newline at end of file diff --git a/Service/Application.Domain.Entity/view/MakePaperView.cs b/Service/Application.Domain.Entity/view/MakePaperView.cs new file mode 100644 index 0000000..c6ec2f7 --- /dev/null +++ b/Service/Application.Domain.Entity/view/MakePaperView.cs @@ -0,0 +1,7 @@ +namespace Application.Domain.Entity; + +public class MakePaperView +{ + public game_goods goods { get; set; } + public long count { get; set; } +} \ No newline at end of file diff --git a/Service/Application.Domain/Config/GameConfig.cs b/Service/Application.Domain/Config/GameConfig.cs index 9b0ba43..0c643ed 100644 --- a/Service/Application.Domain/Config/GameConfig.cs +++ b/Service/Application.Domain/Config/GameConfig.cs @@ -17,4 +17,5 @@ public static class GameConfig public const int GameAutoDrugGoodsId = 10001;//急救箱物品ID public const int GameToMapNeedCopper = 5;//传送每海里费用 public const int TeamCacheTime = 300;//队伍缓存时间 + public const int GameEquApprGoods = 10001;//鉴定装备道具 } \ No newline at end of file diff --git a/Service/Application.Domain/Enum/GameEnum.cs b/Service/Application.Domain/Enum/GameEnum.cs index b99b983..06c8b14 100644 --- a/Service/Application.Domain/Enum/GameEnum.cs +++ b/Service/Application.Domain/Enum/GameEnum.cs @@ -55,11 +55,15 @@ public static class GameEnum RetBlood, RetMorale, RetVigour, + RetEqu, MapTo, + Store, + Make, } public enum DicCode { Awaken,//觉醒配置 + Quality,//洗练配置 } } \ No newline at end of file diff --git a/Service/Application.Domain/Services/Interface/Equ/IGameEquService.cs b/Service/Application.Domain/Services/Interface/Equ/IGameEquService.cs index 937c5c4..9313e39 100644 --- a/Service/Application.Domain/Services/Interface/Equ/IGameEquService.cs +++ b/Service/Application.Domain/Services/Interface/Equ/IGameEquService.cs @@ -20,7 +20,8 @@ public interface IGameEquService Task GetUserEquByEquIdCount(string userId, int equId); Task> GetUserEquByEquId(string userId, int equId); Task AddUserEqu(string userId, int equId, int count, string remark); - + Task AddUserEqu(unit_user_equ equData, string remark); + Task AddUserEqu(string userId, int equId, bool rdAttr = false, string remark = ""); Task UpdateUserEquInfo(unit_user_equ equData, bool isAddLog = false, string code = "", string remark = ""); @@ -44,14 +45,22 @@ public interface IGameEquService #endregion + #region 洗练属性/词条 + + Task> GetRandomEquAttr(string equCode, int lev); + + #endregion + #region 强化相关 Task GetUserEquUpData(int lev); + #endregion #region 辅助 Task GetUserEquWeightSum(string userId); + Task GetMakeEquByGoodsId(int goodsId); #endregion } \ No newline at end of file diff --git a/Service/Application.Domain/Services/Service/Equ/GameEquService.cs b/Service/Application.Domain/Services/Service/Equ/GameEquService.cs index 5e2e576..1962f3a 100644 --- a/Service/Application.Domain/Services/Service/Equ/GameEquService.cs +++ b/Service/Application.Domain/Services/Service/Equ/GameEquService.cs @@ -180,6 +180,115 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame return result; } + public async Task AddUserEqu(unit_user_equ equData, string remark) + { + var db = DbClient.AsTenant().GetConnectionWithAttr(); + var result = await db.Insertable(equData).ExecuteCommandAsync() > 0; + if (result) + { + //添加日志 + await AddEquLogs([equData], 1, remark, true); + //更新负重 + int weightCount = Convert.ToInt32(equData.weight); + if (weightCount > 0) + { + var attrService = App.GetService(); + await attrService.UpdateUserWeight(equData.userId, 1, weightCount); + } + } + + return result; + } + + public async Task AddUserEqu(string userId, int equId, bool rdAttr = false, string remark = "") + { + var equ = await GetEquInfo(equId); + if (equ == null) + { + return null; + } + + unit_user_equ ue = new unit_user_equ(); + string ueId = StringAssist.NewGuid; + ue.ueId = ueId; + ue.userId = userId; + ue.owerId = userId; + ue.equId = equ.equId; + ue.equName = equ.equName; + ue.unitEquName = equ.equName; + ue.img = equ.img; + ue.sign = ""; + ue.isAppr = 1; + if (equ.isAppr == 0) + { + ue.minAtk = equ.minAtk; + ue.maxAtk = equ.maxAtk; + ue.Defense = Convert.ToInt32(equ.defense); + ue.Agility = Convert.ToInt32(equ.agility); + ue.Morale = Convert.ToInt32(equ.morale); + ue.Blood = Convert.ToInt32(equ.blood); + } + else + { + ue.minAtk = RandomAssist.GetFormatedNumeric((int)equ.minAtk, (int)equ.maxAtk); + ue.maxAtk = RandomAssist.GetFormatedNumeric((int)equ.minAtk, (int)equ.maxAtk); + string[] def = equ.defense.Split('-'); + ue.Defense = RandomAssist.GetFormatedNumeric(Convert.ToInt32(def[0]), Convert.ToInt32(def[1])); + string[] agi = equ.agility.Split('-'); + ue.Agility = RandomAssist.GetFormatedNumeric(Convert.ToInt32(agi[0]), Convert.ToInt32(agi[1])); + string[] mor = equ.morale.Split('-'); + ue.Morale = RandomAssist.GetFormatedNumeric(Convert.ToInt32(mor[0]), Convert.ToInt32(mor[1])); + string[] blo = equ.blood.Split('-'); + ue.Blood = RandomAssist.GetFormatedNumeric(Convert.ToInt32(blo[0]), Convert.ToInt32(blo[1])); + } + + ue.code = equ.code; + ue.suitCode = equ.suitCode; + ue.lev = equ.lev; + ue.durability = equ.durability; + ue.maxdurability = equ.durability; + ue.isIntensify = equ.isIntensify; + ue.intensifyLev = 0; + ue.isLock = 0; + ue.holeCount = equ.holeCount; + ue.sex = equ.sex; + ue.weight = equ.weight; + ue.sysPrice = equ.sysPrice; + ue.qualityAttr = new List(); + if (rdAttr == false) + { + ue.quality = equ.quality; + ue.qualityName = GameTool.GetEquQualityName((int)ue.quality); + ue.EquAttr = equ.equAttr; + } + else + { + var randomAttr = await GetRandomEquAttr(equ.code, (int)equ.lev); + ue.quality = randomAttr.Count; + ue.qualityName = GameTool.GetEquQualityName((int)ue.quality); + ue.EquAttr = randomAttr; + } + + ue.canEqualUp = equ.canEqualUp; + ue.isDeal = equ.isDeal; + ue.isGive = equ.isGive; + ue.opTime = 0; + ue.start = 0; + ue.EquMent = new EquMent(); + ue.EquAwaken = new List(); + ue.GemMent = new List(); + ue.useEndTime = TimeExtend.GetTimeStampBySeconds(DateTime.Now.AddYears(20)); + ue.isOn = 0; + if (await AddUserEqu(ue, remark)) + { + return ue; + } + else + { + return null; + } + } + public async Task UpdateUserEquInfo(unit_user_equ equData, bool isAddLog = false, string code = "", string remark = "") { @@ -507,6 +616,93 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame #endregion + #region 洗练属性/词条 + + private async Task> GetEquAttrData(string erCode) + { + string key = string.Format(BaseCache.BaseCacheKeys, "EquData", "EquAttrData"); + if (await redis.HExistsHashAsync(key, erCode)) + { + return await redis.GetHashAsync>(key, erCode); + } + + var db = DbClient.AsTenant().GetConnectionWithAttr(); + var data = await db.Queryable().Where(it => it.equCode == erCode).ToListAsync(); + await redis.AddHashAsync(key, erCode, data); + return data; + } + + public async Task> GetRandomEquAttr(string equCode, int lev) + { + //计算出的数量 + List numData = new List() + { + new RandomDataBase() { random = 100, data = 1 }, + new RandomDataBase() { random = 90, data = 2 }, + new RandomDataBase() { random = 80, data = 3 }, + new RandomDataBase() { random = 50, data = 4 }, + new RandomDataBase() { random = 30, data = 5 }, + new RandomDataBase() { random = 15, data = 6 }, + new RandomDataBase() { random = 5, data = 7 }, + }; + var numR = GameBus.GetRandomByWeight(numData); + int onNum = Convert.ToInt32(numR.data); + var attrData = await GetEquAttrData(equCode); + attrData = attrData.FindAll(it => it.minLev <= lev && it.maxLev >= lev); + + //开始随机拿属性权重 + List data = new List(); + List weights = new List(); + List attrResult = new List(); + Random rand = new Random(); + + foreach (var item in attrData) + { + data.Add(item); + weights.Add(ushort.Parse(item.random.ToString())); + } + + RandomAssist random = new RandomAssist(onNum); + + attrResult = random.ControllerRandomExtract(rand, data, weights); + List result = new List(); + if (attrResult.Count > 0) + { + foreach (var item in attrResult) + { + var onAttr = item as game_equ_attr; + + AttrItem temp = new AttrItem(); + temp.code = onAttr.code; + temp.compute = onAttr.compute; + if (onAttr.nt == "Number") + { + int onMin = Convert.ToInt32(onAttr.min_v); + int onMax = Convert.ToInt32(onAttr.max_v); + int onPar = RandomAssist.GetFormatedNumeric(onMin, onMax + 1); + temp.parameter = onPar; + string onTip = temp.parameter.ToString().TrimEnd('0').TrimEnd('.'); + temp.tip = string.Format(onAttr.tips, onTip); + } + else + { + int onMin = Convert.ToInt32(onAttr.min_v * 100); + int onMax = Convert.ToInt32(onAttr.max_v * 100); + int onPar = RandomAssist.GetFormatedNumeric(onMin, onMax + 1); + temp.parameter = Math.Round(Convert.ToDecimal(onPar / 100.000M), 2); + string onTip = (temp.parameter * 100).ToString().TrimEnd('0').TrimEnd('.'); + temp.tip = string.Format(onAttr.tips, onTip); + } + + result.Add(temp); + } + } + + return result; + } + + #endregion + #region 强化相关 public async Task GetUserEquUpData(int lev) @@ -522,9 +718,9 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame await redis.AddHashAsync(key, lev.ToString(), data); } } + return data; } - #endregion @@ -537,5 +733,43 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame return data.Sum(it => (int)it.weight); } + private async Task> GetEquMakeData(int goodsId) + { + string key = string.Format(BaseCache.BaseCacheKeys, "EquData", "EquUpData"); + if (await redis.HExistsHashAsync(key, goodsId.ToString())) + { + return await redis.GetHashAsync>(key, goodsId.ToString()); + } + + var db = DbClient.AsTenant().GetConnectionWithAttr(); + var data = await db.Queryable().Where(it => it.goodsId == goodsId).ToListAsync(); + await redis.AddHashAsync(key, goodsId.ToString(), data); + return data; + } + + public async Task GetMakeEquByGoodsId(int goodsId) + { + //构建随机数据 + List equBase = new List(); + var equData = await GetEquMakeData(goodsId); + foreach (var me in equData) + { + RandomDataBase temp = new RandomDataBase(); + temp.random = (double)me.random; + temp.data = me; + equBase.Add(temp); + } + + var makeEqu = GameBus.GetRandomByWeight(equBase); + if (makeEqu == null) + { + return null; + } + + var onMakeEqu = makeEqu.data as game_equ_make; + + return onMakeEqu; + } + #endregion } \ No newline at end of file diff --git a/Service/Application.Domain/Tool/Base/GameBus.cs b/Service/Application.Domain/Tool/Base/GameBus.cs index 027528a..64ead07 100644 --- a/Service/Application.Domain/Tool/Base/GameBus.cs +++ b/Service/Application.Domain/Tool/Base/GameBus.cs @@ -64,6 +64,11 @@ public static class GameBus isok = await accService.UpdateUserAcc(userId, operate, nameof(AccEnum.AccType.teach), count, nameof(AccEnum.Name.其他), remark); } + else if (goodsType.Equals(nameof(GameEnum.PropCode.map))) + { + var mapService = App.GetService(); + isok = await mapService.AddUserCityMap(userId, Convert.ToInt32(parameter)); + } return isok; } @@ -338,6 +343,7 @@ public static class GameBus isok = false; } } + result.Needs.Add(item); } @@ -351,6 +357,28 @@ public static class GameBus #region 概率 + public static RandomDataBase GetRandomByWeight(List data) + { + var _randomInstance = new Random(); + if (data.Count == 0) + { + return null; + } + double totalWeight = data.Sum(it => it.random); + int rnd = _randomInstance.Next(Convert.ToInt32(totalWeight) + 1); + double current = 0; + foreach (var item in data) + { + current += item.random; + if (rnd < current) + { + return item; + } + } + + return null; + } + public static List GetRandomGoods(RandomModel random, int count = 1, int luck = 0) { List result = new List(); diff --git a/Service/Application.Domain/Tool/Base/GameTool.cs b/Service/Application.Domain/Tool/Base/GameTool.cs index 3def85b..f9c2bb5 100644 --- a/Service/Application.Domain/Tool/Base/GameTool.cs +++ b/Service/Application.Domain/Tool/Base/GameTool.cs @@ -138,7 +138,41 @@ public class GameTool return result; } - + + public static string GetEquQualityName(int count) + { + string result = "白"; + switch (count) + { + case 1: + result = "红"; + break; + case 2: + result = "橙"; + break; + case 3: + result = "黄"; + break; + case 4: + result = "绿"; + break; + case 5: + result = "青"; + break; + case 6: + result = "粉"; + break; + case 7: + result = "紫"; + break; + case 8: + result = "金"; + break; + + } + return result; + } + #region 距离计算 /// diff --git a/Service/Application.Web/Controllers/Map/StoreController.cs b/Service/Application.Web/Controllers/Map/StoreController.cs index b9ddabe..7a2d084 100644 --- a/Service/Application.Web/Controllers/Map/StoreController.cs +++ b/Service/Application.Web/Controllers/Map/StoreController.cs @@ -50,6 +50,10 @@ 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) @@ -84,6 +88,10 @@ 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) @@ -157,7 +165,10 @@ 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) { diff --git a/Service/Application.Web/Controllers/Pub/BusinessController.cs b/Service/Application.Web/Controllers/Pub/BusinessController.cs new file mode 100644 index 0000000..d0c1a8c --- /dev/null +++ b/Service/Application.Web/Controllers/Pub/BusinessController.cs @@ -0,0 +1,134 @@ +using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json; + +namespace Application.Web.Controllers.Pub; + +/// +/// 业务操作接口 +/// +[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; + } + + /// + /// 获取打造图纸 + /// + /// + [HttpGet] + public async Task GetEquPaper() + { + string userId = StateHelper.userId; + var data = await _goodsService.GetUserGoodsData(userId, nameof(GoodsEnum.Code.Paper)); + List result = new List(); + 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); + } + + /// + /// 打造装备 + /// + /// + /// + /// + [HttpGet] + public async Task 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>(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("材料不足!"); + } + } +} \ No newline at end of file diff --git a/Service/Application.Web/Controllers/Pub/EquController.cs b/Service/Application.Web/Controllers/Pub/EquController.cs index f67438b..8601127 100644 --- a/Service/Application.Web/Controllers/Pub/EquController.cs +++ b/Service/Application.Web/Controllers/Pub/EquController.cs @@ -16,15 +16,17 @@ public class EquController : ControllerBase private readonly IUnitUserService _userService; private readonly IGameDicService _dicService; private readonly IMessageService _messageService; + private readonly IGameGoodsService _goodsService; public EquController(IGameEquService equService, IUnitUserAttrService attrService, IUnitUserService userService, - IGameDicService dicService, IMessageService messageService) + IGameDicService dicService, IMessageService messageService, IGameGoodsService goodsService) { _equService = equService; _attrService = attrService; _userService = userService; _dicService = dicService; _messageService = messageService; + _goodsService = goodsService; } /// @@ -142,6 +144,71 @@ public class EquController : ControllerBase return PoAction.Ok(new { data, suit }); } + /// + /// 鉴定装备 + /// + /// + /// + [HttpGet] + public async Task 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("鉴定失败,请稍后尝试!"); + } + } + /// /// 穿/卸装备 /// @@ -680,7 +747,7 @@ public class EquController : ControllerBase } var nextNeeds = await _equService.GetUserEquUpData((int)equInfo.intensifyLev + 1); - if (needs == null) + if (nextNeeds == null) { isMax = true; } @@ -693,7 +760,7 @@ public class EquController : ControllerBase if (equInfo.intensifyLev >= 60) { string msg = $"[{equInfo.equName}]装备强化至{equInfo.intensifyLev}级!"; - await _messageService.SendBroadcast(userId, nameof(MessageEnum.BroadcastCode.Promote), msg); + await _messageService.SendBroadcast(userId, nameof(MessageEnum.BroadcastCode.Promote), msg); } } else //执行材料返还 @@ -708,7 +775,7 @@ public class EquController : ControllerBase code = item.code, name = item.name, parameter = item.parameter, - count = item.count + count = item.retCount }; retProp.Add(temp); } @@ -736,4 +803,122 @@ public class EquController : ControllerBase return PoAction.Message("强化错误,请稍后尝试!"); } } + + /// + /// 获取洗练装备属性 + /// + /// + /// + [HttpGet] + public async Task 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 CanOp = new List() + { "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 need = JsonConvert.DeserializeObject>(dicConfig.sign); + CheckTowerNeed result = await GameBus.CheckNeed(userId, need); + + return PoAction.Ok(new + { + equData = equInfo, + result + }); + } + + /// + /// 洗练装备 + /// + /// + /// + [HttpGet] + public async Task 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 CanOp = new List() + { "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 need = JsonConvert.DeserializeObject>(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("洗练失败,请稍后尝试!"); + } + } } \ No newline at end of file diff --git a/Service/Application.Web/Controllers/Pub/RecoverController.cs b/Service/Application.Web/Controllers/Pub/RecoverController.cs index 66bf461..29ec57f 100644 --- a/Service/Application.Web/Controllers/Pub/RecoverController.cs +++ b/Service/Application.Web/Controllers/Pub/RecoverController.cs @@ -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; } /// @@ -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("恢复失败,请稍后尝试!"); + } + } + + /// + /// 获取恢复耐久的装备 + /// + /// + /// + [HttpGet] + public async Task 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 }); + } + + /// + /// 恢复装备耐久 + /// + /// + /// + /// + [HttpGet] + public async Task 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) diff --git a/Service/Application.Web/Controllers/User/BagController.cs b/Service/Application.Web/Controllers/User/BagController.cs index 2fe4a17..3d0dda9 100644 --- a/Service/Application.Web/Controllers/User/BagController.cs +++ b/Service/Application.Web/Controllers/User/BagController.cs @@ -136,8 +136,18 @@ public class BagController : ControllerBase public async Task CheckUserProp([FromBody] CheckUserPropParms parms) { string userId = StateHelper.userId; - List needs = JsonConvert.DeserializeObject>(parms.needs); - var result = await GameBus.CheckNeeds(userId, needs, 1); - return PoAction.Ok(result); + parms.count = parms.count < 1 ? 1 : parms.count; + if (parms.type == 0) + { + List needs = JsonConvert.DeserializeObject>(parms.needs); + var result = await GameBus.CheckNeed(userId, needs, parms.count); + return PoAction.Ok(result); + } + else + { + List needs = JsonConvert.DeserializeObject>(parms.needs); + var result = await GameBus.CheckNeeds(userId, needs, parms.count); + return PoAction.Ok(result); + } } } \ No newline at end of file diff --git a/Service/Application.Web/Model/RequestParms/User/CheckUserPropParms.cs b/Service/Application.Web/Model/RequestParms/User/CheckUserPropParms.cs index 0a33a6f..1d9788e 100644 --- a/Service/Application.Web/Model/RequestParms/User/CheckUserPropParms.cs +++ b/Service/Application.Web/Model/RequestParms/User/CheckUserPropParms.cs @@ -2,5 +2,7 @@ public class CheckUserPropParms { + public int type { get; set; } + public int count { get; set; } public string needs { get; set; } } \ No newline at end of file diff --git a/Web/public/images/equ/gw.png b/Web/public/images/equ/gw.png new file mode 100644 index 0000000..f312486 Binary files /dev/null and b/Web/public/images/equ/gw.png differ diff --git a/Web/public/images/equ/hm.gif b/Web/public/images/equ/hm.gif new file mode 100644 index 0000000..617119b Binary files /dev/null and b/Web/public/images/equ/hm.gif differ diff --git a/Web/public/images/equ/l.gif b/Web/public/images/equ/l.gif new file mode 100644 index 0000000..ccb64a8 Binary files /dev/null and b/Web/public/images/equ/l.gif differ diff --git a/Web/public/images/equ/ly.gif b/Web/public/images/equ/ly.gif new file mode 100644 index 0000000..0b0f091 Binary files /dev/null and b/Web/public/images/equ/ly.gif differ diff --git a/Web/public/images/equ/ms.png b/Web/public/images/equ/ms.png new file mode 100644 index 0000000..7c48fcd Binary files /dev/null and b/Web/public/images/equ/ms.png differ diff --git a/Web/public/images/equ/r.gif b/Web/public/images/equ/r.gif new file mode 100644 index 0000000..d4c6282 Binary files /dev/null and b/Web/public/images/equ/r.gif differ diff --git a/Web/public/images/equ/sy.png b/Web/public/images/equ/sy.png new file mode 100644 index 0000000..745b18c Binary files /dev/null and b/Web/public/images/equ/sy.png differ diff --git a/Web/public/images/equ/tq.png b/Web/public/images/equ/tq.png new file mode 100644 index 0000000..13c5e37 Binary files /dev/null and b/Web/public/images/equ/tq.png differ diff --git a/Web/public/images/equ/ty.png b/Web/public/images/equ/ty.png new file mode 100644 index 0000000..a9f3e11 Binary files /dev/null and b/Web/public/images/equ/ty.png differ diff --git a/Web/public/images/equ/zx.png b/Web/public/images/equ/zx.png new file mode 100644 index 0000000..3d9d9e6 Binary files /dev/null and b/Web/public/images/equ/zx.png differ diff --git a/Web/src/assets/css/style.css b/Web/src/assets/css/style.css index 15de8d8..5d6b518 100644 --- a/Web/src/assets/css/style.css +++ b/Web/src/assets/css/style.css @@ -106,9 +106,11 @@ a:focus { margin-right: 2px; vertical-align: middle; } + .border-btm { border-bottom: 1px solid #E3E6EB; } + .input { line-height: 30px; } @@ -124,30 +126,33 @@ a:focus { border: 1px solid #ccc; border-radius: 4px; box-shadow: inset 0 1px 1px rgb(0 0 0 / 8%); - transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s; + transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s; } + .ipt-btn-gray-m { width: 60px; height: 20px; border: none; } -.serch{ - display: flex; + +.serch { + display: flex; align-items: flex-end; } -.search-ipt{ + +.search-ipt { width: 80px; font-size: 11px; - padding: 0 ; + padding: 0; } -.ipt-btn{ +.ipt-btn { width: 61px; height: 21px; font-size: 13px; border: none; margin-top: 5px; - background: url(/css/images/btn_b_gold.gif) no-repeat; + background: url(/css/images/btn_b_gold.gif) no-repeat; color: #af4c00; } @@ -155,14 +160,16 @@ a:focus { word-wrap: break-word; } - .chat img { - margin-right: 2px; - vertical-align: middle; - } +.chat img { + margin-right: 2px; + vertical-align: middle; +} + .em { height: 30px; width: 30px; } + .badge { max-height: 25px; max-width: 25px; @@ -205,3 +212,141 @@ a:focus { background: 0 0; color: #666; } + +/******装备样式******/ +.equImg { + max-width: 130px; + max-height: 230px; +} + +.tq { + background-image: url('/images/equ/tq.png'); + background-repeat: no-repeat; + display: inline-block; + width: 15px; + height: 15px; + background-size: 15px; + /*设置图片大小*/ +} + +.ty { + background-image: url('/images/equ/ty.png'); + background-repeat: no-repeat; + display: inline-block; + width: 15px; + height: 15px; + background-size: 15px; + /*设置图片大小*/ +} + +.ms { + background-image: url('/images/equ/ms.png'); + background-repeat: no-repeat; + display: inline-block; + width: 15px; + height: 15px; + background-size: 15px; + /*设置图片大小*/ +} + +.zx { + background-image: url('/images/equ/zx.png'); + background-repeat: no-repeat; + display: inline-block; + width: 15px; + height: 15px; + background-size: 15px; + /*设置图片大小*/ +} + +.sy { + background-image: url('/images/equ/sy.png'); + background-repeat: no-repeat; + display: inline-block; + width: 15px; + height: 15px; + background-size: 15px; + /*设置图片大小*/ +} + +.gw { + background-image: url('/images/equ/gw.png'); + background-repeat: no-repeat; + display: inline-block; + width: 15px; + height: 15px; + background-size: 15px; + /*设置图片大小*/ +} + +.ly { + background-image: url('/images/equ/ly.gif'); + background-repeat: no-repeat; + display: inline-block; + width: 15px; + height: 15px; + background-size: 15px; + /*设置图片大小*/ +} + +.hm { + background-image: url('/images/equ/hm.gif'); + background-repeat: no-repeat; + display: inline-block; + width: 15px; + height: 15px; + background-size: 15px; + /*设置图片大小*/ +} + +.j_r { + background-image: url('/images/equ/r.gif'); + background-repeat: no-repeat; + display: inline-block; + width: 15px; + height: 15px; + background-size: 15px; + /*设置图片大小*/ +} + +.j_l { + background-image: url('/images/equ/l.gif'); + background-repeat: no-repeat; + display: inline-block; + width: 15px; + height: 15px; + background-size: 15px; + /*设置图片大小*/ +} + +.equ_red { + color: #912334; +} + +.equ_orange { + color: #c75e18; +} + +.equ_yellow { + color: #c28a10; +} + +.equ_green { + color: #2f9130; +} + +.equ_cyan { + color: #269680; +} + +.equ_blue { + color: #c94868; +} + +.equ_purple { + color: #873ea1; +} + +.equ_glod { + color: #e6b020; +} \ No newline at end of file diff --git a/Web/src/components/Business/GameEqu.vue b/Web/src/components/Business/GameEqu.vue index 0c29519..67e3fdc 100644 --- a/Web/src/components/Business/GameEqu.vue +++ b/Web/src/components/Business/GameEqu.vue @@ -1,10 +1,10 @@ \ No newline at end of file diff --git a/Web/src/pages/business/equmake.vue b/Web/src/pages/business/equmake.vue new file mode 100644 index 0000000..3f8adaf --- /dev/null +++ b/Web/src/pages/business/equmake.vue @@ -0,0 +1,105 @@ + + \ No newline at end of file diff --git a/Web/src/pages/business/retEqu.vue b/Web/src/pages/business/retEqu.vue new file mode 100644 index 0000000..a15745b --- /dev/null +++ b/Web/src/pages/business/retEqu.vue @@ -0,0 +1,71 @@ + + \ No newline at end of file diff --git a/Web/src/pages/map/index.vue b/Web/src/pages/map/index.vue index 2153825..25abd0b 100644 --- a/Web/src/pages/map/index.vue +++ b/Web/src/pages/map/index.vue @@ -1,8 +1,5 @@