This commit is contained in:
Putoo
2026-06-30 18:05:40 +08:00
parent 93d21ba9fd
commit 7ce9787172
13 changed files with 558 additions and 42 deletions

View File

@@ -8,6 +8,7 @@
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ANullable_00601_002Ecs_002Fl_003AC_0021_003FUsers_003F29055_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F51505665371d472f8bdbc333fa4d888cf49938_003F58_003F4ed88c93_003FNullable_00601_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003APoAction_002Ecs_002Fl_003AC_0021_003FUsers_003F29055_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F8fb1d14dca1046e78e0684daa8bc3a1b7800_003Fb7_003F35e46383_003FPoAction_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ARandomAssist_002Ecs_002Fl_003AC_0021_003FUsers_003F29055_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fa380d649d5b2495d9bfa0fa24f13662b6400_003F90_003F676312fd_003FRandomAssist_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ARuntimeTypeHandle_002Ecs_002Fl_003AC_0021_003FUsers_003F29055_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F51505665371d472f8bdbc333fa4d888cf49938_003Fa5_003Faf039d5f_003FRuntimeTypeHandle_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASqlSetup_002Ecs_002Fl_003AC_0021_003FUsers_003F29055_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F72993acb059c49dcbba437a858c0b0942000_003F46_003F2e14505d_003FSqlSetup_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASqlSugarScopeProvider_002Ecs_002Fl_003AC_0021_003FUsers_003F29055_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F6c0f22f0a47643a3b2a40899acd2044c2e3a00_003Fc5_003F4738d33f_003FSqlSugarScopeProvider_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AStringAssist_002Ecs_002Fl_003AC_0021_003FUsers_003F29055_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fa380d649d5b2495d9bfa0fa24f13662b6400_003Fee_003F90da4dea_003FStringAssist_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>

View File

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

View File

@@ -0,0 +1,60 @@
using SqlSugar;
using System;
namespace Application.Domain.Entity
{
[Tenant("Kg.SeaTime.Game")]
public class unit_user_stock
{
/// <summary>
/// usId
/// </summary>
[SugarColumn(IsPrimaryKey = true, Length = 50)]
public string usId { get; set; }
/// <summary>
/// userId
/// </summary>
[SugarColumn(Length = 50, IsNullable = true)]
public string? userId { get; set; }
/// <summary>
/// goodsId
/// </summary>
[SugarColumn(Length = 50, IsNullable = true)]
public string? goodsId { get; set; }
[SugarColumn(Length = 50, IsNullable = true)]
public string? name { get; set; }
/// <summary>
/// type
/// </summary>
[SugarColumn(Length = 50, IsNullable = true)]
public string? type { get; set; }
/// <summary>
/// code
/// </summary>
[SugarColumn(Length = 50, IsNullable = true)]
public string? code { get; set; }
/// <summary>
/// sign
/// </summary>
[SugarColumn(IsNullable = true)]
public long? sign { get; set; }
/// <summary>
/// par
/// </summary>
[SugarColumn(IsNullable = true)]
public string? par { get; set; }
/// <summary>
/// endTime
/// </summary>
[SugarColumn(IsNullable = true)]
public long? endTime { get; set; }
}
}

View File

@@ -135,4 +135,16 @@ public static class GameEnum
DisStealth,//反隐效果
TM,//天幕
}
public enum GameStockCode
{
Blood,
Durability,
}
public enum GameStockType
{
Number,//数值
Time,//时间
}
}

View File

@@ -20,4 +20,13 @@ public static class GoodsEnum
State,//状态物品
Ship,//船只
}
public enum DrugCls
{
Blood,//普通体力药品
BloodStock,//体力储存药品
Vigour,//活力
Morale,//士气
LoadBuff,//消除负面状态
}
}

View File

@@ -27,5 +27,13 @@ public interface IGameGoodsService
Task<int> GetUserGoodWeightSum(string userId, int type);
#endregion
#region
Task<string> CheckUseDrug(string userId, int goodsId, string drugConfig, string scene = "");
Task<bool> UseDrug(string userId, int goodsId, string drugConfig, string scene = "");
#endregion
}

View File

@@ -7,6 +7,7 @@ public interface IUnitUserAttrService
Task<UserAttrModel> GetUserAttrModel(string userId, string scene = "Default");
Task<unit_user_attr> GetUserAttr(string userId);
Task<int> GetUserLev(string userId);
#endregion
#region
@@ -29,6 +30,7 @@ public interface IUnitUserAttrService
Task<bool> UpdateUserMorale(string userId, int op, int count);
Task<bool> CheackRecoverMorale(string userId);
Task LockRecoverMorale(string userId);
#endregion
#region
@@ -43,7 +45,6 @@ public interface IUnitUserAttrService
Task<bool> UpdateOnLineTime(string userId, string code, int time);
#endregion
#region
@@ -53,13 +54,33 @@ public interface IUnitUserAttrService
#endregion
#region
#region BUFF状
Task<List<unit_user_state>> GetUserStateData(string userId, string scene = "Default");
Task<bool> AddUserState(string userId, string groupId, string name, string scene, string tips,
List<AttrItem> attr, int time, int count = 1);
#endregion
#region
Task<List<unit_user_stock>> GetUserStock(string userId, string code = "Default");
Task<bool> AddUserStock(string userId, string goodsId,string name, string type, string code, long sign,
string par = "",
int minute = 0);
Task<bool> UpdateUserStock(unit_user_stock data);
#endregion
#region
Task<List<unit_user_load>> GetUserLoadState(string userId);
Task<bool> AddUserLoadState(string userId, string name, string code);
Task<bool> RandomRemoveUserLoadState(string userId, int count);
Task RemoveUserLoadState(string userId);
#endregion
}

View File

@@ -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<List<unit_user_goods>> GetUserGoodsData(string userId, string code)
{
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_goods>();
@@ -163,8 +165,6 @@ public class GameGoodsService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
return await db.Insertable(bagLog).SplitTable().ExecuteCommandAsync() > 0;
}
#endregion
#region
@@ -189,8 +189,140 @@ public class GameGoodsService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
#region
private async Task<long> 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<long>(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<int> 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<int>(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<string> CheckUseDrug(string userId, int goodsId, string drugConfig, string scene = "")
{
string result = string.Empty;
dynamic _drugConfig = JsonConvert.DeserializeObject<dynamic>(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<IUnitUserAttrService>();
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<bool> UseDrug(string userId, int goodsId, string drugConfig, string scene = "")
{
bool result = false;
var attrService = App.GetService<IUnitUserAttrService>();
dynamic _drugConfig = JsonConvert.DeserializeObject<dynamic>(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
}

View File

@@ -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<bool> 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<List<unit_user_state>> 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<List<unit_user_stock>> GetUserStock(string userId)
{
string key = string.Format(UserCache.BaseCacheKeys, "AttrData", "Stock");
var data = await redis.GetHashAsync<List<unit_user_stock>>(key, userId);
if (data == null)
{
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_stock>();
data = await db.Queryable<unit_user_stock>().Where(it => it.userId == userId).ToListAsync();
await redis.AddHashAsync(key, userId, data);
}
return data;
}
public async Task<List<unit_user_stock>> 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<bool> 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<unit_user_stock>();
var usInfo = await db.Queryable<unit_user_stock>().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<bool> UpdateUserStock(unit_user_stock data)
{
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_stock>();
var result = await db.Updateable(data).ExecuteCommandAsync() > 0;
if (result)
{
await ClearUserAttrCache(data.userId);
}
return result;
}
#endregion
#region
public async Task<List<unit_user_load>> GetUserLoadState(string userId)
{
string key = string.Format(UserCache.BaseCacheKeys, "AttrData", "LoadState");
if (await redis.HExistsHashAsync(key, userId))
{
return await redis.GetHashAsync<List<unit_user_load>>(key, userId);
}
return new List<unit_user_load>();
}
public async Task<bool> 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<bool> 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
}

View File

@@ -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<AttrItem> AttrData, decimal unit)
{
decimal result = 0.00M;
@@ -167,4 +169,49 @@ public class GameAttrTool
return result;
}
public static async Task<UserAttrModel> CheckRoleLoadBuff(UserAttrModel temp, List<unit_user_load> 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;
}
}

View File

@@ -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;
}
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
@@ -200,6 +208,7 @@ public class GoodsController : ControllerBase
{
return PoAction.Message("无法使用该物品!");
}
List<ChoiceGoods> choiceGoods = JsonConvert.DeserializeObject<List<ChoiceGoods>>(goodsInfo.content);
var onAward = choiceGoods.Find(it => it.id == num);
if (onAward == null)
@@ -217,6 +226,7 @@ public class GoodsController : ControllerBase
{
message += $"{item.name}+{item.count},";
}
message = message.TrimEnd(',');
await _messageService.SendBroadcast(userId, nameof(MessageEnum.BroadcastCode.Award), message);

View File

@@ -56,8 +56,8 @@ public class UserController : ControllerBase
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 stock = await _attrService.GetUserStock(userId);
object result = new { user, attr = attrInfo, exp, vigourInfo.vitality, acc, buff, stock };
return PoAction.Ok(result);
}

View File

@@ -30,12 +30,18 @@
<div v-for="item in buff">
{{ item.name }}:{{ item.tips }}(剩余{{ item.endTime - TimeExtend.GetSecondStamp() }})
</div>
</div>
<!-- ---药品状态---<br>
体力宝+24370<br>
耐久包+0<br> -->
<div v-if="stock.length > 0">
---其他状态---<br>
<div v-for="item in stock">
<div v-if="item.type == 'Number'">
{{ item.name }}:{{ item.sign }}
</div>
<div v-if="item.type == 'Time'">
{{ item.name }}:剩余{{ item.endTime - TimeExtend.GetSecondStamp() }}
</div>
</div>
</div>
</div>
<div class="content">
<div class="item">
@@ -66,7 +72,8 @@ const vitality = ref(0);
const expData = ref<any>({});
const attrData = ref<any>({});
const accData = ref<any>({});
const buff = ref<any>([]);
const buff = ref<Array<any>>([]);
const stock = ref<Array<any>>([]);
onMounted(async () => {
try {
@@ -88,6 +95,7 @@ const BindData = async (): Promise<void> => {
attrData.value = result.data.attr;
accData.value = result.data.acc;
buff.value = result.data.buff;
stock.value = result.data.stock;
console.log(result);
}
else {