1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
#include <iostream>
#include "Monster.h"
#include <ctime>
using namespace std;
bool CaptureAttempt(Monster monster);
Monster SetMonster();
string RandomNameGenerator();
int main()
{
srand(time(0));
char input;
bool didCatch = false;
int pokeballs = 5;
Monster monster = SetMonster();
cout << "A wild " << monster.name << " appeared!" << endl << endl;
cout << monster.name << endl;
cout << monster.combatpower << endl << endl;
cout << "You have " << pokeballs << " pokeballs left" << endl;
cout << "Attempt to capture? <Y/N>" << endl;
cin >> input;
if (input == 'y' || input == 'Y')
{
CaptureAttempt(monster);
}
didCatch == CaptureAttempt(monster);
while (didCatch == false)
{
pokeballs--;
cout << didCatch << " " << CaptureAttempt(monster) << endl;
cout << monster.name << " broke free!" << endl;
cout << "You have " << pokeballs << " pokeballs left" << endl << "Attempt to capture again? <Y/N>" << endl;
cin >> input;
if (input == 'y' || input == 'Y')
{
CaptureAttempt(monster);
}
}
return 0;
}
bool CaptureAttempt(Monster monster)
{
int chance;
if (monster.combatpower < 100)
{
chance = rand() % 1;
}
else if (monster.combatpower > 99 && monster.combatpower < 201)
{
chance = rand() % 3;
}
else if (monster.combatpower > 200)
{
chance = rand() % 7;
}
if (chance = 0)
{
return false;
}
else
{
return true;
}
}
Monster SetMonster()
{
Monster monster;
monster.name = RandomNameGenerator();
monster.combatpower = rand() % 450 + 1;
return monster;
}
string RandomNameGenerator()
{
string name;
const int size = 25;
string names[size] =
{
"Charmander", "Bulbasaur", "Squirtle", "Pidgey", "Pikachu", "Sandshrew", "Zubat",
"Mankey", "Abra", "Magikarp", "Eevee", "Rattata", "Vulpix", "Scyther", "Jigglypuff",
"Geodude", "Onix", "Staryu", "Snorlax", "Mewtwo", "Oddish", "Caterpie", "Spearow",
"Charizard", "Zapdos"
};
name = names[rand() % 24];
return name;
}
|