]> git.localhorst.tv Git - l2e.git/blobdiff - src/common/Item.h
removed stupid file headers that eclipse put in
[l2e.git] / src / common / Item.h
index 1dde8878f7c0d4f2dfe79fcd80e516ec150f4edd..2fbcbba2648892aa552936f76ffb21df37d12d39 100644 (file)
@@ -1,67 +1,58 @@
-/*
- * Item.h
- *
- *  Created on: Aug 9, 2012
- *      Author: holy
- */
-
 #ifndef COMMON_ITEM_H_
 #define COMMON_ITEM_H_
 
-#include <SDL.h>
+#include "fwd.h"
+#include "Hero.h"
+#include "TargetingMode.h"
+#include "../graphics/fwd.h"
 
-namespace graphics { class Sprite; }
+#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; }
 
-       bool TargetEnemy() const { return targettingMode & TARGETTING_MODE_ENEMY; }
-       bool TargetAlly() const { return !TargetEnemy(); }
-       bool TargetAll() const { return (targettingMode & TARGETTING_MODE_COUNT_MASK) == TARGETTING_MODE_ALL; }
-       bool TargetMultiple() const { return (targettingMode & TARGETTING_MODE_COUNT_MASK) == TARGETTING_MODE_MULTIPLE; }
-       bool TargetOne() const { return (targettingMode & TARGETTING_MODE_COUNT_MASK) == TARGETTING_MODE_ONE; }
+       TargetingMode &GetTargetingMode() { return targettingMode; }
+       const TargetingMode &GetTargetingMode() const { return targettingMode; }
 
        bool HasMenuIcon() const { return menuIcon; }
        const graphics::Sprite *MenuIcon() const { return menuIcon; }
        bool HasChestIcon() const { return chestIcon; }
        const graphics::Sprite *ChestIcon() const { return chestIcon; }
 
+       bool HasIkari() const { return ikari; }
+       const Ikari *GetIkari() const { return ikari; }
+
+       graphics::Animation *AttackAnimation() { return attackAnimation; }
+       const graphics::Animation *AttackAnimation() const { return attackAnimation; }
+
        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 EquipableByMaxim() const { return equipableBy & EQUIPABLE_BY_MAXIM; }
-       bool EquipableBySelan() const { return equipableBy & EQUIPABLE_BY_SELAN; }
-       bool EquipableByGuy() const { return equipableBy & EQUIPABLE_BY_GUY; }
-       bool EquipableByArtea() const { return equipableBy & EQUIPABLE_BY_ARTEA; }
-       bool EquipableByTia() const { return equipableBy & EQUIPABLE_BY_TIA; }
-       bool EquipableByDekar() const { return equipableBy & EQUIPABLE_BY_DEKAR; }
-       bool EquipableByLexis() const { return equipableBy & EQUIPABLE_BY_LEXIS; }
-
-       bool HasItemEffectOnStatusScreen() const { return properties & PROPERTY_HAS_ITEM_EFFECT_STATUS; }
-       bool HasItemEffectInBattle() const { return properties & PROPERTY_HAS_ITEM_EFFECT_BATTLE; }
+       bool EquipableAt(Hero::EquipSlot slot) const { return equipability & (1 << slot); }
+
+       int HeroMask() const { return heroMask; }
+
+       bool HasEffectOnStatusScreen() const { return properties & PROPERTY_HAS_EFFECT_STATUS; }
+       bool HasEffectInBattle() const { return properties & PROPERTY_HAS_EFFECT_BATTLE; }
        bool HasWeaponEffect() const { return properties & PROPERTY_HAS_WEAPON_EFFECT; }
        bool HasArmorEffect() const { return properties & PROPERTY_HAS_ARMOR_EFFECT; }
        bool IncreasesATP() const { return properties & PROPERTY_INCREASE_ATP; }
@@ -74,55 +65,23 @@ 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 SetTargettingMode(int m) { targettingMode = m; }
+       void SetUsableInBattle() { battle = true; }
+       void SetIkari(const Ikari *i) { ikari = i; }
+       void SetAttackAnimation(graphics::Animation *a) { attackAnimation = a; }
 
-public:
-       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 TargettingMode {
-               TARGETTING_MODE_ALL = 0,
-               TARGETTING_MODE_ALLY = 0,
-               TARGETTING_MODE_MULTIPLE = 1,
-               TARGETTING_MODE_ONE = 2,
-               TARGETTING_MODE_COUNT_MASK = 127,
-               TARGETTING_MODE_ENEMY = 128,
-               TARGETTING_MODE_FACTION_MASK = 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 EquipableBy {
-               EQUIPABLE_BY_NOBODY = 0,
-               EQUIPABLE_BY_MAXIM = 1,
-               EQUIPABLE_BY_SELAN = 2,
-               EQUIPABLE_BY_GUY = 4,
-               EQUIPABLE_BY_ARTEA = 8,
-               EQUIPABLE_BY_TIA = 16,
-               EQUIPABLE_BY_DEKAR = 32,
-               EQUIPABLE_BY_LEXIS = 64,
-       };
+       static void CreateTypeDescription();
+       static void Construct(void *);
+
+private:
        enum Property {
-               PROPERTY_HAS_ITEM_EFFECT_STATUS = 1,
-               PROPERTY_HAS_ITEM_EFFECT_BATTLE = 2,
+               PROPERTY_HAS_EFFECT_STATUS = 1,
+               PROPERTY_HAS_EFFECT_BATTLE = 2,
                PROPERTY_HAS_WEAPON_EFFECT = 4,
                PROPERTY_HAS_ARMOR_EFFECT = 8,
                PROPERTY_INCREASE_ATP = 16,
@@ -143,14 +102,23 @@ private:
        const char *name;
        const graphics::Sprite *menuIcon;
        const graphics::Sprite *chestIcon;
+       const Ikari *ikari;
+       graphics::Animation *attackAnimation;
 
        Uint16 value;
        Uint16 properties;
 
-       Uint8 usability;
-       Uint8 targettingMode;
-       Uint8 equipable;
-       Uint8 equipableBy;
+       TargetingMode targettingMode;
+       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;
 
 };