i dont understand this one, its working the program runs but not all of the code runs. it states the first two lines then quits out on me.
Code:
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <time.h>
using namespace std;
string Command;
struct User
{
int UHP; // Users Current Hit Points
int max_UHP; // Users Maximum Hit Points
};
struct Challenger
{
int CHP; // Challengers Hit Points
int max_CHP; // Challengers Maximum Hit Points
};
int main()
{
srand( time(NULL) );
User Player;
Challenger Enemy;
Player.max_UHP = 100;
Player.UHP = 100;
Enemy.max_CHP = 100;
Enemy.CHP = 100;
int UATK = rand()%20; // Users Attack points
int CATK = rand()%15; // Challengers Attack points
cout<<"As your walking down a path a cloaked swordsman ambushes you.\n";
cout<<"He then challenges you to a fight and you humbly accept.\n";
cout<<"You can Attack.\n";
cin>> Command;
cin.ignore();
if ( Command == "Attack" || Command == "attack" ) { Enemy.CHP-=UATK;
cout<<"You took out "<< UATK <<" hp.\n"; }
cout<<"The challenger has "<< Enemy.CHP <<" hp left.\n";
cin.get();
cout<<"The Challenger attacks.\n";
Player.UHP-=CATK;
cout<<"He does "<< CATK <<" damage, leaving you with "<< Player.UHP <<" hp.\n";
cin.get();
while ( Player.UHP > 0 || Enemy.CHP > 0 ) {
cout<<"You can Attack.\n";
cin>> Command;
cin.ignore();
if ( Command == "Attack" || Command == "attack" ) { Enemy.CHP-=UATK;
cout<<"You took out "<< UATK <<" hp.\n"; }
cout<<"The challenger has "<< Enemy.CHP <<" hp left.\n";
cin.get();
cout<<"The Challenger attacks.\n";
Player.UHP-=CATK;
cout<<"He does "<< CATK <<" damage, leaving you with "<< Player.UHP <<" hp.\n";
cin.get();
}
}