1212
This commit is contained in:
@@ -18,12 +18,6 @@ namespace Application.Domain.Entity
|
||||
[SugarColumn(IsNullable = true)]
|
||||
public long? vitality { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最大活力
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = true)]
|
||||
public long? upVitality { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 更新时间
|
||||
/// </summary>
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ public class ChatController : ControllerBase
|
||||
isSend = par != "0";
|
||||
break;
|
||||
case 2:
|
||||
isSend = true;
|
||||
isSend = false;
|
||||
code = nameof(GameChatEnum.Code.Group);
|
||||
par = "";
|
||||
break;
|
||||
|
||||
@@ -15,7 +15,8 @@ public class RecoverController : ControllerBase
|
||||
private readonly IUnitUserAccService _accService;
|
||||
private readonly IGameEquService _equService;
|
||||
|
||||
public RecoverController(IUnitUserAttrService attrService, IGameMapService mapService,IUnitUserAccService accService,IGameEquService equService)
|
||||
public RecoverController(IUnitUserAttrService attrService, IGameMapService mapService,
|
||||
IUnitUserAccService accService, IGameEquService equService)
|
||||
{
|
||||
_attrService = attrService;
|
||||
_mapService = mapService;
|
||||
@@ -144,7 +145,8 @@ public class RecoverController : ControllerBase
|
||||
{
|
||||
string userId = StateHelper.userId;
|
||||
var data = await _attrService.GetUserVigourInfo(userId);
|
||||
return PoAction.Ok(data);
|
||||
long maxVigour = await _attrService.GetUserMaxVitality(userId);
|
||||
return PoAction.Ok(new { data, maxVigour });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -189,12 +191,14 @@ public class RecoverController : ControllerBase
|
||||
{
|
||||
return PoAction.Message("今天已恢复过活力啦!");
|
||||
}
|
||||
if (data.vitality >= data.upVitality)
|
||||
|
||||
long maxVitality = await _attrService.GetUserMaxVitality(userId);
|
||||
if (data.vitality >= maxVitality)
|
||||
{
|
||||
return PoAction.Message("活力满满,无需恢复!");
|
||||
}
|
||||
|
||||
bool result = await _attrService.UpdateUserVigour(userId, 2, (long)data.upVitality,time);
|
||||
bool result = await _attrService.UpdateUserVigour(userId, 2, maxVitality, time);
|
||||
if (result)
|
||||
{
|
||||
return PoAction.Ok(true);
|
||||
@@ -245,8 +249,8 @@ public class RecoverController : ControllerBase
|
||||
var data = await _equService.GetUserOnEqu(userId);
|
||||
var needData = data.FindAll(it =>
|
||||
it.isAppr == 1 && it.durability < it.maxdurability && it.useEndTime > TimeExtend.GetTimeStampSeconds);
|
||||
need = needData.Sum(it => (int)it.maxdurability - (int)it.durability);
|
||||
return PoAction.Ok(new { data, need });
|
||||
need = needData.Sum(it => (int)it.maxdurability - (int)it.durability);
|
||||
return PoAction.Ok(new { data, need });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -256,7 +260,7 @@ public class RecoverController : ControllerBase
|
||||
/// <param name="ueId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> RecoverEqu(int npcId,string? ueId)
|
||||
public async Task<IPoAction> RecoverEqu(int npcId, string? ueId)
|
||||
{
|
||||
string userId = StateHelper.userId;
|
||||
|
||||
@@ -296,7 +300,7 @@ public class RecoverController : ControllerBase
|
||||
{
|
||||
return PoAction.Message("耐久已满,无需恢复!");
|
||||
}
|
||||
|
||||
|
||||
var myAcc = await _accService.GetUserAccInfo(userId, nameof(AccEnum.AccType.copper));
|
||||
if (need > myAcc)
|
||||
{
|
||||
@@ -310,6 +314,7 @@ public class RecoverController : ControllerBase
|
||||
item.durability = item.maxdurability;
|
||||
await _equService.UpdateUserEquInfo(item);
|
||||
}
|
||||
|
||||
return PoAction.Ok(true, $"恢复成功,花费{need}铜贝!");
|
||||
}
|
||||
else
|
||||
@@ -369,27 +374,5 @@ public class RecoverController : ControllerBase
|
||||
return PoAction.Message("恢复失败,请稍后尝试!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var data = await _attrService.GetUserVigourInfo(userId);
|
||||
string time = TimeAssist.GetDateTimeYMDString(0);
|
||||
if (data.upTime == time)
|
||||
{
|
||||
return PoAction.Message("今天已恢复过活力啦!");
|
||||
}
|
||||
if (data.vitality >= data.upVitality)
|
||||
{
|
||||
return PoAction.Message("活力满满,无需恢复!");
|
||||
}
|
||||
|
||||
bool result = await _attrService.UpdateUserVigour(userId, 2, (long)data.upVitality,time);
|
||||
if (result)
|
||||
{
|
||||
return PoAction.Ok(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("恢复失败,请稍后尝试!");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user