#include <iostream>
using namespace std;
int main()
{
char flip;
int coin, flipnum, flipint, count, evod;
string you, enemy;
int hityou, hitenemy, youhealth, enemyhealth;
srand(time(0)); //makes rand work
cout<<"CHOOSE YOUR MANBEAST: "; //Choose a fighter
getline(cin,you);
youhealth = rand() % 15 + 95; //Your fighter's health
cout<<endl<<endl<<"WHO SHALL CHALLENGE HIM?: "; //Choose opponent
getline(cin,enemy);
enemyhealth = rand() % 15 + 95; //Enemy's health
cin.get();
cout<<endl<<endl<<you<<" vs. "<<enemy;
cout<<endl<<endl<<"Flip a coin to see who starts. Heads or tails (h/t): "; //COIN TOSS
cin>>flip;
cout<<endl<<endl;
flipint = static_cast<int>(flip);
coin = rand() % 2 + 1;
cin.get();
if (flipint == 104) {
flipnum = 1;
}
else if (flipint == 116){
flipnum = 2;
}
if (coin == flipnum){
if (coin == 1){
cout<<"Heads! You won the toss!"<<endl;
}
else {
cout<<"Tails! You won the toss!"<<endl;
}
cout<<endl<<"You get the first hit!";
}
else {
if (coin == 1){
cout<<"Sorry it was heads... you lost :("<<endl;
}
else {
cout<<"Sorry it was tails... you lost :("<<endl;
}
cout<<endl<<enemy<<" gets the first hit!";
} // END COIN TOSS
cin.get();
cout<<endl<<endl<<endl<<"FIGHT!"<<endl<<endl;
cin.get();
cout<<"You have "<<youhealth<<" health"<<endl;
cin.get();
cout<<enemy<<" has "<<enemyhealth<<" health"<<endl<<endl;
cin.get();
hityou = rand() % 21;
hitenemy = rand() % 21;
if(coin == flipnum){
enemyhealth = enemyhealth - hityou;
cout<<"You strike "<<enemy<<" for "<<hityou<<" points!!! "<<endl;
cout<<enemy<<" has "<<enemyhealth<<" health left!"<<endl;
}
else{
youhealth = youhealth - hitenemy;
cout<<right<<enemy<<" hits you for "<<hitenemy<<" points!!! "<<endl;
cout<<right<<"You have "<<youhealth<<" health left!"<<endl;
}
cin.get();
while(youhealth > 0 && enemyhealth > 0){
evod = count % 2;
if(evod == 0){
if(coin != flipint){
hityou = rand() % 21;
hitenemy = rand() % 21;
if( hityou > 10 ){
cout<<"\a";
}
enemyhealth = enemyhealth - hityou;
cout<<"You hit "<<enemy<<" for "<<hityou<<" points!"<<endl;
cout<<enemy<<" has "<<enemyhealth<<" health!!!"<<endl;
cin.get();
}
else if(coin == flipint){
hityou = rand() % 21;
hitenemy = rand() % 21;
if( hitenemy > 10 ){
cout<<"\a";
}
youhealth = youhealth - hitenemy;
cout<<right<<enemy<<" hits you for "<<hitenemy<<" points!"<<endl;
cout<<right<<"You have "<<youhealth<<" health!!!"<<endl;
cin.get();
}
count++;
}
else if (evod == 1){
if(coin != flipint){
hityou = rand() % 21;
hitenemy = rand() % 21;
if( hitenemy > 10 ){
cout<<"\a";
}
youhealth = youhealth - hitenemy;
cout<<right<<enemy<<" hits you for "<<hitenemy<<" points!"<<endl;
cout<<right<<"You have "<<youhealth<<" health!!!"<<endl;
cin.get();
}
else if(coin == flipint){
hityou = rand() % 21;
hitenemy = rand() % 21;
if( hityou > 10 ){
cout<<"\a";
}
enemyhealth = enemyhealth - hityou;
cout<<"You hit "<<enemy<<" for "<<hityou<<" points!"<<endl;
cout<<enemy<<" has "<<enemyhealth<<" health!!!"<<endl;
cin.get();
}
count++;
}
}
if (youhealth <= 0){
cout<<right<<"\a\a\a\a\a\a"<<enemy<<" has defeated "<<you<<"!!!!"<<endl<<endl;
}
else if (enemyhealth <= 0){
cout<<right<<"\a\a\a\a\a"<<you<<" has defeated "<<enemy<<"!!!!"<<right<<endl<<endl;
}
cin.get();
return 0;
}
Lol who can make this as short as possible