Rehti MMORPG  1.0.0
Rehti MMORPG is a free and open source MMORPG game.
Inventory.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "FoodItem.hpp"
4 
5 #include <memory>
6 #include <vector>
7 
11 class Inventory
12 {
13 public:
14  Inventory(Entity* owner);
15 
20  const std::vector<std::shared_ptr<Item>>& getItems() const;
21 
28  bool addItem(std::shared_ptr<Item> item);
29 
35  std::shared_ptr<Item> removeItem(int itemId);
36 
40  void removeAllItems();
41 
46  void useItem(int itemId);
47 
53  bool isFull() const;
54 
61  friend std::ostream& operator<<(std::ostream& os, const Inventory& inv);
62 
63 private:
65 
66  const int inventorySizeM = 28;
67 
68  std::vector<std::shared_ptr<Item>> itemsM = {};
69 };
Base pure virtual Entity class. Different types of enities inherit this.
Definition: Entity.hpp:17
Represents the items that an entity can carry.
Definition: Inventory.hpp:12
Entity * ownerM
Definition: Inventory.hpp:64
std::shared_ptr< Item > removeItem(int itemId)
Removes item from the inventory.
Definition: Inventory.cpp:16
void useItem(int itemId)
Uses an item in the inventory.
Definition: Inventory.cpp:45
friend std::ostream & operator<<(std::ostream &os, const Inventory &inv)
Prints the contents of the inventory to ostream.
Definition: Inventory.cpp:61
const int inventorySizeM
Definition: Inventory.hpp:66
bool addItem(std::shared_ptr< Item > item)
Adds item to the inventory.
Definition: Inventory.cpp:6
std::vector< std::shared_ptr< Item > > itemsM
Definition: Inventory.hpp:68
void removeAllItems()
Removes all items from the inventory.
Definition: Inventory.cpp:30
Inventory(Entity *owner)
Definition: Inventory.cpp:4
bool isFull() const
Checks if inventory is full.
Definition: Inventory.cpp:35
const std::vector< std::shared_ptr< Item > > & getItems() const
Returns the items that the inventory contains.
Definition: Inventory.cpp:40