Finished section 1
This commit is contained in:
194
src/spawner.rs
194
src/spawner.rs
@@ -7,9 +7,9 @@ use specs::saveload::{MarkedBuilder, SimpleMarker};
|
||||
use crate::random_table::RandomTable;
|
||||
use crate::rect::Rect;
|
||||
use crate::{
|
||||
AreaOfEffect, BlocksTile, CombatStats, Confusion, Consumable, InflictsDamage, Item, Monster,
|
||||
Name, Player, Position, ProvidesHealing, Ranged, Renderable, SerializeMe, Viewshed, MAP_WIDTH,
|
||||
MAX_ITEMS, MAX_MONSTER,
|
||||
AreaOfEffect, BlocksTile, CombatStats, Confusion, Consumable, DefenseBonus, EquipmentSlot,
|
||||
Equippable, InflictsDamage, Item, MeleePowerBonus, Monster, Name, Player, Position,
|
||||
ProvidesHealing, Ranged, Renderable, SerializeMe, Viewshed, MAP_WIDTH, MAX_ITEMS, MAX_MONSTER,
|
||||
};
|
||||
|
||||
pub fn player(ecs: &mut World, player_x: i32, player_y: i32) -> Entity {
|
||||
@@ -117,6 +117,14 @@ pub fn spawn_room(ecs: &mut World, room: &Rect, map_depth: i32) {
|
||||
"Fireball Scroll" => fireball_scroll(ecs, x, y),
|
||||
"Confusion Scroll" => confusion_scroll(ecs, x, y),
|
||||
"Magic Missile Scroll" => magic_missile_scroll(ecs, x, y),
|
||||
"Dagger" => dagger(ecs, x, y),
|
||||
"Longsword" => longsword(ecs, x, y),
|
||||
"Shield" => shield(ecs, x, y),
|
||||
"Tower Shield" => tower_shield(ecs, x, y),
|
||||
"Helmet" => helmet(ecs, x, y),
|
||||
"Breastplate" => breastplate(ecs, x, y),
|
||||
"Leggings" => leggings(ecs, x, y),
|
||||
"Sabatons" => sabatons(ecs, x, y),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
@@ -210,4 +218,184 @@ pub fn room_table(map_depth: i32) -> RandomTable {
|
||||
.add("Fireball Scroll", 2 + map_depth)
|
||||
.add("Confusion Scroll", 2 + map_depth)
|
||||
.add("Magic Missile Scroll", 4)
|
||||
.add("Dagger", 3)
|
||||
.add("Longsword", map_depth - 1)
|
||||
.add("Shield", 3)
|
||||
.add("Tower Shield", map_depth - 1)
|
||||
.add("Helmet", map_depth - 2)
|
||||
.add("Breastplate", map_depth - 3)
|
||||
.add("Leggings", map_depth - 4)
|
||||
.add("Sabatons", map_depth - 4)
|
||||
}
|
||||
|
||||
fn dagger(ecs: &mut World, x: i32, y: i32) {
|
||||
ecs.create_entity()
|
||||
.with(Position { x, y })
|
||||
.with(Renderable {
|
||||
glyph: rltk::to_cp437('/'),
|
||||
render_order: 2,
|
||||
fg: RGB::named(rltk::CYAN),
|
||||
bg: RGB::named(rltk::BLACK),
|
||||
})
|
||||
.with(Item {})
|
||||
.with(Name {
|
||||
name: "Dagger".to_string(),
|
||||
})
|
||||
.with(Equippable {
|
||||
slot: EquipmentSlot::Melee,
|
||||
})
|
||||
.with(MeleePowerBonus { power: 2 })
|
||||
.marked::<SimpleMarker<SerializeMe>>()
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
fn longsword(ecs: &mut World, x: i32, y: i32) {
|
||||
ecs.create_entity()
|
||||
.with(Position { x, y })
|
||||
.with(Renderable {
|
||||
glyph: rltk::to_cp437('/'),
|
||||
render_order: 2,
|
||||
fg: RGB::named(rltk::CYAN),
|
||||
bg: RGB::named(rltk::BLACK),
|
||||
})
|
||||
.with(Item {})
|
||||
.with(Name {
|
||||
name: "Longsword".to_string(),
|
||||
})
|
||||
.with(Equippable {
|
||||
slot: EquipmentSlot::Melee,
|
||||
})
|
||||
.with(MeleePowerBonus { power: 4 })
|
||||
.marked::<SimpleMarker<SerializeMe>>()
|
||||
.build();
|
||||
}
|
||||
|
||||
fn shield(ecs: &mut World, x: i32, y: i32) {
|
||||
ecs.create_entity()
|
||||
.with(Position { x, y })
|
||||
.with(Renderable {
|
||||
glyph: rltk::to_cp437('('),
|
||||
render_order: 2,
|
||||
fg: RGB::named(rltk::CYAN),
|
||||
bg: RGB::named(rltk::BLACK),
|
||||
})
|
||||
.with(Item {})
|
||||
.with(Name {
|
||||
name: "Shield".to_string(),
|
||||
})
|
||||
.with(Equippable {
|
||||
slot: EquipmentSlot::Shield,
|
||||
})
|
||||
.with(DefenseBonus { defense: 1 })
|
||||
.marked::<SimpleMarker<SerializeMe>>()
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
fn tower_shield(ecs: &mut World, x: i32, y: i32) {
|
||||
ecs.create_entity()
|
||||
.with(Position { x, y })
|
||||
.with(Renderable {
|
||||
glyph: rltk::to_cp437('('),
|
||||
render_order: 2,
|
||||
fg: RGB::named(rltk::CYAN),
|
||||
bg: RGB::named(rltk::BLACK),
|
||||
})
|
||||
.with(Item {})
|
||||
.with(Name {
|
||||
name: "Tower Shield".to_string(),
|
||||
})
|
||||
.with(Equippable {
|
||||
slot: EquipmentSlot::Shield,
|
||||
})
|
||||
.with(DefenseBonus { defense: 3 })
|
||||
.marked::<SimpleMarker<SerializeMe>>()
|
||||
.build();
|
||||
}
|
||||
|
||||
fn helmet(ecs: &mut World, x: i32, y: i32) {
|
||||
ecs.create_entity()
|
||||
.with(Position { x, y })
|
||||
.with(Renderable {
|
||||
glyph: rltk::to_cp437('^'),
|
||||
render_order: 2,
|
||||
fg: RGB::named(rltk::CYAN),
|
||||
bg: RGB::named(rltk::BLACK),
|
||||
})
|
||||
.with(Item {})
|
||||
.with(Name {
|
||||
name: "Helmet".to_string(),
|
||||
})
|
||||
.with(Equippable {
|
||||
slot: EquipmentSlot::Head,
|
||||
})
|
||||
.with(DefenseBonus { defense: 1 })
|
||||
.with(MeleePowerBonus { power: 1 })
|
||||
.marked::<SimpleMarker<SerializeMe>>()
|
||||
.build();
|
||||
}
|
||||
|
||||
fn breastplate(ecs: &mut World, x: i32, y: i32) {
|
||||
ecs.create_entity()
|
||||
.with(Position { x, y })
|
||||
.with(Renderable {
|
||||
glyph: rltk::to_cp437('x'),
|
||||
render_order: 2,
|
||||
fg: RGB::named(rltk::CYAN),
|
||||
bg: RGB::named(rltk::BLACK),
|
||||
})
|
||||
.with(Item {})
|
||||
.with(Name {
|
||||
name: "Breastplate".to_string(),
|
||||
})
|
||||
.with(Equippable {
|
||||
slot: EquipmentSlot::Chest,
|
||||
})
|
||||
.with(DefenseBonus { defense: 2 })
|
||||
.marked::<SimpleMarker<SerializeMe>>()
|
||||
.build();
|
||||
}
|
||||
|
||||
fn leggings(ecs: &mut World, x: i32, y: i32) {
|
||||
ecs.create_entity()
|
||||
.with(Position { x, y })
|
||||
.with(Renderable {
|
||||
glyph: rltk::to_cp437('"'),
|
||||
render_order: 2,
|
||||
fg: RGB::named(rltk::CYAN),
|
||||
bg: RGB::named(rltk::BLACK),
|
||||
})
|
||||
.with(Item {})
|
||||
.with(Name {
|
||||
name: "Leggings".to_string(),
|
||||
})
|
||||
.with(Equippable {
|
||||
slot: EquipmentSlot::Legs,
|
||||
})
|
||||
.with(DefenseBonus { defense: 1 })
|
||||
.marked::<SimpleMarker<SerializeMe>>()
|
||||
.build();
|
||||
}
|
||||
|
||||
fn sabatons(ecs: &mut World, x: i32, y: i32) {
|
||||
ecs.create_entity()
|
||||
.with(Position { x, y })
|
||||
.with(Renderable {
|
||||
glyph: rltk::to_cp437(','),
|
||||
render_order: 2,
|
||||
fg: RGB::named(rltk::CYAN),
|
||||
bg: RGB::named(rltk::BLACK),
|
||||
})
|
||||
.with(Item {})
|
||||
.with(Name {
|
||||
name: "Sabatons".to_string(),
|
||||
})
|
||||
.with(Equippable {
|
||||
slot: EquipmentSlot::Feet,
|
||||
})
|
||||
.with(DefenseBonus { defense: 1 })
|
||||
.with(MeleePowerBonus { power: 1 })
|
||||
.marked::<SimpleMarker<SerializeMe>>()
|
||||
.build();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user