]> jfr.im git - irc/gameservirc.git/blobdiff - gameserv/item.h
Still working on the new item system integration
[irc/gameservirc.git] / gameserv / item.h
index a1f721f6c8bab7875f8a6ad1b4fbc34dfc3544c2..d72e6f98e4f21ad316282e68f3a2ce5c59a6a445 100644 (file)
@@ -3,17 +3,19 @@
 
 
 #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();
   
@@ -24,6 +26,10 @@ class 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;
@@ -35,6 +41,8 @@ class item
   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
@@ -57,35 +65,41 @@ class weapon : public item
 {
   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