/*
Nikolas Van Dam 
Starting Date 2020-12-14
Final Date 2021-1-29
Final Project
Fight 9 monsters to the death
*/
#include <iostream>
#include <iomanip>
#include <unistd.h> //Makes usleep work
using namespace std;

string username;
int level=0;
int title();
int game();
int death();
int choice=0;
char pot;
int potion=3;
int restart=0;
char sure;
int health=100;
int yourNumber=0;
int slimehealth=100;
int slime();
int goblin();
int goblinhealth=200;
int orc();
int orchealth=400;
int ogre();
int ogrehealth=500;
int elf();
int elfhealth=300;
int giant();
int gianthealth=500;
int titan();
int titanhealth=700;
int demon();
int demonhealth=500;
int dungeonmaster();
int dungeonmasterhealth=9999999;
int reaper();
int reaperhealth=1000;
int finish();
int finish2();
int deaths=0;

int main()
{
    srand(time(NULL));
    cout <<"What is your username?"<<endl;
    cin>> username;
    title();
}
int title()
{
    cout<<"\033[2J\033[1;1H"; 
    cout<<"Hello "<<username<<"!"<<endl<<endl;
    cout<<"This game is all about fighting you will keep fighting until you die!"<<endl<<"There are a total of 9 enemies"<<endl<<"No matter what keep fighting until you die!"<<endl<<endl;
    usleep(5000000);
    game();
}


int game()
{
    cout<<"You start off with 100 Health "<<endl<<"The only ways to heal is a successful dodge or the  3 health potions"<<endl<<"Dodging and Attacking can fail which leads to taking damage"<<endl<<"You get 5 retries!"<<endl<<endl;
    usleep(5000000);
    level++;
    slime();
}

int slime()
{
    cout<<"\033[2J\033[1;1H"; 
    cout<<"For the first match you will be fighting against a Slime!"<<endl<<"It is considered the tutorial so it won't deal any damage to you"<<endl<<endl;
    usleep(5000000);
    cout<<"\033[2J\033[1;1H"; 

    while (slimehealth>0)
    {
    cout<<"\033[2J\033[1;1H";
    cout<<username<<" "<<health<<"hp"<<endl<<"Slime "<<slimehealth<<"hp"<<endl<<"------------------"<<endl;
    cout<<"1= Dodge"<<endl<<"2= Attack"<<endl<<"3= Talk to it"<<endl;
    cin>>choice;
    if (choice==1)
    {
        yourNumber= (rand() % 2) + 1;
        if (yourNumber==1)
        {
            cout<<"You failed to Dodge but you didn't take any due to it being a Slime!"<<endl;
            usleep(1000000);
        }
        if (yourNumber==2)
        {
            cout<<"You have successfully dodged and avoided any damage!"<<endl<<"You would heal against any other creature but since this a tutorial you do not heal."<<endl;
            usleep(1500000);
        }
    }
    if (choice==2)
    {
        yourNumber=0;
        yourNumber= (rand() % 2) + 1;
        if (yourNumber==1)
        {
            cout<<"You failed to attack but you didn't take any due to it being a Slime!"<<endl;
            usleep(1000000);
        }
        if (yourNumber==2)
        {
            cout<<"You have succesfully attacked and dealt 50 dmg to the slime!"<<endl;
            slimehealth = slimehealth - 50;
            usleep(1000000);
        }
    }
    if (choice==3)
    {
        death();
    }
    if (choice>3)
    {
        death();
    }
    if (choice<1)
    {
        death();
    }
    }
    level++;
    goblin();
}

int goblin()
{
    cout<<"\033[2J\033[1;1H"; 
    cout<<"Hello "<<username<<"... So you have made it past the tutorial! Well done!" <<endl<<"The next thing you shall fight is a goblin"<<endl<<"Be careful because the goblin can hurt you."<<endl;
    usleep(5000000);
    cout<<"\033[2J\033[1;1H";
    while (goblinhealth>0)
    {
    cout<<"\033[2J\033[1;1H";
    if (health<1)
    {
        death();
    }
    cout<<username<<" "<<health<<"hp"<<endl<<"Goblin "<<goblinhealth<<"hp"<<endl<<"------------------"<<endl; 
    cout<<"1= Dodge"<<endl<<"2= Attack"<<endl;
    if (potion>0)
        {
            cout<<"3= Use a potion"<<endl;
        }
    cin>>choice;
    if (choice==1)
    {
        yourNumber= (rand() % 4) + 1;
        if (yourNumber==1)
        {
            cout<<"You failed to Dodge and took 5 damage!"<<endl;
            health=health - 5;
            usleep(1000000);
        }
        if (yourNumber>1)
        {
            cout<<"You have successfully dodged and avoided any damage!"<<endl<<"You Heal for 5hp."<<endl;
            health=health + 5;
            usleep(1500000);
        }
    }
    if (choice==2)
    {
        yourNumber=0;
        yourNumber= (rand() % 4) + 1;
        if (yourNumber==1)
        {
            cout<<"You failed to attack and took 5 damage"<<endl;
            health=health - 5;
            usleep(1000000);
        }
        if (yourNumber>1)
        {
            cout<<"You have successfully attacked and dealt 40 dmg to the goblin!"<<endl;
            goblinhealth= goblinhealth - 40;
            usleep(1000000);
        }
    }
    if (choice==3)
    {
        if (potion>0)
        {
            
                potion=potion - 1;
                health=health + 100;
                cout<<"You have healed for 100"<<endl;
                usleep(1000000);
        }
        else 
        {
            death();
        }
    }
    if (choice>3)
    {
        death();
    }
    if (choice<1)
    {
        death();
    }
    }
    level++;
    orc();
}


int orc()
{
    cout<<"\033[2J\033[1;1H";
    cout<<"Well done "<<username<<"! You have beat the Goblin, now you shall fight the orc!"<<endl;
    cout<<"The orc attacks slow so you will most likely succeed in a dodge but you heal for 1 less than normal"<<endl<<"The orc has lots of hp and your attack will most likely go through"<<endl<<"If your attack doesn't go through you will take lots of damage!"<<endl;
    usleep(5000000);
    cout<<"\033[2J\033[1;1H";
    while (orchealth>0)
    {
    cout<<"\033[2J\033[1;1H";
    if (health<1)
    {
        death();
    }
    cout<<username<<" "<<health<<"hp"<<endl<<"Orc "<<orchealth<<"hp"<<endl<<"------------------"<<endl; 
    cout<<"1= Dodge"<<endl<<"2= Attack"<<endl;
    if (potion>0)
        {
            cout<<"3= Use a potion"<<endl;
        }
    cin>>choice;
    if (choice==1)
    {
        yourNumber= (rand() % 10) + 1;
        if (yourNumber==1)
        {
            cout<<"You failed to Dodge and took 15 damage!"<<endl;
            health=health - 15;
            usleep(1000000);
        }
        if (yourNumber>1)
        {
            cout<<"You have successfully dodged and avoided any damage!"<<endl<<"You Heal for 4hp."<<endl;
            health=health + 4;
            usleep(1500000);
        }
    }
    
    if (choice==2)
    {
        yourNumber=0;
        yourNumber= (rand() % 4) + 1;
        if (yourNumber==1)
        {
            cout<<"You failed to attack and took 15 damage"<<endl;
            health=health - 15;
            usleep(1000000);
        }
        if (yourNumber>1)
        {
            cout<<"You have successfully attacked and dealt 40 dmg to the Orc!"<<endl;
            orchealth= orchealth - 40;
            usleep(1000000);
        }
    }
    
    if (choice==3)
    {
        if (potion>0)
        {
            
                potion=potion - 1;
                health=health + 100;
                cout<<"You have healed for 100"<<endl;
                usleep(1000000);
        }
        else 
        {
            death();
        }
    }
    if (choice>3)
    {
        death();
    }
    if (choice<1)
    {
        death();
    }
    }
    level++;
    ogre();
}

int ogre()
{
    cout<<"\033[2J\033[1;1H";
    cout<<"So you have even surpassed the orc... You have surprised me"<<endl;
    cout<<"But this time you will fall to the "<<endl;
    usleep(1500000);
    cout << setw(14) << "OOOOO";
    cout << setw(14) << "GGGGG" ;
    cout << setw(14) << "RRRRRR";
    cout << setw(20) << "EEEEEEEEEEEE" << endl;
    
    cout << setw(16) << "OO     OO";
    cout << setw(7) << "GG" ;
    cout << setw(15) << "RR"<<setw(5)<<"RR";
    cout << setw(9) << "EE" << endl;
    
    cout << setw(16) << "OO     OO";
    cout << setw(6) << "GG" ;
    cout << setw(20) << "RRRRRR";
    cout << setw(10) << "EE" << endl;
    
    cout << setw(16) << "OO     OO";
    cout << setw(5) << "GG" <<setw(7)<<"GGGG";
    cout << setw(11) << "RRR";
    cout << setw(23) << "EEEEEEEEEEEE" << endl;
    
    cout << setw(16) << "OO     OO";
    cout << setw(6) << "GG" <<setw(6)<<"GG";
    cout << setw(10) << "RR"<<setw(3)<<"RR";
    cout << setw(11) << "EE" << endl;
    
    cout << setw(16) << "OO     OO";
    cout << setw(7) << "GG" <<setw(5)<<"GG";
    cout << setw(10) << "RR"<<setw(4)<<"RR";
    cout << setw(10) << "EE" << endl;
    
    cout << setw(14) << "OOOOO";
    cout << setw(14) << "GGGGG" ;
    cout << setw(10) << "RR"<<setw(5)<<"RR";
    cout << setw(19) << "EEEEEEEEEEEE" << endl;
    usleep(3000000);
    while (ogrehealth>0)
    {
    cout<<"\033[2J\033[1;1H";
    if (health<1)
    {
        death();
    }
    cout<<username<<" "<<health<<"hp"<<endl<<"Ogre "<<ogrehealth<<"hp"<<endl<<"------------------"<<endl; 
    cout<<"1= Dodge"<<endl<<"2= Attack"<<endl;
    if (potion>0)
        {
            cout<<"3= Use a potion"<<endl;
        }
    cin>>choice;
    if (choice==1)
    {
        yourNumber= (rand() % 3) + 1;
        if (yourNumber==1)
        {
            cout<<"You failed to Dodge and took 20 damage!"<<endl;
            health=health - 20;
            usleep(1000000);
        }
        if (yourNumber>1)
        {
            cout<<"You have successfully dodged and avoided any damage!"<<endl<<"You Heal for 15hp."<<endl;
            health=health + 15;
            usleep(1000000);
        }
    }
    
    if (choice==2)
    {
        yourNumber=0;
        yourNumber= (rand() % 3) + 1;
        if (yourNumber==1)
        {
            cout<<"You failed to attack and took 20 damage"<<endl;
            health=health - 20;
            usleep(1000000);
        }
        if (yourNumber>1)
        {
            cout<<"You have successfully attacked and dealt 40 dmg to the Ogre!"<<endl;
            ogrehealth= ogrehealth - 40;
            usleep(1000000);
        }
    }
    
    if (choice==3)
    {
        if (potion>0)
        {
            
                potion=potion - 1;
                health=health + 100;
                cout<<"You have healed for 100"<<endl;
                usleep(1000000);
        }
        else 
        {
            death();
        }
    }
    if (choice>3)
    {
        death();
    }
    if (choice<1)
    {
        death();
    }
    }
    level++;
    elf();
}

int elf()
{
    cout<<"\033[2J\033[1;1H";
    cout<<"So you have also defeated the Ogre!"<<endl<<"I did not expect you to get through the Orc no less the OGRE!!"<<endl<<"But now you must admit defeat for you will be fighting an elf!"<<endl;
    cout<<"The elf can avoid easily but its attacks deal less damage and it has less hp"<<endl;
    usleep(4500000);
    while (elfhealth>0)
    {
    cout<<"\033[2J\033[1;1H";
    if (health<1)
    {
        death();
    }
    cout<<username<<" "<<health<<"hp"<<endl<<"Elf "<<elfhealth<<"hp"<<endl<<"------------------" <<endl;
    cout<<"1= Dodge"<<endl<<"2= Attack"<<endl;
    if (potion>0)
        {
            cout<<"3= Use a potion"<<endl;
        }
    cin>>choice;
    if (choice==1)
    {
        yourNumber= (rand() % 3) + 1;
        if (yourNumber>1)
        {
            cout<<"You failed to Dodge and took 20 damage!"<<endl;
            health=health - 20;
            usleep(1000000);
        }
        if (yourNumber==1)
        {
            cout<<"You have successfully dodged and avoided any damage!"<<endl<<"You Heal for 15hp."<<endl;
            health=health + 15;
            usleep(1000000);
        }
    }
    if (choice==2)
    {
        yourNumber=0;
        yourNumber= (rand() % 3) + 1;
        if (yourNumber>1)
        {
            cout<<"You failed to attack and took 20 damage"<<endl;
            health=health - 20;
            usleep(1000000);
        }
        if (yourNumber==1)
        {
            cout<<"You have successfully attacked and dealt 40 dmg to the Elf!"<<endl;
            elfhealth= elfhealth - 40;
            usleep(1000000);
        }
    }
    if (choice==3)
    {
        if (potion>0)
        {
            
                potion=potion - 1;
                health=health + 100;
                cout<<"You have healed for 100"<<endl;
                usleep(1000000);
        }
        else 
        {
            death();
        }
    }
    if (choice>3)
    {
        death();
    }
    if (choice<1)
    {
        death();
    }
    }
    cout<<"\033[2J\033[1;1H";
    cout<<"Congratulations as a reward for defeating the first 4 bosses you will be granted 2 more potions and 300hp!"<<endl;
    cout<<"Potions now heal for 200!"<<endl;
    health= health + 300;
    potion= potion + 2;
    usleep(2000000);
    level++;
    giant();
}

