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) {
|
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
|
// Render stats
|
||||||
let pools = ecs.read_storage::<Pools>();
|
let pools = ecs.read_storage::<Pools>();
|
||||||
let attributes = ecs.read_storage::<Attributes>();
|
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")),
|
&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);
|
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) {
|
pub fn item_colour_ecs(ecs: &World, item: Entity) -> (u8, u8, u8) {
|
||||||
let dm = ecs.fetch::<MasterDungeonMap>();
|
if let Some(beatitude) = ecs.read_storage::<Beatitude>().get(item) {
|
||||||
if let Some(name) = ecs.read_storage::<Name>().get(item) {
|
if beatitude.known {
|
||||||
if let Some(magic) = ecs.read_storage::<MagicItem>().get(item) {
|
match beatitude.buc {
|
||||||
if dm.identified_items.contains(&name.name) {
|
BUC::Blessed => return GREEN,
|
||||||
// If identified magic item, use rarity colour
|
BUC::Uncursed => return WHITE,
|
||||||
match magic.class {
|
BUC::Cursed => return RED,
|
||||||
MagicItemClass::Common => return WHITE,
|
|
||||||
MagicItemClass::Uncommon => return GREEN,
|
|
||||||
MagicItemClass::Rare => return BLUE,
|
|
||||||
MagicItemClass::VeryRare => return PURPLE,
|
|
||||||
MagicItemClass::Legendary => return GOLD,
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Unidentified magic item
|
// Unidentified magic item
|
||||||
return GREY;
|
return GREY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// If nonmagic, just use white
|
// If nonmagic, just use white
|
||||||
return WHITE;
|
return WHITE;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn item_colour(
|
pub fn item_colour(item: Entity, beatitudes: &ReadStorage<Beatitude>, dm: &MasterDungeonMap) -> (u8, u8, u8) {
|
||||||
item: Entity,
|
if let Some(beatitude) = beatitudes.get(item) {
|
||||||
names: &ReadStorage<Name>,
|
if beatitude.known {
|
||||||
magic_items: &ReadStorage<MagicItem>,
|
match beatitude.buc {
|
||||||
dm: &MasterDungeonMap,
|
BUC::Blessed => return GREEN,
|
||||||
) -> (u8, u8, u8) {
|
BUC::Uncursed => return WHITE,
|
||||||
if let Some(name) = names.get(item) {
|
BUC::Cursed => return RED,
|
||||||
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,
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Unidentified magic item
|
// Unidentified magic item
|
||||||
return GREY;
|
return GREY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// If nonmagic, just use white
|
// If nonmagic, just use white
|
||||||
return WHITE;
|
return WHITE;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ impl<'a> System<'a> for ItemEquipSystem {
|
||||||
obfuscate_name(*item, &names, &magic_items, &obfuscated_names, &beatitudes, &dm, None)
|
obfuscate_name(*item, &names, &magic_items, &obfuscated_names, &beatitudes, &dm, None)
|
||||||
.0,
|
.0,
|
||||||
)
|
)
|
||||||
.colour(item_colour(*item, &names, &magic_items, &dm))
|
.colour(item_colour(*item, &beatitudes, &dm))
|
||||||
.period();
|
.period();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -90,7 +90,7 @@ impl<'a> System<'a> for ItemEquipSystem {
|
||||||
)
|
)
|
||||||
.0,
|
.0,
|
||||||
)
|
)
|
||||||
.colour(item_colour(wants_to_use_item.item, &names, &magic_items, &dm))
|
.colour(item_colour(wants_to_use_item.item, &beatitudes, &dm))
|
||||||
.period();
|
.period();
|
||||||
logger.log();
|
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::*;
|
use specs::prelude::*;
|
||||||
|
|
||||||
pub struct ItemIdentificationSystem {}
|
pub struct ItemIdentificationSystem {}
|
||||||
|
|
@ -8,6 +8,7 @@ impl<'a> System<'a> for ItemIdentificationSystem {
|
||||||
type SystemData = (
|
type SystemData = (
|
||||||
ReadStorage<'a, Player>,
|
ReadStorage<'a, Player>,
|
||||||
WriteStorage<'a, IdentifiedItem>,
|
WriteStorage<'a, IdentifiedItem>,
|
||||||
|
WriteStorage<'a, Beatitude>,
|
||||||
WriteExpect<'a, MasterDungeonMap>,
|
WriteExpect<'a, MasterDungeonMap>,
|
||||||
ReadStorage<'a, Item>,
|
ReadStorage<'a, Item>,
|
||||||
ReadStorage<'a, Name>,
|
ReadStorage<'a, Name>,
|
||||||
|
|
@ -16,13 +17,11 @@ impl<'a> System<'a> for ItemIdentificationSystem {
|
||||||
);
|
);
|
||||||
|
|
||||||
fn run(&mut self, data: Self::SystemData) {
|
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() {
|
for (_p, id) in (&player, &identified).join() {
|
||||||
rltk::console::log(id.name.clone());
|
|
||||||
let tag = crate::raws::get_id_from_name(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) {
|
if !dm.identified_items.contains(&id.name) && crate::raws::is_tag_magic(&tag) {
|
||||||
dm.identified_items.insert(id.name.clone());
|
dm.identified_items.insert(id.name.clone());
|
||||||
|
|
||||||
for (entity, _item, name) in (&entities, &items, &names).join() {
|
for (entity, _item, name) in (&entities, &items, &names).join() {
|
||||||
if name.name == id.name {
|
if name.name == id.name {
|
||||||
obfuscated_names.remove(entity);
|
obfuscated_names.remove(entity);
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ impl<'a> System<'a> for ItemRemoveSystem {
|
||||||
)
|
)
|
||||||
.0,
|
.0,
|
||||||
)
|
)
|
||||||
.colour(item_colour(to_remove.item, &names, &magic_items, &dm))
|
.colour(item_colour(to_remove.item, &beatitudes, &dm))
|
||||||
.period()
|
.period()
|
||||||
.log();
|
.log();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -572,6 +572,7 @@ fn main() -> rltk::BError {
|
||||||
gs.ecs.register::<HungerClock>();
|
gs.ecs.register::<HungerClock>();
|
||||||
gs.ecs.register::<WantsToMelee>();
|
gs.ecs.register::<WantsToMelee>();
|
||||||
gs.ecs.register::<Item>();
|
gs.ecs.register::<Item>();
|
||||||
|
gs.ecs.register::<Beatitude>();
|
||||||
gs.ecs.register::<IdentifiedItem>();
|
gs.ecs.register::<IdentifiedItem>();
|
||||||
gs.ecs.register::<MagicItem>();
|
gs.ecs.register::<MagicItem>();
|
||||||
gs.ecs.register::<GrantsXP>();
|
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 potion_names = dm.potion_map.clone();
|
||||||
let wand_names = dm.wand_map.clone();
|
let wand_names = dm.wand_map.clone();
|
||||||
let identified_items = dm.identified_items.clone();
|
let identified_items = dm.identified_items.clone();
|
||||||
|
let roll = ecs.write_resource::<RandomNumberGenerator>().roll_dice(1, 3);
|
||||||
std::mem::drop(dm);
|
std::mem::drop(dm);
|
||||||
let mut eb = ecs.create_entity().marked::<SimpleMarker<SerializeMe>>();
|
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 base_damage = "1d4";
|
||||||
let mut hit_bonus = 0;
|
let mut hit_bonus = 0;
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,7 @@ pub fn save_game(ecs: &mut World) {
|
||||||
Attributes,
|
Attributes,
|
||||||
BlocksTile,
|
BlocksTile,
|
||||||
BlocksVisibility,
|
BlocksVisibility,
|
||||||
|
Beatitude,
|
||||||
Burden,
|
Burden,
|
||||||
Chasing,
|
Chasing,
|
||||||
Clock,
|
Clock,
|
||||||
|
|
@ -173,6 +174,7 @@ pub fn load_game(ecs: &mut World) {
|
||||||
Attributes,
|
Attributes,
|
||||||
BlocksTile,
|
BlocksTile,
|
||||||
BlocksVisibility,
|
BlocksVisibility,
|
||||||
|
Beatitude,
|
||||||
Burden,
|
Burden,
|
||||||
Chasing,
|
Chasing,
|
||||||
Clock,
|
Clock,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue