Add healing potions and maps to maps
This commit is contained in:
parent
81b99c632c
commit
4e639f9179
@ -70,3 +70,11 @@ impl FieldOfView {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub struct ProvidesHealing {
|
||||
pub amount: i32,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub struct ProvidesDungeonMap;
|
||||
|
@ -47,7 +47,7 @@ impl State {
|
||||
map_builder
|
||||
.monster_spawns
|
||||
.iter()
|
||||
.for_each(|pos| spawn_monster(&mut ecs, &mut rng, *pos));
|
||||
.for_each(|pos| spawn_entity(&mut ecs, &mut rng, *pos));
|
||||
|
||||
resources.insert(map_builder.map);
|
||||
resources.insert(Camera::new(map_builder.player_start));
|
||||
@ -71,11 +71,9 @@ impl State {
|
||||
spawn_player(&mut self.ecs, map_builder.player_start);
|
||||
spawn_amulet_of_yala(&mut self.ecs, map_builder.amulet_start);
|
||||
map_builder
|
||||
.rooms
|
||||
.monster_spawns
|
||||
.iter()
|
||||
.skip(1)
|
||||
.map(|r| r.center())
|
||||
.for_each(|pos| spawn_monster(&mut self.ecs, &mut rng, pos));
|
||||
.for_each(|pos| spawn_entity(&mut self.ecs, &mut rng, *pos));
|
||||
self.resources.insert(map_builder.map);
|
||||
self.resources.insert(Camera::new(map_builder.player_start));
|
||||
self.resources.insert(TurnState::AwaitingInput);
|
||||
|
@ -53,6 +53,41 @@ pub fn spawn_amulet_of_yala(ecs: &mut World, pos: Point) {
|
||||
));
|
||||
}
|
||||
|
||||
pub fn spawn_healing_potion(ecs: &mut World, pos: Point) {
|
||||
ecs.push((
|
||||
Item,
|
||||
pos,
|
||||
Render {
|
||||
color: ColorPair::new(WHITE, BLACK),
|
||||
glyph: to_cp437('!'),
|
||||
},
|
||||
Name("Healing Potion".to_string()),
|
||||
ProvidesHealing { amount: 6 },
|
||||
));
|
||||
}
|
||||
|
||||
pub fn spawn_magic_mapper(ecs: &mut World, pos: Point) {
|
||||
ecs.push((
|
||||
Item,
|
||||
pos,
|
||||
Render {
|
||||
color: ColorPair::new(WHITE, BLACK),
|
||||
glyph: to_cp437('{'),
|
||||
},
|
||||
Name("Dungeon Map".to_string()),
|
||||
ProvidesDungeonMap,
|
||||
));
|
||||
}
|
||||
|
||||
pub fn spawn_entity(ecs: &mut World, rng: &mut RandomNumberGenerator, pos: Point) {
|
||||
let roll = rng.roll_dice(1, 6);
|
||||
match roll {
|
||||
1 => spawn_healing_potion(ecs, pos),
|
||||
2 => spawn_magic_mapper(ecs, pos),
|
||||
_ => spawn_monster(ecs, rng, pos),
|
||||
}
|
||||
}
|
||||
|
||||
fn goblin() -> (i32, String, FontCharType) {
|
||||
(1, "Goblin".to_string(), to_cp437('g'))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user