From 010ca90575af280e21ae99d54edef2bf935793ad Mon Sep 17 00:00:00 2001 From: LN <2826967552@qq.com> Date: Thu, 9 Jul 2026 17:19:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BD=BF=E7=94=A8=E7=BB=8F?= =?UTF-8?q?=E9=AA=8C=E9=81=93=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Service/Application.Domain/Enum/GoodsEnum.cs | 2 ++ .../Controllers/Pub/GoodsController.cs | 36 ++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/Service/Application.Domain/Enum/GoodsEnum.cs b/Service/Application.Domain/Enum/GoodsEnum.cs index 0d25062..789c566 100644 --- a/Service/Application.Domain/Enum/GoodsEnum.cs +++ b/Service/Application.Domain/Enum/GoodsEnum.cs @@ -21,6 +21,8 @@ public static class GoodsEnum Ship,//船只 Practise,//修炼道具 Durability,//负重道具 + AddExp,//扣除经验获得道具 + GetExp//使用后获得经验 } public enum DrugCls diff --git a/Service/Application.Web/Controllers/Pub/GoodsController.cs b/Service/Application.Web/Controllers/Pub/GoodsController.cs index 5ad3fcf..13c3269 100644 --- a/Service/Application.Web/Controllers/Pub/GoodsController.cs +++ b/Service/Application.Web/Controllers/Pub/GoodsController.cs @@ -42,7 +42,7 @@ public class GoodsController : ControllerBase string userId = StateHelper.userId; int count = await _goodsService.GetUserGoodsCount(userId, goodsId); int UseState = 0; - string[] ShowViewNum = ["Pack", "Weight", "State"]; //显示带数量窗口 + string[] ShowViewNum = ["Pack", "Weight", "State", "AddExp", "GetExp"]; //显示带数量窗口 string[] ShowView = ["Ship", "Drug", "Durability"]; //显示只能使用1个的窗口 if (ShowViewNum.Any(it => it == goodsInfo.code)) { @@ -186,6 +186,40 @@ public class GoodsController : ControllerBase Convert.ToInt32(_drugConfig.minute)); } + if (goodsInfo.code == nameof(GoodsEnum.Code.AddExp)) + { + var expInfo = await _attrService.GetUserExp(userId); + dynamic content = JsonConvert.DeserializeObject(goodsInfo.content); + int needExp = Convert.ToInt32(content.exp) * count; + if (expInfo.exp < needExp) + { + return PoAction.Message($"所需经验不足,无法使用此道具!"); + } + if (await _attrService.UpdateUserExp(userId, needExp, 0)) + { + if (await _goodsService.UpdateUserGoods(userId, 1, Convert.ToInt32(content.goods), count, string.Format("使用道具:{0}获得!", goodsInfo.goodsName))) + { + message = "使用成功!"; + } + } + } + + if (goodsInfo.code == nameof(GoodsEnum.Code.GetExp)) + { + dynamic content = JsonConvert.DeserializeObject(goodsInfo.content); + int minLev = Convert.ToInt32(content.minLev); + int maxLev = Convert.ToInt32(content.maxLev); + if (myLev < minLev || myLev > maxLev) + { + return PoAction.Message(String.Format("*该物品需要{0}级-{1}级才可以使用哦!", minLev, maxLev)); + } + int getExp = Convert.ToInt32(content.exp) * count; + if (await _attrService.UpdateUserExp(userId, getExp, 1)) + { + message = "使用成功!"; + } + } + return PoAction.Ok(true, message); } else