From 7ce9787172f4471c8cf94266fc117dabb57a6200 Mon Sep 17 00:00:00 2001 From: Putoo <290555932@qq.com> Date: Tue, 30 Jun 2026 18:05:40 +0800 Subject: [PATCH] 121212 --- Kx.SeaTime.sln.DotSettings.user | 1 + .../db/unit_user_load.cs | 10 + .../game/user/unit_user_stock.cs | 60 ++++++ Service/Application.Domain/Enum/GameEnum.cs | 12 ++ Service/Application.Domain/Enum/GoodsEnum.cs | 9 + .../Interface/Goods/IGameGoodsService.cs | 8 + .../Interface/User/IUnitUserAttrService.cs | 27 ++- .../Service/Goods/GameGoodsService.cs | 142 +++++++++++- .../Service/User/UnitUserAttrService.cs | 202 +++++++++++++++++- .../Tool/Base/GameAttrTool.cs | 49 ++++- .../Controllers/Pub/GoodsController.cs | 50 +++-- .../Controllers/User/UserController.cs | 8 +- Web/src/pages/user/index.vue | 22 +- 13 files changed, 558 insertions(+), 42 deletions(-) create mode 100644 Service/Application.Domain.Entity/db/unit_user_load.cs create mode 100644 Service/Application.Domain.Entity/game/user/unit_user_stock.cs diff --git a/Kx.SeaTime.sln.DotSettings.user b/Kx.SeaTime.sln.DotSettings.user index b8201f6..f7d6c25 100644 --- a/Kx.SeaTime.sln.DotSettings.user +++ b/Kx.SeaTime.sln.DotSettings.user @@ -8,6 +8,7 @@ ForceIncluded ForceIncluded ForceIncluded + ForceIncluded ForceIncluded ForceIncluded ForceIncluded diff --git a/Service/Application.Domain.Entity/db/unit_user_load.cs b/Service/Application.Domain.Entity/db/unit_user_load.cs new file mode 100644 index 0000000..d0d9e3d --- /dev/null +++ b/Service/Application.Domain.Entity/db/unit_user_load.cs @@ -0,0 +1,10 @@ +namespace Application.Domain.Entity; + +public class unit_user_load +{ + public string id { get; set; } + public string userId { get; set; } + public string name { get; set; } + public string code { get; set; } + public int count { get; set; } +} \ No newline at end of file diff --git a/Service/Application.Domain.Entity/game/user/unit_user_stock.cs b/Service/Application.Domain.Entity/game/user/unit_user_stock.cs new file mode 100644 index 0000000..e60cd51 --- /dev/null +++ b/Service/Application.Domain.Entity/game/user/unit_user_stock.cs @@ -0,0 +1,60 @@ +using SqlSugar; +using System; + +namespace Application.Domain.Entity +{ + [Tenant("Kg.SeaTime.Game")] + public class unit_user_stock + { + /// + /// usId + /// + [SugarColumn(IsPrimaryKey = true, Length = 50)] + public string usId { get; set; } + + /// + /// userId + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? userId { get; set; } + + /// + /// goodsId + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? goodsId { get; set; } + + [SugarColumn(Length = 50, IsNullable = true)] + public string? name { get; set; } + + /// + /// type + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? type { get; set; } + + /// + /// code + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? code { get; set; } + + /// + /// sign + /// + [SugarColumn(IsNullable = true)] + public long? sign { get; set; } + + /// + /// par + /// + [SugarColumn(IsNullable = true)] + public string? par { get; set; } + + /// + /// endTime + /// + [SugarColumn(IsNullable = true)] + public long? endTime { get; set; } + } +} \ No newline at end of file diff --git a/Service/Application.Domain/Enum/GameEnum.cs b/Service/Application.Domain/Enum/GameEnum.cs index e7f60bc..2adf76b 100644 --- a/Service/Application.Domain/Enum/GameEnum.cs +++ b/Service/Application.Domain/Enum/GameEnum.cs @@ -135,4 +135,16 @@ public static class GameEnum DisStealth,//反隐效果 TM,//天幕 } + + public enum GameStockCode + { + Blood, + Durability, + + } + public enum GameStockType + { + Number,//数值 + Time,//时间 + } } \ No newline at end of file diff --git a/Service/Application.Domain/Enum/GoodsEnum.cs b/Service/Application.Domain/Enum/GoodsEnum.cs index 6e0a607..5066e51 100644 --- a/Service/Application.Domain/Enum/GoodsEnum.cs +++ b/Service/Application.Domain/Enum/GoodsEnum.cs @@ -20,4 +20,13 @@ public static class GoodsEnum State,//状态物品 Ship,//船只 } + + public enum DrugCls + { + Blood,//普通体力药品 + BloodStock,//体力储存药品 + Vigour,//活力 + Morale,//士气 + LoadBuff,//消除负面状态 + } } \ No newline at end of file diff --git a/Service/Application.Domain/Services/Interface/Goods/IGameGoodsService.cs b/Service/Application.Domain/Services/Interface/Goods/IGameGoodsService.cs index 2a55a2f..05814d6 100644 --- a/Service/Application.Domain/Services/Interface/Goods/IGameGoodsService.cs +++ b/Service/Application.Domain/Services/Interface/Goods/IGameGoodsService.cs @@ -27,5 +27,13 @@ public interface IGameGoodsService Task GetUserGoodWeightSum(string userId, int type); + #endregion + + #region 药品 + + Task CheckUseDrug(string userId, int goodsId, string drugConfig, string scene = ""); + Task UseDrug(string userId, int goodsId, string drugConfig, string scene = ""); + + #endregion } \ No newline at end of file diff --git a/Service/Application.Domain/Services/Interface/User/IUnitUserAttrService.cs b/Service/Application.Domain/Services/Interface/User/IUnitUserAttrService.cs index 9eecec8..c9d10ba 100644 --- a/Service/Application.Domain/Services/Interface/User/IUnitUserAttrService.cs +++ b/Service/Application.Domain/Services/Interface/User/IUnitUserAttrService.cs @@ -7,6 +7,7 @@ public interface IUnitUserAttrService Task GetUserAttrModel(string userId, string scene = "Default"); Task GetUserAttr(string userId); Task GetUserLev(string userId); + #endregion #region 体力操作 @@ -29,6 +30,7 @@ public interface IUnitUserAttrService Task UpdateUserMorale(string userId, int op, int count); Task CheackRecoverMorale(string userId); Task LockRecoverMorale(string userId); + #endregion #region 活力 @@ -43,23 +45,42 @@ public interface IUnitUserAttrService Task UpdateOnLineTime(string userId, string code, int time); - #endregion - #region 药品栏 + #region 药品栏 Task GetUserDrug(string userId); Task UpdateUserDrug(unit_user_drug data); #endregion - #region 状态 + #region BUFF状态 Task> GetUserStateData(string userId, string scene = "Default"); Task AddUserState(string userId, string groupId, string name, string scene, string tips, List attr, int time, int count = 1); + #endregion + + #region 游戏资源储备 + + Task> GetUserStock(string userId, string code = "Default"); + + Task AddUserStock(string userId, string goodsId,string name, string type, string code, long sign, + string par = "", + int minute = 0); + + Task UpdateUserStock(unit_user_stock data); + + #endregion + + #region 负面状态 + + Task> GetUserLoadState(string userId); + Task AddUserLoadState(string userId, string name, string code); + Task RandomRemoveUserLoadState(string userId, int count); + Task RemoveUserLoadState(string userId); #endregion } \ No newline at end of file diff --git a/Service/Application.Domain/Services/Service/Goods/GameGoodsService.cs b/Service/Application.Domain/Services/Service/Goods/GameGoodsService.cs index 36b2087..1f34601 100644 --- a/Service/Application.Domain/Services/Service/Goods/GameGoodsService.cs +++ b/Service/Application.Domain/Services/Service/Goods/GameGoodsService.cs @@ -1,4 +1,5 @@ using System.Reflection.Metadata; +using Newtonsoft.Json; namespace Application.Domain; @@ -68,6 +69,7 @@ public class GameGoodsService(ISqlSugarClient DbClient, IRedisCache redis) : IGa .OrderBy(it => it.count, OrderByType.Desc) .ToPageListAsync(page, limit, total); } + public async Task> GetUserGoodsData(string userId, string code) { var db = DbClient.AsTenant().GetConnectionWithAttr(); @@ -163,8 +165,6 @@ public class GameGoodsService(ISqlSugarClient DbClient, IRedisCache redis) : IGa return await db.Insertable(bagLog).SplitTable().ExecuteCommandAsync() > 0; } - - #endregion #region 辅助 @@ -187,10 +187,142 @@ public class GameGoodsService(ISqlSugarClient DbClient, IRedisCache redis) : IGa #endregion - #region 药品 + #region 药品 - - + private async Task GetUserDrugLockTime(string userId, int goodsId) + { + long result = 0; + string key = string.Format(UserCache.BaseCacheKey, "UserDrug", $"Lock:{userId}_{goodsId}"); + if (await redis.ExistsAsync(key)) + { + long end = await redis.GetAsync(key); + result = end - TimeExtend.GetTimeStampSeconds; + result = result < 0 ? 0 : result; + } + + return result; + } + + private async Task AddUserDrugLockTime(string userId, int goodsId, int time) + { + if (time > 0) + { + long end = TimeExtend.GetTimeStampSeconds + time; + string key = string.Format(UserCache.BaseCacheKey, "UserDrug", $"Lock:{userId}_{goodsId}"); + await redis.SetAsync(key, end, time); + } + } + + private async Task GetUserDrugLockCount(string userId, int goodsId, string scene = "") + { + int result = 0; + if (!string.IsNullOrEmpty(scene)) + { + string key = string.Format(UserCache.BaseCacheKey, "UserDrug", $"Count:{scene}:{userId}_{goodsId}"); + if (await redis.ExistsAsync(key)) + { + result = await redis.GetAsync(key); + } + } + + return result; + } + + private async Task AddUserDrugLockCount(string userId, int goodsId, string scene = "") + { + if (!string.IsNullOrEmpty(scene)) + { + var count = await GetUserDrugLockCount(userId, goodsId, scene); + count += 1; + string key = string.Format(UserCache.BaseCacheKey, "UserDrug", $"Count:{scene}:{userId}_{goodsId}"); + await redis.SetAsync(key, count, 43200); + } + } + + + public async Task CheckUseDrug(string userId, int goodsId, string drugConfig, string scene = "") + { + string result = string.Empty; + dynamic _drugConfig = JsonConvert.DeserializeObject(drugConfig); + if (_drugConfig.cls == nameof(GoodsEnum.DrugCls.Blood)) + { + //判断所定 + long lockTime = await GetUserDrugLockTime(userId, goodsId); + if (lockTime > 0) + { + result = $"药品冷却中,{lockTime}秒后可使用!"; + } + } + else if (_drugConfig.cls == nameof(GoodsEnum.DrugCls.BloodStock)) + { + if (_drugConfig.type == nameof(GameEnum.GameStockType.Number)) + { + if (string.IsNullOrEmpty(scene)) + { + var attrService = App.GetService(); + var userStock = await attrService.GetUserStock(userId); + if (userStock.Count(it => it.goodsId == goodsId.ToString()) > 0) + { + result = "您已经使用过该药品啦!"; + } + } + else + { + //要判断使用个数 + if (_drugConfig.use > 0) + { + var count = await GetUserDrugLockCount(userId, goodsId, scene); + if (count >= _drugConfig.use) + { + result = $"当前最多可用{_drugConfig.use}个该物品!"; + } + } + } + } + } + + return result; + } + + public async Task UseDrug(string userId, int goodsId, string drugConfig, string scene = "") + { + bool result = false; + var attrService = App.GetService(); + dynamic _drugConfig = JsonConvert.DeserializeObject(drugConfig); + if (_drugConfig.cls == nameof(GoodsEnum.DrugCls.Blood)) + { + result = await attrService.UpdateUserBlood(userId, 1, Convert.ToInt32(_drugConfig.num), true); + if (result) + { + await AddUserDrugLockTime(userId, goodsId, Convert.ToInt32(_drugConfig.time)); + } + } + else if (_drugConfig.cls == nameof(GoodsEnum.DrugCls.Morale)) + { + result = await attrService.UpdateUserMorale(userId, 1, Convert.ToInt32(_drugConfig.num)); + } + else if (_drugConfig.cls == nameof(GoodsEnum.DrugCls.Vigour)) + { + result = await attrService.UpdateUserVigour(userId, 1, Convert.ToInt32(_drugConfig.num)); + } + else if (_drugConfig.cls == nameof(GoodsEnum.DrugCls.LoadBuff)) + { + result = await attrService.RandomRemoveUserLoadState(userId, Convert.ToInt32(_drugConfig.num)); + } + else if (_drugConfig.cls == nameof(GoodsEnum.DrugCls.BloodStock)) + { + result = await attrService.AddUserStock(userId, goodsId.ToString(), Convert.ToString(_drugConfig.name),Convert.ToString(_drugConfig.type), + Convert.ToString(_drugConfig.code), + Convert.ToInt64(_drugConfig.num), Convert.ToString(_drugConfig.par), + Convert.ToInt32(_drugConfig.minute)); + if (result) + { + await AddUserDrugLockCount(userId, goodsId, scene); + } + } + + return result; + } #endregion } \ No newline at end of file diff --git a/Service/Application.Domain/Services/Service/User/UnitUserAttrService.cs b/Service/Application.Domain/Services/Service/User/UnitUserAttrService.cs index 8d8db19..117b9eb 100644 --- a/Service/Application.Domain/Services/Service/User/UnitUserAttrService.cs +++ b/Service/Application.Domain/Services/Service/User/UnitUserAttrService.cs @@ -129,7 +129,8 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) : result.morale = (int)userMorale.morale; //负面状态处理 - //result = await GameAttrTool.CheakRoleLoadBuff(result); + var loadState = await GetUserLoadState(userId); + result = await GameAttrTool.CheckRoleLoadBuff(result, loadState); result = await ReviseUserRoleAttr(result); return result; @@ -241,6 +242,11 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) : else if (op == 1) { data.blood += count; + var myAttr = await GetUserAttrModel(userId); + if (myAttr != null) + { + data.blood = data.blood > myAttr.upBlood ? myAttr.upBlood : data.blood; + } } } @@ -369,6 +375,8 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) : if (op == 1) { data.morale += count; + var myAttr = await GetUserAttrModel(userId); + data.morale = data.morale > myAttr.upMorale ? myAttr.upMorale : data.morale; } else if (op == 2) { @@ -431,6 +439,13 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) : public async Task UpdateUserVigour(string userId, int op, long count, string UpTime = "") { + if (op == 1) + { + var userVigour = await GetUserVigourInfo(userId); + long endVigour = (long)userVigour.upVitality - (long)userVigour.vitality; + count = endVigour > count ? count : endVigour; + } + bool result = false; try { @@ -532,7 +547,7 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) : #endregion - #region 状态 + #region BUFF状态 private async Task> GetUserStateData(string userId) { @@ -557,6 +572,7 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) : { return data; } + data = data.FindAll(it => it.scene == "Default" || it.scene == scene); return data; } @@ -613,4 +629,186 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) : } #endregion + + #region 游戏资源储备 + + private async Task> GetUserStock(string userId) + { + string key = string.Format(UserCache.BaseCacheKeys, "AttrData", "Stock"); + var data = await redis.GetHashAsync>(key, userId); + if (data == null) + { + var db = DbClient.AsTenant().GetConnectionWithAttr(); + data = await db.Queryable().Where(it => it.userId == userId).ToListAsync(); + await redis.AddHashAsync(key, userId, data); + } + + return data; + } + + public async Task> GetUserStock(string userId, string code = "Default") + { + var data = await GetUserStock(userId); + if (code != "Default") + { + data = data.FindAll(it => it.code == code); + } + + long endTime = TimeExtend.GetTimeStampSeconds; + data = data.FindAll(it => + ((it.type == "Number" && it.sign > 0) || it.type != "Number") && it.endTime > endTime); + return data; + } + + public async Task AddUserStock(string userId, string goodsId, string name, string type, string code, + long sign, + string par = "", + int minute = 0) + { + if (minute == 0) + { + minute = 525600; + } + + bool result = false; + string usId = $"{userId}_{goodsId}"; + var db = DbClient.AsTenant().GetConnectionWithAttr(); + var usInfo = await db.Queryable().Where(it => it.usId == usId).SingleAsync(); + if (usInfo == null) + { + long endTime = TimeExtend.GetTimeStampSeconds + minute * 60; + unit_user_stock stock = new unit_user_stock() + { + usId = usId, + userId = userId, + goodsId = goodsId, + name = name, + type = type, + code = code, + sign = sign, + par = par, + endTime = endTime + }; + result = await db.Insertable(stock).ExecuteCommandAsync() > 0; + } + else + { + if (usInfo.type == nameof(GameEnum.GameStockType.Number)) + { + usInfo.sign += sign; + usInfo.endTime = TimeExtend.GetTimeStampSeconds + minute * 60; + } + else if (usInfo.type == nameof(GameEnum.GameStockType.Time)) + { + long onTime = TimeExtend.GetTimeStampSeconds; + if (usInfo.endTime > onTime) + { + usInfo.endTime = usInfo.endTime + (minute * 60); + } + else + { + usInfo.endTime = TimeExtend.GetTimeStampSeconds + (minute * 60); + } + } + + result = await db.Updateable(usInfo).ExecuteCommandAsync() > 0; + } + + if (result) + { + await ClearUserStockCache(userId); + } + + return result; + } + + private async Task ClearUserStockCache(string userId) + { + string key = string.Format(UserCache.BaseCacheKeys, "AttrData", "Stock"); + await redis.DelHashAsync(key, userId); + } + + public async Task UpdateUserStock(unit_user_stock data) + { + var db = DbClient.AsTenant().GetConnectionWithAttr(); + var result = await db.Updateable(data).ExecuteCommandAsync() > 0; + if (result) + { + await ClearUserAttrCache(data.userId); + } + + return result; + } + + #endregion + + #region 负面状态 + + public async Task> GetUserLoadState(string userId) + { + string key = string.Format(UserCache.BaseCacheKeys, "AttrData", "LoadState"); + if (await redis.HExistsHashAsync(key, userId)) + { + return await redis.GetHashAsync>(key, userId); + } + + return new List(); + } + + public async Task AddUserLoadState(string userId, string name, string code) + { + bool result = false; + string key = string.Format(UserCache.BaseCacheKeys, "AttrData", "LoadState"); + var data = await GetUserLoadState(userId); + var onData = data.Find(it => it.code == code); + if (onData == null) + { + unit_user_load load = new unit_user_load() + { + id = $"{userId}_{code}", + userId = userId, + name = name, + code = code, + count = 1 + }; + data.Add(load); + result = await redis.AddHashAsync(key, userId, data); + } + else + { + data.Remove(onData); + onData.count += 1; + result = await redis.AddHashAsync(key, userId, data); + } + + return result; + } + + public async Task RandomRemoveUserLoadState(string userId, int count) + { + var data = await GetUserLoadState(userId); + int opCount = data.Count - count; + opCount = opCount < 0 ? 0 : opCount; + if (opCount > 0) + { + RandomAssist random = new RandomAssist(opCount); + var result = random.RandomExtract(data); + string key = string.Format(UserCache.BaseCacheKeys, "AttrData", "LoadState"); + await redis.AddHashAsync(key, userId, result); + } + else + { + await RemoveUserLoadState(userId); + } + + return true; + } + + public async Task RemoveUserLoadState(string userId) + { + string key = string.Format(UserCache.BaseCacheKeys, "AttrData", "LoadState"); + await redis.DelHashAsync(key, userId); + } + + #endregion } \ No newline at end of file diff --git a/Service/Application.Domain/Tool/Base/GameAttrTool.cs b/Service/Application.Domain/Tool/Base/GameAttrTool.cs index 0ac0e1e..bd73728 100644 --- a/Service/Application.Domain/Tool/Base/GameAttrTool.cs +++ b/Service/Application.Domain/Tool/Base/GameAttrTool.cs @@ -1,4 +1,5 @@ -namespace Application.Domain; + +namespace Application.Domain; public class GameAttrTool { @@ -134,6 +135,7 @@ public class GameAttrTool main.PalsyAtkLess += vice.PalsyAtkLess; return main; } + public static decimal GetAttrItemValue(string attrCode, List AttrData, decimal unit) { decimal result = 0.00M; @@ -167,4 +169,49 @@ public class GameAttrTool return result; } + + public static async Task CheckRoleLoadBuff(UserAttrModel temp, List loadBuff) + { + foreach (var item in loadBuff) + { + if (item.code == nameof(GameEnum.AttrCode.Slow)) + { + decimal radio = item.count * 0.05M; + temp.agility = Convert.ToInt32(temp.agility * (1.0M - radio)); + } + else if (item.code == nameof(GameEnum.AttrCode.Poison)) + { + decimal radio = item.count * 0.08M; + temp.upBlood = Convert.ToInt32(temp.upBlood * (1.0M - radio)); + } + else if (item.code == nameof(GameEnum.AttrCode.Curse)) + { + decimal radio = item.count * 0.08M; + temp.minAtk = Convert.ToInt32(temp.minAtk * (1.0M - radio)); + temp.maxAtk = Convert.ToInt32(temp.maxAtk * (1.0M - radio)); + } + else if (item.code == nameof(GameEnum.AttrCode.Weaken)) + { + decimal radio = item.count * 0.02M; + temp.Crit = temp.Crit - radio; + } + else if (item.code == nameof(GameEnum.AttrCode.Depressed)) + { + decimal radio = item.count * 0.07M; + temp.upMorale = Convert.ToInt32(temp.upMorale * (1.0M - radio)); + } + else if (item.code == nameof(GameEnum.AttrCode.Breach)) + { + decimal radio = item.count * 0.04M; + temp.defense = Convert.ToInt32(temp.defense * (1.0M - radio)); + } + else if (item.code == nameof(GameEnum.AttrCode.PalsyAtk)) + { + decimal radio = item.count * 0.1M; + temp.Atk_Next -= radio; + } + } + + return temp; + } } \ No newline at end of file diff --git a/Service/Application.Web/Controllers/Pub/GoodsController.cs b/Service/Application.Web/Controllers/Pub/GoodsController.cs index 8815f20..0221cab 100644 --- a/Service/Application.Web/Controllers/Pub/GoodsController.cs +++ b/Service/Application.Web/Controllers/Pub/GoodsController.cs @@ -42,25 +42,20 @@ public class GoodsController : ControllerBase string userId = StateHelper.userId; int count = await _goodsService.GetUserGoodsCount(userId, goodsId); int UseState = 0; - switch (goodsInfo.code) + string[] ShowViewNum = ["Pack", "Weight", "State"]; //显示带数量窗口 + string[] ShowView = ["Ship","Drug"]; //显示只能使用1个的窗口 + if (ShowViewNum.Any(it => it == goodsInfo.code)) { - case "Pack": - UseState = 1; - break; - case "Weight": - UseState = 1; - break; - case "State": - UseState = 1; - break; - case "Ship": - UseState = 2; - break; - case "ChoicePack": - UseState = 3; - break; + 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, use = UseState }); } @@ -105,6 +100,15 @@ public class GoodsController : ControllerBase } } + 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, "使用物品")) @@ -159,7 +163,11 @@ public class GoodsController : ControllerBase 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 @@ -167,7 +175,7 @@ public class GoodsController : ControllerBase return PoAction.Message("使用失败,请稍后尝试!"); } } - + /// /// 使用选择物品礼包 /// @@ -200,6 +208,7 @@ public class GoodsController : ControllerBase { return PoAction.Message("无法使用该物品!"); } + List choiceGoods = JsonConvert.DeserializeObject>(goodsInfo.content); var onAward = choiceGoods.Find(it => it.id == num); if (onAward == null) @@ -212,11 +221,12 @@ public class GoodsController : ControllerBase { if (await GameBus.UpdateBag(userId, 1, onAward.award, "打开礼包获取")) { - string message = $"打开[{goodsInfo.goodsName}],获得:"; + 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); diff --git a/Service/Application.Web/Controllers/User/UserController.cs b/Service/Application.Web/Controllers/User/UserController.cs index 13e7d4c..9ab4b4d 100644 --- a/Service/Application.Web/Controllers/User/UserController.cs +++ b/Service/Application.Web/Controllers/User/UserController.cs @@ -55,9 +55,9 @@ public class UserController : ControllerBase var accInfo = await _accService.GetUserAccInfo(userId); object acc = new { accInfo.gold, accInfo.cowry, accInfo.teach, accInfo.renown }; - var buff = await _attrService.GetUserStateData(userId,"ALL"); - - object result = new { user, attr = attrInfo, exp, vigourInfo.vitality, acc,buff }; + 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); } @@ -175,7 +175,7 @@ public class UserController : ControllerBase var suit = await _equService.GetUserEquSuit(userInfo.userId); object result = new { - user, attr = new { attrInfo.lev }, acc, isOnline, onMapName, isFriend, isEnemy, team, equ,suit + user, attr = new { attrInfo.lev }, acc, isOnline, onMapName, isFriend, isEnemy, team, equ, suit }; return PoAction.Ok(result); } diff --git a/Web/src/pages/user/index.vue b/Web/src/pages/user/index.vue index 3b08a59..4dbcd56 100644 --- a/Web/src/pages/user/index.vue +++ b/Web/src/pages/user/index.vue @@ -28,14 +28,20 @@
---◈BUFF状态◈---
- ✧{{item.name}}:{{item.tips}}(剩余{{ item.endTime - TimeExtend.GetSecondStamp() }}秒) + ✧{{ item.name }}:{{ item.tips }}(剩余{{ item.endTime - TimeExtend.GetSecondStamp() }}秒) +
+
+
+ ---◈其他状态◈---
+
+
+ ✦{{ item.name }}:{{ item.sign }} +
+
+ ✧{{ item.name }}:剩余{{ item.endTime - TimeExtend.GetSecondStamp() }}秒 +
-
- -
@@ -66,7 +72,8 @@ const vitality = ref(0); const expData = ref({}); const attrData = ref({}); const accData = ref({}); -const buff = ref([]); +const buff = ref>([]); +const stock = ref>([]); onMounted(async () => { try { @@ -88,6 +95,7 @@ const BindData = async (): Promise => { attrData.value = result.data.attr; accData.value = result.data.acc; buff.value = result.data.buff; + stock.value = result.data.stock; console.log(result); } else {