Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Thomas Garcia
- // Adventure #1
- #include <iostream>
- #include <string>
- #include <thread>
- #include <chrono>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- int main() {
- bool debug = false;
- cout << "If you want to view attack/block/enemy health values input name 'debug'\n";
- this_thread::sleep_for(chrono::milliseconds(500));
- cout << "What is your name hero?\n";
- this_thread::sleep_for(chrono::milliseconds(500));
- string playerName;
- cin >> playerName;
- if (playerName == "debug") {debug = true;}
- this_thread::sleep_for(chrono::milliseconds(500));
- cout << "Hello " + playerName + ", it is nice to meet you.\n";
- this_thread::sleep_for(chrono::milliseconds(500));
- cout << "What weapon will you bring on your quest?\n";
- this_thread::sleep_for(chrono::milliseconds(500));
- string weaponName;
- cin >> weaponName;
- this_thread::sleep_for(chrono::milliseconds(500));
- cout << "that's special now get out of my house.\n";
- this_thread::sleep_for(chrono::milliseconds(500));
- cout << "you leave on your adventure.\n";
- this_thread::sleep_for(chrono::milliseconds(500));
- cout << "After a while you encounter a stray demon!\n";
- int playerHealth = 30;
- int demonHealth = 30;
- srand(time(0));
- int iterator = 0;
- int numberOfTurns = (rand() % 10) + 1;
- this_thread::sleep_for(chrono::milliseconds(500));
- cout << "the fight will last for " << numberOfTurns << " round(s)!\n";
- this_thread::sleep_for(chrono::milliseconds(500));
- cout << "you have " << playerHealth << " health.\n";
- this_thread::sleep_for(chrono::milliseconds(500));
- if (debug) {
- cout << "the demon has " << demonHealth << " health.\n";
- this_thread::sleep_for(chrono::milliseconds(500));
- }
- while (iterator++ < numberOfTurns){
- int playerAttack = (rand() % 20) +1;
- int playerBlock = (rand() % 20) +1;
- int demonAttack = (rand() % 20) +1;
- int demonBlock = (rand() % 20) +1;
- int playerDamage = (rand() % 12) +1;
- int demonDamage = (rand() % 12) +1;
- bool playerIsAlive = true;
- bool demonIsAlive = true;
- cout << "you attack the demon with " << weaponName << "!\n";
- this_thread::sleep_for(chrono::milliseconds(500));
- if (debug) {
- cout << " your attack = " << playerAttack << endl;
- cout << " demon's block = " << demonBlock << endl;
- this_thread::sleep_for(chrono::milliseconds(500));
- }
- if (demonBlock > playerAttack) {
- cout << "the demon has blocked your attack.\n";
- this_thread::sleep_for(chrono::milliseconds(500));
- }
- else if (demonBlock <= playerAttack){
- cout << "you've hit the demon and delt " << playerDamage << " damage!\n";
- demonHealth -= playerDamage;
- if (demonHealth <= 0) {demonIsAlive = false;}
- if (demonIsAlive == false) {
- demonHealth = 0;
- cout << "YOU KILLED THE DEMON AND ARRIVE AT YOUR DESTINATION. THE END.\n";
- break;
- }
- this_thread::sleep_for(chrono::milliseconds(500));
- }
- cout << "the demon attacks you!\n";
- this_thread::sleep_for(chrono::milliseconds(500));
- if (debug) {
- cout << " demon's attack = " << demonAttack << endl;
- cout << " your block = " << playerBlock << endl;
- this_thread::sleep_for(chrono::milliseconds(500));
- }
- if (playerBlock > demonAttack) {
- cout << "you blocked the demon's attack.\n";
- this_thread::sleep_for(chrono::milliseconds(500));
- }
- else if (playerBlock <= demonAttack){
- cout << "you've been hit and delt " << demonDamage << " damage!\n";
- playerHealth -= demonDamage;
- if (playerHealth <= 0) {playerIsAlive = false;}
- if (playerIsAlive == false) {
- playerHealth = 0;
- cout << "YOU DIED\n";
- break;
- }
- this_thread::sleep_for(chrono::milliseconds(500));
- }
- cout << "you have " << playerHealth << " health.\n";
- this_thread::sleep_for(chrono::milliseconds(500));
- if (debug) {
- cout << "the demon has " << demonHealth << " health.\n";
- this_thread::sleep_for(chrono::milliseconds(500));
- }
- if (iterator == numberOfTurns && playerHealth > demonHealth) {
- cout << "the demon has grown tired and you move in for a finishing blow, removing it head.\n";
- demonHealth = 0;
- cout << "YOU KILLED THE DEMON AND ARRIVE AT YOUR DESTINATION. THE END.\n";
- break;
- this_thread::sleep_for(chrono::milliseconds(500));
- }
- else if (iterator == numberOfTurns && playerHealth < demonHealth) {
- cout << "you have grown tired and the demon moves in for a finishing blow, ripping you in half.\n";
- playerHealth = 0;
- cout << "YOU DIED\n";
- break;
- this_thread::sleep_for(chrono::milliseconds(500));
- }
- else if (iterator == numberOfTurns && playerIsAlive && demonIsAlive){
- cout << "both you and the demon grow tired of fighting and go your seperate ways.\n";
- cout << "YOU ARRIVE AT YOUR DESTINATION. THE END.\n";
- break;
- this_thread::sleep_for(chrono::milliseconds(500));
- }
- this_thread::sleep_for(chrono::milliseconds(500));
- }
- }
Add Comment
Please, Sign In to add comment