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 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
|
#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 << endl;
while (didCatch == false)
{
cout << "You have " << pokeballs << " pokeballs left" << endl;
cout << "Attempt to capture? <Y/N> ";
cin >> input; cout << endl;
if (input == 'y' || input == 'Y')
{
pokeballs--;
didCatch = CaptureAttempt(monster);
if (didCatch == false)
{
cout << monster.name << " broke free! Attempt to catch again?" << endl << endl;
}
if (pokeballs == 0)
{
cout << "You do not have any pokeballs, so you ran and got away safely." << endl;
break;
}
}
if (input == 'n' || input == 'N')
{
cout << "Got away safely." << endl;
break;
}
}
if (didCatch == true)
{
cout << "Gotcha! You caught " << monster.name << "!" << endl;
}
return 0;
}
bool CaptureAttempt(Monster monster)
{
int chance;
if (monster.combatpower < 100)
{
chance = rand() % 1;
if (chance == 0)
{
return true;
}
else
{
return false;
}
}
else if (monster.combatpower > 99 && monster.combatpower < 201)
{
chance = rand() % 3;
if (chance == 0)
{
return true;
}
else
{
return false;
}
}
else if (monster.combatpower > 200)
{
chance = rand() % 7;
if (chance == 0)
{
return true;
}
else
{
return false;
}
}
}
Monster SetMonster()
{
Monster monster;
monster.name = RandomNameGenerator();
monster.combatpower = rand() % 450 + 1;
return monster;
}
string RandomNameGenerator()
{
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"
};
return names[rand() % 24];
}
|