diff options
| -rw-r--r-- | dungeon/src/entity.rs | 22 | ||||
| -rw-r--r-- | graphics/src/render.rs | 2 |
2 files changed, 23 insertions, 1 deletions
diff --git a/dungeon/src/entity.rs b/dungeon/src/entity.rs index 22d66e0..a0750dd 100644 --- a/dungeon/src/entity.rs +++ b/dungeon/src/entity.rs @@ -310,11 +310,31 @@ impl Entity { } } +/// The current "weapon" level we have +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] +pub enum Weapon { + RustyKnife, + ShiningBlade, + GodlyBlade, +} +impl Weapon { + /// Returns the number of hit points of damage this weapon does + #[must_use] + pub const fn attack_dmg(self) -> u32 { + match self { + Self::RustyKnife => 2, + Self::ShiningBlade => 3, + Self::GodlyBlade => 5, + } + } +} + /// The `Player` type represents the main player entity #[derive(Clone, Debug, PartialEq)] pub struct Player { pub entity: Entity, pub inventory: Vec<Item>, + pub weapon: Weapon, // How long until we reset potion effects? pub potion_timer: Option<Instant>, } @@ -332,10 +352,12 @@ impl Player { pub const fn new(pos: Pos) -> Self { let entity = Entity::player(pos); let inventory = vec![]; + let weapon = Weapon::RustyKnife; let potion_timer = None; Self { entity, inventory, + weapon, potion_timer, } } diff --git a/graphics/src/render.rs b/graphics/src/render.rs index 208dafb..5841a7b 100644 --- a/graphics/src/render.rs +++ b/graphics/src/render.rs @@ -666,7 +666,7 @@ impl Renderer { R: RaylibDraw, { let health = player.entity.health; - let damage = 0; // TODO: calc damage + let damage = player.weapon.attack_dmg(); const TEXT_WIDTH: u16 = FONT_SIZE * 3 + UI_PADDING; const ICON_WIDTH: u16 = FONT_SIZE; |