#include <string>
+#include "level.h"
using namespace std;
class Player; // Forward declaration
+enum type { WEAPON, ARMOR, POTION };
class item
{
public:
item();
- item(const char *name, long int p=0, int uses=1, int m1=0, int m2=0, int m3=0, int m4=0, int m5=0, int m6=0, int m7=0, int m8=0);
- item(string name, long int p=0, int uses=1, int m1=0, int m2=0, int m3=0, int m4=0, int m5=0, int m6=0, int m7=0, int m8=0);
+ item(const char *name, long int p=0, int uses=1, long int identifier=0, int m1=0, int m2=0, int m3=0, int m4=0, int m5=0, int m6=0, int m7=0, int m8=0);
+ item(string name, long int p=0, int uses=1, long int identifier=0, int m1=0, int m2=0, int m3=0, int m4=0, int m5=0, int m6=0, int m7=0, int m8=0);
virtual ~item();
virtual bool use(Player *p) = 0;
virtual void undo(Player *p) = 0;
+ virtual bool setData(const char *datastr) = 0;
+
+ type getType() {return mytype;};
+ void setType(type);
bool operator<(const item &right) const;
bool operator>(const item &right) const;
long int myprice; // How much does this item cost to buy (half to sell)
int mymodifiers[8]; // Up to 8 different modifiers handled in the sub-classes
int myuses; // How many times this item can be used by default
+ long int id; // Unique identifier for the item
+ type mytype;
};
/*class itemContainer
{
public:
weapon() : item() {myname = "New Weapon";};
- weapon(const char *name, int p=0, int uses = -1, int strength=0, int defense=0, int maxhp=0) : item(name, p, uses, strength, defense, maxhp){};
- weapon(string name, int p=0, int uses = -1, int strength=0, int defense=0, int maxhp=0) : item(name, p, uses, strength, defense, maxhp){};
+ weapon(const char *name, int p=0, int uses = -1, long int identifier=0, int strength=0, int defense=0, int maxhp=0) : item(name, p, uses, strength, defense, maxhp){};
+ weapon(string name, int p=0, int uses = -1, long int identifier=0, int strength=0, int defense=0, int maxhp=0) : item(name, p, uses, strength, defense, maxhp){};
~weapon();
bool use(Player *p);
void undo(Player *p);
+ bool setData(const char *datastr);
};
class armor : public item
{
public:
armor() : item(){};
- armor(const char *name, int p=0, int uses = -1, int strength=0, int defense=0, int maxhp=0) : item(name, p, uses, strength, defense, maxhp){};
- armor(string name, int p=0, int uses = -1, int strength=0, int defense=0, int maxhp=0) : item(name, p, uses, strength, defense, maxhp){};
+ armor(const char *name, int p=0, int uses = -1, long int identifier=0, int strength=0, int defense=0, int maxhp=0) : item(name, p, uses, strength, defense, maxhp){};
+ armor(string name, int p=0, int uses = -1, long int identifier=0, int strength=0, int defense=0, int maxhp=0) : item(name, p, uses, strength, defense, maxhp){};
~armor();
bool use(Player *p);
void undo(Player *p);
+ bool setData(const char *datastr);
};
class potion : public item
{
public:
potion() : item(){};
- potion(const char *name, int p=0, int uses = 1, int strength=0, int defense=0, int maxhp=0, int hp=0, int forest_fights=0, int player_fights=0, int gold=0, int bank=0) : item(name, p, uses, strength, defense, maxhp, hp, forest_fights, player_fights, gold, bank){};
- potion(string name, int p=0, int uses = 1, int strength=0, int defense=0, int maxhp=0, int hp=0, int forest_fights=0, int player_fights=0, int gold=0, int bank=0) : item(name, p, uses, strength, defense, maxhp, hp, forest_fights, player_fights, gold, bank){};
+ potion(const char *name, int p=0, int uses = 1, long int identifier=0, int strength=0, int defense=0, int maxhp=0, int hp=0, int forest_fights=0, int player_fights=0, int gold=0, int bank=0) : item(name, p, uses, strength, defense, maxhp, hp, forest_fights, player_fights, gold, bank){};
+ potion(string name, int p=0, int uses = 1, long int identifier=0, int strength=0, int defense=0, int maxhp=0, int hp=0, int forest_fights=0, int player_fights=0, int gold=0, int bank=0) : item(name, p, uses, strength, defense, maxhp, hp, forest_fights, player_fights, gold, bank){};
~potion();
bool use(Player *p);
void undo(Player *p);
+ bool setData(const char *datastr);
+
+ protected:
+ range myrange;
};
#endif