#include <iostream>
#include<cmath>
#include<cstdlib>
#include<ctime>
usingnamespace std;
int main()
{
int Human;
int Dwarf;
char name[10];
cout << "Welcome, hope you enjoy this game!\n\n";
cout << "What is your name?\n";
cin >> name;
cout << "Hello, " << name << "!!\n\n";
cout << "What is your race?\n" << endl;
cout << "1- Human\n" << "2- Dwarf\n" << "3- Orc\n" << "4- Elf\n" << endl;
int pickRace;
cout << "Pick your race: ";
cin >> pickRace;
switch (pickRace)
{
case 1:
cout << "You picked the Human race.\n" << endl;
break;
case 2:
cout << "You picked the Dwarf race.\n" << endl;
break;
case 3:
cout << "You picked the Orc race.\n" << endl;
break;
case 4:
cout << "You picked the Elf race.\n" << endl;
break;
default:
cout << "Error - Invalid input; only 1, 2, 3, or 4 allowed.\n" << endl;
}
cout << "You are in a cell in the dark reaches of the castle... you must find ";
cout << "a way out or you will be excecuted." << endl;
int o1;
cout << "What will you do?" << endl;
cout << "1- Try to pick the lock\n" << endl;
cout << "2- Wait till they come... and when they open the door you'll escape\n";
cin >> o1;
switch (o1)
{
case 1:
cout << "You try and pick the lock, but it is too hard for you.\n";
cout << "so you wait until the gaurds come to get you\n" << endl;
break;
case 2:
cout << "You wait patiently until they come... they start to open the door\n";
cout << "Suddenly you tackle the gaurd then you make a break for it. \n" << endl;
break;
default:
cout << "Error - Invalid input; only 1 or 2 allowed.\n" << endl;
}
cout << "You are running out of the cell now and the gaurds start chasing you\n" << endl;
cout << "You do not look back and you just keep running... soon you reach a\n";
cout << " hole in the ground that leads to the sewers and without thinking \n";
cout << "you dive in. You realize that the gaurds will keep chasing you so \n";
cout << "you take a rusty sword that you find and you confront the gaurds\n" << endl;
string choice1;
cout << "Will you...";
cout << "[1]- Fight\n [2]- Run\n" << endl;
if (choice1=="1")
{
double Health = 50;
double Sword_Sheild = 4;
double Badguy_Health = 30;
unsigned Badguy_Damage = time(0);
while (Badguy_Health >=1 && Badguy_Health >= 1)
{//master while in combat
srand(static_cast<unsignedint>(time(0)));
//Combat
cout <<" The Badguy attacks!"<<endl;
cout <<" Your HP: "<<Health;
cout <<" Badguy HP: "<<Badguy_Health<<endl;
srand(Badguy_Damage);
Badguy_Damage = (rand() % 5) +1;
//Clear screen before start of Combat
cin.sync();
cin.get();
system("cls");
cout <<" The Badguy did "<<Badguy_Damage<<" Damage"<<endl;
Health = Health - Badguy_Damage;
//Displaying HP after combat
cout <<" Your HP: "<<Health<<endl;
cout <<" Badguy HP: "<<Badguy_Health<<endl;
system("pause");
//Zero HP after combat
char Attack;
if(Badguy_Health > 0 && Badguy_Health < 1)
{
cout <<" You are dead"<<endl;
system("Title Game Over ");
system ("pause");
return 0;
}
cin.sync();
cin.get();
//Main Combat
//Conditions of combat
//Warrior Attacks
if (Human)
cout << "Choose a weapon to fight!"<<endl;
cout << "[R]usty sword: 4 attack"<<endl;
cin >>Attack;
{
if(Attack == 'R' || Attack == 'r')
{
Badguy_Damage = (rand() % 10) + 1;
Badguy_Health = Badguy_Health - Sword_Sheild;
cout<<" You choose Rusty Sword dealing 3 Damage! "<<endl;
}
}
//Wizzard Attacks
if (Dwarf)
cout << "Choose a weapon to fight!"<<endl;
cout << "[R]usty sword: 4 attack"<<endl;
cin >>Attack;
{
if(Attack == 'R' || Attack == 'r')
{
Badguy_Damage = (rand() % 10) + 1;
Badguy_Health = Badguy_Health - Sword_Sheild ;
cout<<" You choose rusty sword dealing 3 Damage! "<<endl;
}
}
//If userName wins
if(Badguy_Health <= 0 && Health > 0)
{
cout <<" You did it, "<< name << " you won!"<<endl;
}
return 0;
}