Add some better equipment
This commit is contained in:
parent
a2ef1810d9
commit
43e9ebd52b
@ -29,8 +29,10 @@ impl RandomTable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn add<S: ToString>(mut self, name: S, weight: i32) -> Self {
|
pub fn add<S: ToString>(mut self, name: S, weight: i32) -> Self {
|
||||||
self.total_weight += weight;
|
if weight > 0 {
|
||||||
self.entries.push(RandomEntry::new(name, weight));
|
self.total_weight += weight;
|
||||||
|
self.entries.push(RandomEntry::new(name, weight));
|
||||||
|
}
|
||||||
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,8 @@ fn room_table(map_depth: i32) -> RandomTable {
|
|||||||
.add("Magic Missile Scroll", 4)
|
.add("Magic Missile Scroll", 4)
|
||||||
.add("Dagger", 3)
|
.add("Dagger", 3)
|
||||||
.add("Shield", 3)
|
.add("Shield", 3)
|
||||||
|
.add("Longsword", map_depth - 1)
|
||||||
|
.add("Tower Shield", map_depth - 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// fills a room with stuff!
|
/// fills a room with stuff!
|
||||||
@ -93,6 +95,8 @@ pub fn spawn_room(ecs: &mut World, room: &Rect, map_depth: i32) {
|
|||||||
"Magic Missile Scroll" => magic_missile_scroll(ecs, x, y),
|
"Magic Missile Scroll" => magic_missile_scroll(ecs, x, y),
|
||||||
"Dagger" => dagger(ecs, x, y),
|
"Dagger" => dagger(ecs, x, y),
|
||||||
"Shield" => shield(ecs, x, y),
|
"Shield" => shield(ecs, x, y),
|
||||||
|
"Longsword" => longsword(ecs, x, y),
|
||||||
|
"Tower Shield" => tower_shield(ecs, x, y),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -237,3 +241,41 @@ fn shield(ecs: &mut World, x: i32, y: i32) {
|
|||||||
.marked::<SimpleMarker<SerializeMe>>()
|
.marked::<SimpleMarker<SerializeMe>>()
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn longsword(ecs: &mut World, x: i32, y: i32) {
|
||||||
|
ecs.create_entity()
|
||||||
|
.with(Position { x, y })
|
||||||
|
.with(Renderable {
|
||||||
|
glyph: rltk::to_cp437('/'),
|
||||||
|
fg: RGB::named(rltk::CYAN),
|
||||||
|
bg: RGB::named(rltk::BLACK),
|
||||||
|
render_order: 2,
|
||||||
|
})
|
||||||
|
.with(Name::new("Longsword"))
|
||||||
|
.with(Item {})
|
||||||
|
.with(Equippable {
|
||||||
|
slot: EquipmentSlot::Melee,
|
||||||
|
})
|
||||||
|
.with(MeleePowerBonus { power: 4 })
|
||||||
|
.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('('),
|
||||||
|
fg: RGB::named(rltk::CYAN),
|
||||||
|
bg: RGB::named(rltk::BLACK),
|
||||||
|
render_order: 2,
|
||||||
|
})
|
||||||
|
.with(Name::new("Tower Shield"))
|
||||||
|
.with(Item {})
|
||||||
|
.with(Equippable {
|
||||||
|
slot: EquipmentSlot::Shield,
|
||||||
|
})
|
||||||
|
.with(DefenseBonus { defense: 3 })
|
||||||
|
.marked::<SimpleMarker<SerializeMe>>()
|
||||||
|
.build();
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user