Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- #include <string>
- #include <unistd.h>
- using namespace std;
- int php = 5; //player health
- int location; //player location(must be between 1 and 100)
- /*
- locations:
- key for chest can be found between 25 and 50
- chest can randomly appear anywhere between 80 and 95
- */
- bool haskey = false;
- bool hastalisman = false;
- bool hasheal = false;
- int d1;
- int d2;
- int movement; //how many tiles will you move
- int dec1; //for decision making
- string name;
- int stage = 1;//stage 1: get to door, stage 2: find chest for talisman, stage 3: find key, stage 4: get talisman, stage 5: leave dungeon
- int chance;
- string dunname;
- int points = 0;
- int walks = 0;
- int heals = 0;
- int hits = 0;
- int picks = 0;
- int main();
- void lose()
- {
- points = (walks - heals) -hits;
- system("clear");
- cout << "YOU LOST" << endl;
- cout << "AND SO, " << name << " HAS DIED IN THE DUNGEON OF " << dunname << endl;
- cout << name << " HAS WALKED A DISTANCE OF " << walks << " AND HAS HEALED " << heals << " TIMES AND" << endl;
- cout << "GOT HIT BY TRAPS " << hits << " TIMES AND PICKED UP " << picks << " LOOT" << endl;
- cout << "END SCORE >>> " << points << endl;
- cout << "PRESS ANY NUMBER THEN ENTER TO CONTINUE" << endl;
- cin >> dec1;
- cout << "RESTARTING GAME..." << endl;
- php =5;
- stage =1;
- haskey =false;
- hasheal = false;
- hastalisman =false;
- sleep(3);
- system("clear");
- main();
- }
- void winner()
- {
- points = (walks - heals) -hits;
- system("clear");
- cout << "YOU WON" << endl;
- cout << "END SCORE >>> " << points << endl;
- cout << "PRESS ANY NUMBER THEN ENTER TO CONTINUE" << endl;
- cin >> dec1;
- cout << "RESTARTING GAME..." << endl;
- php =5;
- stage =1;
- haskey =false;
- hasheal = false;
- hastalisman =false;
- sleep(3);
- system("clear");
- main();
- }
- int main()
- {
- cout << "DEADLY DUNGEON OF DEATH"<< endl;
- cout << "PLEASE ENTER YOUR NAME >> ";
- cin >> name;
- cout << endl;
- cout << "PLEASE ENTER NAME OF DUNGEON >> ";
- cin >> dunname;
- cout << endl;
- cout << "LOADING GAME..." << endl;
- sleep(1);
- cout << "YOU FIND YOURSELF IN THE DUNGEON OF " << dunname << endl;
- cout << "YOU SEE A DOOR IN THE DISTANCE" << endl;
- sleep(2);
- stage =1;
- game:
- points = walks+picks -heals -hits;
- if(php <= 0)
- {
- lose();
- }
- system("clear");
- srand(time(NULL));
- d1 = (rand()%5) +1;
- d2 = (rand()%5) +1;
- movement = d1+d2;
- if(stage == 1)
- {
- cout << "CURRENT GOAL: GET TO DOOR(POSITION 100)" << endl;
- }
- if(stage ==2)
- {
- cout << "CURRENT GOAL: FIND THE CHEST FOR THE TALISMAN(POSITION 80-95)" << endl;
- }
- if(stage ==3)
- {
- cout << "CURRENT GOAL: FIND THE KEY FOR THE CHEST(POSITION 25-50) " << endl;
- }
- if(stage ==4)
- {
- cout << "CURRENT GOAL: FIND THE CHEST(POSITION 80-95)" << endl;
- }
- if(stage == 5)
- {
- cout << "CURRENT GOAL: LEAVE THROUGH THE DOOR (POSITION 100)" << endl;
- }
- cout << "DISTANCE WALKED>> " << walks << endl;
- cout << "ITEMS PICKED UP>> " << picks << endl;
- cout << "NUMBER OF TIMES HEALED>> " << heals << endl;
- cout << "NUMBER OF TIMES GOT HIT>> " << hits << endl;
- cout << endl;
- cout << name << ">> " << php << endl;
- cout << "TOTAL POINTS>> " << points << endl;
- cout << endl;
- cout << "CURRENT POSITION>> " << location << endl;
- cout << endl;
- if(php != 3){
- switch(rand()%10)
- {
- case 1:
- cout << "YOU GOT HIT BY A TRAP!" << endl;
- hits +=1;
- sleep(1);
- php -=1;
- if(php <= 0)
- {
- lose();
- }
- break;
- default:
- break;
- }
- }
- trap:
- if(hasheal == false && php < 5)
- {
- if(rand()% 100 < 50)
- {
- cout << "YOU SEE A HEALING POTION. IT MIGHT BE A TRAP, BUT IT COULD ALSO BE A POTION" << endl;
- cout << "1) GET THE POTION 2)LEAVE THE POTION" << endl;
- cin >> dec1;
- switch(dec1)
- {
- case 1:
- switch(rand()%5)
- {
- case 1:
- case 2:
- cout << "YOU GOT A POTION!" << endl;
- picks +=1;
- hasheal = true;
- break;
- default:
- cout << "IT WAS A TRAP" << endl;
- cout << "YOU LOST 1 HP" << endl;
- hits +=1;
- php -=1;
- if(php <= 0)
- {
- lose();
- }
- break;
- }
- break;
- case 2:
- cout << "YOU LEAVE THE POTION" << endl;
- break;
- default:
- cout << "PICK ONLY ONE OR TWO" << endl;
- goto trap;
- break;
- }
- }
- }
- if(location >25 && location < 50 && haskey == false && stage == 3)
- {
- key:
- cout << "YOU SEE A KEY. IT MAY BE A TRAP, BUT IT COULD ALSO BE A KEY" << endl;
- cout << "1) GET KEY, 2) LEAVE KEY" << endl;
- cin >> dec1;
- switch(dec1)
- {
- case 1:
- switch(rand()%5)
- {
- case 1:
- case 2:
- cout << "YOU GOT A KEY!" << endl;
- cout << "GOAL UPDATED: GET THE TALISMAN" << endl;
- picks +=1;
- stage = 4;
- haskey = true;
- break;
- default:
- cout << "IT WAS A TRAP" << endl;
- cout << "YOU LOST 1 HP" << endl;
- hits +=1;
- php -=1;
- if(php <= 0)
- {
- lose();
- }
- break;
- }
- break;
- case 2:
- cout << "YOU LEAVE THE KEY" << endl;
- break;
- default:
- cout << "PICK ONLY ONE OR TWO" << endl;
- goto key;
- break;
- }
- }
- if(location > 80 && location < 95 && haskey == false && hastalisman == false && stage == 2)
- {
- system("clear");
- cout << "YOU SEE A CHEST. UNFORTUNATELY YOU NEED A KEY TO OPEN IT" << endl;
- cout << "GOAL UPDATED: FIND A KEY" << endl;
- sleep(2);
- stage =3;
- }
- if(location > 80 && location < 95 && haskey == true && hastalisman == false && stage == 4)
- {
- talis:
- cout << "YOU SEE A CHEST. IT MAY BE A TRAP, BUT IT MAY ALSO CONTAIN THE TALISMAN" <<endl;
- cout << "1) OPEN CHEST, 2) LEAVE CHEST" << endl;
- cin >> dec1;
- switch(dec1)
- {
- case 1:
- switch(rand()%5)
- {
- case 1:
- case 2:
- cout << "YOU GOT THE TALISMAN!" << endl;
- cout << "GOAL UPDATED: ESCAPE THE DUNGEON" << endl;
- picks +=1;
- stage =5;
- hasheal = true;
- sleep(2);
- break;
- default:
- cout << "IT WAS A TRAP" << endl;
- cout << "YOU LOST 1 HP" << endl;
- hits +=1;
- php -=1;
- if(php <= 0)
- {
- lose();
- }
- break;
- }
- break;
- case 2:
- cout << "YOU LEAVE THE CHEST" << endl;
- break;
- default:
- cout << "PICK ONLY ONE OR TWO" << endl;
- goto talis;
- break;
- }
- }
- if (location == 100 && stage == 2&&stage ==3&& stage ==4)
- {
- cout << "YOU STILL DON'T HAVE THE TALISMAN" << endl;
- sleep(2);
- }
- if(location ==100 && stage == 1)
- {
- cout << "YOU FINALLY REACH THE DOOR. IT'S LOCKED. YOU SEEM TO NEED A TALISMAN TO OPEN IT" << endl;
- cout << "GOAL UPDATED: FIND THE CHEST THAT CONTAINS A TALISMAN" << endl;
- stage = 2;
- sleep(2);
- }
- if(location == 100 && hastalisman == true && stage == 5)
- {
- system("clear");
- cout << "YOU CAN FINALLY ESCAPE!" << endl;
- cout << "YOU HAVE ESCAPED! GAME END" << endl;
- sleep(5);
- winner();
- }
- heal:
- cout << "PRESS ANY NUMBER THEN ENTER TO ROLL A DICE" << endl;
- if(hasheal == true)
- {
- cout << "PRESS 0 TO HEAL" << endl;
- }
- cin >> dec1;
- if(hasheal == true && dec1 == 0)
- {
- cout << "YOU HEALED 1 HP" << endl;
- heals +=1;
- sleep(2);
- php += 1;
- hasheal = false;
- goto heal;
- }
- cout << "ROLLING DICE..." << endl;
- sleep(1);
- cout << "DICE 1>> " << d1 << endl;
- cout << "DICE 2>> " << d2 << endl;
- cout << "MOVE BY>> " << d1+d2 << endl;
- mov:
- cout << "WHICH DIRECTION DO YOU WANT TO MOVE?" << endl;
- cout << "1) FORWARD, 2) BACKWARD" << endl;
- cin >>dec1;
- walks += (d1+d2);
- switch(dec1)
- {
- case 1:
- cout << "MOVING FORWARD" << endl;
- location += movement;
- break;
- case 2:
- cout << "MOVING BACKWARD" << endl;
- location -= movement;
- break;
- default:
- cout << "ONLY PICK 1 OR 2" << endl;
- goto mov;
- }
- if(location > 100)
- {
- cout << "YOUR DICE ROLL IS TOO HIGH. REDUCING BY 12" << endl;
- location -=12;
- sleep(2);
- }
- if(location <= 0)
- {
- cout << "YOUR DICE ROLL IS TOO LOW. INCREASING BY 12" << endl;
- location += 12;
- sleep(2);
- }
- goto game;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement