i have to create a card game with 30 rounds. i have nearly finished but i a struggling with the end.
questions are;
why is the sorceress not printing cName after the second round?
how do i deduct the attk value from the health?
I'm not sure how to help with the name question but as for the health area. I would define the health outside of the for loop otherwise anytime the for loop iterates it will just go back to 30 even if you change it. So declare and define the default value of it outside. And a simple operation such as health -= attack; should subtract the attack value from the health.
i have read a text file in and stored in an array cName refers to card name there is also card type, card attack and card defense. i have the rounds working now just the cards and health to go.
the wizard cards work but the sorceress deck doesnt
The problem with cName is that "cName" doesn't appear anywhere the code you posted, so we can't help you there.
Why do you have two nested loops? As coded, each round includes going through all of the cards in the decks. Is that what you mean?
You have to break out of the loops when someone wins.
It looks like sorDeck and wizDeck are collections of two different classes. Why are the classes different? They both have a name and attack value, so why not use the same type? You could even go further with something like:
1 2 3 4 5 6 7 8 9 10
class Card {
string name;
unsigned attack;
};
class Player {
int health;
vector<Card> deck;
// other data related to a player.
};