Hmm, this is starting to get a bit heavy-going - like I said, I'm not too confident with classes. I understand the basic ideas behind inheritance though, and it sounds like a perfect way to add types of items (maybe reading from an 'item.obj' file to allow for easier editing? That would have to be some point in the future, though). The ASCII art is great, too - easy to see what you mean there.
I'm not quite sure what you mean by a few things, though- namely
Code:
void add_object(object &o) { items.push_back(o); } //This adds the item to the top of the pile?
int items() { return items.size(); } //I'm guessing this calls a function that reads the number of items at the spot?
object get_object(int x) { return items[x]; } //...even less sure what this means, return the item types one by one?
and vectors. :S
What I have in mind is something like
Code:
class location{
public:
location();
~location();
int get_terrain(int x, int y) //returns the terrain type at location x,y
int get_itemno(int x, int y) //returns the number of items at location
int get_item(int x, int y, int stack) //returns the list of items at that location (not sure quite how to return more than one integer here... maybe do a repeat call from getitemno() if necessary?
int get_monst(int x, int y) //returns any monsters at location
int get_build(int x, int y) //returns any structures at that location - door, window, wall, etc
protected:
int terrain;
int itemno;
int item;
int monst;
int build;
};
class item{
public:
item();
~item();
int can_carry(int itemdesc); //checks if the item described by integer itemdesc is carryable
int get_weight(int itemdesc); //checks the item's weight (possibly making the previous obsolete
protected:
int item_weight
int can_carry
};
class shoe : public item{
public:
int armour(); //returns the armour value of the type of shoe
int encumbrance(); //returns encumbrance value
int footarm;
int footenc;
};
and so forth.