Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Top Posters

Who's Online (0)

Powered by Vanilla. Made with Bootstrap.
[C++] Trial and error based game [basic]
  • Sh3llc0d3
    Posts: 1,910
    Yeah so, another random simple program. Kind of a game I made to demonstrate the 'if' statement for beginner's to C++.

    /*
    Following on from a previous shooting related program,
    this program will work out if you have a specific powered
    rifle would it hit the target... pretty important thing to
    know really. Trial and Error based game, figure out the
    closest you can get from an unknown target by guessing
    what velocity and airtime you will need
    */
    #include <iostream>
    int main()
    {
    //variables
    double vel, dist, time;

    //intro
    std::cout << \"Well yet another random/simple program by me, Semtex-Primed.\n\"
    << \"for this one you need to enter a Velocity followed by a time,\n\"
    << \"from this you have to get close to an unknown target.\n\n\";

    //velocity
    std::cout << \"Enter Velocity: \";
    std::cin >> vel;

    //time
    std::cout << \"Enter Time: \";
    std::cin >> time;

    //calculation
    dist = vel / time;

    /*
    1st if statement, if the calculated distance is less than 15, return the output.
    Notice how when we state the conditions for if, we then begin a new 'code-block'
    which is executed if the 'if' statement is true and then finishes when the code-block
    brackets close. So the if only execute what you put within the '{ }' brackets.
    */
    if(dist < 15)
    {
    std::cout << \"You've missed your target [fell short of the target]\";
    }
    /*
    2nd if, same as 1st but above 15.
    */
    if(dist > 15)
    {
    std::cout << \"You've missed your target [went too far]\";
    }
    /*
    If the calculated distance is equal to 15, then you were correct.
    */
    if(dist == 15)
    {
    std::cout << \"Direct hit!! Congratulations!\";
    }

    std::cout << \"\n\n\" << \"Distance covered [in metre's]: \" << dist;

    return 0;
    }


    Anyone who wants a crack at seeing if they can do it without cheating :P
    Velocity: 800
    Time: 35
    gave a result of 22.8571, a hint is it's below 20. don't know why i'm giving that seeing as though you can see the source lol.
  • Xin
    Posts: 3,251
    Good job again, i recommend making games in the language as its fun and you learn a lot, just like console rpg games or whatever
    Xin
  • To win the game, enter values :
    30 - 2
    45 - 3
    60 - 4
    300 - 20
    150 - 10
    ....
    ...

    I'm bored -_-
  • Sh3llc0d3
    Posts: 1,910
    It's not tagged 'basic' for nothing lol
  • pusoy23
    Posts: 19
    cool i hope me too make such a program like you.
  • Sh3llc0d3
    Posts: 1,910
    said:


    cool i hope me too make such a program like you.



    I have every confidence you'll make a better one ;)

    If you want to see a fairly decent C++ console game here's one I saw posted elsewhere... (I'm assuming it's made in VC++[visual c++])

    [code]//Game Created by Synervix
    //header declarations
    #include <iostream>
    #include <stdlib.h>
    #include <conio.h>
    #include <iomanip>
    #include <string>
    #include <time.h>
    #include <fstream>
    #include <windows.h>
    using namespace std;
    //used to maximize screen
    #pragma comment(lib,"kernel32.lib")
    #pragma comment(lib,"user32.lib")
    //initializing functions
    void spell(int & money, int spells[10]);
    void look(int material[3], int & money, int & lookaround);
    void upgrade(int material[3], int & money, int upgradeitem[2], int weapon, int armor);
    void attribute(int stats[4], int & attributes);
    void levels(int & level, int & enemy, int & alignment);
    void medic(int & money,int potionsize[5]);
    void weapons(int & money, int & weapon, int upgradeitem[2]);
    void armory(int & money, int & armor, int upgradeitem[2]);
    void statistics(int money,int mondef,int potionsize[5],int armor,int weapon,string name,int stats[4], int health, int attributes, int alignment, int deaths, int hp, int tp, int upgradeitem[2], int lookaround, int material[3], int spells[10]);
    void heal(int & health, int & hp);
    void train(int stats[4], int & tp);
    void battlephase(int stats[4], int & enemy, int potionsize[5], string name, int & weapon, int & armor, int & money, int & mondef, int & health, int & level, int & attributes, int & alignment, int & hp, int & tp, int & deaths, int & lookaround, int upgradeitem[2], int spells[10]);
    char spellname[10][25] = {"Lower Enemy Health", "Lower Enemy Attack", "Lower Enemy Defence", "Lower Enemy Speed", "Lower Enemy Accuracy", "Raise Health", "Raise Attack", "Raise Defence", "Raise Speed", "Raise Accuracy"};

    //main function
    int main()
    {
    system("color 0f");
    //tells screen to maximize
    HWND hWnd = GetConsoleWindow();
    ShowWindow(hWnd,SW_MAXIMIZE);
    /*****array declarations*****/
    //potions
    int potionsize[5] = {0, 0, 0, 0, 0};
    //armor
    int armor = 0;
    //weapons
    int weapon = 0;
    //menu array
    char menu[6][50] = {"Go to a Town", "View Stats", "Add Attributes", "Heal", "Train", "Look around the area"};
    char town[5][50] = {"Visit the town medic", "Visit the Weapon Smith", "Go to the Armory", "Upgrade Weapon and Armor", "Go to the spell shop"};
    //area
    char monsters[16][25] = {"Wolf", "Bear", "Bandit", "Traveler", "Gargoyle", "Knight", "Warlock", "Mammoth", "Cyclops", "Unicorn", "Dragon", "Your Mother", "Demon", "Jesus", "Satan", "God"};
    char area[7][25] = {"Go to the Trail", "Go to the Mountains", "Go to the Valley", "Go to the Lake", "Go to the Cliff", "Go to the Cave", "Go to the Land of Fire"};
    int level = 0;
    //character Stats
    int stats[4] = {10, 10, 10, 10};
    //counter
    int count1;
    //name
    string name;
    //money
    int money = 50;
    //which enemy to fight
    int enemy = 0;
    //monsters defeated
    int mondef = 0;
    //User Health
    int health = 100;
    //amount of attributes
    int attributes = 0;
    //alignment
    int alignment = 0;
    //number of times died
    int deaths = 0;
    //health points
    int hp = 0;
    //training points
    int tp = 0;
    //enter page
    char title;
    //decides whether or not you will move on
    int moveon = 0;
    //menu
    char menu1;
    //upgraded weapon/armor
    int material[3] = {0,0,0};
    //amount of material
    int upgradeitem[2] = {0,0};
    //looking around the area
    int lookaround = 1;
    //spells
    int spells[10] = {0,0,0,0,0,0,0,0,0,0};
    //cheat code
    string cheatcode;
    do{
    system("cls");
    cout << "v1.0" << endl
    << "----------by: Synervix----------" << endl << endl << endl;
    cout << "Welcome, what would you like to do?\n\n"
    << "1. Start a New Game" << endl
    << "2. Load Saved Game" << endl
    << "3. Help/Rules" << endl
    << "4. Enter Cheat Codes" << endl << endl << ">> ";
    cin >> title;
    if(title == 'q')
    return 0;
    system("cls");
    switch(title)
    {
    case '1':
    /*****Introduction*****/
    cout << "If you have a saved game this will erase it!!\n"
    << "Are you sure you wish to continue?\n\n"
    << "1. Yes\n"
    << "2. No\n\n>> ";
    cin >> count1;
    system("cls");
    if(count1 == 1)
    {
    cout << "Please Enter your name (One Word): ";
    cin >> name;
    system("cls");
    cout << "Welcome to Grundor, " << name << ", the village where you were born.\n"
    << "Your mother, Marlene was abducted by the Horrid Dragon, Helsmich, in the land \n"
    << "of fire. In order for you to save your mother, you must travel along the \n"
    << "twisted trail into lands that are filled with terror. I bid you the best of \n"
    << "luck, and here is $50 to spend on supplies. I know it is not much, but I am \n"
    << "not the wealthiest man alive!\n\n";
    system("pause");
    system("cls");
    moveon = 1;
    }
    break;
    case '3':
    cout << " **********Rules**********" << endl << endl
    << "The Rules of Helsmich are simple. Just enter a number that is available, and\n"
    << "try to make the CORRECT selection to survive. Every choice or thing that you\n"
    << "do will impact either your character or the way you play the game. As you make\n"
    << "choices, your alignment will change. If your alignment is in the negative, you\n"
    << "will become 'evil'. Thus, the monsters you battle will differ depending on how\n"
    << "your alignment is. Your score nearly depends on ALL the variables in the game,\n"
    << "so don't slack on one aspect and think it won't effect you. Your game has an\n"
    << "auto-save that will save your game each and every time you hit the enter page!\n"
    << "This was a brief review of the game, so have fun!" << endl << endl;
    system("pause");
    break;
    case '4':
    cout << "If you have a saved game this will erase it!!\n"
    << "Are you sure you wish to continue?\n\n"
    << "1. Yes\n"
    << "2. No\n\n>> ";
    cin >> count1;
    system("cls");
    if(count1 == 1)
    {
    do{
    cout << "Please enter your cheat code: \n"
    << "Type '123' to exit.\n\n>> ";
    cin >> cheatcode;
    if(cheatcode == "GiveMeExcaliberPlease")
    weapon = 9;
    else if(cheatcode == "GiveMeBerzerkerArmorPlease")
    armor = 9;
    else if(cheatcode == "MOOONEY")
    money = 9999999;
    else if(cheatcode == "MusclesRule")
    stats[0] = 999;
    else if(cheatcode == "ArmoredLikeAnAnt")
    stats[1] = 999;
    else if(cheatcode == "RunningShoes")
    stats[2] = 999;
    else if(cheatcode == "EagleEye")
    stats[3] = 999;
    else if(cheatcode == "HealthNut")
    health = 9999;
    else if(cheatcode == "LetMeGuess")
    tp = 999;
    else if(cheatcode == "HealMe")
    hp = 999;
    else if(cheatcode == "ILikeAttributes")
    attributes = 999;
    else if(cheatcode == "MakeMeGoodNow")
    alignment = 6;
    else if(cheatcode == "MakeMeEvilNow")
    alignment = -6;
    else if(cheatcode == "MedicMan")
    {
    for(int x=0;x<5;x++)
    potionsize[x]+=999;
    }
    else if(cheatcode == "EvilBoss")
    {
    alignment = 3;
    level = 8;
    }
    else if(cheatcode == "GoodBoss")
    {
    alignment = -3;
    level = 8;
    }
    else if(cheatcode == "IDontFeelLikeActuallyPlaying")
    {
    for(int x=0;x<5;x++)
    potionsize[x]+=999;
    attributes = 999;
    tp = 999;
    hp = 999;
    weapon = 9;
    armor = 9;
    for(int x=0;x<4;x++)
    stats[x]+=999;
    health = 999;
    money = 999;
    mondef = 8;
    }
    else if(cheatcode != "123")
    {
    system("cls");
    cout << "Invalid Cheat Code!!!\n\n";
    system("pause");
    }
    system("cls");
    }while(cheatcode != "123");
    cout << "Please Enter your name (One Word): ";
    cin >> name;
    system("cls");
    moveon = 1;
    }
    break;
    case '2':
    ifstream infoout("test.txt");
    if (infoout.is_open())
    {
    infoout >> name;
    infoout >> money;
    infoout >> mondef;
    infoout >> potionsize[0];
    infoout >> potionsize[1];
    infoout >> potionsize[2];
    infoout >> potionsize[3];
    infoout >> potionsize[4];
    infoout >> armor;
    infoout >> weapon;
    infoout >> deaths;
    infoout >> hp;
    infoout >> tp;
    infoout >> health;
    infoout >> stats[0];
    infoout >> stats[1];
    infoout >> stats[2];
    infoout >> stats[3];
    infoout >> attributes;
    infoout >> alignment;
    infoout >> level;
    infoout >> material[0];
    infoout >> material[1];
    infoout >> material[2];
    infoout >> upgradeitem[0];
    infoout >> upgradeitem[1];
    infoout >> lookaround;
    infoout >> spells[0];
    infoout >> spells[1];
    infoout >> spells[2];
    infoout >> spells[3];
    infoout >> spells[4];
    infoout >> spells[5];
    infoout >> spells[6];
    infoout >> spells[7];
    infoout >> spells[8];
    infoout >> spells[9];
    infoout.close();
    }
    moveon = 1;
    break;
    }
    }while(moveon == 0);
    do{
    ofstream infoin("test.txt");
    infoin << name << endl;
    infoin << money << endl;
    infoin << mondef << endl;
    infoin << potionsize[0] << endl;
    infoin << potionsize[1] << endl;
    infoin << potionsize[2] << endl;
    infoin << potionsize[3] << endl;
    infoin << potionsize[4] << endl;
    infoin << armor << endl;
    infoin << weapon << endl;
    infoin << deaths << endl;
    infoin << hp << endl;
    infoin << tp << endl;
    infoin << health << endl;
    infoin << stats[0] << endl;
    infoin << stats[1] << endl;
    infoin << stats[2] << endl;
    infoin << stats[3] << endl;
    infoin << attributes << endl;
    infoin << alignment << endl;
    infoin << level << endl;
    infoin << material[0] << endl;
    infoin << material[1] << endl;
    infoin << material[2] << endl;
    infoin << upgradeitem[0] << endl;
    infoin << upgradeitem[1] << endl;
    infoin << lookaround << endl;
    infoin << spells[0] << endl;
    infoin << spells[1] << endl;
    infoin << spells[2] << endl;
    infoin << spells[3] << endl;
    infoin << spells[4] << endl;
    infoin << spells[5] << endl;
    infoin << spells[6] << endl;
    infoin << spells[7] << endl;
    infoin << spells[8] << endl;
    infoin << spells[9] << endl;
    infoin.close();
    /*****Main Menu*****/
    //ask what user what they want to do
    cout << "What would you like to do?\n\n";
    for(count1=0;count1<6;count1++)
    cout << count1+1 << ". " << menu[count1] << endl;
    if(level < 7)
    cout << count1+1 << ". " << area[level] << endl;
    if(level > 6)
    {
    if((level == 7)&&(alignment < 0))
    cout << "7. Go to Heaven" << endl;
    if((level == 7)&&(alignment >= 0))
    cout << "7. Go to Hell" << endl;
    if((level == 8)&&(alignment < 0))
    cout << "7. Go to Heaven's Throne" << endl;
    if((level == 8)&&(alignment >= 0))
    cout << "7. Go to Hell's Throne" << endl;
    }
    cout << endl << ">> ";
    cin >> menu1;
    if(menu1 == 'q')
    return 0;
    system("cls");
    //switch to change main event
    switch(menu1)
    {
    case '1':
    do{
    do{
    cout << "You arrive at your small home town with " << money << " gold in your pocket.\n"
    << "What would you like to do now?: \n\n";
    for(count1=0;count1<5;count1++)
    cout << count1+1 << ". " << town[count1] << endl;
    cout << "6. Leave" << endl << "\n>> ";
    cin >> menu1;
    system("cls");
    }while((menu1<1)&&(menu1>6));
    switch(menu1)
    {
    case '1':
    medic(money,potionsize);
    break;
    case '2':
    weapons(money,weapon,upgradeitem);
    break;
    case '3':
    armory(money,armor,upgradeitem);
    break;
    case '4':
    upgrade(material,money,upgradeitem,weapon,armor);
    break;
    case '5':
    spell(money, spells);
    break;
    case '6':
    break;
    case 'q':
    return 0;
    break;
    }
    }while(menu1 != '6');
    system("cls");
    break;
    case '2':
    statistics(money, mondef, potionsize, armor, weapon, name, stats, health, attributes, alignment, deaths, hp, tp, upgradeitem, lookaround, material, spells);
    break;
    case '3':
    attribute(stats,attributes);
    break;
    case '4':
    heal(health,hp);
    break;
    case '5':
    train(stats,tp);
    break;
    case '6':
    look(material, money, lookaround);
    break;
    case '7':
    levels(level, enemy, alignment);
    battlephase(stats, enemy, potionsize, name, weapon, armor, money, mondef, health, level, attributes, alignment, hp, tp, deaths, lookaround, upgradeitem, spells);
    break;
    }
    }while(level!=9);
    //If user won
    system("cls");
    char won[2][25] = {"God", "Satan"};
    if(enemy = 15)
    level = 0;
    if(enemy = 14)
    level = 1;
    cout << "You have beaten the game! I congratulate you on your vistory. \nYou are indeed better than " << won[level] << "!!!";
    system("pause");
    return 0;
    }
    /*****Menu Options*****/

    /*****looking 4 material*****/
    void spell(int &money, int spells[10])
    {
    //minor decloration
    int spellcost[10] = {50, 50, 50, 50, 50, 50, 50, 50, 50, 50};

    system("cls");
    cout << "Welcome to the Spell Shop, what can I do you for?\nYou have $" << money << "\nNote: Spells are only active for ONE battle!\n\n";
    int x=0;
    for(x;x<10;x++)
    cout << x+1 << ". " << spellname[x] << " - cost: " << spellcost[x] << "$" << endl;
    cout << "11. Leave";
    cout << "\n\n>> ";
    cin >> x;
    system("cls");
    if(x!=11)
    {
    if(x<1||x>6)
    cout << "Invalid Selection!\n\n";
    else if(spellcost[x-1]>money)
    cout << "Sorry, you do not have enough gold.\n\n";
    else{
    x-=1;
    money = money - spellcost[x];
    spells[x] += 1;
    cout << "You have succesfully purchased a " << spellname[x] << "!\n"
    << "You have lost " << spellcost[x] << " gold!\n"
    << "You now have " << money << " gold.\n\n";
    cout << "----------------------------\n"
    << "You have: \n";
    for(x=0;x<10;x++)
    cout << spells[x] << " " << spellname[x] << "(s)" << endl;
    cout << "----------------------------\n\n";
    }
    system("pause");
    system("cls");
    cout << "Would you like to buy again?\n\n";
    cout << "1. yes\n2. no\n\n>> ";
    cin >> x;
    if(x==1)
    spell(money, spells);
    }
    system("cls");
    }

    /*****looking 4 material*****/
    void look(int material[3], int & money, int & lookaround)
    {
    int random, randomnum;
    char materialname[3][25] = {"Aluminum", "Iron", "Steel"};
    srand ((unsigned)time(0));
    random = (rand() % 4);
    randomnum = (rand() % 70) + 1;
    if(lookaround == 0)
    cout << "You already looked around this area!!\n\n";
    else
    {
    lookaround = 0;
    cout << "You look around the area for any sign of gold, iron, aluminum, or steel";
    int x=0;
    for(x;x<4;x++)
    {
    cout << ".";
    Sleep(500);
    }
    if(random < 3)
    {
    cout << "\n\nYou found a piece of " << materialname[random] << "!!!\n";
    material[random] += 1;
    cout << "You now have " << material[random] << " " << materialname[random] << "!\n\n";
    }
    if(random == 3)
    {
    cout << "\n\nYou manage to find a bag of gold on the ground, inside is " << randomnum << " gold pieces!\n\n";
    money += randomnum;
    cout << "You now have " << money << " gold!\n\n";
    }
    }
    system("pause");
    system("cls");
    }




    /*****upgrading equipment*****/
    void upgrade(int material[3], int & money, int upgradeitem[2], int weapon, int armor)
    {
    char option = 'y';
    do{
    system("cls");
    if((material[0] == 0)&&(material[1] == 0)&&(material[2] == 0))
    {
    cout << "Sorry, you do not have any material to add to your weapon!\n\n";
    option = 'n';
    system("pause");
    }
    else
    {
    char weaponname[10][25] = {"Fists", "Dagger", "Club", "Axe", "Short Sword", "Cutlass", "Bastard Sword", "Long Sword", "Great Sword", "Excaliber"};
    char armorname[10][25] = {"Rags", "Shirt", "Fur", "Leather", "Studded Leather", "Chain Mail", "Scale Mail", "Plate Mail", "Spiked Plate Mail", "Berzerker Armor"};
    int upgradecost[4] = {10,15,20,0};
    char materialname[3][25] = {"Aluminum", "Iron", "Steel"};
    int menu1 = 0;
    int weaponstrengthmax[10] = {8, 12, 18, 25, 33, 42, 50, 60, 71, 83};
    do{
    cout << "Welcome to the Blacksmith, were I will upgrade your weapon for some material \nand money.\n"
    << "What would you like to do?\n\n"
    << "1. Upgrade Weapon\n"
    << "2. Upgrade Armor\n\n"
    << ">> ";
    cin >> menu1;
    system("cls");
    }while((menu1!=1)&&(menu1!=2));
    switch(menu1)
    {
    case 1:
    do{
    cout << "What would you like to upgrade your " << weaponname[weapon] << " with? You have " << money << " gold.\n\n"
    << "1. Aluminum - " << (weapon + 1)*upgradecost[0] << " gold. You have " << material[0] << " Aluminum.\n"
    << "2. Iron - " << (weapon + 1)*upgradecost[1] << " gold. You have " << material[1] << " Iron.\n"
    << "3. Steel - " << (weapon + 1)*upgradecost[2] << " gold. You have " << material[2] << " Steel.\n"
    << "4. Leave\n\n>> ";
    cin >> menu1;
    system("cls");
    }while((menu1<1)&&(menu1>4)||(material[menu1-1]==0)||(money<((weapon+1)*upgradecost[menu1-1])));
    if(menu1!=4)
    {
    menu1 -= 1;
    cout << "Congrats, you added " << materialname[menu1] << " to your " << weaponname[weapon] << "!!\n";
    upgradeitem[0] += (menu1+1);
    cout << "Your weapon is now " << weaponname[weapon] << "+" << upgradeitem[0] << "! \nThis adds " << (menu1+1)*(weapon+1) << " damage to your weapon!\n";
    material[menu1] -= 1;
    money -= (weapon+1)*upgradecost[menu1];
    cout << "You lost " << (weapon+1)*upgradecost[menu1] << " gold.\n";
    cout << "You now have " << money << " gold.\n";
    cout << "You have lost 1 " << materialname[menu1] << ".\n\n";
    system("pause");
    system("cls");
    }
    break;
    case 2:
    do{
    cout << "What would you like to upgrade your " << armorname[armor] << " with? You have " << money << " gold.\n\n"
    << "1. Aluminum - " << (armor + 1)*upgradecost[0] << " gold. You have " << material[0] << " Aluminum.\n"
    << "2. Iron - " << (armor + 1)*upgradecost[1] << " gold. You have " << material[1] << " Iron.\n"
    << "3. Steel - " << (armor + 1)*upgradecost[2] << " gold. You have " << material[2] << " Steel.\n"
    << "4. Leave\n\n>> ";
    cin >> menu1;
    system("cls");
    }while((menu1<1)&&(menu1>3)||(material[menu1-1]==0)||(money<((armor+1)*upgradecost[menu1-1])));
    if(menu1!=4)
    {
    menu1 -= 1;
    cout << "Congrats, you added " << materialname[menu1] << " to your " << armorname[armor] << "!!\n";
    upgradeitem[1] += (menu1+1);
    cout << "Your armor is now " << armorname[armor] << "+" << upgradeitem[1] << "! \nThis adds " << upgradeitem[1]*(weapon+1) << " defense to your armor!\n";
    material[menu1] -= 1;
    money -= (armor+1)*upgradecost[menu1];
    cout << "You lost " << (armor+1)*upgradecost[menu1] << " gold.\n";
    cout << "You now have " << money << " gold.\n";
    cout << "You have lost 1 " << materialname[menu1] << ".\n\n";
    system("pause");
    system("cls");
    }
    break;
    }
    cout << "Would you like to upgrade another piece of equipment?(y or n): ";
    cin >> option;
    system("cls");
    }
    }while(option == 'y');

    }
    /*****Adding Attributes*****/
    void attribute(int stats[4], int & attributes)
    {
    int number=0;
    char statname[4][25] = {"Attack", "Defense", "Speed", "Accuracy"};
    system("cls");
    do{
    if(attributes==0)
    cout << "Sorry, you do not have any free attributes at the moment, please earn some and \ncome back.\n\n";
    else
    {
    cout << "Welcome! You have " << attributes << " free attribute(s). What would you like to add them to?\n";
    cout << "-----------" << endl << endl
    << "****Stats****" << endl
    << "-----------" << endl;
    for(int x=0;x<4;x++)
    cout << x+1 << ". " << statname[x] << " - " << stats[x] << endl;
    cout << "-----------" << endl << endl;
    cout << "5. Leave\n";
    cout << ">> ";
    cin >> number;
    system("cls");
    if((number<5)&&(number>0))
    {
    system("cls");
    attributes = attributes - 1;
    cout << "You have succesfully added one attribute to " << statname[number-1] << ".\n\n";
    stats[number-1] = stats[number-1] + 1;
    system("pause");
    system("cls");
    }
    }
    }while((attributes!=0)&&(number!=5));
    system("pause");
    system("cls");
    }
    /*****Visiting the Medic*****/
    void medic(int & money,int potionsize[5])
    {
    //minor decloration
    char potionname[5][25] = {"Small Tonic", "Medium Tonic", "Large Tonic", "Grand Tonic", "Godly Tonic"};
    int potioncost[5] = {5, 10, 20, 40, 80};

    system("cls");
    cout << "Welcome to the Town Medic, what can I do you for?\nYou have $" << money << endl << endl;
    int x=0;
    for(x;x<5;x++)
    cout << x+1 << ". " << potionname[x] << " - cost: " << potioncost[x] << "$" << endl;
    cout << "6. Leave";
    cout << "\n\n>> ";
    cin >> x;
    system("cls");
    if(x!=6)
    {
    if(x<1||x>6)
    cout << "Invalid Selection!\n\n";
    else if(potioncost[x-1]>money)
    cout << "Sorry, you do not have enough gold.\n\n";
    else{
    money = money - potioncost[x-1];
    potionsize[x-1] = potionsize[x-1] + 1;
    cout << "You have succesfully purchased a " << potionname[x-1] << "!\n"
    << "You have lost " << potioncost[x-1] << " gold!\n"
    << "You now have " << money << " gold.\n\n";
    cout << "----------------------------\n"
    << "You have: \n";
    for(x=0;x<5;x++)
    cout << potionsize[x] << " " << potionname[x] << "(s)" << endl;
    cout << "----------------------------\n\n";
    }
    system("pause");
    system("cls");
    cout << "Would you like to buy again?\n\n";
    cout << "1. yes\n2. no\n\n>> ";
    cin >> x;
    if(x==1)
    medic(money, potionsize);
    }
    system("cls");
    }
    /*****Visiting the Weaponry*****/
    void weapons(int & money,int & weapon, int upgradeitem[2])
    {
    //minor declarations
    int weaponcost[9] = {15, 33, 53, 75, 99, 125, 153, 183, 215};
    char weaponname[10][25] = {"Dagger", "Club", "Axe", "Short Sword", "Cutlass", "Bastard Sword", "Long Sword", "Great Sword", "Excaliber", "Fists"};

    system("cls");
    cout << "Welcome to the Weapon Smith, what is it that you are looking for?\nYou have $" << money << endl << endl;
    int x=0;
    for(x;x<9;x++)
    cout << x+1 << ". " << weaponname[x] << " - cost: " << weaponcost[x] << "$" << endl;
    cout << "10. Leave";
    cout << "\n\n>> ";
    cin >> x;
    system("cls");
    if(x!=10)
    {
    if(x<=weapon)
    cout << "You don't need this! You already have the " << weaponname[weapon-1] << "!\n\n";
    else if(x<1||x>10)
    cout << "Invalid Selection!\n\n";
    else if(weaponcost[x-1]>money)
    cout << "Sorry, you do not have enough gold.\n\n";
    else{
    money = money - weaponcost[x-1];
    weapon = x;
    upgradeitem[0] = 0;
    cout << "You have succesfully purchased a " << weaponname[x-1] << "!\n"
    << "You have lost " << weaponcost[x-1] << " gold!\n"
    << "You now have " << money << " gold.\n\n";
    }
    system("pause");
    system("cls");
    cout << "Would you like to buy again?\n\n";
    cout << "1. yes\n2. no\n\n>> ";
    cin >> x;
    if(x==1)
    weapons(money, weapon, upgradeitem);
    }
    system("cls");
    }
    /*****Visiting the Armory*****/
    void armory(int & money,int & armor, int upgradeitem[2])
    {
    //minor declarations
    int armorcost[9] = {10, 28, 48, 70, 94, 120, 148, 177, 210};
    char armorname[10][25] = {"Shirt", "Fur", "Leather", "Studded Leather", "Chain Mail", "Scale Mail", "Plate Mail", "Spiked Plate Mail", "Berzerker Armor", "Rags"};

    system("cls");
    cout << "This is the Armory, what the hell do you want?\nYou have $" << money << endl << endl;
    int x=0;
    for(x;x<9;x++)
    cout << x+1 << ". " << armorname[x] << " - cost: " << armorcost[x] << "$" << endl;
    cout << "10. Leave";
    cout << "\n\n>> ";
    cin >> x;
    system("cls");
    if(x!=10)
    {
    if(x-1<armor)
    cout << "You don't need this! You already have " << armorname[armor-1] << "!\n\n";
    else if(x<1||x>10)
    cout << "Invalid Selection!\n\n";
    else if(armorcost[x-1]>money)
    cout << "Sorry, you do not have enough gold.\n\n";
    else{
    money = money - armorcost[x-1];
    armor = x;
    upgradeitem[1] = 0;
    cout << "You have succesfully purchased a " << armorname[x-1] << "!\n"
    << "You have lost " << armorcost[x-1] << " gold!\n"
    << "You now have " << money << " gold.\n\n";
    }
    system("pause");
    system("cls");
    cout << "Would you like to buy again?\n\n";
    cout << "1. yes\n2. no\n\n>> ";
    cin >> x;
    if(x==1)
    armory(money, armor, upgradeitem);
    }
    system("cls");
    }
    /**********Stats**********/
    void statistics(int money,int mondef,int potionsize[5],int armor,int weapon,string name,int stats[4], int health, int attributes, int alignment, int deaths, int hp, int tp, int upgradeitem[2], int lookaround, int material[3], int spells[10])
    {
    //minor decloration
    char materialname[3][25] = {"Aluminum", "Iron", "Steel"};
    char potionname[5][25] = {"Small Tonic", "Medium Tonic", "Large Tonic", "Grand Tonic", "Godly Tonic"};
    char armorname[10][25] = {"Rags", "Shirt", "Fur", "Leather", "Studded Leather", "Chain Mail", "Scale Mail", "Plate Mail", "Spiked Plate Mail", "Berzerker Aromor"};
    char weaponname[10][25] = {"Fists", "Dagger", "Club", "Axe", "Short Sword", "Cutlass", "Bastard Sword", "Long Sword", "Great Sword", "Excaliber"};
    char statname[4][25] = {"Attack", "Defense", "Speed", "Accuracy"};
    char status1[25][25] = {"Satan", "Satan", "Satan", "Satan", "Demon", "Demon", "Fiend", "Fiend", "Shadow", "Shadow", "Man", "Man", "Man", "Worshipper", "Worshipper", "Monk", "Monk", "Angel", "Angel", "God", "God", "God", "God"};
    char status2[18][25] = {"Poor", "Sad", "Flawed", "Known", "Creative", "Intreguing", "Excellent", "Great", "Grand", "Awesome", "Incredible", "Conquering", "Best", "Sublime", "Master", "Perfect", "Godly", "Omniscent"};
    int status = 0;
    status = 12 + alignment;
    cout << "Name: " << name << endl << endl
    << "****Important Stuff****" << endl
    << "----------" << endl
    << "Status: " << status2[mondef] << " " << status1[status] << endl
    << "Health: " << health << endl
    << "Weapon: " << weaponname[weapon] << "+" << upgradeitem[0] << endl
    << "Armor: " << armorname[armor] << "+" << upgradeitem[1] << endl
    << "Gold: " << money << "$" << endl
    << "Monsters Defeated: " << mondef << endl
    << "You Died " << deaths << " time(s)." << endl
    << "Alignment: " << alignment << endl
    << "----------" << endl << endl
    << "****Potions****" << endl
    << "-----------" << endl;
    for(int x=0;x<5;x++)
    cout << " you have " << potionsize[x] << " " << potionname[x] << "(s)" << endl;
    cout << "-----------" << endl << endl
    << "****Stats****" << endl
    << "-----------" << endl;
    for(int x=0;x<4;x++)
    cout << " " << statname[x] << " - " << stats[x] << endl;
    cout << "-----------" << endl << endl;
    cout << "****Unused Points****" << endl
    << "-----------" << endl
    << "You have " << attributes << " free attribute point(s)." << endl
    << "You have " << tp << " free training point(s)." << endl
    << "You have " << hp << " free health point(s)." << endl;
    cout << "-----------" << endl << endl;
    cout << "****Material****" << endl
    << "-----------" << endl
    << "You have " << material[0] << " piece(s) of Aluminum" << endl
    << "You have " << material[1] << " piece(s) of Iron" << endl
    << "You have " << material[2] << " piece(s) of Steel" << endl;
    cout << "-----------" << endl << endl;
    cout << "****Spells****" << endl
    << "-----------" << endl;
    for(int x=0;x<10;x++)
    cout << " " << spellname[x] << " - " << spells[x] << endl;
    cout << "-----------" << endl;
    system("pause");
    system("cls");
    }
    /**********Healing**********/
    void heal(int & health, int & hp)
    {
    int option;
    system("cls");
    do{
    if(hp == 0)
    cout << "Sorry, you do are not able to increase your health more at this time.\n\n";
    else
    {
    cout << "Would you like to increase your health?\n" << endl
    << "1. Yes" << endl
    << "2. No\n" << endl
    << ">> ";
    cin >> option;
    system("cls");
    if(option == 1)
    {
    int random;
    srand ((unsigned)time(0));
    random = (rand() % 100) + 1;
    health += random;
    cout << "Congrats, you have increased your health by " << random << " points!\nYour health is now: " << health << endl << endl;
    hp-=1;
    }
    }
    system("pause");
    system("cls");
    }while((hp!=0)&&(option!=2));
    }
    /**********Training**********/
    void train(int stats[4], int & tp)
    {
    char statname[4][25] = {"Attack", "Defense", "Speed", "Accuracy"};
    int option;
    system("cls");
    if(tp == 0)
    cout << "Sorry, you do not have any training points left.\n\n";
    else
    {
    do{
    cout << "Would you like to try and gain an attribute?\n"
    << "1. Yes " << endl
    << "2. No" << endl
    << ">> ";
    cin >> option;
    system("cls");
    if(option == 1)
    {
    tp -= 1;
    int random, randomstat, guess;
    srand ((unsigned)time(0));
    random = (rand() % 3) + 1;
    randomstat = (rand() % 3);
    cout << "Please guess a random number 1-3 to gain an attribute: ";
    cin >> guess;
    system("cls");
    if(guess == random)
    {
    cout << "Congrats, you guessed the right number of, " << random << "!" << endl
    << "You gain 1 point added on to " << statname[randomstat] << "!" << endl << endl;
    stats[randomstat] += 1;
    }
    else
    cout << "Sorry, you guessed " << guess << ", when the number was " << random << endl << endl;
    }
    }while((option!=2)&&(tp!=0));
    }
    system("pause");
    system("cls");
    }
    /**********Levels**********/
    void levels(int & level,int & enemy,int & alignment)
    {
    char monsters[16][25] = {"Wolf", "Bear", "Bandit", "Traveler", "Gargoyle", "Knight", "Warlock", "Mammoth", "Cyclops", "Unicorn", "Dragon", "Your Mother", "Demon", "Jesus", "Satan", "God"};
    int option;
    switch(level)
    {
    case 0:
    cout << "As you look around the trail, you see a wolf tearing apart a corpse in the\n"
    << "dirt. As you try to shoo away the wolf it turns on you, and acts aggrssivly.\nPrepare for battle!\n\n";
    enemy = 0;
    level = 1;
    break;
    case 1:
    cout << "After the long and painful fight with the wolf, you limp off further down the\n"
    << "trail, into the Mountains. The corpse that the wolf was eating seems to be the\n"
    << "remnance of some old lady..too bad for her. As you continue to walk down the\n"
    << "beaten trail, you see a cute little cub run in front of you. You pick it up and\n"
    << "hold it...but then Momma Bear sees you!!!\n"
    << "Prepare for battle!\n\n";
    enemy = 1;
    level = 2;
    break;
    case 2:
    cout << "You managed to kill the outraged Momma bear, and travel to the top of the\n"
    << "mountain. As you peer over the grand mountain you see a valley surrounded by\n"
    << "gorgeous trees. As you travel past the trees to get to the valley, a Bandit\n"
    << "jumps out from no where. He asks why you are leaving, and you explain your\n"
    << "situation to him. He asks if you would mind helping him kill a notorius\n"
    << "traveler. What will you do?\n\n"
    << "1. Help the Evil Bandit kill the good Traveler.\n"
    << "2. Don't listen to the bandit, and battle him for his unjust actions.\n\n>> ";
    cin >> option;
    system("cls");
    switch(option)
    {
    case 1:
    cout << "You listen to the bandit, and decided to help him out. You get down to the\n"
    << "valley, and see a husky looking man with an axe."
    << "Prepare for battle!\n\n";
    alignment -= 2;
    enemy = 3;
    break;
    case 2:
    cout << "You look at the bandit in disgust, and you tell him that no innocent deserves\n"
    << "death. He is shocked, and picks up his knife. \nPrepare for battle!\n\n";
    alignment += 2;
    enemy = 2;
    break;
    }
    level = 3;
    break;
    case 3:
    if(alignment >= 0)
    {
    cout << "The battle with the " << monsters[enemy] << " was harsh and painful. However,\n"
    << "your good instincts gave you the strength to carry on. As you look accross the\n"
    << "valley, you notice a small isolated lake. You are very thirsty, and begin to\n"
    << "walk towards the lake. However, as you approch it a giant Gargoyle swoops in out"
    << "of no where. He looks angry, and you look like food!!!\n"
    << "Prepare for battle!\n\n";
    enemy = 4;
    }
    if(alignment < 0)
    {
    cout << "The battle with the " << monsters[enemy] << " was great and fun. You give an\n"
    << "evil laugh, and begin walking once again. As you carry on, you look accross the\n"
    << "valley, and notice a small isolated lake. You are very thirsty, and begin to\n"
    << "walk towards the lake. However, as you approch it, a good knight trots up to\n"
    << "you. He saw your evil deed, and wants to avenge the villager!!!\n"
    << "Prepare for battle!\n\n";
    enemy = 5;
    }
    level = 4;
    break;
    case 4:
    if(alignment >= 0)
    {
    cout << "You finished the battle with the " << monsters[enemy] << ", and you are ready to\n"
    << "look for the dragon that took your mother. As you search around, you see a cliff"
    << "leading off the top of the mountain. You decide to investigate it, but as you\n"
    << "reach to climb the treaturous cliff, you hear a voice, \"Get down from there now!!\"\n"
    << "the voice screamed. As you turn around to see who was talking, you see the wizard\n"
    << "with his wand ready to cast a spell on you.\nPrepare for Battle!\n\n";
    enemy = 6;
    }
    if(alignment < 0)
    {
    cout << "You finished the battle with the " << monsters[enemy] << ", it was your most\n"
    << "fun battle yet. As you look around the valley and lake around you, you notice\n"
    << "a large cliff. You decide to head towards it, to see if you can find the grand\n"
    << "dragon. However, as you approach the cliff, a giant mammoth appears from the\n"
    << "side of the cliff. You look at it in astonishment..however the bigger they are,\n"
    << "the harder they fall!\nPrepare for Battle!\n\n";
    enemy = 7;
    }
    level = 5;
    break;
    case 5:
    if(alignment >= 0)
    {
    cout << "The great " << monsters[enemy] << " was finally defeated, and you begin to\n"
    << "climb the treacherous cliff once again. As you begin nearing to the top you\n"
    << "notice a hole in the cliff. It appears to be a cave infested with bats. You\n"
    << "begin heading towards the cliff, and stop sudenly when a giant club swings\n"
    << "through the air. It is a giant Cyclops, and the only way you can save your\n"
    << "mother is to get past him.\n\n";
    enemy = 8;
    }
    if(alignment < 0)
    {
    cout << "The great " << monsters[enemy] << " was finally defeated, and you begin to\n"
    << "climb the treacherous cliff. Your evil ways have yet to dicieve you, so you\n"
    << "continue onwards led by your blackened heart. As you approach the top of the\n"
    << "cliff, you see a cave infested with bats. You walk inside, and see a glorious\n"
    << "unicorn standing in front of you. You decide to cut off the creatures head, \n"
    << "because you feel like it. However, as you approch the Unicorn it charges!\n\n";
    enemy = 9;
    }
    level = 6;
    break;
    case 6:
    if(alignment >= 0)
    {
    cout << "The battle with the " << monsters[enemy] << " is now over. You climb the last\n"
    << "rock on the cliff, and arrive at the cave you saw earlier. You peer inside, and\n"
    << "see darkness and fire everywhere, this must be the land of fire everyone talks\n"
    << "about. Luckily you remembered to bring a flashlight.. You shine it inside the\n"
    << "cave, and flash over what seemed to be a rock. You walk over to the rock..and it"
    << "appears to be breathing!...you notice it is Helsmich's nostril..he awakens!\n"
    << "Get Ready!\n\n";
    enemy = 10;
    }
    if(alignment < 0)
    {
    cout << "The battle with the " << monsters[enemy] << " is now over. You climb the last\n"
    << "rock on the cliff, and arrive at the cave you saw earlier. You walk up to the\n"
    << "cave and scream Helsmich's name. There is fire everywhere, and you know that \n"
    << "you have arrived in the land of fire. You see Helsmich the dragon approching\n"
    << "towards you. However, your heart is so corrupt that you tell him you are on his\n"
    << "side. He snorts and tells you that if he is going to believe you, you must kill\n"
    << "your very own mother. He steps aside and reviels her to you...\n\n";
    enemy = 11;
    }
    level = 7;
    break;
    case 7:
    if(alignment >= 0)
    {
    cout << "The body of the " << monsters[enemy] << " lays accross the floor, however you\n"
    << "cannot seem to find your mother. You look around some more and discover a dark\n"
    << "and dreary portal leaning against the door. You step up to it, and peer inside.\n"
    << "A giant hand reaches out from inside, and grabs you..and you realize you have\n"
    << "been seized by a demon. You struggle free, but he does not let you escape!!!\n";
    enemy = 12;
    }
    if(alignment < 0)
    {
    cout << "The body of " << monsters[enemy] << " lays jumbled along the floor, yet you\n"
    << "couldn't care less. Helsmich is there, and he looks you in the eye, and says,\n"
    << "\"You did well, as a matter of fact, you may be strong enough to kill my most\n"
    << "fierce competitor, God!\" You look at him in disbelief, but you can't resist\n"
    << "the urge to rule god's throne. Helsmich leads you to a portal to the afterlife\n"
    << "and you step inside. Once you have arrived, a gaurdian angel blocks the door..\n\n";
    enemy = 13;
    }
    level = 8;

    break;
    case 8:
    if(alignment >= 0)
    {
    cout << "You've done it! You killed the " << monsters[enemy] << ". You realize that the\n"
    << "only way to travel further to save your mother is to kill the source of all evil"
    << ", Satan himself. You are in the realm of Hades, and you notice a long twisted\n"
    << "path leading to a throne of great stature. You walk towards it, and you realize\n"
    << "the figure sitting in the throne is Satan..and your mother is locked in a cage\n"
    << "next to him...you can no longer conceal your anger!\n\n";
    enemy = 14;
    }
    if(alignment < 0)
    {
    cout << "You've done it! You killed the " << monsters[enemy] << ". Your next goal is\n"
    << "the purest pure, God! You look around the white puffy clouds of heaven, and\n"
    << "see a shining path of gold leading up to a throne of great magnitude. You\n"
    << "begin to approach it, and take note of all the clean and shimmering clouds\n"
    << "around you. You get closer to the throne, and notice an enourmous figure\n"
    << "on it. This is God, the creater of all things good...well not for long!!\n\n";
    enemy = 15;
    }
    level = 9;
    break;
    default:
    break;
    }
    system("pause");
    system("cls");
    }
    void battlephase(int stats[4], int & enemy, int potionsize[5], string name, int & weapon, int & armor, int & money, int & mondef, int & health, int & level, int & attributes, int & alignment, int & hp, int & tp, int & deaths, int & lookaround, int upgradeitem[2], int spells[10])
    {
    //minor declaration
    char potionname[5][25] = {"Small Tonic", "Medium Tonic", "Large Tonic", "Grand Tonic", "Godly Tonic"};
    int potioneffect[5] = {6, 12, 25, 50, 100};
    char monsters[16][25] = {"Wolf", "Bear", "Bandit", "Traveler", "Gargoyle", "Knight", "Warlock", "Mammoth", "Cyclops", "Unicorn", "Dragon", "Your Mother", "Demon", "Jesus", "Satan", "God"};
    //monster strengths
    int monsterdamagemax[16] = {32, 42, 53, 53, 65, 65, 75, 75, 85, 85, 90, 90, 95, 95, 110, 110};
    int monsterdamagemin[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    int monsterdefensemax[16] = {2, 7, 13, 13, 20, 20, 25, 25, 35, 35, 40, 40, 45, 45, 55, 55};
    int monsterdefensemin[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    int monsterhealth[16] = {32, 52, 73, 73, 95, 95, 118, 118, 142, 142, 167, 167, 193, 193, 220, 220};
    int monsterspeed[16] = {7, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15};
    int monstergold[16] = {20, 30, 41, 41, 53, 53, 66, 66, 80, 80, 95, 95, 110, 110, 125, 125};
    int mdamage = 0, mdefense = 0, maccuracy = 0;
    //hero strengths
    int armorstrengthmin[10] = {0, 2, 7, 13, 20, 27, 35, 44, 54, 65};
    char armorname[10][25] = {"Rags", "Shirt", "Fur", "Leather", "Studded Leather", "Chain Mail", "Scale Mail", "Plate Mail", "Spiked Plate Mail", "Berzerker Armor"};
    int armorstrengthmax[10] = {4, 7, 13, 20, 28, 36, 45, 55, 66, 78};
    int weaponstrengthmin[10] = {4, 7, 12, 18, 25, 32, 40, 49, 59, 70};
    char weaponname[10][25] = {"Fists", "Dagger", "Club", "Axe", "Short Sword", "Cutlass", "Bastard Sword", "Long Sword", "Great Sword", "Excaliber"};
    int weaponstrengthmax[10] = {8, 12, 18, 25, 33, 42, 50, 60, 71, 83};
    int damage = 0, defense = 0, accuracy = 0;
    char options[4][25] = {"Attack", "Cast Spell", "Drink Potion", "Forfeit"};
    int decision;
    //determines whether the user used the health spell
    int healthnich = 0;
    //random numbers
    int random1, random2, randomevent, randomnum, random3, random4;
    //potion
    int potion = 0;
    //minimum monster damage
    for(int x=0;x<16;x++)
    monsterdamagemin[x] = monsterdamagemax[x] - 10;
    //minimum monster defense
    for(int x=0;x<16;x++)
    monsterdefensemin[x] = monsterdefensemax[x] - 10;
    cout << name << "(" << health << " health) VS. " << monsters[enemy] << "(" << monsterhealth[enemy] << " health)!!!";
    Sleep(2000);
    srand ((unsigned)time(0));
    random3 = (rand() % 150) + 1;
    random4 = (rand() % 50) + 1;
    do{
    //random generator
    srand ((unsigned)time(0));
    random1 = (rand() % 100) + 1;
    random2 = (rand() % 100) + 1;
    randomevent = (rand() % 20) + 1;
    randomnum = (rand() % 5) + 1;
    /***monster stats***/
    //monster's damage
    mdamage = (monsterdamagemin[enemy] + (rand()%(monsterdamagemax[enemy] - monsterdamagemin[enemy]))) - stats[1];
    //monster's defense
    mdefense = (monsterdefensemin[enemy] + (rand()%(monsterdefensemax[enemy] - monsterdefensemin[enemy])));
    //monster's accuracy
    maccuracy = (monsterspeed[enemy]*5 - stats[2]*5)+80;
    /***hero stats***/
    //hero's damage
    damage = (weaponstrengthmin[weapon] + (rand()%(weaponstrengthmax[weapon] - weaponstrengthmin[weapon]))) + stats[0] + (upgradeitem[0]*weapon+1);
    //hero's defense
    defense = (armorstrengthmin[armor] + (rand()%(armorstrengthmax[armor] - armorstrengthmin[armor]))) + (upgradeitem[0]*weapon+1);
    //hero's accuracy
    accuracy = (stats[3]*5 - monsterspeed[enemy]*5)+80;
    /***End Results***/
    //hero's overall damagage
    damage = damage - mdefense;
    //monster overall damage
    mdamage = mdamage - defense;
    system("cls");
    cout << "What would you like to do?\n\n";
    int x = 0;
    for(x;x<4;x++)
    cout << x+1 << ". " << options[x] << endl;
    cout << "\n>> ";
    cin >> decision;
    system("cls");
    switch(decision)
    {
    case 1:
    if(random1<=accuracy)
    {
    if(damage < 5)
    damage = 5;
    monsterhealth[enemy] = monsterhealth[enemy] - damage;
    cout << "You took " << damage << " health points away from the opponent! \n";
    if(monsterhealth[enemy]<0)
    monsterhealth[enemy] = 0;
    cout << "\nThe opponent has " << monsterhealth[enemy] << " health points left!!\nYou have " << health << " health points left.\n\n";
    }
    else
    cout << "You missed!\n\n";
    break;
    case 2:
    do{
    cout << "Which spell would you like to cast?\n\n";
    for(x=0;x<10;x++)
    cout << x+1 << ". " << spellname[x] << ": " << spells[x] << " left" << endl;
    cout << "11. Leave\n\n>> ";
    cin >> decision;
    system("cls");
    }while((decision<1)&&(decision>11)||(spells[decision-1]==0));
    switch(decision)
    {
    case 1:
    monsterhealth[enemy] -= random4;
    break;
    case 2:
    mdamage -= 5;
    break;
    case 3:
    mdefense -= 5;
    break;
    case 4:
    accuracy += 10;
    break;
    case 5:
    maccuracy -= 10;
    break;
    case 6:
    health += random3;
    healthnich = 1;
    break;
    case 7:
    damage += 5;
    break;
    case 8:
    defense += 5;
    break;
    case 9:
    maccuracy -= 10;
    break;
    case 10:
    accuracy += 10;
    break;
    }
    if(decision != 11)
    {
    spells[decision-1]-=1;
    cout << "You have successfully used the " << spellname[decision-1] << "!\n\n";
    }
    system("pause");
    break;
    case 3:
    do{
    cout << "Which potion would you like to drink?" << endl << endl
    << "****Potions****" << endl
    << "-----------" << endl;
    for(int x=0;x<5;x++)
    cout << x+1 << ". " << potionsize[x] << " " << potionname[x] << "(s)" << endl;
    cout << "6. Leave\n";
    cout << "-----------" << endl << endl << ">> ";
    cin >> potion;
    system("cls");
    if(potion==6)
    cout << "bye\n\n";
    else if(potionsize[potion-1] == 0)
    cout << "Sorry, you do not have any more of these potions!\n\n";
    else
    {
    health = health + potioneffect[potion-1];
    potionsize[potion-1] = potionsize[potion-1] - 1;
    cout << "You have succesfully drank a " << potionname[potion-1] << "!!! \nYou gained " << potioneffect[potion-1] << " health! \nYou now have " << health << " health.";
    }
    }while(potion!=6);
    break;
    system("pause");
    system("cls");
    }
    system("pause");
    system("cls");
    if((decision==1)||(decision==2))
    {
    if(monsterhealth[enemy]>0)
    {
    system("cls");
    if(random2<=maccuracy)
    {
    if(mdamage < 5)
    mdamage = 5;
    health = health - mdamage;
    cout << "Opponent took " << mdamage << " health points away from You! \n\nThe opponent has " << monsterhealth[enemy] << " health points left.\nYou have ";
    if(health<0)
    health = 0;
    cout << health << " health points left.\n\n";
    }
    else
    cout << "Opponent missed!\n\n";
    system("pause");
    system("cls");
    }
    }
    }while((monsterhealth[enemy]>0)&&(health>0)&&(decision!=4));
    system("cls");
    if(monsterhealth[enemy]>0)
    {
    cout << "You lost to a " << monsters[enemy] << "!\nSince He is still alive, you will have to face him again.\nYou have also gained 1 attribute point for your hindered efforts.\n\nYour Health has risen to 100 pts.\n\n";
    attributes += 1;
    enemy = enemy-1;
    level = level-1;
    if(money < 0)
    money = 0;
    health = 100;
    deaths += 1;
    }
    else
    {
    if(healthnich == 1)
    {
    cout << "Your health has gone down " << random3 << " since the spell ended!\n";
    health -= random3;
    if(health < 1)
    health = 1;
    cout << "Your health is now " << health << "!";
    }
    mondef++;
    money = money + monstergold[enemy];
    attributes = attributes + 2;
    tp += 2;
    hp += 1;
    lookaround = 1;
    cout << "Congratulations on your victory!\n\n"
    << "You gained " << monstergold[enemy] << " gold
  • good job bro :)