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 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
|
#include <iostream>
#include <windows.h>
#include <ctime>
#include <random>
void intro_text ();
void clear_screen ();
void stats_screen (int& human_health, int& current_orc_health, int& number_of_orcs, int& human_damage, int& orc_damage, int& round);
using namespace std;
int main ()
{
mt19937 random_engine (time(0));
uniform_int_distribution <int> dice_roll (1, 8);
char next_orc = 'Y';
char turn = 'H';
int round = 0;
int number_of_orcs = 1;
int human_health = 50;
int orc_health = 15;
int human_result = 0;
int human_damage = 0;
int orc_result = 0;
int orc_damage = 0;
int current_orc_health = orc_health;
intro_text ();
while (next_orc == 'Y' || next_orc == 'y')
{
round ++;
stats_screen (human_health, current_orc_health, number_of_orcs, human_damage, orc_damage, round);
clear_screen ();
cout << "Press Enter to battle!";
cin.get ();
cout << endl;
while (turn == 'H') // human turn
{
human_result = dice_roll (random_engine);
if (human_result > 2)
{
human_damage = dice_roll (random_engine) + 1;
current_orc_health -= human_damage;
turn = 'O';
if (current_orc_health < 0)
{
clear_screen ();
stats_screen (human_health, current_orc_health, number_of_orcs, human_damage, orc_damage, round);
clear_screen ();
cout << "Press Enter.";
cin.get ();
cout << " ------- Orc Hunting ------- " << endl << endl << endl;
cout << "This orc has died." << endl << endl << endl << endl << endl << endl << endl << endl;
number_of_orcs ++;
current_orc_health = orc_health;
clear_screen ();
cout << "Battle another orc? (Y or N)";
next_orc = cin.get ();
clear_screen ();
turn = 'O';
if (next_orc != 'Y' || next_orc != 'y')
{
clear_screen ();
cout << " ------- Orc Hunting ------- " << endl << endl << endl;
cout << "You go back safely to camp." << endl << endl;
cout << "You killed " << number_of_orcs -1 << " orcs." << endl << endl << endl;
clear_screen ();
}
}
}
else
{
human_damage = 0;
turn = 'O';
}
}
orc_result = dice_roll (random_engine); // orc turn
if (orc_result > 3)
{
orc_damage = dice_roll (random_engine);
human_health -= orc_damage;
turn = 'H';
if (human_health < 0)
{
clear_screen ();
stats_screen (human_health, current_orc_health, number_of_orcs, human_damage, orc_damage, round);
clear_screen ();
cout << "Press Enter.";
cin.get ();
cout << " ------- Orc Hunting ------- " << endl << endl << endl;
cout << "You died." << endl << endl;
cout << "But you killed " << number_of_orcs - 1 << " orcs first." << endl << endl << endl;
clear_screen();
break;
}
}
else
{
orc_damage = 0;
turn = 'H';
}
}
return 0;
}
void intro_text ()
{
cout << " ------- Orc Hunting ------- " << endl << endl << endl;
cout << "You will hunt and fight orcs " << endl;
cout << "one at a time." << endl << endl << endl << endl;
clear_screen ();
cout << "Press Enter to begin.";
cin.get ();
clear_screen ();
}
void clear_screen ()
{
for (int i = 0; i < 13; i ++)
{
cout << endl;
}
}
void stats_screen (int& human_health, int& current_orc_health, int& number_of_orcs, int& human_damage, int& orc_damage, int& round)
{
cout << " ------- Orc Hunting ------- " << endl << endl << endl;
cout << "Round: " << round << endl << endl;
cout << "Orc number: " << number_of_orcs << endl << endl;
cout << "Your attack damage: " << human_damage << endl;
cout << "Orc attack damage: " << orc_damage << endl << endl;
cout << "Your health: " << human_health << endl;
cout << "Orc health: " << current_orc_health;
}
|