增加使用经验道具
This commit is contained in:
@@ -21,6 +21,8 @@ public static class GoodsEnum
|
||||
Ship,//船只
|
||||
Practise,//修炼道具
|
||||
Durability,//负重道具
|
||||
AddExp,//扣除经验获得道具
|
||||
GetExp//使用后获得经验
|
||||
}
|
||||
|
||||
public enum DrugCls
|
||||
|
||||
@@ -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<dynamic>(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<dynamic>(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
|
||||
|
||||
Reference in New Issue
Block a user