From 76c74df028bb1d2c137ad515f500440f9ad3421a Mon Sep 17 00:00:00 2001 From: Llywelwyn Date: Wed, 23 Aug 2023 02:31:23 +0100 Subject: [PATCH] inventory system messages to config --- src/config/messages.rs | 7 +++++++ src/effects/damage.rs | 8 ++------ src/inventory/collection_system.rs | 3 ++- src/inventory/drop_system.rs | 3 ++- src/inventory/equip_system.rs | 7 ++++--- src/inventory/remove_system.rs | 5 +++-- 6 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/config/messages.rs b/src/config/messages.rs index b910f87..e0fadb0 100644 --- a/src/config/messages.rs +++ b/src/config/messages.rs @@ -22,3 +22,10 @@ pub const MAGICMAP_CURSED: &str = "... but forget where you last were"; pub const NUTRITION: &str = "You eat the"; pub const NUTRITION_CURSED: &str = "Blech! Rotten"; pub const NUTRITION_BLESSED: &str = "Delicious"; + +pub const LEVELUP_PLAYER: &str = "Welcome to experience level"; +pub const YOU_PICKUP_ITEM: &str = "You pick up the"; +pub const YOU_DROP_ITEM: &str = "You drop the"; +pub const YOU_EQUIP_ITEM: &str = "You equip the"; +pub const YOU_REMOVE_ITEM: &str = "You unequip your"; +pub const YOU_REMOVE_ITEM_CURSED: &str = "You can't remove the"; diff --git a/src/effects/damage.rs b/src/effects/damage.rs index 60d8b2b..bb9eeeb 100644 --- a/src/effects/damage.rs +++ b/src/effects/damage.rs @@ -11,6 +11,7 @@ use crate::{ Pools, }; use crate::config::visuals::{ DEFAULT_PARTICLE_LIFETIME, LONG_PARTICLE_LIFETIME }; +use crate::config::messages::LEVELUP_PLAYER; use rltk::prelude::*; use specs::prelude::*; @@ -161,12 +162,7 @@ pub fn entity_death(ecs: &mut World, effect: &EffectSpawner, target: Entity) { // If it was the PLAYER that levelled up: if ecs.read_storage::().get(source).is_some() { gamelog::record_event("player_level", 1); - gamelog::Logger - ::new() - .append("Welcome to experience level") - .append_n(source_pools.level) - .append("!") - .log(); + gamelog::Logger::new().append(LEVELUP_PLAYER).append_n(source_pools.level).append("!").log(); let player_pos = ecs.fetch::(); let map = ecs.fetch_mut::(); for i in 0..5 { diff --git a/src/inventory/collection_system.rs b/src/inventory/collection_system.rs index 7a21b7c..b1500f3 100644 --- a/src/inventory/collection_system.rs +++ b/src/inventory/collection_system.rs @@ -13,6 +13,7 @@ use crate::{ WantsToPickupItem, }; use specs::prelude::*; +use crate::config::messages; pub struct ItemCollectionSystem {} @@ -57,7 +58,7 @@ impl<'a> System<'a> for ItemCollectionSystem { if pickup.collected_by == *player_entity { gamelog::Logger ::new() - .append("You pick up the") + .append(messages::YOU_PICKUP_ITEM) .item_name_n( format!( "{}", diff --git a/src/inventory/drop_system.rs b/src/inventory/drop_system.rs index f5cc0f6..39a8a0f 100644 --- a/src/inventory/drop_system.rs +++ b/src/inventory/drop_system.rs @@ -13,6 +13,7 @@ use crate::{ WantsToDropItem, }; use specs::prelude::*; +use crate::config::messages; pub struct ItemDropSystem {} @@ -65,7 +66,7 @@ impl<'a> System<'a> for ItemDropSystem { if entity == *player_entity { gamelog::Logger ::new() - .append("You drop the") + .append(messages::YOU_DROP_ITEM) .item_name_n( format!( "{}", diff --git a/src/inventory/equip_system.rs b/src/inventory/equip_system.rs index acf5780..7d04e1c 100644 --- a/src/inventory/equip_system.rs +++ b/src/inventory/equip_system.rs @@ -16,6 +16,7 @@ use crate::{ BUC, }; use specs::prelude::*; +use crate::config::messages; pub struct ItemEquipSystem {} @@ -71,7 +72,7 @@ impl<'a> System<'a> for ItemEquipSystem { if beatitude.buc == BUC::Cursed { can_equip = false; logger = logger - .append("You can't remove the") + .append(messages::YOU_REMOVE_ITEM_CURSED) .colour(item_colour(item_entity, &beatitudes)) .append_n( obfuscate_name( @@ -103,7 +104,7 @@ impl<'a> System<'a> for ItemEquipSystem { backpack.insert(*item, InBackpack { owner: target }).expect("Unable to insert backpack"); if target == *player_entity { logger = logger - .append("You remove your") + .append(messages::YOU_REMOVE_ITEM) .colour(item_colour(*item, &beatitudes)) .append_n( obfuscate_name(*item, &names, &magic_items, &obfuscated_names, &beatitudes, &dm, None).0 @@ -120,7 +121,7 @@ impl<'a> System<'a> for ItemEquipSystem { backpack.remove(wants_to_use_item.item); if target == *player_entity { logger = logger - .append("You equip the") + .append(messages::YOU_EQUIP_ITEM) .colour(item_colour(wants_to_use_item.item, &beatitudes)) .append_n( obfuscate_name( diff --git a/src/inventory/remove_system.rs b/src/inventory/remove_system.rs index d9b9587..f093820 100644 --- a/src/inventory/remove_system.rs +++ b/src/inventory/remove_system.rs @@ -13,6 +13,7 @@ use crate::{ }; use rltk::prelude::*; use specs::prelude::*; +use crate::config::messages; pub struct ItemRemoveSystem {} @@ -53,7 +54,7 @@ impl<'a> System<'a> for ItemRemoveSystem { can_remove = false; gamelog::Logger ::new() - .append("You can't remove the") + .append(messages::YOU_REMOVE_ITEM_CURSED) .colour(item_colour(to_remove.item, &beatitudes)) .append_n( obfuscate_name( @@ -80,7 +81,7 @@ impl<'a> System<'a> for ItemRemoveSystem { if entity == *player_entity { gamelog::Logger ::new() - .append("You unequip the") + .append(messages::YOU_REMOVE_ITEM) .colour(item_colour(to_remove.item, &beatitudes)) .append_n( obfuscate_name(