This commit is contained in:
Putoo
2026-07-07 11:51:45 +08:00
parent 49ac29c50a
commit 7f29fd46b8
10 changed files with 84 additions and 25 deletions

View File

@@ -28,6 +28,7 @@ public interface IGameFightService
Task<game_map_goods> GetFightGoodsInfo(string mapId, string mgId);
Task RemoveFightGoods(string mapId, string mgId);
Task AutoUseDrug(UserAttrModel user, game_fight_data fight);
Task HandelFightEnd(string userId, List<dynamic> data);
#endregion
}

View File

@@ -79,6 +79,7 @@ public interface IUnitUserAttrService
Task<List<unit_user_load>> GetUserLoadState(string userId);
Task<bool> AddUserLoadState(string userId, string name, string code);
Task AddUserLoadState(string userId, List<string> codes);
Task<bool> RandomRemoveUserLoadState(string userId, int count);
Task RemoveUserLoadState(string userId);

View File

@@ -51,6 +51,7 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame
.WhereIF(isRemLock, it => it.isLock == 0)
.WhereIF(!string.IsNullOrEmpty(equName),
it => it.equName.Contains(equName) || it.unitEquName.Contains(equName))
.OrderByDescending(it => it.isOn)
.OrderByDescending(it => it.lev)
.OrderByDescending(it => it.ueId).ToPageListAsync(PageIndex, PageSize, Total);
}

View File

@@ -563,5 +563,10 @@ public class GameFightService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
#endregion
public async Task HandelFightEnd(string userId, List<dynamic> data)
{
await Task.CompletedTask;
}
#endregion
}

View File

@@ -257,24 +257,23 @@ public class GameGoodsService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
{
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)
{
var attrService = App.GetService<IUnitUserAttrService>();
var userStock = await attrService.GetUserStock(userId);
if (userStock.Count(it => it.goodsId == goodsId.ToString()) > 0)
{
result = "您已经使用过该药品啦!";
}
result = "您已经使用过该药品啦!";
}
else
if (!string.IsNullOrEmpty(scene))
{
//要判断使用个数
if (_drugConfig.use > 0)
int useCount = Convert.ToInt32(_drugConfig.use);
if (useCount > 0)
{
var count = await GetUserDrugLockCount(userId, goodsId, scene);
if (count >= _drugConfig.use)
if (count >= Convert.ToInt32(useCount))
{
result = $"当前最多可用{_drugConfig.use}个该物品!";
result = $"当前最多可用{useCount}个该物品!";
}
}
}

View File

@@ -805,7 +805,44 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) :
return result;
}
public async Task AddUserLoadState(string userId, List<string> codes)
{
foreach (var code in codes)
{
string name = string.Empty;
switch (code)
{
case "Slow":
name = "迟缓";
break;
case "Poison":
name = "中毒";
break;
case "Curse":
name = "诅咒";
break;
case "Weaken":
name = "弱化";
break;
case "Depressed":
name = "消沉";
break;
case "Breach":
name = "突破";
break;
case "PalsyAtk":
name = "麻痹";
break;
}
await AddUserLoadState(userId, name, code);
}
}
public async Task<bool> RandomRemoveUserLoadState(string userId, int count)
{
var data = await GetUserLoadState(userId);
@@ -831,6 +868,7 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) :
string key = string.Format(UserCache.BaseCacheKeys, "AttrData", "LoadState");
await redis.DelHashAsync(key, userId);
}
#endregion
}