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 116 117 118 119 120 121 122 123 124 125 126
|
void attack()
{
int dmg = rand()%30;
int dmgb = rand()%30;
healtha = healtha - dmg;
cout << "\n\nYou hitted your opponent, dealing him " << dmg << " damage";
healthb = healthb - dmgb;
cout << "\n\nOpponent hitted you back, dealing " << dmgb << " damage";
cout << "\n\nOpponent health: " << healtha << ". Your health: " << healthb << ".\n";
}
void get()
{
int prob = rand()%5;
if(healtha > 0 && healtha < 21)
{
if(x > 0)
{
cout << "You threw a pokeball, in order to catch the opponent pokemon!";
if(prob == 0)
{
cout << "______";
cout << "\nFailure! You didn't caugh any pokemon and lost a pokeball instead!\n\n";
x = x-1;
save(x, y, z);
}
else if(prob ==1)
{
cout << "______";
cout << "\nSuceed! You caught a pokemon!\n\n";
save(x, y, z);
y = y+1;
x = x-1;
}
else if(prob == 2)
{
cout << "______";
cout << "\nFailure! You didn't caugh any pokemon and lost a pokeball instead!\n\n";
x = x-1;
save(x, y, z);
}
else if(prob == 3)
{
cout << "______";
cout << "\nFailure! You didn't caugh any pokemon and lost a pokeball instead!\n\n";
x = x-1;
save(x, y, z);
}
else if(prob == 4)
{
cout << "______";
cout << "\nFailure! You didn't caugh any pokemon and lost a pokeball instead!\n\n";
x = x-1;
save(x, y, z);
}
else if(prob == 5)
{
cout << "______";
cout << "\nSuceed! You caught the opponent pokemon!\n\n";
y = y+1;
x = x-1;
save(x, y, z);
}
}
else
{
cout << "\n\n You don't have enough pokeballs to catch this pokemon.";
}
}
}
void flee()
{
if(healthb > 49)
{
cout << "You fled away successfully.";
}
else { cout << "Opponent didn't let you flee away."; attack(); }
}
void battle()
{
string o;
int dmg = rand()%30;
int dmgb = rand()%30;
healtha = 100;
healthb = 100;
cout << "\nBattle has started. You will now be able to attack, catch the pokemon or flee away.\n\n";
cout << "Opponent health: " << healtha << ". Your health: " << healthb << ".\n";
cout << "What do you want to do next? Attack (a), catch (c - opponent health must be at least 20 or less) or flee (f)?";
cin >> o;
if(o == "a" || o == "A")
{
attack();
if(healtha < 1)
{
healtha = 0;
cout << "\n\nYou killed the opponent, winning the match.\n\n";
}
else
{
cout << "What do you want to do next? Attack (a), catch (c) or flee (f)?";
cin >> o;
if(o == "a" || o == "A")
{
attack();
}
else if(o == "c" || o == "C")
{
get();
}
else if(o == "f" || o == "F")
{
flee();
}
}
}
else if(o == "c" || o == "C")
{
get();
}
else if(o == "f" || o == "F")
{
flee();
}
}
|