Rehti MMORPG  1.0.0
Rehti MMORPG is a free and open source MMORPG game.
Inventory Class Reference

Represents the items that an entity can carry. More...

#include <Inventory.hpp>

Collaboration diagram for Inventory:
Collaboration graph

Public Member Functions

 Inventory (Entity *owner)
 
const std::vector< std::shared_ptr< Item > > & getItems () const
 Returns the items that the inventory contains. More...
 
bool addItem (std::shared_ptr< Item > item)
 Adds item to the inventory. More...
 
std::shared_ptr< ItemremoveItem (int itemId)
 Removes item from the inventory. More...
 
void removeAllItems ()
 Removes all items from the inventory. More...
 
void useItem (int itemId)
 Uses an item in the inventory. More...
 
bool isFull () const
 Checks if inventory is full. More...
 

Private Attributes

EntityownerM
 
const int inventorySizeM = 28
 
std::vector< std::shared_ptr< Item > > itemsM = {}
 

Friends

std::ostream & operator<< (std::ostream &os, const Inventory &inv)
 Prints the contents of the inventory to ostream. More...
 

Detailed Description

Represents the items that an entity can carry.

Constructor & Destructor Documentation

◆ Inventory()

Inventory::Inventory ( Entity owner)

Member Function Documentation

◆ addItem()

bool Inventory::addItem ( std::shared_ptr< Item item)

Adds item to the inventory.

Parameters
itemshared pointer to Item
Returns
true if the item was added, false if not.
Here is the caller graph for this function:

◆ getItems()

const std::vector< std::shared_ptr< Item > > & Inventory::getItems ( ) const

Returns the items that the inventory contains.

Returns
const std::vector<std::shared_ptr<Item>>&
Here is the caller graph for this function:

◆ isFull()

bool Inventory::isFull ( ) const

Checks if inventory is full.

Returns
true if inventory is full, false if not.
Here is the caller graph for this function:

◆ removeAllItems()

void Inventory::removeAllItems ( )

Removes all items from the inventory.

◆ removeItem()

std::shared_ptr< Item > Inventory::removeItem ( int  itemId)

Removes item from the inventory.

Parameters
itemIdinstance id of item to be removed
Returns
true if item was successfully removed, false if not
Here is the caller graph for this function:

◆ useItem()

void Inventory::useItem ( int  itemId)

Uses an item in the inventory.

Parameters
itemIdinstance id of item to be used

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const Inventory inv 
)
friend

Prints the contents of the inventory to ostream.

Parameters
osostream where to print
invinventory to be printed
Returns
os

Member Data Documentation

◆ inventorySizeM

const int Inventory::inventorySizeM = 28
private

◆ itemsM

std::vector<std::shared_ptr<Item> > Inventory::itemsM = {}
private

◆ ownerM

Entity* Inventory::ownerM
private

The documentation for this class was generated from the following files: