Advertisement
Guest User

Dumb Text game in C

a guest
Oct 8th, 2016
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.58 KB | None | 0 0
  1. /* This was where my name and contact shit was
  2. * " "
  3. * Use a g++ compiler to compile or enter "g++ menu.cpp -o app" then run with "./app"
  4. */
  5. #include <iostream>
  6. #include <string.h>
  7. #include <ctime>
  8. #include <cstdlib>
  9. #include <string>
  10. #include <fstream>
  11. using namespace std;
  12.  
  13. void newGame(string name);
  14. void loseScreen(int steps, int etime, double money, int intelligence, int bowserVictory, string name);
  15.  
  16. class HighScore
  17. {
  18. private:
  19. ifstream inStream;
  20. ofstream outStream;
  21. string listOfNames[10];
  22. int listOfScores[10];
  23. public:
  24. HighScore()
  25. {
  26. cout << "Eating Pancakes\n" << endl;
  27. }
  28. void readFromFile()
  29. {
  30. inStream.open("highscore.txt");
  31. if(inStream.fail())
  32. {
  33. cout << "File Not Found.\n" << endl;
  34. }
  35. string name = "";
  36. int score = 0;
  37. int count = 0;
  38. string scoreBoth = "";
  39. while(inStream >> name >> score)
  40. {
  41. cout << name << " " << score << endl;
  42. count++;
  43. }
  44. if(count < 10)
  45. {
  46. cout << "No more scores to display.\n" << endl;
  47. }
  48. inStream.close();
  49. }
  50.  
  51. bool writeToFile(string writeName, int writeScore)
  52. {
  53. outStream.open("highscore.txt");
  54. if(outStream.fail())
  55. {
  56. cout << "Error, File not found.\n" << endl;
  57. }
  58. outStream << writeName << " " << writeScore << endl;
  59. outStream.close();
  60. return true;
  61. }
  62. };
  63.  
  64. class Encounter
  65. {
  66. protected:
  67. int encounterChance;
  68. int selection;
  69.  
  70. public:
  71. int selectEncounter()
  72. {
  73. encounterChance = rand() % 100 + 1;
  74.  
  75. if(encounterChance >= 2 && encounterChance <= 20) //Nothing
  76. {
  77. selection = 1;
  78. return selection;
  79. }
  80. else if(encounterChance > 20 && encounterChance <= 45) //Puzzle
  81. {
  82. selection = 2;
  83. return selection;
  84. }
  85. else if(encounterChance > 45 && encounterChance <= 65) //Professor
  86. {
  87. selection = 3;
  88. return selection;
  89. }
  90. else if(encounterChance > 65 && encounterChance <= 85) //Grad Student
  91. {
  92. selection = 4;
  93. return selection;
  94. }
  95. else if(encounterChance > 85 && encounterChance <= 95) //Papers
  96. {
  97. selection = 5;
  98. return selection;
  99. }
  100. else if (encounterChance > 95 && encounterChance <= 100) //Grunt Work
  101. {
  102. selection = 6;
  103. return selection;
  104. }
  105. else if (encounterChance == 1) //Prize
  106. {
  107. selection = 7;
  108. return selection;
  109. }
  110. }
  111. int displayEncounter(int i, int& etime, double& money, int& intelligence)
  112. {
  113. int tempTime = 0;
  114. int tempMoney = 0;
  115. int tempInt = 0;
  116. switch(i)
  117. {
  118. case 1:
  119. {
  120. cout << "And nothing happens.\n" << endl;
  121. tempTime = rand() % 1;
  122. etime -= tempTime;
  123. break;
  124. }
  125. case 2:
  126. {
  127. cout << "What's this? A puzzle of some sort?\n" << endl;
  128. break;
  129. }
  130. case 3:
  131. {
  132. cout << "Oh no! A professor has made eye contact! It looks like he wants to battle!" << endl;
  133. cout << "Professor sends out, Ungraded Mandatory Assignment!" << endl;
  134. cout << "Ungraded Mandatory Assignment attacks Trainer Student! It uses Tedious! Its super effective!" << endl;
  135. tempTime = rand() % 3 + 1;
  136. etime -= tempTime;
  137. cout << "You lost, " << tempTime << " time." << endl;
  138. intelligence += tempInt;
  139. cout << " You gain, " << tempInt << " intelligence.\n" << endl;
  140. break;
  141. }
  142. case 4:
  143. {
  144. cout << "Shambling around in the darkness a fellow Grad Student stumbles into view." << endl;
  145. cout << "You greet him with the traditional awkward stare-down." << endl;
  146. tempTime = rand() % 3 + 1;
  147. etime -= tempTime;
  148. cout << "You lost, " << tempTime << " time from the stare-down show-down.\n" << endl;
  149. break;
  150. }
  151. case 5:
  152. {
  153. cout << "A gust of wind blows some papers into your face." << endl;
  154. cout << "Enraged you bust out your red pen and viciously tackle this stack of unruly pages." << endl;
  155. tempTime = rand() % 3 + 1;
  156. etime -= tempTime;
  157. cout << "You lost, " << tempTime << " time." << endl;
  158. tempMoney = rand() % 2 + 1;
  159. money += tempMoney;
  160. cout << "You gained, $" << tempMoney << " money from grading those tests.\n" << endl;
  161. break;
  162. }
  163. case 6:
  164. {
  165. cout << "A giant wall forms infront of you. Roughly taped to its surface is a stack of papers along with a note:" << endl;
  166. cout << "To proceed further you must finish and file all of these papers in the magical desk of unended servitude." << endl;
  167. tempTime = rand() % 3 + 1;
  168. tempInt = rand() % 2 + 1;
  169. etime -= tempTime;
  170. intelligence -= tempInt;
  171. cout << "After finishing the grind you feel a bit dumber and time has flown by." << endl;
  172. cout << "You lost: " << tempTime << " time." << endl;
  173. cout << "You lost: " << tempInt << " intelligence.\n" << endl;
  174. break;
  175. }
  176. case 7:
  177. {
  178. cout << "A gold bar descends from the heavens. This is a gift from the all-seer known only to some as... boss." << endl;
  179. money += 100;
  180. cout << "You gain one-hundred dollars. I can't believe it!\n" << endl;
  181. break;
  182. tempTime = rand() % 2 + 1;
  183. etime -= tempTime;
  184. }
  185. }
  186. return i;
  187.  
  188. }
  189. };
  190.  
  191. class Puzzle : protected Encounter
  192. {
  193. private:
  194. bool correctAnswer;
  195. int puzzleChoice;
  196. public:
  197. int puzzleNumber()
  198. {
  199. puzzleChoice = rand() % 100 + 1;
  200. if(puzzleChoice >= 1 && puzzleChoice <= 20)
  201. {
  202. selection = 1;
  203. return selection;
  204. }
  205. else if(puzzleChoice > 20 && puzzleChoice <= 40)
  206. {
  207. selection = 2;
  208. return selection;
  209. }
  210. else if(puzzleChoice > 40 && puzzleChoice <= 60)
  211. {
  212. selection = 3;
  213. return selection;
  214. }
  215. else if(puzzleChoice > 60 && puzzleChoice <= 80)
  216. {
  217. selection = 4;
  218. return selection;
  219. }
  220. else if(puzzleChoice > 80 && puzzleChoice <= 100)
  221. {
  222. selection = 5;
  223. return selection;
  224. }
  225. }
  226. void displayPuzzle(int i, int& etime, double& money, int& intelligence)
  227. {
  228. int tempTime = rand() % 2 + 1;
  229. double tempMoney = 0;
  230. int tempInt = 0;
  231. int userAnswer = 0;
  232. switch(i)
  233. {
  234. case 1:
  235. {
  236. cout << "What is the capital of Greenland? " << endl;
  237. cout << "1) Nuuk" << endl;
  238. cout << "2) Ittoqqortoormiit" << endl;
  239. cout << "3) Qeqertarsuatsiaat" << endl;
  240. cout << "4) Kangerluarsoruseq\n" << endl;
  241.  
  242. cin >> userAnswer;
  243. if(userAnswer == 1)
  244. {
  245. correctAnswer = true;
  246. cout << "Correct, the Capital of Greenland is Nuuk.\n" << endl;
  247. }
  248. else
  249. {
  250. correctAnswer = false;
  251. cout << "This one was a bit tricky, and you got it wrong.\n" << endl;
  252. }
  253. break;
  254. }
  255. case 2:
  256. {
  257. cout << "What was the new weapon introduced at the battle of Somme?" << endl;
  258. cout << "1) U-boat" << endl;
  259. cout << "2) Tank" << endl;
  260. cout << "3) Poison Gas" << endl;
  261. cout << "4) Mankind itself.\n" << endl;
  262.  
  263. cin >> userAnswer;
  264. if(userAnswer == 2)
  265. {
  266. correctAnswer = true;
  267. cout << "Somewhat correct, while plans for tanks had been proposed before, this was the first use of it.\n" << endl;
  268. }
  269. else if(userAnswer == 4)
  270. {
  271. correctAnswer = false;
  272. cout << "Go get a job Hippie!\n" << endl;
  273. }
  274. else
  275. {
  276. correctAnswer = false;
  277. cout << "Incorrect Answer, try again next time.\n" << endl;
  278. }
  279. break;
  280. }
  281. case 3:
  282. {
  283. cout << "In the epic Jeopardy fight between NIXON and DIXON, what did Larry answer to the question, " << endl;
  284. cout << "The true vampire bat is native to this continent, not Translyvania." << endl;
  285. cout << "1) SO*/?/?/?/?/?*/?/?" << endl;
  286. cout << "2) Germany" << endl;
  287. cout << "3) France" << endl;
  288. cout << "4) South Africa\n" << endl;
  289.  
  290. cin >> userAnswer;
  291. if(userAnswer == 1)
  292. {
  293. correctAnswer = true;
  294. cout << "In true comedic fashion the Game Grumps and their games deliver.\n" << endl;
  295. }
  296. else
  297. {
  298. correctAnswer = false;
  299. cout << "Game Grumps. Look it up, Live life happy.\n" << endl;
  300. }
  301. break;
  302. }
  303. case 4:
  304. {
  305. cout << "In the Google search engine, what is the phrase that you can type into the search bar that causes a script to run." << endl;
  306. cout << "1) Where is Chuck Norris" << endl;
  307. cout << "2) Do a barrel Roll" << endl;
  308. cout << "3) Do you even lift" << endl;
  309. cout << "4) When does the narwhal bacon\n" << endl;
  310.  
  311. cin >> userAnswer;
  312. if(userAnswer == 2)
  313. {
  314. correctAnswer = true;
  315. cout << "Try it yourself if you don't believe me. Just not on IE.\n" << endl;
  316. }
  317. else
  318. {
  319. correctAnswer = false;
  320. cout << "Stair Fax\n" << endl;
  321. }
  322. break;
  323. }
  324. case 5:
  325. {
  326. cout << "Is the answer to this question no?" << endl;
  327. cout << "1) Yes" << endl;
  328. cout << "2) No\n" << endl;
  329.  
  330. cin >> userAnswer;
  331. if(userAnswer == 1 || userAnswer == 2)
  332. {
  333. correctAnswer = true;
  334. cout << "I'm not that mean... am I?\n" << endl;
  335. }
  336. else
  337. {
  338. correctAnswer = false;
  339. cout << "Yes, No, Yes, No, Yes, No, Yes, No, Yes, No...\n" << endl;
  340. }
  341. break;
  342. }
  343. }
  344. if(correctAnswer == true)
  345. {
  346. tempTime = rand() % 2 + 1;
  347. tempInt = rand() % 2 + 1;
  348. tempMoney = rand() % 3 + 1;
  349. intelligence += tempInt;
  350. money += tempMoney;
  351. etime -= tempTime;
  352. cout << "You've beaten the puzzle! You find a few pennies deposit themselves from the ceiling and onto your head." << endl;
  353. cout << "This minor severe head trauma has somehow made you smarter!\n" << "Intelligence Gain: " << tempInt;
  354. cout << " Money gain: $" << tempMoney << " Time Lost: " << tempTime << "\n" << endl;
  355. }
  356. else
  357. {
  358. tempTime = rand() % 2 + 2;
  359. tempInt = rand() % 4 + 3;
  360. tempMoney = rand() % 10 + 2;
  361. intelligence -= tempInt;
  362. money -= tempMoney;
  363. etime -= tempTime;
  364. cout << "The puzzle has bested you! The walls begin to close in on you Indian Jones style! You quickly throw your money at them to get them to stop!" << endl;
  365. cout << "Unfortunately you also hit your head on the now lowered ceiling." << "Money Lost: $" << tempMoney << "\n" << " Intelligence Lost: " << tempInt << endl;
  366. cout << "Time lost: " << tempTime << "\n" << endl;
  367. }
  368. }
  369. };
  370.  
  371. int main()
  372. {
  373. string name = "";
  374. int userChoice = 0;
  375. int checkChoice = 0;
  376. HighScore highscore;
  377.  
  378. cout << "Hello Traveler; Before we get started, What is your name? ";
  379. cin >> name;
  380. cout << "\n";
  381. cout << "\n";
  382.  
  383. cout << "======================================================================================\n";
  384. cout << "Welcome, " << name << " to a text based simulator of a real college experience." << endl;
  385. cout << "======================================================================================\n\n";
  386. while(userChoice != 3)
  387. {
  388. do
  389. {
  390. userChoice = 0;
  391. cout << "1) Start a New Game of !" << endl;
  392. cout << "2) View top 10 High Scores" << endl;
  393. cout << "3) Quit" << endl;
  394. cout << "Please choose an option: ";
  395. cin >> userChoice;
  396. }
  397. while(userChoice != 1 && userChoice != 2 && userChoice != 3); //Needs Fixing
  398.  
  399. switch(userChoice)
  400. {
  401. case 1:
  402. {
  403. newGame(name);
  404. break;
  405. }
  406. case 2:
  407. {
  408. highscore.readFromFile();
  409. break;
  410. }
  411. case 3:
  412. {
  413. cout << "Goodbye." << endl;
  414. return 0;
  415. break;
  416. }
  417. }
  418. }
  419. }
  420.  
  421. void newGame(string name)
  422. {
  423. int intelligence = 0;
  424. double money = 0;
  425. int etime = 0;
  426. int steps = 20;
  427. int actionChoice = 0;
  428. int tempInt = 0;
  429. int tempTime = 0;
  430. double tempMoney = 0;
  431. string userQuit = "";
  432. string actionCheck = "";
  433. string n = name;
  434. int bowserChoice = 0;
  435. int bowserDodgeChoice = 0;
  436. int bowserAttackChoice = 0;
  437. int bowserItemChoice = 0;
  438. bool gameOver = false;
  439. int bowserVictory = 0;
  440.  
  441. cout.setf(ios::fixed);
  442. cout.setf(ios::showpoint);
  443. cout.precision(2);
  444.  
  445. srand(time(0));
  446. intelligence = rand() % 18 + 8;
  447. etime = rand() % 6 + 34; //review time during testing
  448. money = rand() % 11 + 5;
  449.  
  450. cout << "Entering the game..." << endl;
  451. cout << "\n";
  452. cout << "You have:" << endl;
  453. cout << "\n";
  454. cout << "Intelligence: " << intelligence << endl;
  455. cout << "Time: " << etime << endl;
  456. cout << "Money: $" << money << endl;
  457. cout << "\n";
  458.  
  459.  
  460. while(actionChoice != 5 && !gameOver)
  461. {
  462. do
  463. {
  464. if(money <= 0 || intelligence <= 0 || etime <=0 || steps == 0)
  465. {
  466. gameOver = true;
  467. loseScreen(steps, etime, money, intelligence, bowserVictory, n);
  468. }
  469. else
  470. {
  471. cout << "You are " << steps << " steps from the goal. Time left: " << etime << "." << endl;
  472. cout << "\n";
  473. cout << "1) Move forward (lose time, could be FUN...)" << endl;
  474. cout << "2) Read technical papers (boosts intelligence, lose time)" << endl;
  475. cout << "3) Search for loose change (gain money, lose time)" << endl;
  476. cout << "4) View character (boosts EGO, lose SELF RESPECT)" << endl;
  477. cout << "5) Quit the game (Do I really have to explain this one?)" << endl;
  478. cout << "\n";
  479. cout << "Please chose an action: ";
  480. cin >> actionChoice;
  481. }
  482. }
  483. while(actionChoice != 1 && actionChoice != 2 && actionChoice != 3 && actionChoice != 4 && actionChoice != 5);
  484. if(!gameOver)
  485. {
  486. switch(actionChoice)
  487. {
  488. case 1:
  489. {
  490. int puzzleCheck = 0;
  491. if(etime >= 20)
  492. {
  493. cout << "You take some tentative steps forward down the dark... hallway.\n" << endl;
  494. steps = steps - 1;
  495. Encounter gameEncounter;
  496. Puzzle gamePuzzle;
  497. puzzleCheck = gameEncounter.displayEncounter(gameEncounter.selectEncounter(), etime, money, intelligence);
  498. if(puzzleCheck == 2)
  499. {
  500. gamePuzzle.displayPuzzle(gamePuzzle.puzzleNumber(), etime, money, intelligence);
  501. }
  502. }
  503. else if(etime < 20 && etime > 10)
  504. {
  505. cout << "You start to briskly... hop, down the corridor... time starts to nag you.\n" << endl;
  506. steps = steps - 1;
  507. Encounter gameEncounter;
  508. Puzzle gamePuzzle;
  509. puzzleCheck = gameEncounter.displayEncounter(gameEncounter.selectEncounter(), etime, money, intelligence);
  510. if(puzzleCheck == 2)
  511. {
  512. gamePuzzle.displayPuzzle(gamePuzzle.puzzleNumber(), etime, money, intelligence);
  513. }
  514. }
  515. else if(etime <= 10)
  516. {
  517. cout << "Mentally you start to hear the Super Mario World danger theme, this can only mean one thing..." << endl;
  518. cout << " Okay, maybe two... But its more likely time is running out than you'll be attacked by Bowser.. I think.\n" << endl;
  519. if(n == ("Mario") || n == ("Luigi") || n == ("mario") || n == ("luigi"))
  520. {
  521. cout << "Bowser appears! He throws a giant boulder at you! Quick, react!" << endl;
  522. cout << "1) Dodge!" << endl;
  523. cout << "2) Attack!" << endl;
  524. cout << "3) Item!" << endl;
  525. cout << "Action: ";
  526. cin >> bowserChoice;
  527.  
  528. switch(bowserChoice)
  529. {
  530. case 1:
  531. {
  532. cout << "You barely manage to squeeze by the boulder in this narrow hallway!";
  533. cout << "Now you go straight for Bowser!" << endl;
  534. cout << "1) Jump on his head!" << endl;
  535. cout << "2) Fire punch!" << endl;
  536. cout << "Action: ";
  537. cin >> bowserDodgeChoice;
  538.  
  539. switch(bowserDodgeChoice)
  540. {
  541. case 1:
  542. {
  543. cout << "You leap forth into the air majestically, for a plumber." << endl;
  544. cout << "And promply land on the Koopa King's Spiked Shell. Ouch..." << endl;
  545. cout << "Game Over.\n\n";
  546. gameOver = true;
  547. loseScreen(steps, etime, money, intelligence, bowserVictory, n);
  548. break;
  549. }
  550. case 2:
  551. {
  552. cout << "You wind up that blast of fire-y plumber magic." << endl;
  553. cout << "Landing it dead center, the Koopa King is going to become the Fried Fiend." << endl;
  554. cout << "You've saved the Mushroom Kingdom once again! You WIN!\n\n";
  555. bowserVictory = 1;
  556. gameOver = true;
  557. loseScreen(steps, etime, money, intelligence, bowserVictory, n);
  558. break;
  559. }
  560. }
  561. break;
  562. }
  563. case 2:
  564. {
  565. cout << "You break through that rocky obstruction, but your fist is a bit sore!";
  566. cout << "You've got to act fast!" << endl;
  567. cout << "1) Somersault Kick!" << endl;
  568. cout << "2) Hammer!" << endl;
  569. cout << "Action: ";
  570. cin >> bowserAttackChoice;
  571.  
  572. switch(bowserAttackChoice)
  573. {
  574. case 1:
  575. {
  576. cout << "With a running start-up you leap towards your nemisis!" << endl;
  577. cout << "You land your kick square in his jaw and send that reptile reeling!" << endl;
  578. cout << "You've saved the Mushroom Kingdom once again! You WIN!\n\n";
  579. bowserVictory = 1;
  580. gameOver = true;
  581. loseScreen(steps, etime, money, intelligence, bowserVictory, n);
  582. break;
  583. }
  584. case 2:
  585. {
  586. cout << "You lift your trusty hammer and swing it around towards the boss!" << endl;
  587. cout << "Unfortunately you lack the force due to your hurt hand to harm the heinous hide!" << endl;
  588. cout << "Bowser strikes back viciously!" << endl;
  589. cout << "Game Over.\n\n";
  590. gameOver = true;
  591. loseScreen(steps, etime, money, intelligence, bowserVictory, n);
  592. break;
  593. }
  594. }
  595. break;
  596. }
  597. case 3:
  598. {
  599.  
  600. cout << "You break out the big guns with your POW block!";
  601. cout << "Now that the way is clear you've got a clean shot on that Bulky Bowser!" << endl;
  602. cout << "1) Earthquake!" << endl;
  603. cout << "2) Sleepy Sheep!" << endl;
  604. cout << "Action: ";
  605. cin >> bowserItemChoice;
  606.  
  607. switch(bowserItemChoice)
  608. {
  609. case 1:
  610. {
  611. cout << "You toss out Earthquake at the evil lord!" << endl;
  612. cout << "Unfortunately for you, while you were rummaging through your bag King Koopa climbed in his Koopa Clown Car!" << endl;
  613. cout << "Bowser menacingly runs you down!" << endl;
  614. cout << "Game Over.\n\n";
  615. gameOver = true;
  616. loseScreen(steps, etime, money, intelligence, bowserVictory, n);
  617. break;
  618. }
  619. case 2:
  620. {
  621. cout << "You toss out the most fearsome weapon in your arsenal!" << endl;
  622. cout << "The fluffy sleepy sheep spread their sleepyness all around!";
  623. cout << " Not even the fearsome Koopa King can resist the eternal sleep!" << endl;
  624. cout << "You have condemned Bowser to a fate worse than death. You WIN!\n\n";
  625. bowserVictory = 1;
  626. gameOver = true;
  627. loseScreen(steps, etime, money, intelligence, bowserVictory, n);
  628. break;
  629. }
  630. }
  631. break;
  632. }
  633. }
  634. }
  635. else
  636. {
  637. cout << "You flee down the passageway, frightened of the mental clock that keeps ticking.\n" << endl;
  638. steps = steps - 1;
  639. Encounter gameEncounter;
  640. Puzzle gamePuzzle;
  641. puzzleCheck = gameEncounter.displayEncounter(gameEncounter.selectEncounter(), etime, money, intelligence);
  642. if(puzzleCheck == 2)
  643. {
  644. gamePuzzle.displayPuzzle(gamePuzzle.puzzleNumber(), etime, money, intelligence);
  645. }
  646.  
  647. }
  648.  
  649. }
  650. break;
  651. }
  652. case 2:
  653. {
  654. cout << "You find some technical papers...\n";
  655. if(intelligence < 12)
  656. {
  657. cout << "You can't really make out this techno-bable. So you eat the papers."<< endl;
  658. tempInt = rand() % 3 + 1;
  659. intelligence += tempInt;
  660. tempTime = rand() % 1 + 1;
  661. etime -= tempTime;
  662. cout << " Oh well, you let the information digest. Intelligence gain: " << tempInt;
  663. cout << " Time lost: " << tempTime << "\n" << endl;
  664. }
  665. else if(intelligence < 20 && intelligence >= 12)
  666. {
  667. cout << "Ah, it appears to be some papers on Quantum dimensional flux capacitors." << endl;
  668. tempInt = rand() % 3 + 1;
  669. intelligence += tempInt;
  670. tempTime = rand() % 1 + 1;
  671. etime -= tempTime;
  672. cout << " ...No I don't know what that means either. Intelligence gain: " << tempInt;
  673. cout << " Time lost: " << tempTime << "\n" << endl;
  674. }
  675. else if(intelligence >= 20)
  676. {
  677. cout << "These papers appear to be written in the scrawl of some pitiable under-graduate student." << endl;
  678. tempInt = rand() % 2;
  679. intelligence += tempInt;
  680. tempTime = rand() % 1 + 1;
  681. etime -= tempTime;
  682. cout << " You take some time to mock their lack of understanding of the mesosphere and symbiotic silicon-based pseudo-organic AI." << endl;
  683. cout << "This doesn't really seem to help your considerable intelligence. Intelligence gain: " << tempInt;
  684. cout << " Time lost: " << tempTime << "\n" << endl;
  685. }
  686. break;
  687. }
  688. case 3:
  689. {
  690. cout << "Like every college student, you find yourself face to face with your greatest nemisis... lack of funds." << endl;
  691. if(money < 6)
  692. {
  693. cout << "Scrounging around like the street urchin you are, you manage to find some shinies..." << endl;
  694. tempMoney = rand() % 3;
  695. money += tempMoney;
  696. tempTime = rand() % 1 + 1;
  697. etime -= tempTime;
  698. cout << "You've never seen coins like this, or coins at all for that matter, you gain, $" << tempMoney;
  699. cout << " Time lost: " << tempTime << "\n" << endl;
  700. }
  701. else if(money > 6 && money < 14)
  702. {
  703. cout << "You have a few coins in your pocket, but you know you can always use more..." << endl;
  704. tempMoney = rand() % 3;
  705. money += tempMoney;
  706. tempTime = rand() % 1 + 1;
  707. etime -= tempTime;
  708. cout << "You've managed to scrounge up some old bills, I hope they're current! You gain, $" << tempMoney;
  709. cout << " Time lost: " << tempTime << "\n" << endl;
  710. }
  711. else if(money >= 14)
  712. {
  713. cout << "Greed has completely overtaken you. You collosal wealth, for a college student, weighs you down considerably, but you must have more..." << endl;
  714. tempMoney = rand() % 3;
  715. money += tempMoney;
  716. tempTime = rand() % 2 + 1;
  717. etime -= tempTime;
  718. cout << "You barely manage to fill your overstuffed pockets, the immense weight of the coins impeedes your progress. You gain, $" << tempMoney;
  719. cout << " Time lost: " << tempTime << "\n" << endl;
  720. }
  721. break;
  722. }
  723. case 4:
  724. {
  725. if(intelligence == 1)
  726. {
  727. cout << "You..?" << endl;
  728. cout << "Intelligence: You see... a station." << endl;
  729. cout << "Time: ...a smiling... face." << endl;
  730. cout << "Money: ...HONK." << endl;
  731. cout << "\n";
  732. }
  733. else
  734. {
  735. cout << "You examine yourself: " << endl;
  736. cout << "Intelligence: " << intelligence << endl;
  737. cout << "Time: " << etime << endl;
  738. cout << "Money: $" << money << endl;
  739. cout << "\n";
  740. }
  741. break;
  742. }
  743. case 5:
  744. {
  745. cout << "Do you really want to quit? Y/N: ";
  746. cin >> userQuit;
  747. if(userQuit == ("Y") || userQuit == ("y") || userQuit == ("Yes") || userQuit == ("yes"))
  748. {
  749. loseScreen(steps, etime, money, intelligence, bowserVictory, n);
  750. }
  751. else if(userQuit == ("N") || userQuit == ("n") || userQuit == ("No") || userQuit == ("no"))
  752. {
  753. cout << "Then don't jump the gun!" << endl;
  754. }
  755. else if(userQuit == ("Banana"))
  756. {
  757. cout << "You hear a voice in your head... " << endl;
  758. int i = 0;
  759. do
  760. {
  761. cout << "HONK.";
  762. i++;
  763. }
  764. while(i < 500);
  765. cout << endl;
  766. loseScreen(steps, etime, money, intelligence, bowserVictory, n);
  767. }
  768. else
  769. {
  770. cout << "What..? Are instructions really that hard to follow?" << endl;
  771. cout << "\n";
  772. cout << "...";
  773. cout << "\n";
  774. cout << "You know... just for that. Game Over." << endl;
  775. loseScreen(steps, etime, money, intelligence, bowserVictory, n);
  776. }
  777. break;
  778. }
  779. }
  780. }
  781. }
  782. }
  783. void loseScreen(int steps, int etime, double money, int intelligence, int bowserVictory, string name)
  784. {
  785. int score = 0;
  786. HighScore highscore;
  787. if(steps == 0)
  788. {
  789. cout << "Congratulations, you managed to conquer the College of Winterhold! All hail the new High King of Skyrim!" << endl;
  790. score = (int)money * intelligence * etime;
  791. cout << "Your score is: " << score << "\n\n";
  792. highscore.writeToFile(name, score);
  793. }
  794. else if(money <= 0)
  795. {
  796. cout << "Your body is as devoid of soul as your wallet is of cash." << endl;
  797. cout << "Oh did I forget to mention the two were linked? Better luck next time." << endl;
  798. cout << "It looks like the perils of College have claimed another.\n\n";
  799. }
  800. else if(intelligence <=0)
  801. {
  802. cout << "You feel strange. You feel Nervous. You start convulsing violently! You twitch." << endl;
  803. cout << "You mutate into the CLOWN! HONK." << endl;
  804. cout << "It looks like the perils of College have claimed another.\n\n";
  805. }
  806. else if(etime <= 0)
  807. {
  808. cout << "You see the passageway ahead seal off forever. And such is your fate. To be entombed by the college." << endl;
  809. cout << "Also your glasses break. Such a shame, there was finally time." << endl;
  810. cout << "It looks like the perils of College have claimed another.\n\n";
  811. }
  812. else if(bowserVictory == 1)
  813. {
  814. cout << "Congratulations! You found an easter egg!\n" << endl;
  815. cout << "And in addition to that you managed to save the Mushroom Kingdom!\n" << endl;
  816. cout << "Here's what your score might have looked like had you choosen a different name: ";
  817. cout << ((int)money * intelligence * (steps - etime)) << endl;
  818. }
  819. else
  820. {
  821. cout << "Perhaps a savior will come for the Mushroom Kingdom some day." << endl;
  822. }
  823. cout << "Thanks for playing!\n\n";
  824. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement