diff options
Diffstat (limited to 'src/core/inventory.h')
-rw-r--r-- | src/core/inventory.h | 77 |
1 files changed, 62 insertions, 15 deletions
diff --git a/src/core/inventory.h b/src/core/inventory.h index 0a412b0..aff9790 100644 --- a/src/core/inventory.h +++ b/src/core/inventory.h @@ -21,20 +21,59 @@ class Inventory { public: /** - * @brief type definition for the items in the inventory + * @brief type definition for items in the inventory */ typedef std::vector<Item *> Items; /** * @brief default constructor */ - Inventory(); + Inventory(const float capacity = 0); /** * @brief default destructor */ ~Inventory(); + /* ---- inspectors ------------------------------------------------- */ + + /** + * @brief items in the inventory + */ + inline Items &items() { + return inventory_items; + }; + + /** + * @brief return the timestamp + */ + inline const unsigned long timestamp() const { + return inventory_timestamp; + } + + /** + * @brief return the maximal inventory capacity, in cubic meters + */ + inline const float capacity() const { + return inventory_capacity; + } + + /** + * @brief return the used inventory capacity, in cubic meters + */ + inline const float capacity_used() const { + return inventory_capacity_used; + } + + /** + * @brief return the availableinventory capacity, in cubic meters + */ + inline const float capacity_available() const { + return inventory_capacity - inventory_capacity_used; + } + + /* ---- mutators --------------------------------------------------- */ + /** * @brief add an item to the inventory */ @@ -54,32 +93,40 @@ public: * @brief search the inventory for a specific item type */ Item *find(const Info *info); - - inline Items &items() { - return inventory_items; - }; - - /** - * @brief return the timestamp - */ - inline const unsigned long timestamp() const { - return inventory_timestamp; - } - + /** * @brief set the timestamp */ void set_timestamp(const unsigned long timestamp); /** - * @brief set the timestamp to the current game time + * @brief mark the inventory as dirty + * This method will set the timestamp to the current game time + * and will recalculate the available capacity + * @see recalculate() */ void set_dirty(); + /** + * @brief set the maximal inventory capacity, in cubic meters + */ + void set_capacity(const float capacity); + private: + // recalculate inventory capacity + void recalculate(); + + // items in the inventory Items inventory_items; + // timestamp when inventory was last updated unsigned long inventory_timestamp; + + // maximum inventory capacity, in cubic meters + float inventory_capacity; + + // current capacity used, in cubic meters + float inventory_capacity_used; }; } // namsepace core |