]> git.localhorst.tv Git - l2e.git/blobdiff - src/common/Item.h
removed lazy fwd headers
[l2e.git] / src / common / Item.h
index 1d9d51c56baa8260779f6b3115d876bc8d4a964d..bacdfb090614f37956062327d27a1e75f58a25c7 100644 (file)
@@ -1,44 +1,41 @@
-/*
- * Item.h
- *
- *  Created on: Aug 9, 2012
- *      Author: holy
- */
-
 #ifndef COMMON_ITEM_H_
 #define COMMON_ITEM_H_
 
-#include "HeroGroup.h"
-#include "TargetingMode.h"
-
-#include <SDL.h>
-
+namespace common {
+       class Ikari;
+}
 namespace graphics {
        class Animation;
        class Sprite;
 }
 
-namespace common {
+#include "Hero.h"
+#include "TargetingMode.h"
 
-class Ikari;
+#include <SDL.h>
+
+namespace common {
 
 class Item {
 
+public:
+       static const int TYPE_ID = 303;
+
 public:
        Item();
 
 public:
        const char *Name() const { return name; }
 
-       bool IsMostUseful() const { return usability & USABILITY_MOST_USEFUL; }
-       bool IsEquipable() const { return usability & USABILITY_EQUIPABLE; }
-       bool IsCursed() const { return usability & USABILITY_CURSED; }
-       bool IsFruit() const { return usability & USABILITY_FRUIT; }
-       bool IsScenario() const { return usability & USABILITY_SCENARIO; }
+       bool IsMostUseful() const { return mostUseful; }
+       bool IsEquipable() const { return equipability; }
+       bool IsCursed() const { return cursed; }
+       bool IsFruit() const { return fruit; }
+       bool IsScenario() const { return scenario; }
        bool CanSell() const { return !IsScenario(); }
        bool CanDrop() const { return !IsScenario(); }
-       bool CanUseOnStatusScreen() const { return usability & USABILITY_STATUS; }
-       bool CanUseInBattle() const { return usability & USABILITY_BATTLE; }
+       bool CanUseOnStatusScreen() const { return status; }
+       bool CanUseInBattle() const { return battle; }
 
        TargetingMode &GetTargetingMode() { return targettingMode; }
        const TargetingMode &GetTargetingMode() const { return targettingMode; }
@@ -56,15 +53,9 @@ public:
 
        Uint16 Value() const { return value; }
 
-       bool CanEquipWeapon() const { return equipable & EQUIPPABLE_WEAPON; }
-       bool CanEquipArmor() const { return equipable & EQUIPPABLE_ARMOR; }
-       bool CanEquipShield() const { return equipable & EQUIPPABLE_SHIELD; }
-       bool CanEquipHelmet() const { return equipable & EQUIPPABLE_HELMET; }
-       bool CanEquipRing() const { return equipable & EQUIPPABLE_RING; }
-       bool CanEquipJewel() const { return equipable & EQUIPPABLE_JEWEL; }
+       bool EquipableAt(Hero::EquipSlot slot) const { return equipability & (1 << slot); }
 
-       HeroGroup &EquipableBy() { return equipableBy; }
-       const HeroGroup &EquipableBy() const { return equipableBy; }
+       int HeroMask() const { return heroMask; }
 
        bool HasEffectOnStatusScreen() const { return properties & PROPERTY_HAS_EFFECT_STATUS; }
        bool HasEffectInBattle() const { return properties & PROPERTY_HAS_EFFECT_BATTLE; }
@@ -80,34 +71,20 @@ public:
        bool HasBattleAnimation() const { return properties & PROPERTY_HAS_BATTLE_ANIMATION; }
        bool HasIkariEffect() const { return properties & PROPERTY_HAS_IKARI_EFFECT; }
 
+       static bool Less(const Item &, const Item &);
+
 // temporary setters
 public:
        void SetName(const char *n) { name = n; }
        void SetMenuIcon(const graphics::Sprite *icon) { menuIcon = icon; }
-       void SetUsableInBattle() { usability |= USABILITY_BATTLE; }
+       void SetUsableInBattle() { battle = true; }
        void SetIkari(const Ikari *i) { ikari = i; }
        void SetAttackAnimation(graphics::Animation *a) { attackAnimation = a; }
 
+       static void CreateTypeDescription();
+       static void Construct(void *);
+
 private:
-       enum Usability {
-               USABILITY_MOST_USEFUL = 1,
-               USABILITY_EQUIPABLE = 2,
-               // USABILITY_UNUSED = 4,
-               USABILITY_CURSED = 8,
-               USABILITY_FRUIT = 16,
-               USABILITY_SCENARIO = 32,
-               USABILITY_STATUS = 64,
-               USABILITY_BATTLE = 128,
-       };
-       enum Equipable {
-               EQUIPPABLE_NONE = 0,
-               EQUIPPABLE_WEAPON = 1,
-               EQUIPPABLE_ARMOR = 2,
-               EQUIPPABLE_SHIELD = 4,
-               EQUIPPABLE_HELMET = 8,
-               EQUIPPABLE_RING = 16,
-               EQUIPPABLE_JEWEL = 32,
-       };
        enum Property {
                PROPERTY_HAS_EFFECT_STATUS = 1,
                PROPERTY_HAS_EFFECT_BATTLE = 2,
@@ -137,10 +114,17 @@ private:
        Uint16 value;
        Uint16 properties;
 
-       Uint8 usability;
        TargetingMode targettingMode;
-       Uint8 equipable;
-       HeroGroup equipableBy;
+       int equipability;
+       int heroMask;
+
+       // TODO: turn these back into bits as soon as fields are implemented in the loader
+       bool mostUseful;
+       bool cursed;
+       bool fruit;
+       bool scenario;
+       bool status;
+       bool battle;
 
 };