1212
This commit is contained in:
@@ -37,8 +37,7 @@ public interface IUnitUserAttrService
|
||||
|
||||
Task<unit_user_vigour> GetUserVigourInfo(string userId);
|
||||
Task<bool> UpdateUserVigour(string userId, int op, long count, string UpTime = "");
|
||||
Task<bool> UpdateUserUpVigour(string userId, decimal count);
|
||||
|
||||
Task<long> GetUserMaxVitality(string userId);
|
||||
#endregion
|
||||
|
||||
#region 在线时间
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
namespace Application.Domain;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Application.Domain;
|
||||
|
||||
public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) : IUnitUserAttrService, ITransient
|
||||
{
|
||||
@@ -87,29 +89,17 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) :
|
||||
{
|
||||
foreach (var item in MyState)
|
||||
{
|
||||
minAtk += Convert.ToInt32(GameAttrTool.GetAttrItemValue(GameEnum.AttrCode.Atk.ToString(), item.attr,
|
||||
temp.minAtk));
|
||||
maxAtk += Convert.ToInt32(GameAttrTool.GetAttrItemValue(GameEnum.AttrCode.Atk.ToString(), item.attr,
|
||||
temp.maxAtk));
|
||||
Defense += Convert.ToInt32(GameAttrTool.GetAttrItemValue(GameEnum.AttrCode.Defense.ToString(),
|
||||
item.attr, temp.defense));
|
||||
Agility += Convert.ToInt32(GameAttrTool.GetAttrItemValue(GameEnum.AttrCode.Agility.ToString(),
|
||||
item.attr, temp.agility));
|
||||
upBlood += Convert.ToInt32(GameAttrTool.GetAttrItemValue(GameEnum.AttrCode.Blood.ToString(), item.attr,
|
||||
temp.upBlood));
|
||||
upMorale += Convert.ToInt32(GameAttrTool.GetAttrItemValue(GameEnum.AttrCode.Morale.ToString(),
|
||||
item.attr, temp.upMorale));
|
||||
ExtendAttrData.AddRange(item.attr);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 加层处理
|
||||
|
||||
var otTemp = GameAttrTool.GetRoleAttrTemp(temp, ExtendAttrData);
|
||||
|
||||
result = GameAttrTool.GetRoleAttrTempMerge(result, otTemp); //加层其他
|
||||
result = GameAttrTool.GetRoleAttrTempMerge(result, temp); //加层其他
|
||||
|
||||
result.minAtk += minAtk;
|
||||
result.maxAtk += maxAtk;
|
||||
result.defense += Defense;
|
||||
@@ -313,9 +303,6 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) :
|
||||
var data = GameTool.GetAttrData(OnLev);
|
||||
result = await db.Updateable<unit_user_attr>(data).Where(i => i.userId == userId)
|
||||
.ExecuteCommandAsync() > 0;
|
||||
int upVigour = GameConfig.GameBaseVigour + (OnLev * 10);
|
||||
await UpdateUserUpVigour(userId, upVigour);
|
||||
|
||||
IsUpUserAttr = result;
|
||||
}
|
||||
}
|
||||
@@ -439,7 +426,7 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) :
|
||||
if (op == 1)
|
||||
{
|
||||
var userVigour = await GetUserVigourInfo(userId);
|
||||
long endVigour = (long)userVigour.upVitality - (long)userVigour.vitality;
|
||||
long endVigour = await GetUserMaxVitality(userId) - (long)userVigour.vitality;
|
||||
count = endVigour > count ? count : endVigour;
|
||||
}
|
||||
|
||||
@@ -470,17 +457,12 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) :
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<bool> UpdateUserUpVigour(string userId, decimal count)
|
||||
{
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_vigour>();
|
||||
bool isok = await db.Updateable<unit_user_vigour>().SetColumns(i => i.upVitality == count)
|
||||
.Where(i => i.userId == userId).ExecuteCommandAsync() > 0;
|
||||
if (isok)
|
||||
{
|
||||
await ClearUserVigourCache(userId);
|
||||
}
|
||||
|
||||
return isok;
|
||||
|
||||
public async Task<long> GetUserMaxVitality(string userId)
|
||||
{
|
||||
var OnLev = await GetUserLev(userId);
|
||||
return GameConfig.GameBaseVigour + (OnLev * 10);
|
||||
}
|
||||
|
||||
#endregion 活力
|
||||
|
||||
@@ -244,7 +244,6 @@ public class UnitUserService(ISqlSugarClient DbClient, IRedisCache redis) : IUni
|
||||
unit_user_vigour vitality = new unit_user_vigour();
|
||||
vitality.userId = userId;
|
||||
vitality.vitality = GameConfig.GameBaseVigour;
|
||||
vitality.upVitality = GameConfig.GameBaseVigour;
|
||||
vitality.upTime = TimeAssist.GetDateTimeYMDString(-1);
|
||||
db.Insertable(vitality).AddQueue();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user