Advertisement
JangoBingoBango

main

Apr 13th, 2020
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.72 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <ctime>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int choice;
  9.     int mhp, hp, i, init, atk, def, rit, damage, mdamage;
  10.     atk = 10;
  11.     def = 15;
  12.     int currentMonsterCount = 1;
  13.     int totalMonsterCount = 3;
  14.     int medkitDrop;
  15.     int totalMedkits = 0;
  16.  
  17.     srand(unsigned(time(0)));
  18.     init = rand() % 2 + 1;
  19.     mhp = rand() % 50 + 60;
  20.     hp = rand() % 20 + 80;
  21.     if (init == 1) {
  22.         cout << "You can start!\n";
  23.     }
  24.     while (currentMonsterCount <= totalMonsterCount)
  25.  
  26.     {
  27.  
  28.             if (hp < 1) {
  29.                 cout << "You died! The beast still has " << mhp << " HP left, you suck!\n";
  30.                 cin.get();
  31.                 return 0;
  32.             }
  33.             else {
  34.                 cout << "You can start!\n";
  35.                 cout << "Monsters: " << currentMonsterCount << " / " << totalMonsterCount << "\n";
  36.  
  37.                 mhp = rand() % 50 + 60;
  38.  
  39.                 while (hp > 0 && mhp > 0)
  40.                 {
  41.                     cout << "\nWhat do you want to do?\n 1 -> Fierce Attack \n 2 -> Coward's Retreat\n 3 -> Use Medkit.";
  42.                     cout << " You have " << totalMedkits << " medkits left.\n";
  43.  
  44.                     do { cin >> choice; } while (choice > 3 || choice < 1);
  45.                     switch (choice) {
  46.                     case 1:
  47.                         atk = rand() % 20 + 10;
  48.                         def = rand() % 10 + 10;
  49.                         break;
  50.                     case 2:
  51.                         cout << "You decided to retreat, you coward!\n";
  52.  
  53.                         return 0;
  54.                     case 3:
  55.                         if (totalMedkits > 0) {
  56.                             hp = 100;
  57.                             totalMedkits -= 1;
  58.                             cout << "You have used a medkit. You now have full health!";
  59.                         }
  60.  
  61.                         else {
  62.                             cout << "You do not have any medkits";
  63.                         }
  64.  
  65.                         break;
  66.                     }
  67.                     choice = rand() % 3;
  68.  
  69.                     switch (choice) {
  70.                     case 1:
  71.                         break;
  72.                     case 2:
  73.                         break;
  74.                     case 3:
  75.                         break;
  76.                     }
  77.                     mdamage = (atk)-(def / atk);
  78.                     if (mdamage < 0) {
  79.                         mdamage = 0;
  80.                     }
  81.                     mhp = mhp - mdamage;
  82.                     cout << "You did " << mdamage << " damage to the monster!\n";
  83.  
  84.  
  85.                     damage = (atk)-(def / atk);
  86.                    
  87.  
  88.  
  89.                     if (mhp < 1) {
  90.                         cout << "You killed the monster! How dare you kill something!\n";
  91.                         currentMonsterCount += 1;
  92.  
  93.  
  94.                         medkitDrop = rand() % 2 + 1;
  95.                         if (medkitDrop == 1)
  96.                         {
  97.                             totalMedkits += 1;
  98.                             cout << "Medkit found! Current medkit count: " << totalMedkits << "\n";
  99.                         }
  100.  
  101.  
  102.                    
  103.                     }
  104.  
  105.  
  106.                     else if (damage < 0)
  107.                     {
  108.                         damage = 0;
  109.                     }
  110.  
  111.                     if (mhp > 0) {
  112.                         cout << "The monster now has " << mhp << " HP left.\n";
  113.  
  114.                         hp = hp - damage;
  115.  
  116.                         cout << "The monster stole " << damage << " points from you. You still have, " << hp << " HP points availalble\n";
  117.                     }
  118.  
  119.                 }
  120.             }
  121.         }
  122.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement