Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- int gameShop(float charMoney, float charHealth, float charInv);
- int gameFight(float charMoney, float charHealth, float charInv);
- int first(float charMoney, float charHealth, float charInv);
- int inventory(float charMoney, float charHealth, float charInv);
- int gameSettings(float charMoney, float charHealth, float charInv);
- int main()
- {
- float charHealth = 100;
- float charMoney = 30;
- float charInv = 0;
- cout << first(charMoney, charHealth, charInv);
- }
- int first(float charMoney, float charHealth, float charInv)
- {
- string mainChoice;
- cout << "You have " << charMoney << " GP" << endl;
- cout << "You have " << charHealth << " health" << endl << endl;
- cout << "What would you like to do?" << endl << endl;
- cout << "1. Shop" << endl;
- cout << "2. Fight" << endl;
- cout << "3. My medalians" << endl;
- cout << "4. Settings" << endl << endl;
- cout << "Choice: ";
- cin >> mainChoice;
- if(mainChoice == "1")
- {
- cout << gameShop(charMoney, charHealth, charInv);
- }
- else if(mainChoice == "2")
- {
- cout << gameFight(charMoney, charHealth, charInv);
- }
- else if(mainChoice == "3")
- {
- cout << inventory(charMoney, charHealth, charInv);
- }
- else
- {
- system("cls");
- cout << "ERROR: That was not a choice. Please try again." << endl << endl;
- system("PAUSE");
- cout << first(charMoney, charHealth, charInv);
- system("cls");
- }
- }
- int gameShop(float charMoney, float charHealth, float charInv)
- {
- string shopChoice, buyChoice;
- float itemPrice, itemPurchase;
- system("cls");
- cout << "You have " << charMoney << " GP" << endl << endl;
- cout << "What would you like to buy?" << endl << endl;
- cout << "1. Medalion One - 50 GP" << endl;
- cout << "2. Medalion Two - 100 GP" << endl;
- cout << "3. Medalion Three - 150 GP" << endl;
- cout << "4. Medalion Four - 250 GP" << endl;
- cout << "5. Full Health - 75 GP" << endl;
- cout << "6. Back to main menu" << endl << endl;
- cout << "Choice: ";
- cin >> shopChoice;
- //Madalion One
- if(shopChoice == "1")
- {
- system("cls");
- cout << "Are you sure that you would like to make this purchase?" << endl;
- cout << "1 = Yes. 2 = No." << endl << endl;
- cout << "Choice: ";
- cin >> buyChoice;
- if(buyChoice == "1")
- {
- itemPrice = 50;
- if(charMoney < 50)
- {
- system("cls");
- cout << "ERROR: You do not have enough to make this purchase." << endl << endl;
- system("PAUSE");
- system("cls");
- cout << gameShop(charMoney, charHealth, charInv);
- }
- else if(charInv == 1)
- {
- system("cls");
- cout << "ERROR: You already have this medalion!" << endl << endl;
- system("PAUSE");
- system("cls");
- cout << gameShop(charMoney, charHealth, charInv);
- }
- else if(charInv == 2)
- {
- system("cls");
- cout << "ERROR: You already have this medalion!" << endl << endl;
- system("PAUSE");
- system("cls");
- cout << gameShop(charMoney, charHealth, charInv);
- }
- else if(charInv == 3)
- {
- system("cls");
- cout << "ERROR: You already have this medalion!" << endl << endl;
- system("PAUSE");
- system("cls");
- cout << gameShop(charMoney, charHealth, charInv);
- }
- else if(charInv == 4)
- {
- system("cls");
- cout << "ERROR: You already have this medalion!" << endl << endl;
- system("PAUSE");
- system("cls");
- cout << gameShop(charMoney, charHealth, charInv);
- }
- }
- else if(buyChoice == "2")
- {
- system("cls");
- cout << gameShop(charMoney, charHealth, charInv);
- }
- else
- {
- system("cls");
- cout << "ERROR: That was not an option. Please try again." << endl << endl;
- system("PAUSE");
- system("cls");
- cout << gameShop(charMoney, charHealth, charInv);
- }
- charMoney = charMoney - itemPrice;
- charInv = 1;
- system("cls");
- cout << "Purchase is complete!" << endl << endl;
- system("PAUSE");
- system("cls");
- cout << gameShop(charMoney, charHealth, charInv);
- }
- //Medalion Two
- if(shopChoice == "2")
- {
- system("cls");
- cout << "Are you sure that you would like to make this purchase?" << endl;
- cout << "1 = Yes. 2 = No." << endl << endl;
- cout << "Choice: ";
- cin >> buyChoice;
- if(buyChoice == "1")
- {
- itemPrice = 100;
- if(charMoney < 100)
- {
- system("cls");
- cout << "ERROR: You do not have enough to make this purchase." << endl << endl;
- system("PAUSE");
- system("cls");
- cout << gameShop(charMoney, charHealth, charInv);
- }
- else if(charInv == 0)
- {
- system("cls");
- cout << "ERROR: You have to buy the previous medalion first!" << endl << endl;
- system("PAUSE");
- system("cls");
- cout << gameShop(charMoney, charHealth, charInv);
- }
- else if(charInv == 2)
- {
- system("cls");
- cout << "ERROR: You already have this medalion!" << endl << endl;
- system("PAUSE");
- system("cls");
- cout << gameShop(charMoney, charHealth, charInv);
- }
- else if(charInv == 3)
- {
- system("cls");
- cout << "ERROR: You need to buy the previous medallions first!" << endl << endl;
- system("PAUSE");
- system("cls");
- cout << gameShop(charMoney, charHealth, charInv);
- }
- else if(charInv == 4)
- {
- system("cls");
- cout << "ERROR: You need to buy the previous medallions first!" << endl << endl;
- system("PAUSE");
- system("cls");
- cout << gameShop(charMoney, charHealth, charInv);
- }
- }
- else if(buyChoice == "2")
- {
- system("cls");
- cout << gameShop(charMoney, charHealth, charInv);
- }
- else
- {
- system("cls");
- cout << "ERROR: That was not an option. Please try again." << endl << endl;
- system("PAUSE");
- system("cls");
- cout << gameShop(charMoney, charHealth, charInv);
- }
- charInv = 2;
- charMoney = charMoney - itemPrice;
- system("cls");
- cout << "Purchase is complete!" << endl << endl;
- system("PAUSE");
- system("cls");
- cout << gameShop(charMoney, charHealth, charInv);
- }
- //Medalion Three
- if(shopChoice == "3")
- {
- system("cls");
- cout << "Are you sure that you would like to make this purchase?" << endl;
- cout << "1 = Yes. 2 = No." << endl << endl;
- cout << "Choice: ";
- cin >> buyChoice;
- if(buyChoice == "1")
- {
- itemPrice = 150;
- if(charMoney < 150)
- {
- system("cls");
- cout << "ERROR: You do not have enough to make this purchase." << endl << endl;
- system("PAUSE");
- system("cls");
- cout << gameShop(charMoney, charHealth, charInv);
- }
- else if(charInv == 0)
- {
- system("cls");
- cout << "ERROR: You have to buy the previous medalion first!" << endl << endl;
- system("PAUSE");
- system("cls");
- cout << gameShop(charMoney, charHealth, charInv);
- }
- else if(charInv == 1)
- {
- system("cls");
- cout << "ERROR: You have to buy the previous medalion first!" << endl << endl;
- system("PAUSE");
- system("cls");
- cout << gameShop(charMoney, charHealth, charInv);
- }
- else if(charInv == 3)
- {
- system("cls");
- cout << "ERROR: You already have this medalion!" << endl << endl;
- system("PAUSE");
- system("cls");
- cout << gameShop(charMoney, charHealth, charInv);
- }
- else if(charInv == 4)
- {
- system("cls");
- cout << "ERROR: You already have this medalion!" << endl << endl;
- system("PAUSE");
- system("cls");
- cout << gameShop(charMoney, charHealth, charInv);
- }
- }
- else if(buyChoice == "2")
- {
- system("cls");
- cout << gameShop(charMoney, charHealth, charInv);
- }
- else
- {
- system("cls");
- cout << "ERROR: That was not an option. Please try again." << endl << endl;
- system("PAUSE");
- system("cls");
- cout << gameShop(charMoney, charHealth, charInv);
- }
- charInv = 3;
- charMoney = charMoney - itemPrice;
- system("cls");
- cout << "Purchase is complete!" << endl << endl;
- system("PAUSE");
- system("cls");
- cout << gameShop(charMoney, charHealth, charInv);
- }
- //Medalion Four
- if(shopChoice == "4")
- {
- system("cls");
- cout << "Are you sure that you would like to make this purchase?" << endl;
- cout << "1 = Yes. 2 = No." << endl << endl;
- cout << "Choice: ";
- cin >> buyChoice;
- if(buyChoice == "1")
- {
- itemPrice = 250;
- if(charMoney < 250)
- {
- system("cls");
- cout << "ERROR: You do not have enough to make this purchase." << endl << endl;
- system("PAUSE");
- system("cls");
- cout << gameShop(charMoney, charHealth, charInv);
- }
- else if(charInv == 0)
- {
- system("cls");
- cout << "ERROR: You have to buy the previous medallions first!" << endl << endl;
- system("PAUSE");
- system("cls");
- cout << gameShop(charMoney, charHealth, charInv);
- }
- else if(charInv == 1)
- {
- system("cls");
- cout << "ERROR: You have to buy the previous medallions first!" << endl << endl;
- system("PAUSE");
- system("cls");
- cout << gameShop(charMoney, charHealth, charInv);
- }
- else if(charInv == 2)
- {
- system("cls");
- cout << "ERROR: You have to buy the previous medallions first!" << endl << endl;
- system("PAUSE");
- system("cls");
- cout << gameShop(charMoney, charHealth, charInv);
- }
- else if(charInv == 4)
- {
- system("cls");
- cout << "ERROR: You already have this medalion!" << endl << endl;
- system("PAUSE");
- system("cls");
- cout << gameShop(charMoney, charHealth, charInv);
- }
- }
- else if(buyChoice == "2")
- {
- system("cls");
- cout << gameShop(charMoney, charHealth, charInv);
- }
- else
- {
- system("cls");
- cout << "ERROR: That was not an option. Please try again." << endl << endl;
- system("PAUSE");
- system("cls");
- cout << gameShop(charMoney, charHealth, charInv);
- }
- charInv = 4;
- charMoney = charMoney - itemPrice;
- system("cls");
- cout << "Purchase is complete!" << endl << endl;
- system("PAUSE");
- system("cls");
- cout << gameShop(charMoney, charHealth, charInv);
- }
- //Full Health
- if(shopChoice == "5")
- {
- system("cls");
- cout << "Are you sure that you would like to make this purchase?" << endl;
- cout << "1 = Yes. 2 = No." << endl << endl;
- cout << "Choice: ";
- cin >> buyChoice;
- if(buyChoice == "1")
- {
- itemPrice = 75;
- if(charMoney < 75)
- {
- cout << "ERROR: You don't have enough money to purchase this." << endl << endl;
- system("PAUSE");
- cout << gameShop(charMoney, charHealth, charInv);
- }
- system("cls");
- }
- else if(buyChoice == "2")
- {
- system("cls");
- cout << gameShop(charMoney, charHealth, charInv);
- }
- else
- {
- system("cls");
- cout << "ERROR: That was not a choice." << endl << endl;
- system("PAUSE");
- system("cls");
- cout << cout << gameShop(charMoney, charHealth, charInv);
- }
- charMoney = charMoney - itemPrice;
- charHealth = 100;
- system("cls");
- cout << "Purchase complete!" << endl << endl;
- system("PAUSE");
- system("cls");
- cout << gameShop(charMoney, charHealth, charInv);
- }
- if(shopChoice == "6")
- {
- system("cls");
- cout << first(charMoney, charHealth, charInv);
- }
- else
- {
- system("cls");
- cout << "ERROR: That was not an option." << endl << endl;
- system("PAUSE");
- system("cls");
- cout << gameShop(charMoney, charHealth, charInv);
- }
- }
- int gameFight(float charMoney, float charHealth, float charInv)
- {
- string fightChoice;
- float monsterHealth, monsterAttack, cashPrize, charAttack;
- srand(static_cast<unsigned int>(time(0)));
- charAttack = rand()%10 + 10;
- system("cls");
- cout << "Who would you like to fight?" << endl << endl;
- cout << "1. Ratman" << endl;
- cout << "2. Vampire" << endl;
- cout << "3. Giant" << endl;
- cout << "4. Boss (Secret until you get there. hehehe)" << endl;
- cout << "5. Go back to main menu" << endl << endl;
- cout << "Choice: ";
- cin >> fightChoice;
- while( 0 < 1 )
- {
- if(fightChoice == "1")
- {
- while( 0 < 1 )
- {
- srand(static_cast<unsigned int>(time(0)));
- monsterAttack = rand()%15 + 5;
- monsterHealth = 20;
- cashPrize = 30;
- monsterHealth = (monsterHealth - charAttack);
- charHealth = (charHealth - monsterAttack);
- if(monsterHealth < 0)
- {
- system("cls");
- cout << "You delt " << charAttack << " damage!" << endl;
- cout << "You opponant delt " << monsterAttack << " damage!" << endl << endl;
- cout << "You win!" << endl << endl;
- charHealth = (charHealth + monsterHealth);
- charMoney = (charMoney + cashPrize);
- system("PAUSE");
- cout << gameFight(charMoney, charHealth, charInv);
- }
- else if(charHealth < 0)
- {
- system("cls");
- cout << "You delt " << charAttack << " damage!" << endl;
- cout << "You opponant delt " << monsterAttack << " damage!" << endl << endl;
- cout << "You lose!" << endl << endl;
- charHealth = 100;
- charMoney = (charMoney / 3);
- system("PAUSE");
- cout << cout << gameFight(charMoney, charHealth, charInv);
- }
- else
- {
- srand(static_cast<unsigned int>(time(0)));
- charAttack = rand()%25 + 10;
- system("cls");
- cout << "You delt " << charAttack << " damage!" << endl;
- cout << "You opponant delt " << monsterAttack << " damage!" << endl << endl;
- system("PAUSE");
- }
- }
- }
- if(fightChoice == "2")
- {
- while( 0 < 1 )
- {
- srand(static_cast<unsigned int>(time(0)));
- monsterAttack = rand()%15 + 5;
- monsterHealth = 40;
- cashPrize = 60;
- monsterHealth = (monsterHealth - charAttack);
- charHealth = (charHealth - monsterAttack);
- if(monsterHealth < 0)
- {
- system("cls");
- cout << "You delt " << charAttack << " damage!" << endl;
- cout << "You opponant delt " << monsterAttack << " damage!" << endl << endl;
- cout << "You win!" << endl << endl;
- charHealth = (charHealth + monsterHealth);
- charMoney = (charMoney + cashPrize);
- system("PAUSE");
- cout << gameFight(charMoney, charHealth, charInv);
- }
- else if(charHealth < 0)
- {
- system("cls");
- cout << "You delt " << charAttack << " damage!" << endl;
- cout << "You opponant delt " << monsterAttack << " damage!" << endl << endl;
- cout << "You lose!" << endl << endl;
- charHealth = 100;
- charMoney = (charMoney / 3);
- system("PAUSE");
- cout << cout << gameFight(charMoney, charHealth, charInv);
- }
- else
- {
- srand(static_cast<unsigned int>(time(0)));
- charAttack = rand()%25 + 10;
- system("cls");
- cout << "You delt " << charAttack << " damage!" << endl;
- cout << "You opponant delt " << monsterAttack << " damage!" << endl << endl;
- system("PAUSE");
- }
- }
- }
- if(fightChoice == "3")
- {
- while( 0 < 1 )
- {
- srand(static_cast<unsigned int>(time(0)));
- monsterAttack = rand()%15 + 5;
- monsterHealth = 60;
- cashPrize = 100;
- monsterHealth = (monsterHealth - charAttack);
- charHealth = (charHealth - monsterAttack);
- if(monsterHealth < 0)
- {
- system("cls");
- cout << "You delt " << charAttack << " damage!" << endl;
- cout << "You opponant delt " << monsterAttack << " damage!" << endl << endl;
- cout << "You win!" << endl << endl;
- charHealth = (charHealth + monsterHealth);
- charMoney = (charMoney + cashPrize);
- system("PAUSE");
- cout << gameFight(charMoney, charHealth, charInv);
- }
- else if(charHealth < 0)
- {
- system("cls");
- cout << "You delt " << charAttack << " damage!" << endl;
- cout << "You opponant delt " << monsterAttack << " damage!" << endl << endl;
- cout << "You lose!" << endl << endl;
- charHealth = 100;
- charMoney = (charMoney / 3);
- system("PAUSE");
- cout << cout << gameFight(charMoney, charHealth, charInv);
- }
- else
- {
- srand(static_cast<unsigned int>(time(0)));
- charAttack = rand()%25 + 10;
- system("cls");
- cout << "You delt " << charAttack << " damage!" << endl;
- cout << "You opponant delt " << monsterAttack << " damage!" << endl << endl;
- system("PAUSE");
- }
- }
- }
- if(fightChoice == "4")
- {
- while( 0 < 1 )
- {
- srand(static_cast<unsigned int>(time(0)));
- monsterAttack = rand()%60 + 15;
- monsterHealth = 100;
- cashPrize = 250;
- monsterHealth = (monsterHealth - charAttack);
- charHealth = (charHealth - monsterAttack);
- if(monsterHealth < 0)
- {
- system("cls");
- cout << "You delt " << charAttack << " damage!" << endl;
- cout << "You opponant delt " << monsterAttack << " damage!" << endl << endl;
- cout << "You win!" << endl << endl;
- charHealth = (charHealth + monsterHealth);
- charMoney = (charMoney + cashPrize);
- system("PAUSE");
- cout << gameFight(charMoney, charHealth, charInv);
- }
- else if(charHealth < 0)
- {
- system("cls");
- cout << "You delt " << charAttack << " damage!" << endl;
- cout << "You opponant delt " << monsterAttack << " damage!" << endl << endl;
- cout << "You lose!" << endl << endl;
- charHealth = 100;
- charMoney = (charMoney / 3);
- system("PAUSE");
- cout << cout << gameFight(charMoney, charHealth, charInv);
- }
- else
- {
- srand(static_cast<unsigned int>(time(0)));
- charAttack = rand()%25 + 10;
- cout << "You delt " << charAttack << " damage!" << endl;
- cout << "You opponant delt " << monsterAttack << " damage!" << endl << endl;
- system("PAUSE");
- }
- }
- }
- else if(fightChoice == "5")
- {
- system("cls");
- cout << first(charMoney, charHealth, charInv);
- }
- }
- }
- int inventory(float charMoney, float charHealth, float charInv)
- {
- system("cls");
- if(charInv == 0)
- {
- cout << "My medallions: " << endl << endl;
- cout << "You have no medallions...." << endl << endl;
- system("PAUSE");
- system("cls");
- cout << first(charMoney, charHealth, charInv);
- }
- if(charInv == 1)
- {
- cout << "My medallions: " << endl << endl;
- cout << "1. Medallion One" << endl << endl;
- system("PAUSE");
- system("cls");
- cout << first(charMoney, charHealth, charInv);
- }
- if(charInv == 2)
- {
- cout << "My medallions: " << endl << endl;
- cout << "1. Medallion One" << endl;
- cout << "2. Medallion Two" << endl << endl;
- system("PAUSE");
- system("cls");
- cout << first(charMoney, charHealth, charInv);
- }
- if(charInv == 3)
- {
- cout << "My medallions: " << endl << endl;
- cout << "1. Medallion One" << endl;
- cout << "2. Medallion Two" << endl;
- cout << "3. Medallion Three" << endl << endl;
- system("PAUSE");
- system("cls");
- cout << first(charMoney, charHealth, charInv);
- }
- if(charInv == 4)
- {
- cout << "My medallions: " << endl << endl;
- cout << "1. Medallion One" << endl;
- cout << "2. Medallion Two" << endl;
- cout << "3. Medallion Three" << endl;
- cout << "4. Medallion Four" << endl << endl;
- cout << "You have all four! Go fight le boss!" << endl << endl;
- system("PAUSE");
- system("cls");
- cout << first(charMoney, charHealth, charInv);
- }
- }
- int gameSettings(float charMoney, float charHealth, float charInv)
- {
- system("cls");
- cout << "This function is not quite ready!" << endl << endl;
- system("PAUSE");
- system("cls");
- cout << first(charMoney, charHealth, charInv);
- cout << "Choose a setting that you would like to edit: ";
- cout << "1. Color" << endl;
- }
Add Comment
Please, Sign In to add comment