fix formatting

This commit is contained in:
Joachim Lusiardi 2024-11-25 21:20:36 +01:00
parent 94c787d8c7
commit 530067f743
2 changed files with 7 additions and 3 deletions

View File

@ -192,7 +192,7 @@ impl Game {
0, 0,
format!("you hit {} for {} damage.", m.get_name(), player_dmg).to_string(), format!("you hit {} for {} damage.", m.get_name(), player_dmg).to_string(),
); );
let monster_dmg =m.damage().saturating_sub(self.player.defense()); let monster_dmg = m.damage().saturating_sub(self.player.defense());
self.player.change_life(-(monster_dmg as i16)); self.player.change_life(-(monster_dmg as i16));
self.messages.insert( self.messages.insert(

View File

@ -147,7 +147,9 @@ impl Level {
if player.get_immutable_position().get_x() == new_x if player.get_immutable_position().get_x() == new_x
&& player.get_immutable_position().get_y() == new_y && player.get_immutable_position().get_y() == new_y
{ {
let monster_dmg =self.monsters[index].damage().saturating_sub(player.defense()); let monster_dmg = self.monsters[index]
.damage()
.saturating_sub(player.defense());
player.change_life(-(monster_dmg as i16)); player.change_life(-(monster_dmg as i16));
if player.is_dead() { if player.is_dead() {
messages.insert( messages.insert(
@ -172,7 +174,9 @@ impl Level {
// player not dead => monster can occupy new position // player not dead => monster can occupy new position
self.monsters[index].get_position().change(-dx, -dy); self.monsters[index].get_position().change(-dx, -dy);
// player fights back // player fights back
let player_dmg = player.damage().saturating_sub(self.monsters[index].defense()); let player_dmg = player
.damage()
.saturating_sub(self.monsters[index].defense());
self.monsters[index].decrease_life(player_dmg); self.monsters[index].decrease_life(player_dmg);
if self.monsters[index].is_dead() { if self.monsters[index].is_dead() {
let level_up: bool = player let level_up: bool = player