232323
This commit is contained in:
@@ -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
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -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}个该物品!";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -158,6 +158,8 @@ public class FightController : ControllerBase
|
||||
myHarm += await _fightService.GetUserFightHarm(userId);
|
||||
otHarm = fightResult.otHarm;
|
||||
await _attrService.UpdateUserBlood(userId, 1, fightResult.myHarm);
|
||||
await _attrService.AddUserLoadState(userId, fightResult.myStateData);
|
||||
await _fightService.HandelFightEnd(userId, fightResult.myRemData);
|
||||
}
|
||||
|
||||
var myAttr = await _attrService.GetUserAttrModel(userId, fight.scene);
|
||||
@@ -179,6 +181,8 @@ public class FightController : ControllerBase
|
||||
{
|
||||
await _fightService.SetUserFightHarm(fight.mainId, fightResult.otHarm);
|
||||
await _attrService.UpdateUserBlood(fight.mainId, 1, fightResult.otHarm);
|
||||
await _attrService.AddUserLoadState(fight.mainId, fightResult.otStateData);
|
||||
await _fightService.HandelFightEnd(fight.mainId, fightResult.otRemData);
|
||||
}
|
||||
|
||||
otAttr = await _attrService.GetUserAttrModel(fight.mainId, fight.scene);
|
||||
@@ -224,7 +228,7 @@ public class FightController : ControllerBase
|
||||
{
|
||||
decimal diff = myAttr.agility - otAttr.agility;
|
||||
decimal bl = diff / otAttr.agility;
|
||||
cool = Convert.ToInt32((1-bl) * 1000.0m);
|
||||
cool = Convert.ToInt32((1 - bl) * 1000.0m);
|
||||
cool = cool < 10 ? 10 : cool;
|
||||
cool = cool > 1000 ? 1000 : cool;
|
||||
}
|
||||
@@ -300,7 +304,7 @@ public class FightController : ControllerBase
|
||||
{
|
||||
if (await _fightService.RemoveUserFight(userId, fightId))
|
||||
{
|
||||
await _fightService.SetFightWin(fight, fight.mainId,false);
|
||||
await _fightService.SetFightWin(fight, fight.mainId, false);
|
||||
await _fightService.RemoveFightHarm(fightId, userId); //移除伤害
|
||||
var nextFight = myFight.FindAll(it => it != fightId);
|
||||
string nextId = nextFight.Count > 0 ? nextFight[0] : "";
|
||||
|
||||
Reference in New Issue
Block a user