Give me feedback on my text based rpg. Any improvments I could make?

#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 << "Your Health: " << ph << endl;
cout << "Potions: " << pot << endl;
cout << "Troll's Health: " << eh << endl;

cout << "\n\n------- \n\n";

cout << "Would you like to [1] ATTACK or [2] HEAL? \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 (true)
{
//Attacking
while (fight == 1)
{

if (ph >= 1 && eh >= 1)
{
cout << "Troll hits you for " << eatk << endl;
cout << "You hit troll for " << patk << endl;

ph = ph - eatk;
eh = eh - patk;

if (ph <= 0)
{
cout << "\n Your Health: " << 0 <<endl;
cout << "Potions: " << pot << endl;
cout << "Troll's Health: " << eh <<endl;
}
else if (eh <= 0)
{
cout << "\n Your Health: " << ph << endl;
cout << "Potions: " << pot << endl;
cout << "Troll's Health: " << 0 << endl;
}
else
{

cout << "\nYour Health: " << ph << endl;
cout << "Potions: " << pot << endl;
cout << "Troll's Health: " << eh << endl;
}
}
if (ph <= 0)
{
cout << "Troll Kills You!\n";
system ("PAUSE");
return 0;
}
if (eh <= 0)
{
cout << "You kill Troll!\n";
system ("PAUSE");
return 0;
}

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;

cout << "\nPress [1] ATTACK or [2] HEAL. \n";
cin >> fight;

while (fight <= 0 || fight >= 3)
{
cout << "That is not a valid response. Press [1] ATTACK or [2] HEAL. \n";
cin >> fight;
}
}


else if (50 - ph <= 20)
{
heal = 50 - ph;
cout << "You heal for " << heal << endl;
pot--;
ph = ph + heal;
cout << "Your health is now " << ph << endl;

cout << "\nPress [1] ATTACK or [2] HEAL. \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 <= 0 || fight >= 3)
{
cout << "That is not a valid response. Press [1] ATTACK or [2] HEAL. \n";
cin >> fight;
}
}

}

}
system ("PAUSE");
return 0;
}
It would be easier for us to read if you put it in code tags:

[code]
// put your code here

int foo = bar;
[/code]

...becomes:

1
2
3
// put your code here

int foo = bar;
Also instead of system("pause") use cin.get();
Topic archived. No new replies allowed.