Pokemon Text game (HELP)

hello! so i need some help badly on my program i am making about pokemon. it is text based game and must have requirements etc etc. so the only thing i need now is a battle system which i litterly cannot figure out. i have this so far:


#include<iostream>
#include<string>
#include<cmath>
#include<windows.h>
using namespace std;


struct TrainerInfo
{
string trainerName; //ash
string trainersHometown; //PalletTown
string nemesis; //gary


};

struct PokemonStats
{
int HP; //health points
int attack; //attack percentage
int defence;
};

struct PokemonCondition
{
int numberWin;
int currentHp;
};

struct Pokemon
{
string name;
int nationalPokedexNumber;
string type;
TrainerInfo trainer;
PokemonStats stats;
PokemonCondition condition;
};

//prototype
Pokemon getInfo(int);
void showInfo(Pokemon[]);
void battleChoices(Pokemon[], string[]);

int main()
{
Pokemon characters[3];

for (int x = 0; x < 3; x++)
{
characters[x] = getInfo(x+1);
}

//show data
showInfo(characters);

//battleChoices[3];
string choices[2];
battleChoices(characters, choices);

cout << "Your choices: " << endl;
cout << choices[0] << endl;
cout << choices[1] << endl;

int playerA, playerB;

for (int y = 0; y < 2; y++)
{
for (int x = 0; x < 3; x++)
{
if (characters[x].name == choices[y])
{
if (y == 0)
playerA = x;
else
playerB = x;
}
}
}

cout << "Found: " << characters[playerA].name << endl;
cout << "Found: " << characters[playerB].name << endl;

//battleformula
for ( int playerA;)
{
int attack
string Pokemon



}

} //end of main

Pokemon getInfo(int num) //name,dex#,type,trainer,hometown,rival,HP,atkk,defence,number of wins,current HP.
{
Pokemon characterList[5] = { {"Charizard",0.6,"Fire", {"Joe", "Pallet Town", "Gary"}, {250, 70, 80}, {12, 170} },
{"Raichu",0.26,"Electric", {"Joe", "Pallet Town", "Gary"}, {210, 76, 90}, {13, 160} },
{"Poliwhirl",0.61,"Water", {"Joe", "Pallet Town", "Gary"}, {175, 85, 78}, {10, 181} },
{"Infernape",0.392,"Fire", {"Joe", "Pallet Town", "Gary"}, {375, 100, 97}, {16, 210} },
{"Greninja",0.658,"Water", {"Joe", "Pallet Town", "Gary"}, {275, 97, 99}, {20, 196} } };
string choice;
bool answer = true;
while (answer)
{
cout << "Enter pokemon # " << num << endl;
cout << "Choose between Charizard, Raichu, Poliwhirl, Infernape, Greninja" << endl;
getline(cin, choice);
for (int x = 0; x < 5; x++)
{
if (characterList[x].name == choice)
return characterList[x];
}
cout << "Invalid selection, Try again." << endl;
}

} //end of getInfo

void showInfo(Pokemon c[])
{
system("cls"); //clear screen
cout << "Your choices are: " << endl;
cout << "_________________" << endl;
for (int x = 0; x < 3; x++)
{
cout << "Name: " << c[x].name << endl;
cout << "Pokedex ID Number: " << c[x].nationalPokedexNumber << endl;
cout << "Type: " << c[x].type << endl;
cout << "Trainer name: " << c[x].trainer.trainerName << endl;
cout << "Trainer hometown: " << c[x].trainer.trainersHometown << endl;
cout << "Pokemon nemesis: " << c[x].trainer.nemesis << endl;
cout << "HP: " << c[x].stats.HP << endl;
cout << "Attack: " << c[x].stats.attack << endl;
cout << "Defense: " << c[x].stats.defence << endl;
cout << "Number of wins: " << c[x].condition.numberWin << endl;
cout << "Current HP: " << c[x].condition.currentHp << endl;

cout << endl << endl;
}

} //end of showInfo

void battleChoices(Pokemon characters[], string choices[])
{
cout << "Pick 2 of the following: " << endl;
cout << "Enter characeters name: " << endl;
for (int x = 0; x < 3; x++)
{
cout << "Choice " << x+1 << ": " << characters[x].name << endl;
}
cin >> choices[0];
cin >> choices[1];

}

ok here are the last requirements i need help with. Mostly creating the structure for the battling system itself i believe:
Pokemon A – HP = 2000 Attack 75 Defense 25 this is ex numbers
Pokemon B – HP = 2500 Attack 60 Defense 30 Thsi is also ex numbers

If A attacks B, the chance that A lands the attack will be based on this
formula (Attack of A)/(Attack of A+Defense of B)= 75/(75+30)≈71%
You will then generate a random number from 1-100. If the number is
less than the percent calculated in the previous step, then the attack
hits.
If the attack hits, then B will lose HP = abs(Attack of A – Defense of
B).
If the attack doesn't hit, no one loses HP.
If you are facing your nemesis, then your pokemon's attack gains 10% of
their attack.
If you are playing in your hometown, then your pokemon's attack gains
10% of their attack.
At the end of each attack, you should say the outcome and print the HP
of each pokemon, then say press any key to continue.
The battle is over when a pokemon's HP is less than or equal to 0.
Increase the pokemon's number of wins by 1.
Note – the formulas will change when B attacks A.

any help with this would be greatly appreciated! thanks in advance people!


Last edited on
Your fourth "for-loop" in the project is incomplete. More specifically, it says "for (int PlayerA;)". You need "PlayerA" to be initialized to some number, after, it needs a limit for the loop, and finally, in needs something to imrement PlayerA. Or, if it controlled differently, you should fill it in appropriately.
Best Regards,
~RobertG
Topic archived. No new replies allowed.