Peoplemon  0.1.0
Peoplemon 3 game source documentation
Classes | Public Member Functions | Friends | List of all members
core::player::Bag Class Reference

Basic inventory class for managing player items. More...

#include <Bag.hpp>

Classes

struct  Item
 Simple struct representing a set of items in the bag. More...
 

Public Member Functions

void getByCategory (item::Category category, std::vector< Item > &result) const
 Returns the set of owned items in the given category. More...
 
void getByType (item::Type type, std::vector< Item > &result) const
 Returns the set of owned items of the given type. More...
 
void getAll (std::vector< Item > &result) const
 Returns all owned items. More...
 
unsigned int itemCount (item::Id item) const
 Returns the number of the given item owned. More...
 
bool hasItem (item::Id item) const
 Returns true if at least one of the given items is owned. More...
 
void addItem (item::Id item, unsigned int qty=1)
 Adds the given item to the bag. More...
 
bool removeItem (item::Id item, unsigned int qty=1)
 Removes the given item from the bag. More...
 
void clear ()
 Removes all items. More...
 

Friends

struct bl::serial::SerializableObject< Bag >
 

Detailed Description

Basic inventory class for managing player items.

Definition at line 18 of file Bag.hpp.

Member Function Documentation

◆ addItem()

void core::player::Bag::addItem ( item::Id  item,
unsigned int  qty = 1 
)

Adds the given item to the bag.

Parameters
itemThe item to add
qtyHow many to add

Definition at line 44 of file Bag.cpp.

◆ clear()

void core::player::Bag::clear ( )

Removes all items.

Definition at line 64 of file Bag.cpp.

◆ getAll()

void core::player::Bag::getAll ( std::vector< Item > &  result) const

Returns all owned items.

Parameters
resultPopulated with all owned items

Definition at line 31 of file Bag.cpp.

◆ getByCategory()

void core::player::Bag::getByCategory ( item::Category  category,
std::vector< Item > &  result 
) const

Returns the set of owned items in the given category.

Parameters
categoryThe category to search for
resultVector to populate with results

Definition at line 17 of file Bag.cpp.

◆ getByType()

void core::player::Bag::getByType ( item::Type  type,
std::vector< Item > &  result 
) const

Returns the set of owned items of the given type.

Parameters
categoryThe type to search for
resultVector to populate with results

Definition at line 24 of file Bag.cpp.

◆ hasItem()

bool core::player::Bag::hasItem ( item::Id  item) const

Returns true if at least one of the given items is owned.

Parameters
itemThe item to search for
Returns
True if owned, false if none

Definition at line 42 of file Bag.cpp.

◆ itemCount()

unsigned int core::player::Bag::itemCount ( item::Id  item) const

Returns the number of the given item owned.

Parameters
itemThe item to search for
Returns
unsigned int The amount of that item that is owned

Definition at line 37 of file Bag.cpp.

◆ removeItem()

bool core::player::Bag::removeItem ( item::Id  item,
unsigned int  qty = 1 
)

Removes the given item from the bag.

Parameters
itemThe item to remove
qtyHow many to remove
Returns
True if the item was removed, false if not enough to remove

Definition at line 52 of file Bag.cpp.

Friends And Related Function Documentation

◆ bl::serial::SerializableObject< Bag >

friend struct bl::serial::SerializableObject< Bag >
friend

Definition at line 111 of file Bag.hpp.


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