#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
int main ()
{
int ph = 50, eh = 50, patk, eatk = 7, pot = 2, heal, wep, fight;
string Bonecrusher = "Bonecrusher";
string pn;
//Intro
cout << "Welcome to the world of Enaria. Enaria is a beautiful world of many things, but can be dangerous if one is not careful. Press 1) to ATTACK and 2) HEAL.\n Health Potions heal for 20 health.\n What is your name, friend?\n";
cin >> pn;
//Check if name is Bonecrusher.
if (pn == Bonecrusher)
{
cout << Bonecrusher << " now that's a cool name!\n";
}
else
{
cout << pn << " huh? Bonecrusher would have been cooler\n";
}
cout << "Challenger, choose your weapon. [1] SWORD or [2] AXE?\n";
cin >> wep;
while (wep < 1 || wep > 2)
{
cout << "That is not a valid weapon choice, please press [1] SWORD or [2] AXE\n";
cin >> wep;
}
// Check for what weapon. Make patk according to weapon.
if (wep == 1)
{
cout << "You choose the sword\n";
patk = 6;
}
if (wep == 2)
{
cout << "You choose the axe\n";
patk = 8;
}
cout << "\nYou encounter a mean looking troll! Get ready to fight!\n\n";
cout << "\nWould you like to [1] ATTACK or [2] HEAL? ";
cin >> fight;
while (fight <= 0 || fight >= 3)
{
cout << "That is not a valid response. Press [1] ATTACK or [2] HEAL. \n";
cin >> fight;
}
}
//Healing
while (fight == 2)
{
if (fight == 2 && ph >= 50)
{
cout << "You are at max health, you must attack. Press [1] to ATTACK. \n";
cin >> fight;
}
while (fight <= 0 || fight >= 3)
{
cout << "That is not a valid response. Press [1] ATTACK or [2] HEAL. \n";
cin >> fight;
}
while (fight == 2 && pot == 0)
{
cout << "You have no more potions, you must attack! Press [1] to ATTACK \n";
cin >> fight;
while (fight <= 0 || fight >= 3)
{
cout << "That is not a valid response. Press [1] ATTACK or [2] HEAL. \n";
cin >> fight;
}
}
while (fight == 2 && ph <= 49 && pot >= 1)
{
if (50 - ph > 20)
{
heal = 20;
cout << "You heal for " << heal << endl;
pot--;
ph = ph + heal;
cout << "Your health is now " << ph << endl;