Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Dominic Grant, Muhammad Qureshi, Nathan Galdamez Gomez
- 03/21/2019
- Software Engineering Project*/
- #include <iostream> //preprocessor directive
- #include <iomanip>//preprocessor directive
- #include <cmath>//preprocessor directive
- #include <string>//preprocessor directive
- #include <cstdlib>//preprocessor directive
- 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 playerene
- getline(cin, playerName);
- cin.clear();
- int shop, shopLoop;
- int playerLevel = 1;
- int playerBaseDamage = 5;
- int playerExtraDamage = 0;
- int playerExp = 0;
- int playerExpToGive = 0;
- int playerGold = 5;
- int playerGoldToGive = 0;
- int playerExpNeeded = 10;
- int playerHealth = 100;
- int playerMaxHealth = 100;
- int enemyHealth = 100;
- int playerPotionCount = 3;
- int dragonOwned = 0;
- int enemyAttack = 0;
- 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;
- playerExpToGive = 75;
- enemyAttack = 50;
- enemyHealth = 150;
- }
- else if (beastRandom > 80 && beastRandom < 96)
- {
- beastName = "bandit";
- playerGoldToGive = 5;
- playerExpToGive = 15;
- enemyAttack = 15;
- enemyHealth = 60;
- }
- else if (beastRandom >= 66 && beastRandom <= 80)
- {
- beastName = "skeleton";
- playerGoldToGive = 3;
- playerExpToGive = 5;
- enemyAttack = 8;
- enemyHealth = 30;
- }
- else if (beastRandom >= 51 && beastRandom < 66)
- {
- beastName = "troll";
- playerGoldToGive = 7;
- playerExpToGive = 20;
- enemyAttack = 20;
- enemyHealth = 70;
- }
- else if (beastRandom >= 36 && beastRandom < 51)
- {
- beastName = "goblin";
- playerGoldToGive = 2;
- playerExpToGive = 3;
- enemyAttack = 5;
- enemyHealth = 20;
- }
- else if (beastRandom >= 21 && beastRandom < 36)
- {
- beastName = "slime";
- playerGoldToGive = 5;
- playerExpToGive = 3;
- enemyAttack = 5;
- enemyHealth = 10;
- }
- else if (beastRandom >= 0 && beastRandom < 21)
- {
- beastName = "boar";
- playerGoldToGive = 1;
- playerExpToGive = 5;
- enemyAttack = 5;
- enemyHealth = 15;
- }
- if (beastGrade >= 96 && beastGrade <= 100)
- {
- beastRank = "legendary";
- playerGoldToGive *= 5;
- playerExpToGive *= 3;
- enemyAttack *= 4;
- enemyHealth *= 4;
- }
- else if (beastGrade > 80 && beastGrade < 96)
- {
- beastRank = "rare";
- playerGoldToGive *= 3;
- playerExpToGive *= 2;
- enemyAttack *= 3;
- enemyHealth *= 3;
- }
- else if (beastGrade >= 61 && beastGrade <= 80)
- {
- beastRank = "uncommon";
- playerGoldToGive *= 2;
- playerExpToGive *= 1.5;
- enemyAttack *= 2;
- enemyHealth *= 2;
- }
- else if (beastGrade >= 0 && beastGrade < 61)
- {
- beastRank = "common";
- playerGoldToGive *= 1;
- }
- cout << "You've encountered a " << beastRank << " " << beastName << "." << endl;
- cout << "What do you want to do " << playerName << "?\n\n[1] Fight.\n[2] Run.\n";
- cin >> choice;
- //cout << "enemy health is: " << enemyHealth << endl;
- if (choice == "1") {
- //cout << "1 sword attack";
- //cin >> choice;
- cout << "enemy health is: " << enemyHealth << endl;
- string beastFullName = beastRank + " " + beastName;
- int dragonCooldown = 0;
- int attackChoice = 0;
- while (enemyHealth > 0 && playerHealth > 0)
- {
- cout << "\n\n Pick an attack: \n[1] Punch \n[2] Sword Slash.\n";
- if (dragonOwned == 1 && dragonCooldown == 0)
- {
- cout << "[3] Dragon attack \n" << endl;
- }
- if (playerPotionCount > 0)
- {
- cout << "[0] Health potion \n" << endl;
- }
- cin >> attackChoice;
- system("CLS");
- if (attackChoice == 1)
- {
- enemyHealth = enemyHealth - playerBaseDamage;
- cout << "The enemy health is:" << enemyHealth << endl;
- dragonCooldown = 0;
- if (enemyHealth > 0)
- {
- cout << "The " << beastFullName << " attacks you and deals you " << enemyAttack << " damage." << endl;
- playerHealth -= enemyAttack;
- cout << "You now have " << playerHealth << " health remaining from your max health of " << playerMaxHealth << "." << endl;
- if (playerHealth <= 0)
- {
- cout << "You died to the monster. You resurrect at a church." << endl;
- }
- }
- }
- else if (attackChoice == 2)
- {
- enemyHealth = enemyHealth - (playerBaseDamage + playerExtraDamage + 5);//5 is what im calling the damage for a basic beginner sword
- cout << "The enemy health is: " << enemyHealth << endl;
- dragonCooldown = 0;
- if (enemyHealth > 0)
- {
- cout << "The " << beastFullName << " attacks you and deals you " << enemyAttack << " damage." << endl;
- playerHealth -= enemyAttack;
- cout << "You now have " << playerHealth << " health remaining from your max health of " << playerMaxHealth << "." << endl;
- if (playerHealth <= 0)
- {
- cout << "You died to the monster. You resurrect at a church." << endl;
- }
- }
- }
- else if (attackChoice == 3 && dragonOwned == 1 && dragonCooldown == 0)
- {
- enemyHealth = enemyHealth - 50;
- cout << "The enemy health is: " << enemyHealth << endl;
- dragonCooldown = 1;
- if (enemyHealth > 0)
- {
- cout << "The " << beastFullName << " attacks you and deals you " << enemyAttack << " damage." << endl;
- playerHealth -= enemyAttack;
- cout << "You now have " << playerHealth << " health remaining from your max health of " << playerMaxHealth << "." << endl;
- if (playerHealth <= 0)
- {
- cout << "You died to the monster. You resurrect at a church." << endl;
- }
- }
- }
- else if (attackChoice == 0 && playerPotionCount > 0)
- {
- playerHealth += 50;
- if (playerHealth > playerMaxHealth)
- {
- playerHealth = playerMaxHealth;
- }
- cout << "Your health has increased by 50." << endl;
- cout << "The enemy health is: " << enemyHealth << endl;
- dragonCooldown = 0;
- if (enemyHealth > 0)
- {
- cout << "The " << beastFullName << " attacks you and deals you " << enemyAttack << " damage." << endl;
- playerHealth -= enemyAttack;
- cout << "You now have " << playerHealth << " health remaining from your max health of " << playerMaxHealth << "." << endl;
- if (playerHealth <= 0)
- {
- cout << "You died to the monster. You resurrect at a church." << endl;
- }
- }
- }
- else
- {
- cout << "Pick a valid option." << endl;
- }
- }
- if (playerHealth > 0)
- {
- cout << beastFullName << " has been eliminated. You have gained " << playerGoldToGive << " gold." << endl;
- playerGold += playerGoldToGive;
- playerExp += playerExpToGive;
- cout << "You have gained " << playerExpToGive << " XP. Your current XP is : [" << playerExp << "/" << playerExpNeeded << "]" << endl;
- if (playerExp >= playerExpNeeded)
- {
- playerExp -= playerExpNeeded;
- playerLevel += 1;
- playerMaxHealth += 10;
- playerExpNeeded *= 2;
- playerHealth = playerMaxHealth;
- cout << "You have leveled up! You are now level " << playerLevel << ". Your health has been replenished and you now have a max health of " << playerMaxHealth << "." << endl;
- }
- cout << "Gold amount: \n" << playerGold << endl;
- }
- else
- {
- playerHealth = (playerMaxHealth / 2);
- }
- enemyHealth = 100;
- //cout <<"health right after fight after if loop" <<enemyHealth << endl;
- }
- else {
- cout << "you ran away...\n";
- }
- 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. Increases base attack by 2 << 25 gold\n";
- cout << "[4] Pet Dragon. Battle option to do 50 damage. 1 turn cooldown << 100 gold\n[5] XP potion. Gives 50 XP<< 25 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 (playerGold >= 25)
- {
- system("CLS");
- playerGold -= 25;
- cout << "You've purchased a Strength potion!\n";
- cout << "Your base attack has increased by 2\n";
- playerBaseDamage += 2;
- system("pause");
- }
- else
- {
- system("CLS");
- cout << "You do not have enough currency for a Strength potion.\n";
- system("pause");
- }
- }
- else if (shop == 4)
- {
- if (dragonOwned == 0)
- {
- if (playerGold >= 100)
- {
- system("CLS");
- dragonOwned = 1;
- playerGold -= 100;
- cout << "You've purchased the 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 >= 25)
- {
- system("CLS");
- playerGold -= 25;
- cout << "You have purchased a XP potion!\n";
- cout << "You have gained 50 XP\n";
- playerExp += 50;
- system("pause");
- }
- else
- {
- system("CLS");
- cout << "You do not have the required money for a XP 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 && dragonOwned == 0)
- {
- cout << "-Steel Sword +10 Damage\n";
- }
- else if (playerExtraDamage >= 20 && playerExtraDamage < 30 && dragonOwned == 0)
- {
- cout << "-Bronze Sword +20 Damage\n";
- }
- else if (playerExtraDamage == 30 && dragonOwned == 0)
- {
- cout << "-Steel Sword +10 Damage\n";
- cout << "-Bronze Sword +20 Damage\n";
- }
- else if (playerExtraDamage == 0 && dragonOwned == 1)
- {
- cout << "-Pet Dragon +50 Damage\n";
- }
- else if (playerExtraDamage == 10 && dragonOwned == 0)
- {
- cout << "-Steel Sword +10 Damage\n";
- cout << "-Pet Dragon +50 Damage\n";
- }
- else if (playerExtraDamage == 20 && dragonOwned == 0)
- {
- cout << "-Bronze Sword +20 Damage\n";
- cout << "-Pet Dragon +50 Damage\n";
- }
- else if (playerExtraDamage == 30 && dragonOwned == 0)
- {
- 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