diff options
author | drumsetmonkey <abelleisle@roadrunner.com> | 2016-04-28 10:31:16 -0400 |
---|---|---|
committer | drumsetmonkey <abelleisle@roadrunner.com> | 2016-04-28 10:31:16 -0400 |
commit | 2e026aff928b30267a39ef6fdeec3e43e9f106e6 (patch) | |
tree | b787550264cb3f1a88401f0240968c99b5138237 /include/inventory.hpp | |
parent | 53800e07513f4a625ba70ff7d805d158a6b42121 (diff) |
New inventory system
Diffstat (limited to 'include/inventory.hpp')
-rw-r--r-- | include/inventory.hpp | 172 |
1 files changed, 145 insertions, 27 deletions
diff --git a/include/inventory.hpp b/include/inventory.hpp index 4fb45f9..a568faf 100644 --- a/include/inventory.hpp +++ b/include/inventory.hpp @@ -8,54 +8,170 @@ #define DEBUG -class Item{ +/** + * The base item class + * This stores the name, width, height, and texture(s) + */ +class Item { public: - std::string name, type; + // what we want to call each item + std::string name; + + // how many pixel tall and white each thing is + dim2 dim; - float width; - float height; - int maxStackSize; - float attribValue; + // the total amount of this item each slot can have + uint maxStackSize; - std::string texloc; + // the array of textures for each frame of animation Texturec *tex; - GLuint rtex() - { - return tex->image[0]; - } + /** + * The function we use to call the child classes ability + * Note: Since this function is abstract, we HAVE to create one for each + * child class/type of item. + */ + virtual int useItem()=0; + + virtual Item* clone()=0; + + // destructor + virtual ~Item(); + // return the first texture for the item + GLuint rtex(); + + // return the nth texture for the item + GLuint rtex(int n); }; -class Currency{ +/** + * Class for blank items, we use this for items that do not have an ability + * Like Quest or Debug items + */ +class BaseItem : public Item { public: - std::string name; + // since the items don't have a use, we don't make one for it + int useItem(); - float width; - float height; + BaseItem* clone(); - std::string texloc; - Texturec *tex; + //~BaseItem(){} +}; + +/** + * Sword class. This is for swords, y'know. Pretty basic stuff + */ +class Sword : public Item { +// can't touch this +private: + /** + * How much damage our sword will do + * notice that it's private to avoid a change + */ + float damage; + +//can touch this +public: + /** + * Lets us return the amount of damage the sword has + * TODO takes into account enchants and/or buffs/nerfs + */ + //TODO move + float getDamage(); + + /** + * handles the swinging of the sword + */ + //TODO move + int useItem(); + + Sword* clone(); +}; + +/** + * Bow class. We use this for shooting bow and arrows + */ +class Bow : public Item { +private: + // same as sword + float damage; +public: + // returns the amount of damage, see sword + float getDamage(); + + // handles shooting and arrow curving + int useItem(); + + Bow* clone(); +}; + +/** + * Raw food class, this will be used for uncooked meats... + * TODO Eating this may cause health loss, salmonela, mad cow diese + */ +class RawFood : public Item { +private: + // the amount of the health the food heals + float health; + +public: + // since the health is private, we get how much it is here + float getHealth(); + + // TODO chance to hurt + virtual int useItem(); + + RawFood* clone(); +}; + +/** + * Cooked/Naturale food class + * When this food is consumed, higher stats are gained than Raw Food and + * there is no chance of damage/de-buffs + */ +class Food : public RawFood { +private: +public: - float value; + // consume food in hand, no chance for de-buff; + int useItem(); - GLuint rtex() - { - return tex->image[0]; - } + Food* clone(); }; -struct item_t{ - uint count; - uint id; -} __attribute__((packed)); +/** + * Currency class. Well, it's used for currency + */ +class NewCurrency : public Item { +private: + // how much the coin is "worth" so to say + int value; +public: + // get the value of the coin + int getValue(); + + // TODO maybe play a jingling noise + // probably won't have a use + int useItem(); + NewCurrency(){} + ~NewCurrency(){} +}; + +/*********************************************************************************** + * OLD STUFF THAT NEEDS TO BURN * + **********************************************************************************/ + +/*********************************************************************************** + * OLD STUFF THAT NEEDS TO GET UPDATED * + **********************************************************************************/ class Inventory { private: unsigned int size; //how many slots our inventory has unsigned int sel; //what item is currently selected int os = 0; public: - std::vector<item_t> items; + std::vector<std::pair<Item*, uint>> Items; bool invOpen = false; //is the inventory open bool invOpening = false; //is the opening animation playing @@ -67,6 +183,8 @@ public: Inventory(unsigned int s); // Creates an inventory of size 's' ~Inventory(void); // Free's allocated memory + int useCurrent(); + int addItem(std::string name,uint count); int takeItem(std::string name,uint count); int hasItem(std::string name); |