]>
jfr.im git - irc/gameservirc.git/blob - gameserv/item.h
10 class Player
; // Forward declaration
11 enum type
{ WEAPON
, ARMOR
, POTION
};
17 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);
18 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);
22 int uses() { return myuses
; };
23 long int price() { return myprice
; };
25 string
getName () { return myname
; };
27 virtual bool use(Player
*p
) = 0;
28 virtual void undo(Player
*p
) = 0;
29 virtual bool setData(char *datastr
) = 0;
31 type
getType() {return mytype
;};
33 long int getID() {return id
;};
35 bool operator<(const item
&right
) const;
36 bool operator>(const item
&right
) const;
37 bool operator==(const item
&right
) const;
38 bool operator!=(const item
&right
) const;
39 item
&operator=(const item
&right
);
42 string myname
; // Name to use in game
43 long int myprice
; // How much does this item cost to buy (half to sell)
44 int mymodifiers
[8]; // Up to 8 different modifiers handled in the sub-classes
45 int myuses
; // How many times this item can be used by default
46 long int id
; // Unique identifier for the item
54 itemContainer(item
*);
55 itemContainer(const itemContainer
&);
58 itemContainer
&operator ++();
59 itemContainer
operator ++(int);
61 itemContainer
&operator --();
62 itemContainer
operator --(int);
64 bool operator <(const itemContainer
&right
) const;
65 bool operator >(const itemContainer
&right
) const;
66 bool operator ==(const itemContainer
&right
) const;
67 bool operator !=(const itemContainer
&right
) const;
69 item
*getItem() {return myitem
;};
72 int getUses() { return myuses
; };
77 int myuses
; // How many times this item can be used
81 class weapon
: public item
84 weapon() : item() {myname
= "New Weapon";};
85 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
){};
86 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
){};
89 bool setData(char *datastr
);
95 class armor
: public item
99 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
){};
100 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
){};
103 bool setData(char *datastr
);
105 void undo(Player
*p
);
108 class potion
: public item
112 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
){};
113 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
){};
116 bool setData(char *datastr
);
118 void undo(Player
*p
);
128 tavernItem(item
*, int);
132 item
*getItem() { return myItem
; };
135 int getLevel() { return myLevel
; };
137 bool visible(Player
*);
142 item
*myItem
; // The item this actually points to
143 int myLevel
; // The level the item shows up