diff --git a/src/artifacts.rs b/src/artifacts.rs index bab05c6..e907f1e 100644 --- a/src/artifacts.rs +++ b/src/artifacts.rs @@ -1,3 +1,4 @@ +use rand::Rng; use ratatui::style::Color; use crate::player::Player; @@ -22,11 +23,11 @@ pub struct Chest { impl Chest { pub fn new(position: Position) -> Self { - let level = position.get_level(); + let min_gold = 10 * (position.get_level()+1); + let max_gold = min_gold + 10*position.get_level(); Self { position, - // TODO maybe randomize this? - gold: (level + 1) * 10, + gold: rand::thread_rng().gen_range(min_gold..=max_gold), } } } @@ -61,9 +62,11 @@ pub struct Potion { impl Potion { pub fn new(position: Position) -> Self { + let min_health_gain = 5 + position.get_level(); + let max_health_gain = min_health_gain + 3 * position.get_level(); Self { position, - health: 5, + health: rand::thread_rng().gen_range(min_health_gain..=max_health_gain), } } } diff --git a/src/game.rs b/src/game.rs index 32969a7..ad9b077 100644 --- a/src/game.rs +++ b/src/game.rs @@ -164,7 +164,6 @@ impl Game { match m { None => {} Some(m) => { - // TODO fight the monster let player_dmg = self.player.damage(); m.decrease_life(player_dmg); if m.is_dead() { diff --git a/src/level.rs b/src/level.rs index 2d183c9..1fa3066 100644 --- a/src/level.rs +++ b/src/level.rs @@ -147,7 +147,6 @@ impl Level { if player.get_immutable_position().get_x() == new_x && player.get_immutable_position().get_y() == new_y { - // TODO handle fight between monster and player let monster_dmg = self.monsters[index].damage() as i16; player.change_life(-monster_dmg); messages.insert( diff --git a/src/level_widget.rs b/src/level_widget.rs index 520a4e3..9204fa3 100644 --- a/src/level_widget.rs +++ b/src/level_widget.rs @@ -45,7 +45,7 @@ impl StatefulWidget for LevelWidget { self.set_cell(buf, x, y, "Ω", Color::Black, Color::Gray); } StructureElement::Wall => { - // TODO add fancy walls + // TODO add fancy walls with https://en.wikipedia.org/wiki/Box-drawing_characters self.set_cell(buf, x, y, "#", FG_BROWN, Color::Gray); } StructureElement::Floor => { diff --git a/src/position.rs b/src/position.rs index b9d9ae1..f29fc3c 100644 --- a/src/position.rs +++ b/src/position.rs @@ -8,7 +8,7 @@ pub trait HasPosition { fn get_immutable_position(&self) -> &Position; } -#[derive(PartialEq, Debug)] +#[derive(PartialEq, Debug, Clone, Copy)] pub struct Position { level: usize, x: usize,