I have done a lot of searching online for help with enums, I have found none that apply to this situation. I'm trying to make a simple single player RPG game. Right now I am in the stage of developing the items and the crafting. My problem is this:
1 2 3 4 5 6 7 8
struct Item{
string Name;
int BuyPrice;
int SellPrice;
int WeaponDamage;
bool Equippable;
enum ItemType {Type1 = 0,Type2 = 1,Type3 = 2};
};
When I try to apply the enum to the actual items, which are saved in Items.h(not main.cpp in case it matters) I get the error saying there are too many initializers. please help, and thank you for reading
There isn't anything wrong with the enum itself, though there is no reason to manually assign values to ItemType - enum already does that for you. Where exactly do you get your error?
I'm getting the error in Items.h, I think that I know what my error is but I don't know why it is occuring. When I had the enum as the last value in the Items such as Item Log = {"Log",10,5};
it was telling me that there were to many initializer values. When I started moving onto the next set of items:EquippableItem WoodenSword = {"WoodenSword",35,17,2,0,false};
I'm getting the same error, but on the bool that says if the Item is equipped or not. The constructors are acting as if there is one less value in the struct?
I don't believe that this is the best fix to the problem, but in the struct I added a useless int named SpaceTaker. This extra int allows for the input of the last necessary values. I still would like to know why the struct would do this.
The enum was being used to tell if the item was craftable, smeltable, etc. I'm very new to enums so I don't believe that I need this enum. I thought it would be more efficient to do the crafting with an ItemType enum, however I can merely do it Name based.