Browse Source

突破成功以后应该更新角色的当前生命值

master
hanqin 2 weeks ago
parent
commit
fff808c7ea
  1. 10
      Build_God_Api/Build_God_Api/Services/Game/CharacterAttributeCalculateService.cs

10
Build_God_Api/Build_God_Api/Services/Game/CharacterAttributeCalculateService.cs

@ -182,14 +182,8 @@ namespace Build_God_Api.Services.Game
public async Task RecalculateMaxHPAsync(Character character) public async Task RecalculateMaxHPAsync(Character character)
{ {
var profession = await _context.Queryable<Profession>().FirstAsync(x => x.Id == character.ProfessionId); var attributes = await CalculateAttributesAsync(character);
var newMaxHP = CalculateMaxHP(character, profession); character.CurrentHP = attributes.MaxHP;
if (newMaxHP > 0)
{
decimal hpPercentage = character.CurrentHP / newMaxHP;
character.CurrentHP = hpPercentage * newMaxHP;
}
await _context.Updateable(character).ExecuteCommandAsync(); await _context.Updateable(character).ExecuteCommandAsync();
} }

Loading…
Cancel
Save