int giant()
{
    cout<<"\033[2J\033[1;1H";
    cout<<"You shall now face a Giant!"<<endl<<"Beware of their deadly swings for it might just kill you..."<<endl;
    usleep(4500000);
    while (gianthealth>0)
    {
    cout<<"\033[2J\033[1;1H";
    if (health<1)
    {
        death();
    }
    cout<<username<<" "<<health<<"hp"<<endl<<"Giant "<<gianthealth<<"hp"<<endl<<"------------------" <<endl;
    cout<<"1= Dodge"<<endl<<"2= Attack"<<endl;
    if (potion>0)
        {
            cout<<"3= Use a potion"<<endl;
        }
    cin>>choice;
    if (choice==1)
    {
        yourNumber= (rand() % 5) + 1;
        if (yourNumber>1)
        {
            cout<<"You failed to Dodge and took 50 damage!"<<endl;
            health=health - 50;
            usleep(1000000);
        }
        if (yourNumber==1)
        {
            cout<<"You have successfully dodged and avoided any damage!"<<endl<<"You Heal for 25hp."<<endl;
            health=health + 25;
            usleep(1000000);
        }
    }
    if (choice==2)
    {
        yourNumber=0;
        yourNumber= (rand() % 5) + 1;
        if (yourNumber==1)
        {
            cout<<"You failed to attack and took 50 damage"<<endl;
            health=health - 50;
            usleep(1000000);
        }
        if (yourNumber>1)
        {
            cout<<"You have successfully attacked and dealt 40 dmg to the Giant!"<<endl;
            gianthealth= gianthealth - 40;
            usleep(1000000);
        }
    }
    if (choice==3)
    {
        if (potion>0)
        {
            
                potion=potion - 1;
                health=health + 200;
                cout<<"You have healed for 200"<<endl;
                usleep(1000000);
        }
        else 
        {
            death();
        }
    }
    if (choice>3)
    {
        death();
    }
    if (choice<1)
    {
        death();
    }
    }
    level++;
    titan();
}

int titan()
{
    cout<<"\033[2J\033[1;1H";
    cout<<"Congratulations for beating the Giant but now you will face an enemy even greater!!!"<<endl<<"THE TITAN"<<endl<<"It does 100 with each swing so be careful!"<<endl;
    usleep(4500000);
    while (titanhealth>0)
    {
    cout<<"\033[2J\033[1;1H";
    if (health<1)
    {
        death();
    }
    cout<<username<<" "<<health<<"hp"<<endl<<"Titan "<<titanhealth<<"hp"<<endl<<"------------------" <<endl;
    cout<<"1= Dodge"<<endl<<"2= Attack"<<endl;
    if (potion>0)
        {
            cout<<"3= Use a potion"<<endl;
        }
    cin>>choice;
    if (choice==1)
    {
        yourNumber= (rand() % 7) + 1;
        if (yourNumber==1)
        {
            cout<<"You failed to Dodge and took 100 damage!"<<endl;
            health=health - 100;
            usleep(1000000);
        }
        if (yourNumber>1)
        {
            cout<<"You have successfully dodged and avoided any damage!"<<endl<<"You Heal for 50hp."<<endl;
            health=health + 50;
            usleep(1000000);
        }
    }
    if (choice==2)
    {
        yourNumber=0;
        yourNumber= (rand() % 7) + 1;
        if (yourNumber==1)
        {
            cout<<"You failed to attack and took 100 damage"<<endl;
            health=health - 100;
            usleep(1000000);
        }
        if (yourNumber>1)
        {
            cout<<"You have successfully attacked and dealt 50 dmg to the Titan!"<<endl;
            titanhealth= titanhealth - 50;
            usleep(1000000);
        }
    }
    if (choice==3)
    {
        if (potion>0)
        {
            
                potion=potion - 1;
                health=health + 200;
                cout<<"You have healed for 200"<<endl;
                usleep(1000000);
        }
        else 
        {
            death();
        }
    }
    if (choice>3)
    {
        death();
    }
    if (choice<1)
    {
        death();
    }
    }
    level++;
    demon();
}

int demon()
{
    cout<<"\033[2J\033[1;1H";
    cout<<"I see that you have beaten the titan!"<<endl<<"Now you shall fight the demon straight from *****!"<<endl<<"I wish you the most brutal death imaginal!"<<endl;
    usleep(4500000);
    while (demonhealth>0)
    {
    cout<<"\033[2J\033[1;1H";
    if (health<1)
    {
        death();
    }
    cout<<username<<" "<<health<<"hp"<<endl<<"Demon "<<demonhealth<<"hp"<<endl<<"------------------" <<endl;
    cout<<"1= Dodge"<<endl<<"2= Attack"<<endl;
    if (potion>0)
        {
            cout<<"3= Use a potion"<<endl;
        }
    cin>>choice;
    if (choice==1)
    {
        yourNumber= (rand() % 3) + 1;
        if (yourNumber==1)
        {
            cout<<"You failed to Dodge and took 120 damage!"<<endl;
            health=health - 120;
            usleep(1000000);
        }
        if (yourNumber>1)
        {
            cout<<"You have successfully dodged and avoided any damage!"<<endl<<"You Heal for 60hp."<<endl;
            health=health + 60;
            usleep(1000000);
        }
    }
    if (choice==2)
    {
        yourNumber=0;
        yourNumber= (rand() % 3) + 1;
        if (yourNumber==1)
        {
            cout<<"You failed to attack and took 120 Damage!"<<endl;
            health= health - 120;
            usleep(1000000);
        }
        if (yourNumber>1)
        {
            cout<<"You have successfully attacked and dealt 100 dmg to the Demon!"<<endl;
            demonhealth= demonhealth - 100;
            usleep(1000000);
        }
    }
    if (choice==3)
    {
        if (potion>0)
        {
            
                potion=potion - 1;
                health=health + 200;
                cout<<"You have healed for 200"<<endl;
                usleep(1000000);
        }
        else 
        {
            death();
        }
    }
    if (choice>3)
    {
        death();
    }
    if (choice<1)
    {
        death();
    }
    }
    level++;
    reaper();
}

int reaper()
{
    cout<<"\033[2J\033[1;1H";
    cout<<"Wow you are indeed a fighter to think you could make it this far!"<<endl<<"But now you shall die to the reaper"<<endl<<"You have a 1 in 2 chance of success"<<endl<<"I wish you no luck!"<<endl;
    usleep(4500000);
    while (reaperhealth>0)
    {
    cout<<"\033[2J\033[1;1H";
    if (health<1)
    {
        death();
    }
    cout<<username<<" "<<health<<"hp"<<endl<<"Reaper "<<reaperhealth<<"hp"<<endl<<"------------------" <<endl;
    cout<<"1= Dodge"<<endl<<"2= Attack"<<endl;
    if (potion>0)
        {
            cout<<"3= Run Away (Uses all the potions you have left)"<<endl;
        }
    cin>>choice;
    if (choice==1)
    {
        yourNumber= (rand() % 100) + 1;
        if (yourNumber==1)
        {
            cout<<"You failed to Dodge and got your soul reaped!"<<endl;
            health=0;
            usleep(1000000);
        }
        if (yourNumber>1)
        {
            cout<<"You have successfully dodged and avoided any damage!"<<endl<<"You have 9999999 hp."<<endl;
            health=9999999;
            usleep(1000000);
        }
    }
    if (choice==2)
    {
        yourNumber=0;
        yourNumber= (rand() % 2) + 1;
        if (yourNumber==1)
        {
            cout<<"You failed to attack and got your soul reaped!"<<endl;
            health=0;
            usleep(1000000);
        }
        if (yourNumber>1)
        {
            cout<<"You have successfully attacked and Killed the Reaper!"<<endl;
            reaperhealth=0;
            usleep(1000000);
        }
    }
    if (choice==3)
    {
        if (potion>0)
        {
            
            potion=0;
            dungeonmaster();
        }
        else 
        {
            death();
        }
    }
    if (choice<1)
    {
        death();
    }
    if (choice>4)
    {
        death();
    }
    }
    finish();
} 

