weapon fix, and inability to remove cursed items
This commit is contained in:
parent
d277384cc5
commit
e403a6d845
6 changed files with 79 additions and 23 deletions
|
|
@ -1,8 +1,9 @@
|
|||
use crate::{
|
||||
gamelog,
|
||||
gui::{item_colour, obfuscate_name},
|
||||
Beatitude, Equipped, InBackpack, MagicItem, MasterDungeonMap, Name, ObfuscatedName, WantsToRemoveItem,
|
||||
Beatitude, Equipped, InBackpack, MagicItem, MasterDungeonMap, Name, ObfuscatedName, WantsToRemoveItem, BUC,
|
||||
};
|
||||
use rltk::prelude::*;
|
||||
use specs::prelude::*;
|
||||
|
||||
pub struct ItemRemoveSystem {}
|
||||
|
|
@ -37,11 +38,14 @@ impl<'a> System<'a> for ItemRemoveSystem {
|
|||
) = data;
|
||||
|
||||
for (entity, to_remove) in (&entities, &wants_remove).join() {
|
||||
equipped.remove(to_remove.item);
|
||||
if let Some(_) = names.get(to_remove.item) {
|
||||
if entity == *player_entity {
|
||||
let mut can_remove = true;
|
||||
if let Some(beatitude) = beatitudes.get(to_remove.item) {
|
||||
// If cursed, can't remove!
|
||||
if beatitude.buc == BUC::Cursed {
|
||||
can_remove = false;
|
||||
gamelog::Logger::new()
|
||||
.append("You unequip the")
|
||||
.append("You can't remove the")
|
||||
.colour(item_colour(to_remove.item, &beatitudes, &dm))
|
||||
.append_n(
|
||||
obfuscate_name(
|
||||
to_remove.item,
|
||||
|
|
@ -54,7 +58,34 @@ impl<'a> System<'a> for ItemRemoveSystem {
|
|||
)
|
||||
.0,
|
||||
)
|
||||
.colour(WHITE)
|
||||
.append("!")
|
||||
.log();
|
||||
}
|
||||
}
|
||||
if !can_remove {
|
||||
continue;
|
||||
}
|
||||
// If not cursed, remove it
|
||||
equipped.remove(to_remove.item);
|
||||
if let Some(_) = names.get(to_remove.item) {
|
||||
if entity == *player_entity {
|
||||
gamelog::Logger::new()
|
||||
.append("You unequip the")
|
||||
.colour(item_colour(to_remove.item, &beatitudes, &dm))
|
||||
.append_n(
|
||||
obfuscate_name(
|
||||
to_remove.item,
|
||||
&names,
|
||||
&magic_items,
|
||||
&obfuscated_names,
|
||||
&beatitudes,
|
||||
&dm,
|
||||
None,
|
||||
)
|
||||
.0,
|
||||
)
|
||||
.colour(WHITE)
|
||||
.period()
|
||||
.log();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue