Hey guys,
I'm writing an RPG, and I've gotten around to item management. Right now, my definition of an item is simple and I've taken the data-driven approach, but the thing that I'm not sure about now is how to implement item effects. One solution that comes to mind is to have a member that is a pointer to some function that does the item action according to the item code. The other solution was have the client perform the action since it already knows what type of item that is being used.
Below are the contents of my item declaration. Clearly, the item class is derived from a base class, and there is one important inherited member: std::string id. id holds the unique identifier for each item.
# ifndef ITEM_H
# define ITEM_H
# include <string>
class ITEM : public D_OBJECT
{
public :
ITEM () ;
ITEM (const char* id) ;
std::string description ;
int quantity ;
bool usable ;
bool sellable ;
int value ;
bool showQuantity ;
} ;
# endif