1212
This commit is contained in:
@@ -92,12 +92,13 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) :
|
||||
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;
|
||||
@@ -272,7 +273,6 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) :
|
||||
try
|
||||
{
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_exp>();
|
||||
await DbClient.AsTenant().BeginTranAsync();
|
||||
if (op == 0) //扣除经验
|
||||
{
|
||||
result = await db.Updateable<unit_user_exp>().SetColumns(it => it.exp == it.exp - exp)
|
||||
@@ -290,40 +290,44 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) :
|
||||
else //足够升级
|
||||
{
|
||||
var myAttr = await GetUserAttr(userId);
|
||||
int OnLev = (int)myAttr.lev + 1;
|
||||
if (OnLev <= GameConfig.GameMaxLev)
|
||||
int OnLev = (int)myAttr.lev;
|
||||
if (OnLev >= GameConfig.GameMaxLev)
|
||||
{
|
||||
long upExp = onExp - (long)MyExp.upExp;
|
||||
decimal nextExp = GameTool.GetUserUpExp(OnLev);
|
||||
result = await db.Updateable<unit_user_exp>().SetColumns(it => it.exp == upExp)
|
||||
.SetColumns(it => it.upExp == nextExp).Where(it => it.userId == userId)
|
||||
.ExecuteCommandAsync() > 0;
|
||||
if (result) //更新成功,更新各项属性
|
||||
return true;
|
||||
}
|
||||
|
||||
long upExp = (long)MyExp.upExp;
|
||||
|
||||
while (onExp >= upExp)
|
||||
{
|
||||
if (OnLev < GameConfig.GameMaxLev)
|
||||
{
|
||||
var data = GameTool.GetAttrData(OnLev);
|
||||
result = await db.Updateable<unit_user_attr>(data).Where(i => i.userId == userId)
|
||||
.ExecuteCommandAsync() > 0;
|
||||
IsUpUserAttr = result;
|
||||
OnLev = OnLev + 1;
|
||||
onExp -= upExp;
|
||||
upExp = GameTool.GetUserUpExp(OnLev);
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
result = await db.Updateable<unit_user_exp>().SetColumns(it => it.exp == onExp)
|
||||
.SetColumns(it => it.upExp == upExp).Where(it => it.userId == userId)
|
||||
.ExecuteCommandAsync() > 0;
|
||||
if (result) //更新成功,更新各项属性
|
||||
{
|
||||
decimal maxOnExp = (decimal)MyExp.upExp - 1;
|
||||
if ((decimal)MyExp.exp < maxOnExp)
|
||||
{
|
||||
result = await db.Updateable<unit_user_exp>().SetColumns(it => it.exp == maxOnExp)
|
||||
.Where(it => it.userId == userId).ExecuteCommandAsync() > 0;
|
||||
}
|
||||
var data = GameTool.GetAttrData(OnLev);
|
||||
result = await db.Updateable<unit_user_attr>(data).Where(i => i.userId == userId)
|
||||
.ExecuteCommandAsync() > 0;
|
||||
IsUpUserAttr = result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await DbClient.AsTenant().CommitTranAsync();
|
||||
}
|
||||
catch
|
||||
{
|
||||
result = false;
|
||||
await DbClient.AsTenant().RollbackTranAsync();
|
||||
}
|
||||
|
||||
if (result && IsUpUserAttr)
|
||||
@@ -458,7 +462,6 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) :
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<long> GetUserMaxVitality(string userId)
|
||||
{
|
||||
var OnLev = await GetUserLev(userId);
|
||||
|
||||
Reference in New Issue
Block a user