daily pastebin goal
20%
SHARE
TWEET

Untitled

a guest Sep 14th, 2018 54 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
  1. // Thomas Garcia
  2. // Adventure #1
  3.  
  4. #include <iostream>
  5. #include <string>
  6. #include <thread>
  7. #include <chrono>
  8. #include <cstdlib>
  9. #include <ctime>
  10. using namespace std;
  11.  
  12. int main() {
  13.   bool debug = false;
  14.   cout << "If you want to view attack/block/enemy health values input name 'debug'\n";
  15.   this_thread::sleep_for(chrono::milliseconds(500));
  16.   cout << "What is your name hero?\n";
  17.   this_thread::sleep_for(chrono::milliseconds(500));
  18.   string playerName;  
  19.   cin >> playerName;
  20.   if (playerName == "debug") {debug = true;}
  21.   this_thread::sleep_for(chrono::milliseconds(500));
  22.   cout << "Hello " + playerName + ", it is nice to meet you.\n";
  23.   this_thread::sleep_for(chrono::milliseconds(500));
  24.   cout << "What weapon will you bring on your quest?\n";
  25.   this_thread::sleep_for(chrono::milliseconds(500));
  26.   string weaponName;
  27.   cin >> weaponName;
  28.   this_thread::sleep_for(chrono::milliseconds(500));
  29.   cout << "that's special now get out of my house.\n";
  30.   this_thread::sleep_for(chrono::milliseconds(500));
  31.   cout << "you leave on your adventure.\n";
  32.   this_thread::sleep_for(chrono::milliseconds(500));
  33.   cout << "After a while you encounter a stray demon!\n";
  34.   int playerHealth = 30;
  35.   int demonHealth = 30;
  36.   srand(time(0));
  37.   int iterator = 0;
  38.   int numberOfTurns = (rand() % 10) + 1;
  39.   this_thread::sleep_for(chrono::milliseconds(500));
  40.   cout << "the fight will last for " << numberOfTurns << " round(s)!\n";
  41.   this_thread::sleep_for(chrono::milliseconds(500));
  42.   cout << "you have " << playerHealth << " health.\n";
  43.   this_thread::sleep_for(chrono::milliseconds(500));
  44.   if (debug) {
  45.      cout << "the demon has " << demonHealth << " health.\n";
  46.      this_thread::sleep_for(chrono::milliseconds(500));
  47.      }
  48.  
  49.         while (iterator++ < numberOfTurns){
  50.             int playerAttack = (rand() % 20) +1;
  51.             int playerBlock = (rand() % 20) +1;
  52.             int demonAttack = (rand() % 20) +1;
  53.             int demonBlock = (rand() % 20) +1;
  54.             int playerDamage = (rand() % 12) +1;
  55.             int demonDamage = (rand() % 12) +1;
  56.             bool playerIsAlive = true;
  57.             bool demonIsAlive = true;
  58.             cout << "you attack the demon with " << weaponName << "!\n";
  59.             this_thread::sleep_for(chrono::milliseconds(500));
  60.                 if (debug) {
  61.                   cout << " your attack = " << playerAttack << endl;
  62.                   cout << " demon's block = " << demonBlock << endl;
  63.                   this_thread::sleep_for(chrono::milliseconds(500));
  64.                  }
  65.                   if (demonBlock > playerAttack) {
  66.                       cout << "the demon has blocked your attack.\n";
  67.                       this_thread::sleep_for(chrono::milliseconds(500));
  68.                  }
  69.                  else if (demonBlock <= playerAttack){
  70.                       cout << "you've hit the demon and delt " << playerDamage << " damage!\n";
  71.                       demonHealth -= playerDamage;
  72.                       if (demonHealth <= 0) {demonIsAlive = false;}
  73.                         if (demonIsAlive == false) {
  74.                          demonHealth = 0;
  75.                          cout << "YOU KILLED THE DEMON AND ARRIVE AT YOUR DESTINATION. THE END.\n";
  76.                          break;
  77.                          }
  78.                       this_thread::sleep_for(chrono::milliseconds(500));
  79.                      }
  80.            
  81.              cout << "the demon attacks you!\n";
  82.              this_thread::sleep_for(chrono::milliseconds(500));
  83.                 if (debug) {
  84.                   cout << " demon's attack = " << demonAttack << endl;
  85.                   cout << " your block = " << playerBlock << endl;
  86.                   this_thread::sleep_for(chrono::milliseconds(500));
  87.                  }
  88.                     if (playerBlock > demonAttack) {
  89.                       cout << "you blocked the demon's attack.\n";
  90.                       this_thread::sleep_for(chrono::milliseconds(500));
  91.                      }
  92.                 else if (playerBlock <= demonAttack){
  93.                   cout << "you've been hit and delt " << demonDamage << " damage!\n";
  94.                   playerHealth -= demonDamage;
  95.                   if (playerHealth <= 0) {playerIsAlive = false;}
  96.                     if (playerIsAlive == false) {
  97.                       playerHealth = 0;
  98.                       cout << "YOU DIED\n";
  99.                       break;
  100.                      }
  101.                       this_thread::sleep_for(chrono::milliseconds(500));
  102.                 }
  103.              
  104.          cout << "you have " << playerHealth << " health.\n";
  105.          this_thread::sleep_for(chrono::milliseconds(500));
  106.          if (debug) {
  107.              cout << "the demon has " << demonHealth << " health.\n";
  108.              this_thread::sleep_for(chrono::milliseconds(500));
  109.              }
  110.  
  111.             if (iterator == numberOfTurns && playerHealth > demonHealth) {
  112.                cout << "the demon has grown tired and you move in for a finishing blow, removing it head.\n";
  113.                demonHealth = 0;
  114.                cout << "YOU KILLED THE DEMON AND ARRIVE AT YOUR DESTINATION. THE END.\n";
  115.                break;
  116.                this_thread::sleep_for(chrono::milliseconds(500));
  117.              }
  118.                 else if (iterator == numberOfTurns && playerHealth < demonHealth) {
  119.                     cout << "you have grown tired and the demon moves in for a finishing blow, ripping you in half.\n";
  120.                     playerHealth = 0;
  121.                     cout << "YOU DIED\n";
  122.                     break;
  123.                     this_thread::sleep_for(chrono::milliseconds(500));
  124.                  }
  125.                     else if (iterator == numberOfTurns && playerIsAlive && demonIsAlive){
  126.                       cout << "both you and the demon grow tired of fighting and go your seperate ways.\n";
  127.                       cout << "YOU ARRIVE AT YOUR DESTINATION. THE END.\n";
  128.                       break;
  129.                       this_thread::sleep_for(chrono::milliseconds(500));
  130.                      }
  131.          
  132.          
  133.          this_thread::sleep_for(chrono::milliseconds(500));
  134.         }
  135.  
  136. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top