With what I have so far, how would I code as to ask the user to input the the name of an item and output the resulting information stored.
Ex.
Enter Card's Name: "Ancient of Lore"
Name: Ancient of Lore
Mana: 7
Attack: 5
Health: 5
Has Taunt: False
Can't do using defines without writing the most tedious code ever. If you want your program to have that capability, however, it certainly is possible. You'd have to create an array of either struct or class objects, initialize the information, and then search through for what the user is looking for. A snippet would look like such:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
//declare/define struct
struct cards {
string name;
int mana, attack, health;
bool taunt;
} cards_array[total_cards];
int main (void)
{
/*Ask user for input */
//search
for (int i = 0; i < total_cards; i++)
{
if (user_input == cards_array[i].name) {
/* output data */
}
}
}
//Fixed your struct, needed name to be a string and forgot the ending semicolon
struct Minions {
std::string Name;
int Mana, Attack, Health;
bool Taunt;
};
Minions ancientOfLore;
ancientOfLore.Name = "Ancient of Lore";
ancientOfLore.Mana = 7;
ancientOfLore.Attack = 5;
ancientOfLore.Health = 5;
ancientOfLore.Taunt = false;