#include <iostream>
using namespace std;
struct Monster
{
string name;
int combatPower;
};
bool captureAttempt(Monster monster)
{
int chance = 0;
if(monster.combatPower < 100)
chance = rand()%1;
else if(monster.combatPower > 99)
chance = rand()%3;
else if(monster.combatPower > 200)
chance = rand()%7;
if(chance == 0)
return true;
else return false;
}
string randomNameGenerator()
{
string names[25] = {"Charmander", "Bulbasor", "Squrtile", "Pidgey", "Pikachu",
"Sandshrew", "Zubat", "Mankey", "Abra", "Magikarp",
"Eevee", "Rattata", "Vulpix", "Scyther", "Jigglypuff",
"Geodude", "Onix", "Staryu", "Snorlax", "Mewtwo",
"Oddish", "Caterpie", "Spearow", "Charizard", "Zapdos",};
return names[rand()%24];
}
Monster setMonster(Monster monster)
{
monster.name = randomNameGenerator();
monster.combatPower = rand()%450 + 1;
return monster;
}
int main() {
srand(time(NULL));
Monster monster;
char input;
bool didCatch = false;
int pokeballs = 5;
while(true)
{
pokeballs--;
monster = setMonster(monster);
didCatch = captureAttempt(monster);
if(didCatch)
{
cout<<"Gotcha! You caught the monster "<<monster.name<<"!"<<endl;
cout<<"Attempt to catch again? (Y?N): " ;
}
else
cout<<"broke free! Attempt to catch again? (Y/N)"<<endl;
cin>>input;
if(input == 'N' || input == 'n')
{
cout<<"\nGot away safely."<<endl;
exit(0);
}
if(pokeballs == 0)
{
cout<<"\nYou do not have any pokeballs, so you ran and got away safely.";
exit(0);
}
else
{
cout<<"\nRemianing pokeballs: "<<pokeballs<<endl;
}
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKCnN0cnVjdCBNb25zdGVyCnsKCXN0cmluZyBuYW1lOwoJaW50IGNvbWJhdFBvd2VyOwp9OwoKYm9vbCBjYXB0dXJlQXR0ZW1wdChNb25zdGVyIG1vbnN0ZXIpCnsKCWludCBjaGFuY2UgPSAwOwoJaWYobW9uc3Rlci5jb21iYXRQb3dlciA8IDEwMCkKCQljaGFuY2UgPSByYW5kKCklMTsKC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