So I have made a text based role playing game and pretty much when the character gets to a certain coordinate on the map they receive the option to go into the store or not. What I need to do is display a list of items in my in-game store once they enter. I thought the best way to do this would be to put all the items (weapon structs, armor structs) that are in my in-game store into an array. I would then be able to do something like:
1 2 3 4 5 6 7 8
for (int i=0; i!=arraysize; i++)
{
//This should display both weapon and armor
// including the price, name, and damage/armor value
//for example:
//weapon1.mName, weapon1.mCost, weapon1.mDamageRange
cout << StoreItemsArray[i] << endl;
}
My store will contain both weapon items and armor items, which are defined as follows:
1 2 3 4 5 6 7 8 9 10 11 12
struct Weapon
{
std::string mName;
Range mDamageRange;//range is another struct that is 2 values (1 low and 1 high value)
int mCost;
};
struct Armor
{
std::string mName;
int mArmorValue;
int mCost;
};
So as you can see, I could do this the manual way.
but I feel like that is not general enough and is harder to maintain (if someone feels differently please tell me). So my question is how would i do this? How would I make this more general and more manageable? I hope this is enough information to receive some help, and hopefully its not confusing!