more work on dungeon slayer

This commit is contained in:
Joachim Lusiardi 2024-01-10 11:00:23 +01:00
parent cad08bd300
commit 0b08cb41c2
3 changed files with 62 additions and 6 deletions

View File

@ -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();
}

View File

@ -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))));

View File

@ -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,
}