beatitudes
This commit is contained in:
parent
831720ce37
commit
d0416b2563
7 changed files with 42 additions and 48 deletions
|
|
@ -57,11 +57,6 @@ pub fn draw_lerping_bar(
|
|||
}
|
||||
|
||||
pub fn draw_ui(ecs: &World, ctx: &mut Rltk) {
|
||||
ctx.draw_hollow_box(0, 0, 70, 8, RGB::named(rltk::WHITE), RGB::named(rltk::BLACK)); // Log box
|
||||
ctx.draw_hollow_box(0, 9, 70, 42, RGB::named(rltk::WHITE), RGB::named(rltk::BLACK)); // Camera box
|
||||
ctx.draw_hollow_box(0, 52, 70, 3, RGB::named(rltk::WHITE), RGB::named(rltk::BLACK)); // Stats box
|
||||
ctx.draw_hollow_box(71, 0, 33, 55, RGB::named(rltk::WHITE), RGB::named(rltk::BLACK)); // Side box
|
||||
|
||||
// Render stats
|
||||
let pools = ecs.read_storage::<Pools>();
|
||||
let attributes = ecs.read_storage::<Attributes>();
|
||||
|
|
@ -281,6 +276,11 @@ pub fn draw_ui(ecs: &World, ctx: &mut Rltk) {
|
|||
&format!("T{}", crate::gamelog::get_event_count("turns")),
|
||||
);
|
||||
|
||||
// Boxes and tooltips last, so they draw over everything else.
|
||||
ctx.draw_hollow_box(0, 0, 70, 8, RGB::named(rltk::WHITE), RGB::named(rltk::BLACK)); // Log box
|
||||
ctx.draw_hollow_box(0, 9, 70, 42, RGB::named(rltk::WHITE), RGB::named(rltk::BLACK)); // Camera box
|
||||
ctx.draw_hollow_box(0, 52, 70, 3, RGB::named(rltk::WHITE), RGB::named(rltk::BLACK)); // Stats box
|
||||
ctx.draw_hollow_box(71, 0, 33, 55, RGB::named(rltk::WHITE), RGB::named(rltk::BLACK)); // Side box
|
||||
tooltip::draw_tooltips(ecs, ctx);
|
||||
}
|
||||
|
||||
|
|
@ -506,51 +506,35 @@ pub fn renderable_colour(renderables: &ReadStorage<Renderable>, entity: Entity)
|
|||
}
|
||||
|
||||
pub fn item_colour_ecs(ecs: &World, item: Entity) -> (u8, u8, u8) {
|
||||
let dm = ecs.fetch::<MasterDungeonMap>();
|
||||
if let Some(name) = ecs.read_storage::<Name>().get(item) {
|
||||
if let Some(magic) = ecs.read_storage::<MagicItem>().get(item) {
|
||||
if dm.identified_items.contains(&name.name) {
|
||||
// If identified magic item, use rarity colour
|
||||
match magic.class {
|
||||
MagicItemClass::Common => return WHITE,
|
||||
MagicItemClass::Uncommon => return GREEN,
|
||||
MagicItemClass::Rare => return BLUE,
|
||||
MagicItemClass::VeryRare => return PURPLE,
|
||||
MagicItemClass::Legendary => return GOLD,
|
||||
if let Some(beatitude) = ecs.read_storage::<Beatitude>().get(item) {
|
||||
if beatitude.known {
|
||||
match beatitude.buc {
|
||||
BUC::Blessed => return GREEN,
|
||||
BUC::Uncursed => return WHITE,
|
||||
BUC::Cursed => return RED,
|
||||
}
|
||||
} else {
|
||||
// Unidentified magic item
|
||||
return GREY;
|
||||
}
|
||||
}
|
||||
}
|
||||
// If nonmagic, just use white
|
||||
return WHITE;
|
||||
}
|
||||
|
||||
pub fn item_colour(
|
||||
item: Entity,
|
||||
names: &ReadStorage<Name>,
|
||||
magic_items: &ReadStorage<MagicItem>,
|
||||
dm: &MasterDungeonMap,
|
||||
) -> (u8, u8, u8) {
|
||||
if let Some(name) = names.get(item) {
|
||||
if let Some(magic) = magic_items.get(item) {
|
||||
if dm.identified_items.contains(&name.name) {
|
||||
// If identified magic item, use rarity colour
|
||||
match magic.class {
|
||||
MagicItemClass::Common => return WHITE,
|
||||
MagicItemClass::Uncommon => return GREEN,
|
||||
MagicItemClass::Rare => return BLUE,
|
||||
MagicItemClass::VeryRare => return PURPLE,
|
||||
MagicItemClass::Legendary => return GOLD,
|
||||
pub fn item_colour(item: Entity, beatitudes: &ReadStorage<Beatitude>, dm: &MasterDungeonMap) -> (u8, u8, u8) {
|
||||
if let Some(beatitude) = beatitudes.get(item) {
|
||||
if beatitude.known {
|
||||
match beatitude.buc {
|
||||
BUC::Blessed => return GREEN,
|
||||
BUC::Uncursed => return WHITE,
|
||||
BUC::Cursed => return RED,
|
||||
}
|
||||
} else {
|
||||
// Unidentified magic item
|
||||
return GREY;
|
||||
}
|
||||
}
|
||||
}
|
||||
// If nonmagic, just use white
|
||||
return WHITE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ impl<'a> System<'a> for ItemEquipSystem {
|
|||
obfuscate_name(*item, &names, &magic_items, &obfuscated_names, &beatitudes, &dm, None)
|
||||
.0,
|
||||
)
|
||||
.colour(item_colour(*item, &names, &magic_items, &dm))
|
||||
.colour(item_colour(*item, &beatitudes, &dm))
|
||||
.period();
|
||||
}
|
||||
}
|
||||
|
|
@ -90,7 +90,7 @@ impl<'a> System<'a> for ItemEquipSystem {
|
|||
)
|
||||
.0,
|
||||
)
|
||||
.colour(item_colour(wants_to_use_item.item, &names, &magic_items, &dm))
|
||||
.colour(item_colour(wants_to_use_item.item, &beatitudes, &dm))
|
||||
.period();
|
||||
logger.log();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{IdentifiedItem, Item, MasterDungeonMap, Name, ObfuscatedName, Player};
|
||||
use crate::{Beatitude, IdentifiedItem, Item, MasterDungeonMap, Name, ObfuscatedName, Player};
|
||||
use specs::prelude::*;
|
||||
|
||||
pub struct ItemIdentificationSystem {}
|
||||
|
|
@ -8,6 +8,7 @@ impl<'a> System<'a> for ItemIdentificationSystem {
|
|||
type SystemData = (
|
||||
ReadStorage<'a, Player>,
|
||||
WriteStorage<'a, IdentifiedItem>,
|
||||
WriteStorage<'a, Beatitude>,
|
||||
WriteExpect<'a, MasterDungeonMap>,
|
||||
ReadStorage<'a, Item>,
|
||||
ReadStorage<'a, Name>,
|
||||
|
|
@ -16,13 +17,11 @@ impl<'a> System<'a> for ItemIdentificationSystem {
|
|||
);
|
||||
|
||||
fn run(&mut self, data: Self::SystemData) {
|
||||
let (player, mut identified, mut dm, items, names, mut obfuscated_names, entities) = data;
|
||||
let (player, mut identified, mut beatitudes, mut dm, items, names, mut obfuscated_names, entities) = data;
|
||||
for (_p, id) in (&player, &identified).join() {
|
||||
rltk::console::log(id.name.clone());
|
||||
let tag = crate::raws::get_id_from_name(id.name.clone());
|
||||
if !dm.identified_items.contains(&id.name) && crate::raws::is_tag_magic(&tag) {
|
||||
dm.identified_items.insert(id.name.clone());
|
||||
|
||||
for (entity, _item, name) in (&entities, &items, &names).join() {
|
||||
if name.name == id.name {
|
||||
obfuscated_names.remove(entity);
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ impl<'a> System<'a> for ItemRemoveSystem {
|
|||
)
|
||||
.0,
|
||||
)
|
||||
.colour(item_colour(to_remove.item, &names, &magic_items, &dm))
|
||||
.colour(item_colour(to_remove.item, &beatitudes, &dm))
|
||||
.period()
|
||||
.log();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -572,6 +572,7 @@ fn main() -> rltk::BError {
|
|||
gs.ecs.register::<HungerClock>();
|
||||
gs.ecs.register::<WantsToMelee>();
|
||||
gs.ecs.register::<Item>();
|
||||
gs.ecs.register::<Beatitude>();
|
||||
gs.ecs.register::<IdentifiedItem>();
|
||||
gs.ecs.register::<MagicItem>();
|
||||
gs.ecs.register::<GrantsXP>();
|
||||
|
|
|
|||
|
|
@ -140,6 +140,7 @@ pub fn spawn_named_item(raws: &RawMaster, ecs: &mut World, key: &str, pos: Spawn
|
|||
let potion_names = dm.potion_map.clone();
|
||||
let wand_names = dm.wand_map.clone();
|
||||
let identified_items = dm.identified_items.clone();
|
||||
let roll = ecs.write_resource::<RandomNumberGenerator>().roll_dice(1, 3);
|
||||
std::mem::drop(dm);
|
||||
let mut eb = ecs.create_entity().marked::<SimpleMarker<SerializeMe>>();
|
||||
|
||||
|
|
@ -177,7 +178,14 @@ pub fn spawn_named_item(raws: &RawMaster, ecs: &mut World, key: &str, pos: Spawn
|
|||
}
|
||||
}
|
||||
}
|
||||
eb = eb.with(Beatitude { buc, known: false });
|
||||
if buc == BUC::Uncursed {
|
||||
match roll {
|
||||
1 => buc = BUC::Cursed,
|
||||
2 => buc = BUC::Blessed,
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
eb = eb.with(Beatitude { buc, known: true });
|
||||
|
||||
let mut base_damage = "1d4";
|
||||
let mut hit_bonus = 0;
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ pub fn save_game(ecs: &mut World) {
|
|||
Attributes,
|
||||
BlocksTile,
|
||||
BlocksVisibility,
|
||||
Beatitude,
|
||||
Burden,
|
||||
Chasing,
|
||||
Clock,
|
||||
|
|
@ -173,6 +174,7 @@ pub fn load_game(ecs: &mut World) {
|
|||
Attributes,
|
||||
BlocksTile,
|
||||
BlocksVisibility,
|
||||
Beatitude,
|
||||
Burden,
|
||||
Chasing,
|
||||
Clock,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue