ShopItems Class Reference

#include <shop.h>

List of all members.


Detailed Description

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 41 of file shop.h.


Public Member Functions

 ShopItems (bool mergeDuplicates=false)
 Constructor.
 ~ShopItems ()
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 ()
 Returns the number of items in the shop.
std::string getElementAt (int i)
 Returns the name of item number i in the shop.
ShopItemat (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

ShopItemfindItem (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.

Constructor & Destructor Documentation

ShopItems::ShopItems ( bool  mergeDuplicates = false  ) 

Constructor.

Parameters:
mergeDuplicates lets the Shop look for duplicate entries and merges them to one item.

Definition at line 28 of file shop.cpp.

ShopItems::~ShopItems (  ) 

Definition at line 33 of file shop.cpp.


Member Function Documentation

void ShopItems::addItem ( int  id,
int  amount,
int  price 
)

Adds an item to the list.

Definition at line 48 of file shop.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.

Parameters:
inventoryIndex the inventory index of the item
id the id of the item
quantity number of available copies of the item
price price of the item

Definition at line 53 of file shop.cpp.

int ShopItems::getNumberOfElements (  ) 

Returns the number of items in the shop.

Definition at line 38 of file shop.cpp.

std::string ShopItems::getElementAt ( int  i  ) 

Returns the name of item number i in the shop.

Parameters:
i the index to retrieve

Definition at line 43 of file shop.cpp.

ShopItem * ShopItems::at ( int  i  )  const

Returns the item number i in the shop.

Definition at line 72 of file shop.cpp.

void ShopItems::erase ( int  i  ) 

Removes an element from the shop.

Parameters:
i index to remove

Definition at line 77 of file shop.cpp.

void ShopItems::clear (  ) 

Clears the list of items in the shop.

Definition at line 82 of file shop.cpp.

ShopItem * ShopItems::findItem ( int  id  )  [private]

Searches the current items in the shop for the specified id and returns the item if found, or 0 else.

Returns:
the item found or 0

Definition at line 88 of file shop.cpp.


Member Data Documentation

std::vector<ShopItem*> ShopItems::mShopItems [private]

The list of items in the shop.

Definition at line 109 of file shop.h.

Look for duplicate entries on addition.

Definition at line 112 of file shop.h.


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

Generated on Sun Apr 26 17:30:44 2009 for The Mana World by  doxygen 1.5.5