Implement scrolls to uncurse cursed items
This commit is contained in:
parent
03f5bc779b
commit
5c438cc3c0
@ -45,3 +45,6 @@ pub struct TownPortal {}
|
|||||||
|
|
||||||
#[derive(Component, Debug, Serialize, Deserialize, Clone)]
|
#[derive(Component, Debug, Serialize, Deserialize, Clone)]
|
||||||
pub struct CursedItem {}
|
pub struct CursedItem {}
|
||||||
|
|
||||||
|
#[derive(Component, Debug, Serialize, Deserialize, Clone)]
|
||||||
|
pub struct ProvidesRemoveCurse {}
|
||||||
|
@ -3,8 +3,8 @@ use ::specs::prelude::*;
|
|||||||
use super::{add_effect, EffectType, Targets};
|
use super::{add_effect, EffectType, Targets};
|
||||||
use crate::components::{
|
use crate::components::{
|
||||||
Confusion, Consumable, Hidden, InflictsDamage, MagicMapper, Name, ProvidesFood,
|
Confusion, Consumable, Hidden, InflictsDamage, MagicMapper, Name, ProvidesFood,
|
||||||
ProvidesHealing, SingleActivation, SpawnParticleBurst, SpawnParticleLine, TeleportTo,
|
ProvidesHealing, ProvidesRemoveCurse, SingleActivation, SpawnParticleBurst, SpawnParticleLine,
|
||||||
TownPortal,
|
TeleportTo, TownPortal,
|
||||||
};
|
};
|
||||||
use crate::effects::{entity_position, targeting};
|
use crate::effects::{entity_position, targeting};
|
||||||
use crate::{colors, GameLog, Map, RunState};
|
use crate::{colors, GameLog, Map, RunState};
|
||||||
@ -106,6 +106,18 @@ fn event_trigger(
|
|||||||
did_something = true;
|
did_something = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove Curse
|
||||||
|
if ecs
|
||||||
|
.read_storage::<ProvidesRemoveCurse>()
|
||||||
|
.get(entity)
|
||||||
|
.is_some()
|
||||||
|
{
|
||||||
|
let mut runstate = ecs.fetch_mut::<RunState>();
|
||||||
|
*runstate = RunState::ShowRemoveCurse;
|
||||||
|
|
||||||
|
did_something = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Town Portal
|
// Town Portal
|
||||||
if ecs.read_storage::<TownPortal>().get(entity).is_some() {
|
if ecs.read_storage::<TownPortal>().get(entity).is_some() {
|
||||||
let map = ecs.fetch::<Map>();
|
let map = ecs.fetch::<Map>();
|
||||||
|
@ -11,10 +11,10 @@ pub use menu::*;
|
|||||||
use tooltip::draw_tooltips;
|
use tooltip::draw_tooltips;
|
||||||
|
|
||||||
use crate::components::{
|
use crate::components::{
|
||||||
Attribute, Attributes, Consumable, CursedItem, Equipped, HungerClock, HungerState, InBackpack, MagicItem, MagicItemClass, Name, ObfuscatedName, Pools, Viewshed,
|
Attribute, Attributes, Consumable, CursedItem, Equipped, HungerClock, HungerState, InBackpack,
|
||||||
|
MagicItem, MagicItemClass, Name, ObfuscatedName, Pools, Viewshed,
|
||||||
};
|
};
|
||||||
use crate::game_log::GameLog;
|
use crate::game_log::GameLog;
|
||||||
|
|
||||||
use crate::{camera, colors, Map, MasterDungeonMap, State};
|
use crate::{camera, colors, Map, MasterDungeonMap, State};
|
||||||
|
|
||||||
pub fn get_item_color(ecs: &World, item: Entity) -> RGB {
|
pub fn get_item_color(ecs: &World, item: Entity) -> RGB {
|
||||||
|
@ -1,15 +1,9 @@
|
|||||||
|
|
||||||
|
|
||||||
use ::rltk::{Rltk, VirtualKeyCode, RGB};
|
use ::rltk::{Rltk, VirtualKeyCode, RGB};
|
||||||
use ::specs::prelude::*;
|
use ::specs::prelude::*;
|
||||||
|
|
||||||
use super::enums::*;
|
use super::enums::*;
|
||||||
use super::{get_item_color, get_item_display_name};
|
use super::{get_item_color, get_item_display_name};
|
||||||
use crate::components::{
|
use crate::components::{CursedItem, Equipped, InBackpack, Item, Name, Vendor};
|
||||||
CursedItem, Equipped, InBackpack,
|
|
||||||
Item, Name, Vendor,
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::rex_assets::RexAssets;
|
use crate::rex_assets::RexAssets;
|
||||||
use crate::{colors, MasterDungeonMap, RunState, State, VendorMode};
|
use crate::{colors, MasterDungeonMap, RunState, State, VendorMode};
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@ use crate::components::{
|
|||||||
CursedItem, EquipmentChanged, Equippable, Equipped, IdentifiedItem, InBackpack, Name,
|
CursedItem, EquipmentChanged, Equippable, Equipped, IdentifiedItem, InBackpack, Name,
|
||||||
WantsToUseItem,
|
WantsToUseItem,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::GameLog;
|
use crate::GameLog;
|
||||||
|
|
||||||
pub struct ItemEquipOnUse {}
|
pub struct ItemEquipOnUse {}
|
||||||
|
@ -97,6 +97,7 @@ fn init_state() -> State {
|
|||||||
Position,
|
Position,
|
||||||
ProvidesFood,
|
ProvidesFood,
|
||||||
ProvidesHealing,
|
ProvidesHealing,
|
||||||
|
ProvidesRemoveCurse,
|
||||||
Quips,
|
Quips,
|
||||||
Ranged,
|
Ranged,
|
||||||
Renderable,
|
Renderable,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{HashMap, HashSet};
|
||||||
|
|
||||||
use ::regex::Regex;
|
use ::regex::Regex;
|
||||||
use ::rltk::{RandomNumberGenerator, RGB};
|
use ::rltk::{console, RandomNumberGenerator, RGB};
|
||||||
use ::specs::prelude::*;
|
use ::specs::prelude::*;
|
||||||
use ::specs::saveload::{MarkedBuilder, SimpleMarker};
|
use ::specs::saveload::{MarkedBuilder, SimpleMarker};
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ impl RawMaster {
|
|||||||
let mut used_names: HashSet<String> = HashSet::new();
|
let mut used_names: HashSet<String> = HashSet::new();
|
||||||
for (i, item) in self.raws.items.iter().enumerate() {
|
for (i, item) in self.raws.items.iter().enumerate() {
|
||||||
if used_names.contains(&item.name) {
|
if used_names.contains(&item.name) {
|
||||||
rltk::console::log(format!(
|
console::log(format!(
|
||||||
"WARNING - duplicate item name in raws [{}]",
|
"WARNING - duplicate item name in raws [{}]",
|
||||||
item.name
|
item.name
|
||||||
));
|
));
|
||||||
@ -84,7 +84,7 @@ impl RawMaster {
|
|||||||
}
|
}
|
||||||
for (i, mob) in self.raws.mobs.iter().enumerate() {
|
for (i, mob) in self.raws.mobs.iter().enumerate() {
|
||||||
if used_names.contains(&mob.name) {
|
if used_names.contains(&mob.name) {
|
||||||
rltk::console::log(format!(
|
console::log(format!(
|
||||||
"WARNING - duplicate mob name in raws [{}]",
|
"WARNING - duplicate mob name in raws [{}]",
|
||||||
mob.name
|
mob.name
|
||||||
));
|
));
|
||||||
@ -94,7 +94,7 @@ impl RawMaster {
|
|||||||
}
|
}
|
||||||
for (i, prop) in self.raws.props.iter().enumerate() {
|
for (i, prop) in self.raws.props.iter().enumerate() {
|
||||||
if used_names.contains(&prop.name) {
|
if used_names.contains(&prop.name) {
|
||||||
rltk::console::log(format!(
|
console::log(format!(
|
||||||
"WARNING - duplicate prop name in raws [{}]",
|
"WARNING - duplicate prop name in raws [{}]",
|
||||||
prop.name
|
prop.name
|
||||||
));
|
));
|
||||||
@ -105,7 +105,7 @@ impl RawMaster {
|
|||||||
|
|
||||||
for spawn in self.raws.spawn_table.iter() {
|
for spawn in self.raws.spawn_table.iter() {
|
||||||
if !used_names.contains(&spawn.name) {
|
if !used_names.contains(&spawn.name) {
|
||||||
rltk::console::log(format!(
|
console::log(format!(
|
||||||
"WARNING - Spawn tables references unspecified entity {}",
|
"WARNING - Spawn tables references unspecified entity {}",
|
||||||
spawn.name
|
spawn.name
|
||||||
));
|
));
|
||||||
@ -261,7 +261,7 @@ pub fn string_to_slot(slot: &str) -> EquipmentSlot {
|
|||||||
"Hands" => EquipmentSlot::Hands,
|
"Hands" => EquipmentSlot::Hands,
|
||||||
"Melee" => EquipmentSlot::Melee,
|
"Melee" => EquipmentSlot::Melee,
|
||||||
_ => {
|
_ => {
|
||||||
rltk::console::log(format!("Warning: unknown equipment slot type [{}]", slot));
|
console::log(format!("Warning: unknown equipment slot type [{}]", slot));
|
||||||
|
|
||||||
EquipmentSlot::Melee
|
EquipmentSlot::Melee
|
||||||
}
|
}
|
||||||
@ -322,9 +322,10 @@ macro_rules! apply_effects {
|
|||||||
"single_activation" => $eb = $eb.with(SingleActivation {}),
|
"single_activation" => $eb = $eb.with(SingleActivation {}),
|
||||||
"particle_line" => $eb = $eb.with(parse_particle_line(&effect.1)),
|
"particle_line" => $eb = $eb.with(parse_particle_line(&effect.1)),
|
||||||
"particle" => $eb = $eb.with(parse_particle(&effect.1)),
|
"particle" => $eb = $eb.with(parse_particle(&effect.1)),
|
||||||
|
"remove_curse" => $eb = $eb.with(ProvidesRemoveCurse {}),
|
||||||
_ => {
|
_ => {
|
||||||
::rltk::console::log(format!(
|
console::log(format!(
|
||||||
"Warning: consumable effect {} not implemented.",
|
"Warning: consumable effect '{}' not implemented.",
|
||||||
effect_name
|
effect_name
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -554,7 +555,7 @@ pub fn spawn_named_mob(
|
|||||||
skills.skills.insert(Skill::Magic, *sk.1);
|
skills.skills.insert(Skill::Magic, *sk.1);
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
::rltk::console::log(format!("Unknown skill referenced [{}]", sk.0));
|
console::log(format!("Unknown skill referenced [{}]", sk.0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,6 +102,7 @@ pub fn save_game(ecs: &mut World) {
|
|||||||
Position,
|
Position,
|
||||||
ProvidesFood,
|
ProvidesFood,
|
||||||
ProvidesHealing,
|
ProvidesHealing,
|
||||||
|
ProvidesRemoveCurse,
|
||||||
Quips,
|
Quips,
|
||||||
Ranged,
|
Ranged,
|
||||||
Renderable,
|
Renderable,
|
||||||
@ -220,6 +221,7 @@ pub fn load_game(ecs: &mut World) {
|
|||||||
Position,
|
Position,
|
||||||
ProvidesFood,
|
ProvidesFood,
|
||||||
ProvidesHealing,
|
ProvidesHealing,
|
||||||
|
ProvidesRemoveCurse,
|
||||||
Quips,
|
Quips,
|
||||||
Ranged,
|
Ranged,
|
||||||
Renderable,
|
Renderable,
|
||||||
|
@ -174,8 +174,9 @@ pub fn spawn_region(
|
|||||||
pub fn spawn_entity(ecs: &mut World, spawn: &(&usize, &String)) {
|
pub fn spawn_entity(ecs: &mut World, spawn: &(&usize, &String)) {
|
||||||
let map = ecs.fetch::<Map>();
|
let map = ecs.fetch::<Map>();
|
||||||
let width = map.width as usize;
|
let width = map.width as usize;
|
||||||
let x = (*spawn.0 % width) as i32;
|
let (idx, name) = *spawn;
|
||||||
let y = (*spawn.0 / width) as i32;
|
let x = (*idx % width) as i32;
|
||||||
|
let y = (*idx / width) as i32;
|
||||||
|
|
||||||
// Drop this map reference to make the borrow checker happy
|
// Drop this map reference to make the borrow checker happy
|
||||||
std::mem::drop(map);
|
std::mem::drop(map);
|
||||||
@ -183,17 +184,14 @@ pub fn spawn_entity(ecs: &mut World, spawn: &(&usize, &String)) {
|
|||||||
let item_result = spawn_named_entity(
|
let item_result = spawn_named_entity(
|
||||||
&RAWS.lock().unwrap(),
|
&RAWS.lock().unwrap(),
|
||||||
ecs,
|
ecs,
|
||||||
spawn.1,
|
name,
|
||||||
SpawnType::AtPosition { x, y },
|
SpawnType::AtPosition { x, y },
|
||||||
);
|
);
|
||||||
if item_result.is_some() {
|
if item_result.is_some() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
rltk::console::log(format!(
|
::rltk::console::log(format!("WARNING: We don't know how to spawn [{}]!", name));
|
||||||
"WARNING: We don't know how to spawn [{}]!",
|
|
||||||
spawn.1
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn spawn_town_portal(ecs: &mut World) {
|
pub fn spawn_town_portal(ecs: &mut World) {
|
||||||
|
15
src/state.rs
15
src/state.rs
@ -49,6 +49,7 @@ pub enum RunState {
|
|||||||
ShowCheatMenu,
|
ShowCheatMenu,
|
||||||
ShowVendor { vendor: Entity, mode: VendorMode },
|
ShowVendor { vendor: Entity, mode: VendorMode },
|
||||||
TeleportingToOtherLevel { x: i32, y: i32, depth: i32 },
|
TeleportingToOtherLevel { x: i32, y: i32, depth: i32 },
|
||||||
|
ShowRemoveCurse,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct State {
|
pub struct State {
|
||||||
@ -260,6 +261,7 @@ impl GameState for State {
|
|||||||
RunState::TeleportingToOtherLevel { x, y, depth } => {
|
RunState::TeleportingToOtherLevel { x, y, depth } => {
|
||||||
RunState::TeleportingToOtherLevel { x, y, depth }
|
RunState::TeleportingToOtherLevel { x, y, depth }
|
||||||
}
|
}
|
||||||
|
RunState::ShowRemoveCurse => RunState::ShowRemoveCurse,
|
||||||
_ => RunState::Ticking,
|
_ => RunState::Ticking,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -535,6 +537,19 @@ impl GameState for State {
|
|||||||
|
|
||||||
newrunstate = RunState::MapGeneration;
|
newrunstate = RunState::MapGeneration;
|
||||||
}
|
}
|
||||||
|
RunState::ShowRemoveCurse => {
|
||||||
|
let result = gui::remove_curse_menu(self, ctx);
|
||||||
|
match result.0 {
|
||||||
|
gui::ItemMenuResult::Cancel => newrunstate = RunState::AwaitingInput,
|
||||||
|
gui::ItemMenuResult::NoResponse => {}
|
||||||
|
gui::ItemMenuResult::Selected => {
|
||||||
|
let item_entity = result.1.unwrap();
|
||||||
|
self.ecs.write_storage::<CursedItem>().remove(item_entity);
|
||||||
|
|
||||||
|
newrunstate = RunState::Ticking;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user