From 0b08cb41c28bebfe3d5c9971d99b60fb7819f735 Mon Sep 17 00:00:00 2001 From: Joachim Lusiardi Date: Wed, 10 Jan 2024 11:00:23 +0100 Subject: [PATCH] more work on dungeon slayer --- src/game.rs | 1 + src/level_generator.rs | 4 +-- src/monster.rs | 63 +++++++++++++++++++++++++++++++++++++++--- 3 files changed, 62 insertions(+), 6 deletions(-) diff --git a/src/game.rs b/src/game.rs index bfdf85a..017125f 100644 --- a/src/game.rs +++ b/src/game.rs @@ -175,6 +175,7 @@ impl Game { // monster died, player gains experience if m.is_dead() { self.player.gain_experience(m.get_experience_gain()); + self.messages.insert(0, format!("you killed the {}..", m.get_name()).to_string()); } return m.is_dead(); } diff --git a/src/level_generator.rs b/src/level_generator.rs index a894d89..19ffa2e 100644 --- a/src/level_generator.rs +++ b/src/level_generator.rs @@ -11,7 +11,7 @@ use rand::rngs::ThreadRng; use crate::artifacts::{Artifact, Chest, Potion}; use crate::level::{Level, StructureElement}; -use crate::monster::{Monster, Orc, Rat}; +use crate::monster::{LowerDaemon, Monster, Orc, Rat}; use crate::position::Position; const ROOMS_VERTICAL: usize = 7; @@ -276,7 +276,7 @@ impl LevelGenerator { // TODO randomize enemies here match rng.gen_range(1..=100) { 1..=50 => { - enemies.push(Box::new(Orc::new_with_position(Position::new(self.level, t_x, t_y)))); + enemies.push(Box::new(LowerDaemon::new_with_position(Position::new(self.level, t_x, t_y)))); } _ => { enemies.push(Box::new(Rat::new_with_position(Position::new(self.level, t_x, t_y)))); diff --git a/src/monster.rs b/src/monster.rs index 108fe0b..331ff5b 100644 --- a/src/monster.rs +++ b/src/monster.rs @@ -44,6 +44,58 @@ macro_rules! default_monster { )+) } +/// Lower Daemon +/// Page: 107 +/// GH: 1 +pub struct LowerDaemon { + name: String, + life: usize, + position: Position, + symbol: String, + color: Color, + experience_gain: usize, + ticks_between_steps: u128, + monster_stats: MonsterStats, +} + +impl crate::monster::LowerDaemon { + pub fn new_with_position(position: Position) -> Self { + let monster_stats = MonsterStats { + body: 5, + agility: 5, + mind: 5, + strength: 2, + toughness: 2, + movement: 2, + dexterity: 2, + wisdom: 2, + aura: 2, + max_life: 9, + defense: 9, + initiative: 7, + walk: 3, + hit: 8, + shoot: 0, + cast: 0, + targeted_cast: 0, + }; + Self { + name: "lower daemon".to_string(), + life: monster_stats.max_life as usize, + position, + symbol: String::from("d"), + color: Color::Black, + experience_gain: 104, + ticks_between_steps: 5, + monster_stats, + } + } +} +default_monster!(LowerDaemon); + +/// Rat +/// Page: 119 +/// GH: 1 pub struct Rat { name: String, life: usize, @@ -78,11 +130,11 @@ impl Rat { }; Self { name: "rat".to_string(), - life: 3, + life: monster_stats.max_life as usize, position, symbol: String::from("R"), color: Color::Black, - experience_gain: 5, + experience_gain: 26, ticks_between_steps: 5, monster_stats, } @@ -90,6 +142,9 @@ impl Rat { } default_monster!(Rat); +/// Orc +/// Page: 118 +/// GH: 2 pub struct Orc { name: String, life: usize, @@ -124,11 +179,11 @@ impl Orc { }; Self { name: "orc".to_string(), - life: 23, + life: monster_stats.max_life as usize, position, symbol: String::from("O"), color: Color::DarkGray, - experience_gain: 10, + experience_gain: 63, ticks_between_steps: 10, monster_stats, }