int dungeonmaster()
{
    cout<<"\033[2J\033[1;1H";
    cout<<"Hello!"<<"Congratulations now instead of fighting the reaper you shall fight me!"<<endl;
    usleep(4500000);
    if (health<999999)
    {
        cout<<"Hahaha just kidding you are far to weak to fight me";
        return 0;
    }
    if (health>999999)
    {
        cout<<"You have indeed surpassed my expectations to think that you would be able to have a chance against me!"<<endl;
        cout<<"If I knew this from the beginning I would've just slain you then and there but oh well no regrets"<<endl;
        cout<<"I look forward to how you shall face me!"<<endl;
        usleep(5000000);
        cout<<"\033[2J\033[1;1H";
    }
    while (dungeonmasterhealth>0)
    {
        cout<<"\033[2J\033[1;1H";
    if (health<1)
    {
        death();
    }
    cout<<username<<" "<<health<<"hp"<<endl<<"Dungeonmaster "<<dungeonmasterhealth<<"hp"<<endl<<"------------------" <<endl;
    cout<<"1= Dodge"<<endl<<"2= Attack"<<endl;
    cin>>choice;
    if (choice==1)
    {
        cout<<"HAHAHA YOU CANNOT DODGE ME FOOLISH CHILD!"<<endl;
        death();
    }
    if (choice==2)
    {
        yourNumber=0;
        yourNumber= (rand() % 4) + 1;
        if (yourNumber==1)
        {
            cout<<"You failed to attack and got booted from the program"<<endl;
            health=0;
            usleep(1000000);
            return 0;
        }
        if (yourNumber>1)
        {
            cout<<"You have successfully attacked but still lost"<<endl;
            dungeonmasterhealth=0;
            usleep(1000000);
        }
    }
    }
    finish2();
}

int finish()
{
    cout<<"\033[2J\033[1;1H";
    cout<<"ERROR"<<setw(50)<<"ERROR"<<endl<<endl;
    usleep(500000);
    cout<<"\033[2J\033[1;1H";
    cout << setw(20) << "EEEEEEEEEEEE";
    cout << setw(14) << "RRRRRR";
    cout << setw(14) << "RRRRRR";
    cout << setw(14) << "OOOOO";
    cout << setw(14) << "RRRRRR" << endl;
    
    cout << setw(10) << "EE";
    cout << setw(20) << "RR"<<setw(5)<<"RR";
    cout << setw(9) << "RR"<<setw(5)<<"RR";
    cout << setw(15) << "OO     OO";
    cout << setw(8) << "RR"<<setw(5)<<"RR" << endl;
    
    cout << setw(10) << "EE";
    cout << setw(24) << "RRRRRR";
    cout << setw(14) << "RRRRRR";
    cout << setw(16) << "OO     OO";
    cout << setw(12) << "RRRRRR" << endl;

    cout << setw(20) << "EEEEEEEEEEEE";
    cout << setw(12) << "RRRR";
    cout << setw(14) << "RRRR";
    cout << setw(18) << "OO     OO";
    cout << setw(10) << "RRRR" << endl;

    cout << setw(10) << "EE";
    cout << setw(20) << "RR"<<setw(3)<<"RR";
    cout << setw(11) << "RR"<<setw(3)<<"RR";
    cout << setw(17) << "OO     OO";
    cout << setw(8) << "RR"<<setw(3)<<"RR" << endl;

    cout << setw(10) << "EE";
    cout << setw(20) << "RR"<<setw(4)<<"RR";
    cout << setw(10) << "RR"<<setw(4)<<"RR";
    cout << setw(16) << "OO     OO";
    cout << setw(8) << "RR"<<setw(4)<<"RR" << endl;

    cout << setw(20) << "EEEEEEEEEEEE";
    cout << setw(10) << "RR"<<setw(5)<<"RR";
    cout << setw(9) << "RR"<<setw(5)<<"RR";
    cout << setw(13) << "OOOOO";
    cout << setw(10) << "RR"<<setw(5)<<"RR" << endl;
    usleep(5000000);
    cout<<"\033[2J\033[1;1H";
    cout<<endl<<endl<<endl<<setw(23)<<"Shutting";
    usleep(500000);
    cout<<" Down";
    usleep(2500000);
    return 0;
    
}

int finish2()
{
    cout<<"\033[2J\033[1;1H";
    cout<<"Congratulations your attack went through but it still did nothing to me for I am the Dungeon Master"<<endl;
    cout<<"I still consider this as your win so...";
    cout<<"You have successfully beat this dungeon I wish you luck on your future adventures!"<<endl<<endl;
    cout<<"╭━━━┳━━━┳━╮╱╭┳━━━┳━━━┳━━━┳━━━━┳╮╱╭┳╮╱╱╭━━━┳━━━━┳━━┳━━━┳━╮╱╭┳━━━╮"<<endl;
    cout<<"┃╭━╮┃╭━╮┃┃╰╮┃┃╭━╮┃╭━╮┃╭━╮┃╭╮╭╮┃┃╱┃┃┃╱╱┃╭━╮┃╭╮╭╮┣┫┣┫╭━╮┃┃╰╮┃┃╭━╮┃"<<endl;
    cout<<"┃┃╱╰┫┃╱┃┃╭╮╰╯┃┃╱╰┫╰━╯┃┃╱┃┣╯┃┃╰┫┃╱┃┃┃╱╱┃┃╱┃┣╯┃┃╰╯┃┃┃┃╱┃┃╭╮╰╯┃╰━━╮"<<endl;
    cout<<"┃┃╱╭┫┃╱┃┃┃╰╮┃┃┃╭━┫╭╮╭┫╰━╯┃╱┃┃╱┃┃╱┃┃┃╱╭┫╰━╯┃╱┃┃╱╱┃┃┃┃╱┃┃┃╰╮┃┣━━╮┃"<<endl;
    cout<<"┃╰━╯┃╰━╯┃┃╱┃┃┃╰┻━┃┃┃╰┫╭━╮┃╱┃┃╱┃╰━╯┃╰━╯┃╭━╮┃╱┃┃╱╭┫┣┫╰━╯┃┃╱┃┃┃╰━╯┃"<<endl;
    cout<<"╰━━━┻━━━┻╯╱╰━┻━━━┻╯╰━┻╯╱╰╯╱╰╯╱╰━━━┻━━━┻╯╱╰╯╱╰╯╱╰━━┻━━━┻╯╱╰━┻━━━╯"<<endl;
    usleep(5000000);
    return 0;
}

int death()
{
        deaths++;
        if (deaths>5)
        {
            return 0;
        }
        cout<<"\033[2J\033[1;1H";
        cout<<"So you have died..."<<endl<<endl;
        usleep(1500000);
        cout<<"▒▒▒▒▒▒▒▒▒▒▒▄▄▄▄░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒"<<endl;
        cout<<"▒▒▒▒▒▒▒▒▒▄██████▒▒▒▒▒▄▄▄█▄▒▒▒▒▒▒▒▒▒▒"<<endl;
        cout<<"▒▒▒▒▒▒▒▄██▀░░▀██▄▒▒▒▒████████▄▒▒▒▒▒▒"<<endl;
        cout<<"▒▒▒▒▒▒███░░░░░░██▒▒▒▒▒▒█▀▀▀▀▀██▄▄▒▒▒"<<endl;
        cout<<"▒▒▒▒▒▄██▌░░░░░░░██▒▒▒▒▐▌▒▒▒▒▒▒▒▒▀█▄▒"<<endl;
        cout<<"▒▒▒▒▒███░░▐█░█▌░██▒▒▒▒█▌▒▒▒▒▒▒▒▒▒▒▀▌"<<endl;
        cout<<"▒▒▒▒████░▐█▌░▐█▌██▒▒▒██▒▒▒▒▒▒▒▒▒▒▒▒▒"<<endl;
        cout<<"▒▒▒▐████░▐░░░░░▌██▒▒▒█▌▒▒▒▒▒▒▒▒▒▒▒▒▒"<<endl;
        cout<<"▒▒▒▒████░░░▄█░░░██▒▒▐█▒▒▒▒▒▒▒▒▒▒▒▒▒▒"<<endl;
        cout<<"▒▒▒▒████░░░██░░██▌▒▒█▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒"<<endl;
        cout<<"▒▒▒▒████▌░▐█░░███▒▒▒█▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒"<<endl;
        cout<<"▒▒▒▒▐████░░▌░███▒▒▒██▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒"<<endl;
        cout<<"▒▒▒▒▒████░░░███▒▒▒▒█▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒"<<endl;
        cout<<"▒▒▒██████▌░████▒▒▒██▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒"<<endl;
        cout<<"▒▐████████████▒▒███▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒"<<endl;
        cout<<"▒█████████████▄████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒"<<endl;
        cout<<"██████████████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒"<<endl;
        cout<<"██████████████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒"<<endl;
        cout<<"█████████████████▀▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒"<<endl;
        cout<<"█████████████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒"<<endl;
        cout<<"████████████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒"<<endl;
        cout<<"████████████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒";
        usleep(3000000);
        restart=0;
        cout<<endl<<endl<<endl<<"Press 1 to Try Again"<<endl<<"Press 2 to Leave"<<endl;
        cin>>restart;
        if (restart==1)
        {
            health=100;
            if (level==1)
            {
                slime();
            }
            if (level==2)
            {
                goblin();
            }
            if (level==3)
            {
                orc();
            }
            if (level==4)
            {
                ogre();
            }
            if (level==5)
            {
                elf();
            }
            if (level==6)
            {
                giant();
            }
            if (level==7)
            {
                titan();
            }
            if (level==8)
            {
                demon();
            }
            if (level==9)
            {
                reaper();
            }
            title();
            
        }
        if (restart==2)
        {
            cout<<"\033[2J\033[1;1H";
            cout<<"So you have been defeated both mentally and physically..."<<" Well... Bye Bye!";
            usleep(1500000);
            return 0;
        }
        if (restart>1)
        {
            cout<<"\033[2J\033[1;1H";
            cout<<"So you have been defeated both mentally and physically..."<<" Well... Bye Bye!";
            usleep(1500000);
            return 0;
        }
        if (restart<1) 
        {
            cout<<"\033[2J\033[1;1H";
            cout<<"So you have been defeated both mentally and physically..."<<" Well... Bye Bye!";
            usleep(1500000);
            return 0;
        }
} 

C++ Online Compiler

Write, Run & Share C++ code online using OneCompiler's C++ online compiler for free. It's one of the robust, feature-rich online compilers for C++ language, running on the latest version 17. Getting started with the OneCompiler's C++ compiler is simple and pretty fast. The editor shows sample boilerplate code when you choose language as C++ and start coding!

Read inputs from stdin

OneCompiler's C++ online compiler supports stdin and users can give inputs to programs using the STDIN textbox under the I/O tab. Following is a sample program which takes name as input and print your name with hello.

#include <iostream>
#include <string>
using namespace std;

int main() 
{
    string name;
    cout << "Enter name:";
    getline (cin, name);
    cout << "Hello " << name;
    return 0;
}

About C++

C++ is a widely used middle-level programming language.

  • Supports different platforms like Windows, various Linux flavours, MacOS etc
  • C++ supports OOPS concepts like Inheritance, Polymorphism, Encapsulation and Abstraction.
  • Case-sensitive
  • C++ is a compiler based language
  • C++ supports structured programming language
  • C++ provides alot of inbuilt functions and also supports dynamic memory allocation.
  • Like C, C++ also allows you to play with memory using Pointers.

Syntax help

Loops

1. If-Else:

When ever you want to perform a set of operations based on a condition If-Else is used.

if(conditional-expression) {
   //code
}
else {
   //code
}

You can also use if-else for nested Ifs and If-Else-If ladder when multiple conditions are to be performed on a single variable.

2. Switch:

Switch is an alternative to If-Else-If ladder.

switch(conditional-expression){    
case value1:    
 // code    
 break;  // optional  
case value2:    
 // code    
 break;  // optional  
......    
    
default:     
 code to be executed when all the above cases are not matched;    
} 

3. For:

For loop is used to iterate a set of statements based on a condition.

for(Initialization; Condition; Increment/decrement){  
  //code  
} 

4. While:

While is also used to iterate a set of statements based on a condition. Usually while is preferred when number of iterations are not known in advance.

while (condition) {  
// code 
}  

5. Do-While:

Do-while is also used to iterate a set of statements based on a condition. It is mostly used when you need to execute the statements atleast once.

do {  
 // code 
} while (condition); 

Functions

Function is a sub-routine which contains set of statements. Usually functions are written when multiple calls are required to same set of statements which increases re-usuability and modularity. Function gets run only when it is called.

How to declare a Function:

return_type function_name(parameters);

How to call a Function:

function_name (parameters)

How to define a Function:

return_type function_name(parameters) {  
 // code
}