Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream> //preprocessor directive
- #include <iomanip>
- #include <cmath>
- #include <string>
- using namespace std;
- int main()
- {
- string playerName, beastName, beastRank, choice;
- int beastGrade = 0;//1-60 is common, 61-80 is uncommon, 81-95 is rare, 96-100 is legendary
- int beastRandom = 0;//1-20 is a boar, 21-35 is a slime, 36-50 is a goblin, 51-65 is a troll, 66-80 is a skeleton, 81-95 is a bandit, 96-100 is a dragon
- cout << "Enter your player name and enter.\n"; //ask for the name of player
- getline(cin, playerName);
- cin.clear();
- int shop, shopLoop;
- int playerLevel = 1;
- int playerExtraDamage = 0;
- int playerExp = 0;
- int playerGold = 5;
- int playerGoldToGive = 0;
- int playerExpNeeded = 10;
- int playerHealth = 100;
- int playerMaxHealth = 100;
- int enemyHealth = 100;
- int playerPotionCount = 3;
- int gameContinue = 0;
- while (gameContinue == 0)
- {
- cin.clear();
- system("CLS");
- cout << "What do you want to do " << playerName << "?\n\n[1] Go adventuring.\n[2] Go to the shop.\n[3] See your stats and inventory.\n[4] End the game.\n";
- cin >> choice;
- if (choice == "1")
- {
- system("CLS");
- srand(time(NULL));//sets random set to current time so always unique
- beastRandom = rand() % 100 + 1;
- beastGrade = rand() % 100 + 1;
- if (beastRandom >= 96 && beastRandom <= 100)
- {
- beastName = "dragon";
- playerGoldToGive = 100;
- }
- else if (beastRandom > 80 && beastRandom < 96)
- {
- beastName = "bandit";
- playerGoldToGive = 5;
- }
- else if (beastRandom >= 66 && beastRandom <= 80)
- {
- beastName = "skeleton";
- playerGoldToGive = 3;
- }
- else if (beastRandom >= 51 && beastRandom < 66)
- {
- beastName = "troll";
- playerGoldToGive = 7;
- }
- else if (beastRandom >= 36 && beastRandom < 51)
- {
- beastName = "goblin";
- playerGoldToGive = 2;
- }
- else if (beastRandom >= 21 && beastRandom < 36)
- {
- beastName = "slime";
- playerGoldToGive = 5;
- }
- else if (beastRandom >= 0 && beastRandom < 21)
- {
- beastName = "boar";
- playerGoldToGive = 1;
- }
- if (beastGrade >= 96 && beastGrade <= 100)
- {
- beastRank = "legendary";
- playerGoldToGive *= 5;
- }
- else if (beastGrade > 80 && beastGrade < 96)
- {
- beastRank = "rare";
- playerGoldToGive *= 3;
- }
- else if (beastGrade >= 61 && beastGrade <= 80)
- {
- beastRank = "uncommon";
- playerGoldToGive *= 2;
- }
- else if (beastGrade >= 0 && beastGrade < 61)
- {
- beastRank = "common";
- playerGoldToGive *= 1;
- }
- cout << "You've encountered a " << beastRank << " " << beastName << ". You've gained " << playerGoldToGive << " gold." << endl;
- playerGold += playerGoldToGive;
- system("pause");
- }
- else if (choice == "2")
- {
- system("CLS");
- shopLoop = 0;
- //cout << "You've come to the shop. There's several items on display.\n\n[1] Health potion << 5 Gold\n[2] Steel Sword +10 damage << 30 Gold\n[3] Leave the Shop\n";
- //cin >> shop;
- while (shopLoop == 0)
- {
- system("CLS");
- cout << "You've come to the shop. There's several items on display.\n\n[1] Health potion << 5 Gold\n[2] Steel Sword +10 damage << 30 Gold\n[3] Strength potion << 5 gold\n";
- cout << "[4] Pet Dragon +50 damage << 100 gold\n[5] Stamina potion << 5 Gold\n[6] Bronze Sword +20 damage << 60 Gold\n[7] Leave the shop\n";
- cin >> shop;
- if (shop == 1)
- {
- if (playerGold >= 5)
- {
- system("CLS");
- playerGold -= 5;
- playerPotionCount += 1;
- cout << "You've bought a Health potion.\n";
- system("pause");
- }
- else
- {
- system("CLS");
- cout << "You don't have enough money to buy a Health potion.\n";
- system("pause");
- }
- }
- else if (shop == 2)
- {
- if (playerExtraDamage == 0)
- {
- if (playerGold >= 30)
- {
- system("CLS");
- playerExtraDamage = 10;
- playerGold -= 30;
- cout << "You've bought a Steel Sword!. We are now out of stock.\n";
- system("pause");
- }
- else
- {
- system("CLS");
- cout << "You don't have enough money to buy the Steel Sword.\n";
- system("pause");
- }
- }
- else
- {
- system("CLS");
- cout << "You have already bought the Steel Sword. We are out of stock.\n";
- system("pause");
- }
- }
- else if (shop == 3)
- {
- if (playerExtraDamage >= 0)
- {
- if (playerGold >= 5)
- {
- system("CLS");
- playerGold -= 5;
- playerPotionCount += 1;
- playerExtraDamage += 1;
- cout << "You've purchased a Strength potion!\n";
- system("pause");
- }
- }
- else
- {
- system("CLS");
- cout << "You do not have enough currency for a Strength potion.\n";
- system("pause");
- }
- }
- else if (shop == 4)
- {
- if (playerExtraDamage < 50)
- {
- if (playerGold >= 100)
- {
- system("CLS");
- playerExtraDamage += 50;
- playerGold -= 100;
- cout << "You've purchased a pet dragon! We are out of stock\n";
- system("pause");
- }
- else
- {
- system("CLS");
- cout << "You do not have enough money for the pet dragon\n";
- system("pause");
- }
- }
- else
- {
- system("CLS");
- cout << "You have already bought the pet dragon. We longer have this.\n";
- system("pause");
- }
- }
- else if (shop == 5)
- {
- if (playerGold >= 5)
- {
- system("CLS");
- playerGold -= 5;
- playerPotionCount += 1;
- cout << "You have purchased a Stamina potion!\n";
- system("pause");
- }
- else
- {
- system("CLS");
- cout << "You do not have the required money for a Stamina potion.\n";
- system("pause");
- }
- }
- else if (shop == 6)
- {
- if (playerExtraDamage < 20)
- {
- if (playerGold >= 60)
- {
- system("CLS");
- playerExtraDamage += 20;
- playerGold -= 60;
- cout << "You've purchased a Bronze Sword! We are out of stock now.\n";
- system("pause");
- }
- else
- {
- system("CLS");
- cout << "You do not enough money for the Bronze Sword.\n";
- system("pause");
- }
- }
- else
- {
- system("CLS");
- cout << "You have already bought the Bronze Sword. There are no more available.\n";
- system("pause");
- }
- }
- else if (shop == 7)
- {
- system("CLS");
- shopLoop = 1;
- }
- }
- }
- else if (choice == "3")
- {
- system("CLS");
- cout << "Your stats:\nHealth: " << playerHealth << "/" << playerMaxHealth << endl;
- cout << "Level: " << playerLevel << endl;
- cout << "Gold: " << playerGold << endl;
- cout << "Potions: " << playerPotionCount << endl;
- cout << "Weapons and Equipment:\n";
- if (playerExtraDamage >= 10 && playerExtraDamage < 20)
- {
- cout << "-Steel Sword +10 Damage\n";
- }
- else if (playerExtraDamage >= 20 && playerExtraDamage < 30)
- {
- cout << "-Bronze Sword +20 Damage\n";
- }
- else if (playerExtraDamage >= 30 && playerExtraDamage < 50)
- {
- cout << "-Steel Sword +10 Damage\n";
- cout << "-Bronze Sword +20 Damage\n";
- }
- else if (playerExtraDamage == 50)
- {
- cout << "-Pet Dragon +50 Damage\n";
- }
- else if (playerExtraDamage > 50)
- {
- cout << "-Steel Sword +10 Damage\n";
- cout << "-Bronze Sword +20 Damage\n";
- cout << "-Pet Dragon +50 Damage\n";
- }
- else
- {
- cout << "No weapons and/or equipment.\n";
- }
- system("pause");
- }
- else if (choice == "4")
- {
- system("CLS");
- gameContinue = 1;
- cout << "Thanks for playing!\n";
- }
- else
- {
- system("CLS");
- cout << "Invalid input.\n";
- system("pause");
- }
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement