Add immediate handling for deceased characters in health update: Implement logic to check if a character's health is less than or equal to zero and handle their death accordingly, improving character state management.

This commit is contained in:
Torsten Schulz (local)
2026-01-31 08:55:49 +01:00
parent c24aa63f97
commit f6d566427a
2 changed files with 12 additions and 0 deletions

View File

@@ -175,6 +175,12 @@ impl UserCharacterWorker {
}
fn update_character_health(&mut self, character: &mut Character) -> Result<(), DbError> {
// Bereits verstorbene Charaktere (health <= 0) sofort behandeln
if character.health <= 0 {
self.handle_character_death(character.id)?;
return Ok(());
}
let health_change = self.calculate_health_change(character.age);
if health_change == 0 {
return Ok(());

View File

@@ -175,6 +175,12 @@ impl UserCharacterWorker {
}
fn update_character_health(&mut self, character: &mut Character) -> Result<(), DbError> {
// Bereits verstorbene Charaktere (health <= 0) sofort behandeln
if character.health <= 0 {
self.handle_character_death(character.id)?;
return Ok(());
}
let health_change = self.calculate_health_change(character.age);
if health_change == 0 {
return Ok(());