aboutsummaryrefslogtreecommitdiff
path: root/engines/xeen/item.h
diff options
context:
space:
mode:
authorPaul Gilbert2018-03-31 12:37:36 -0400
committerPaul Gilbert2018-03-31 12:37:36 -0400
commit31bcb0961981e3e647b2de912927145e8e9429aa (patch)
tree0bc9f8c159820509b3bf8628a80b4345050488c0 /engines/xeen/item.h
parent572dbd86239426c54776f02a538f1bea45f4abd3 (diff)
downloadscummvm-rg350-31bcb0961981e3e647b2de912927145e8e9429aa.tar.gz
scummvm-rg350-31bcb0961981e3e647b2de912927145e8e9429aa.tar.bz2
scummvm-rg350-31bcb0961981e3e647b2de912927145e8e9429aa.zip
XEEN: Cleanup of item bonus flags to a bitfield state structure
Diffstat (limited to 'engines/xeen/item.h')
-rw-r--r--engines/xeen/item.h70
1 files changed, 64 insertions, 6 deletions
diff --git a/engines/xeen/item.h b/engines/xeen/item.h
index 105df0e661..9bd70c71da 100644
--- a/engines/xeen/item.h
+++ b/engines/xeen/item.h
@@ -52,11 +52,54 @@ enum ElementalCategory {
ELEM_ENERGY = 4, ELEM_MAGIC = 5
};
+enum ItemId {
+ XEEN_SLAYER_SWORD = 34
+};
+
+enum Effectiveness {
+ EFFECTIVE_NONE = 0, EFFECTIVE_DRAGON = 1, EFFECTIVE_UNDEAD = 2, EFFECTIVE_GOLEM = 3,
+ EFFECTIVE_INSECT = 4, EFFEctIVE_MONSTERS = 5, EFFECTIVE_ANIMAL = 6
+};
+
+struct ItemState {
+ byte _counter : 6; // Stores charges for Misc items, and the effective against for weapons
+ bool _cursed : 1;
+ bool _broken : 1;
+
+ /**
+ * Constructor
+ */
+ ItemState() : _counter(0), _cursed(false), _broken(false) {}
+
+ /**
+ * Clear the state
+ */
+ void clear() {
+ _counter = 0;
+ _cursed = _broken = false;
+ }
+
+ /**
+ * Returns true if the state is empty
+ */
+ bool empty() const { return !_counter && !_cursed && !_broken; }
+
+ /**
+ * Synchronizes the item's state
+ */
+ void synchronize(Common::Serializer &s);
+
+ /**
+ * Set the entire state value
+ */
+ void operator=(byte val);
+};
+
class XeenItem {
public:
int _material;
uint _id;
- int _bonusFlags;
+ ItemState _state;
int _frame;
public:
/**
@@ -70,11 +113,6 @@ public:
XeenItem();
/**
- * Constructor
- */
- XeenItem(uint id, int material, int bonusFlags) : _id(id), _material(material), _bonusFlags(bonusFlags) {}
-
- /**
* Clear the data for the item
*/
void clear();
@@ -85,6 +123,16 @@ public:
bool empty() const { return _id == 0; }
/**
+ * Returns true if the item is cursed or broken
+ */
+ bool isBad() const { return _state._cursed || _state._broken; }
+
+ /**
+ * Returns true for weapons if it's equipped
+ */
+ bool isEquipped() const { return _frame != 0; }
+
+ /**
* Synchronizes the data for the item
*/
void synchronize(Common::Serializer &s);
@@ -305,6 +353,16 @@ public:
* Breaks all the items in a given character's inventory
*/
void breakAllItems();
+
+ /**
+ * Curses or curses all the items
+ */
+ void curseUncurse(bool curse);
+
+ /**
+ * Returns true if the character has any cursed items
+ */
+ bool hasCursedItems() const;
};
} // End of namespace Xeen