2021-08-28 04:25:52 +00:00
|
|
|
pub use crate::prelude::*;
|
|
|
|
|
|
|
|
pub fn spawn_player(ecs: &mut World, pos: Point) {
|
|
|
|
ecs.push((
|
|
|
|
Player,
|
|
|
|
pos,
|
|
|
|
Render {
|
|
|
|
color: ColorPair::new(WHITE, BLACK),
|
|
|
|
glyph: to_cp437('@'),
|
|
|
|
},
|
2021-08-30 03:13:45 +00:00
|
|
|
Health {
|
|
|
|
current: 20,
|
|
|
|
max: 20,
|
|
|
|
},
|
2021-08-28 04:25:52 +00:00
|
|
|
));
|
|
|
|
}
|
2021-08-28 20:59:12 +00:00
|
|
|
|
|
|
|
pub fn spawn_monster(ecs: &mut World, rng: &mut RandomNumberGenerator, pos: Point) {
|
2021-08-30 03:13:45 +00:00
|
|
|
let (hp, name, glyph) = match rng.roll_dice(1, 10) {
|
|
|
|
1..=8 => goblin(),
|
|
|
|
_ => orc(),
|
|
|
|
};
|
|
|
|
|
2021-08-28 20:59:12 +00:00
|
|
|
ecs.push((
|
|
|
|
Enemy,
|
|
|
|
pos,
|
|
|
|
Render {
|
|
|
|
color: ColorPair::new(WHITE, BLACK),
|
2021-08-30 03:13:45 +00:00
|
|
|
glyph,
|
2021-08-28 20:59:12 +00:00
|
|
|
},
|
2021-08-28 23:28:48 +00:00
|
|
|
MovingRandomly {},
|
2021-08-30 03:13:45 +00:00
|
|
|
Health {
|
|
|
|
current: hp,
|
|
|
|
max: hp,
|
|
|
|
},
|
|
|
|
Name(name),
|
2021-08-28 20:59:12 +00:00
|
|
|
));
|
|
|
|
}
|
2021-08-30 03:13:45 +00:00
|
|
|
|
|
|
|
fn goblin() -> (i32, String, FontCharType) {
|
|
|
|
(1, "Goblin".to_string(), to_cp437('g'))
|
|
|
|
}
|
|
|
|
fn orc() -> (i32, String, FontCharType) {
|
|
|
|
(2, "orc".to_string(), to_cp437('o'))
|
|
|
|
}
|