]> jfr.im git - irc/gameservirc.git/blobdiff - gameserv/item.h
Shrunk the dependencies immensely with forward declarations in all H files instead...
[irc/gameservirc.git] / gameserv / item.h
index 69719c453c149db80706d19b770a91e575cb61f3..a1f721f6c8bab7875f8a6ad1b4fbc34dfc3544c2 100644 (file)
@@ -2,21 +2,28 @@
 #define ITEM_H
 
 
-#include <string.h>
-#include "player.h"
+#include <string>
+
+using namespace std;
+
+class Player; // Forward declaration
 
 class item
 {
  public:
-  item(char *name=NULL, 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=NULL, 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();
+  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);
+
   virtual ~item();
   
   int uses() { return myuses; };
   long int price() { return myprice; };
+
+  string getName () { return myname; };
   
   virtual bool use(Player *p) = 0;
-  virtual void undo() = 0;
+  virtual void undo(Player *p) = 0;
 
   bool operator<(const item &right) const;
   bool operator>(const item &right) const;
@@ -27,39 +34,58 @@ class item
   string myname;         // Name to use in game & sorting
   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 you can use this item
+  int myuses;            // How many times this item can be used by default
+};
+
+/*class itemContainer
+{
+ public:
+  itemContainer();
+  itemContainer(item *);
+  ~itemContainer();
+
+  itemContainer &operator ++();
+  itemContainer operator ++(itemContainer);
+
+ private:
+  int myuses;              How many times 
+  item *myitem; 
 };
+*/
 
 class weapon : public item
 {
   public:
-  weapon(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() : 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){};
-  virtual ~weapon();
+  ~weapon();
 
-  virtual bool use(Player *p);
-  virtual void undo(Player *p);
+  bool use(Player *p);
+  void undo(Player *p);
 };
 
 class armor : public item
 {
   public:
-  armor(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() : 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){};
-  virtual ~armor();
+  ~armor();
 
-  virtual bool use(Player *p);
-  virtual void undo(Player *p);
+  bool use(Player *p);
+  void undo(Player *p);
 };
 
 class potion : public item
 {
   public:
-  potion(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() : 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){};
-  virtual ~potion();
+  ~potion();
 
-  virtual bool use(Player *p);
-  virtual void undo(Player *p) { return; }; // You can't undo a potion
+  bool use(Player *p);
+  void undo(Player *p);
 };
 #endif