Mana
|
This class handles the list of items available in a shop. More...
#include <shopitems.h>
Public Member Functions | |
ShopItems (bool mergeDuplicates=false) | |
Constructor. | |
~ShopItems () override | |
void | addItem (int id, int amount, int price) |
Adds an item to the list. | |
void | addItem (int inventoryIndex, int id, int amount, int price) |
Adds an item to the list (used by sell dialog). | |
int | getNumberOfElements () override |
Returns the number of items in the shop. | |
std::string | getElementAt (int i) override |
Returns the name of item number i in the shop. | |
ShopItem * | at (int i) const |
Returns the item number i in the shop. | |
void | erase (int i) |
Removes an element from the shop. | |
void | clear () |
Clears the list of items in the shop. | |
Private Member Functions | |
ShopItem * | findItem (int id) |
Searches the current items in the shop for the specified id and returns the item if found, or 0 else. | |
Private Attributes | |
std::vector< ShopItem * > | mShopItems |
The list of items in the shop. | |
bool | mMergeDuplicates |
Look for duplicate entries on addition. | |
This class handles the list of items available in a shop.
The addItem routine can automatically check, if an item already exists and only adds duplicates to the old item, if one is found. The original distribution of the duplicates can be retrieved from the item.
This functionality can be enabled in the constructor.
Definition at line 40 of file shopitems.h.
ShopItems::ShopItems | ( | bool | mergeDuplicates = false | ) |
Constructor.
mergeDuplicates | lets the Shop look for duplicate entries and merges them to one item. |
Definition at line 28 of file shopitems.cpp.
|
override |
Definition at line 33 of file shopitems.cpp.
void ShopItems::addItem | ( | int | id, |
int | amount, | ||
int | price | ||
) |
Adds an item to the list.
Definition at line 48 of file shopitems.cpp.
void ShopItems::addItem | ( | int | inventoryIndex, |
int | id, | ||
int | amount, | ||
int | price | ||
) |
Adds an item to the list (used by sell dialog).
Looks for duplicate entries, if mergeDuplicates was turned on.
inventoryIndex | the inventory index of the item |
id | the id of the item |
amount | number of available copies of the item |
price | price of the item |
Definition at line 53 of file shopitems.cpp.
ShopItem * ShopItems::at | ( | int | i | ) | const |
Returns the item number i in the shop.
Definition at line 72 of file shopitems.cpp.
void ShopItems::clear | ( | ) |
Clears the list of items in the shop.
Definition at line 82 of file shopitems.cpp.
void ShopItems::erase | ( | int | i | ) |
Removes an element from the shop.
i | index to remove |
Definition at line 77 of file shopitems.cpp.
|
private |
Searches the current items in the shop for the specified id and returns the item if found, or 0 else.
Definition at line 88 of file shopitems.cpp.
|
override |
Returns the name of item number i in the shop.
i | the index to retrieve |
Definition at line 43 of file shopitems.cpp.
|
override |
Returns the number of items in the shop.
Definition at line 38 of file shopitems.cpp.
|
private |
Look for duplicate entries on addition.
Definition at line 111 of file shopitems.h.
|
private |
The list of items in the shop.
Definition at line 108 of file shopitems.h.