Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.30 KB | None | 0 0
  1. let fear = 0;
  2. const maxFear = 4
  3. let name = ' Paula Castanheira'
  4. const yodaArgument = 'The path to the Dark Side of the Brute Force, fear is. To anger, fear leads. To hate, anger leads. To buggy code, hate leads. Do not let fear get to you, young';
  5. function javascript_abort(){
  6. throw new Error('GAME OVER!');}
  7.  
  8. //Setting the mood
  9. window.alert("The Code Wars: A battle for a spot in the Academy");
  10. console.log("The Code Wars: A battle for a spot in the Academy");
  11.  
  12. window.alert('The adventure of '+ name)
  13. console.log('The adventure of '+ name)
  14.  
  15. window.alert("As you step into the Academy main doors an alarm rings as you set foot inside. \n\nTo your stations Master Han Sudo has been taken prisioner. \n\nSomeone grabs you by the shirt and drags you into the shadows and tells you: \n\nYoung padawan we need your help. Use your Padawan Coder mind hacks to get yourself past Jabba the Bug's thugs and rescue Han Sudo, by freeing him from his carbonite encasing, without getting caught by Jabba the Bug himself!\n\n You have to hurry!");
  16. console.log("As you step into the Academy main doors an alarm rings as you set foot inside. \n\nTo your stations Master Han Sudo has been taken prisioner. \n\nSomeone grabs you by the shirt and drags you into the shadows and tells you: \n\nYoung padawan we need your help. Use your Padawan Coder mind hacks to get yourself past Jabba the Bug's thugs and rescue Han Sudo, and only him can accept members into the Academy.\n\n You have to hurry!");
  17.  
  18. //Dry run
  19. window.alert(yodaArgument + ' ' + name + '.');
  20. console.log(yodaArgument + ' ' + name + '.');
  21.  
  22. window.alert("Remember: Fear level must always be smaller than MaxFear.\n\nFear: "+fear+"\nMax Fear: "+maxFear);
  23. console.log("Remember: Fear level must always be smaller than MaxFear.\n\nFear: "+fear+"\nMax Fear: "+maxFear);
  24.  
  25.  
  26. //Force Task #1
  27. console.log("Force Task #1")
  28.  
  29. //level specific variables
  30. let percentageFrozen = 100;
  31. const totalTries = 4;
  32. let switchHit = 0;
  33. let rescued = false;
  34.  
  35. //Action
  36.  
  37. window.alert("\n\nYou used your coders mind and find Jabba's lair and you know the room were Han Sudo is being kept.\n\nAs you sneak inside the room you hear laser blasters! A group of hackertroopers is looking for you. Seems you were not as sneaky as you wanted. You have to hurry!");
  38. console.log("\n\nYou used your coders mind and find Jabba's lair and you know the room were Han Sudo is being kept.\n\nAs you sneak inside the room you hear laser blasters! A group of hackertroopers is looking for you. Seems you were not as sneaky as you wanted. You have to hurry!");
  39.  
  40. window.alert('Oh no, Han Sudo is trapped in carbonite. Quick, we must release him, before we get caught. Press the button');
  41. console.log('Oh no, Han Sudo is trapped in carbonite. Quick, we must release him, before we get caught. Press the button');
  42.  
  43. for (i=0;i<5;i++) {
  44. var hanSudoRescued=prompt("Press the button? Write Yes or No. " + i);
  45. while (hanSudoRescued===null) {
  46. window.alert("Clicking the cancel button is path to the darkside. Write Yes or No.");
  47. hanSudoRescued=prompt("Press the button? Write Yes or No.");
  48. }
  49.  
  50. var userInput=hanSudoRescued.toLowerCase();
  51. if (userInput==="") {
  52. switchHit = switchHit+1;
  53. fear = fear+1
  54. console.log("That's no answer! You just lost a chance.");
  55. window.alert("What kind of an answer is that? You just lost a chance to save Han!\n\nFear: "+fear+++"\nMax Fear: "+maxFear);
  56.  
  57. if(switchHit === totalTries+1 && rescued === false) {
  58. //if reader does not read properly and exceeds the number of empty answers
  59. console.log("You activated the inbeded alarm the room is troopers have found you, you have been taken prisioner.");
  60. window.alert("You activated the inbeded alarm the room is troopers have found you, you have been taken prisioner.\n\nGAME OVER");
  61. javascript_abort();
  62. }
  63.  
  64. } else if (userInput === "yes"){
  65. if(switchHit <= totalTries || rescued === false){
  66. function deFrost(){
  67. let defrost = percentageFrozen - (i*25)
  68. return defrost;
  69. };
  70. switch (deFrost()){
  71. case 75:
  72. console.log('Good job, it seems to be the right button, lets do this quickly and quietly.');
  73. rescue = false;
  74. break;
  75. case 50:
  76. console.log('Yes its almost done. One more try.');
  77. rescue = false;
  78. break;
  79. case 25:
  80. console.log('Hurry there\'s not much time, they are almost here.');
  81. rescue = false;
  82. break;
  83. case 0:
  84. rescue = true
  85. switchHit = switchHit+i;
  86. console.log("The Code Force is still strong with me, my fear level is "+fear);
  87. window.alert("Master you are free, only had to press " + switchHit +" times. Master we must get out quickly. Come with me! \n\nFear: "+fear+"\nMax Fear: "+maxFear);
  88. console.log ("Button Pressed " + switchHit + " times")
  89. break;
  90. }
  91. }
  92. }
  93. }
  94.  
  95. if(fear<maxFear){
  96. window.alert("The Brute Force is still strong with me. My fear level is"+ fear +".")
  97. console.log("The Brute Force is still strong with me. My fear level is"+ fear +".")
  98. }
  99.  
  100. //Force Task #2
  101. console.log("Force Task #2")
  102.  
  103. //level specific variables
  104.  
  105. const databaseEntry = ['Faction: First Galactic Empire', 'Name: Firms Piett', 'Rank: Admiral'];
  106. const stringtroopers = 4;
  107.  
  108. //Action
  109. window.alert("The Rebels are going to use the blueprints to invade and destroy the Death Star’s CPU. Go to the Moon of GNU to deactivate the merge conflicts deflective shield that protects the Death Star's Git repository. But first, you\'ll need R2-D2 (aka ‘Arturito’) to open the control room doors...")
  110. console.log("The Rebels are going to use the blueprints to invade and destroy the Death Star’s CPU. Go to the Moon of GNU to deactivate the merge conflicts deflective shield that protects the Death Star's Git repository. But first, you\'ll need R2-D2 (aka ‘Arturito’) to open the control room doors...")
  111.  
  112. let name1 = databaseEntry.find(a=>a.includes('Firms Piett'));
  113. let rank = databaseEntry.find(a=>a.includes('Admiral'));
  114. let faction = databaseEntry.find(a=>a.includes('First Galactic Empire'));
  115. const part1 = [name1.split(":") , rank.split(":") , faction.split(":")];
  116. let password = part1[0][1] + ',' + part1[1][1] + ' of the' + part1[2][1];
  117.  
  118. if (password.length>50) {
  119. window.alert("Alarms ring all over the base, the password was wrong." +stringtroopers+ " stringtoopers surround you")
  120. console.log("Alarms ring all over the base, the password was wrong." +stringtroopers+ " stringtoopers surround you")
  121. }else if (password.length<50){
  122. fear = fear + (stringtrooper/2)
  123. window.alert("Door opens, however you were seen by "+ stringtroopers/2+ " Stringtroopers.\n\nFear: "+fear+"\nMax Fear: "+maxFear)
  124. console.log("Door opens, however you were seen by "+ stringtroopers/2+ " Stringtroopers.\n\nFear: "+fear+"\nMax Fear: "+maxFear)
  125. }else if(password.length == 50) {
  126. window.alert("Doors open and you pass unoticed. Arturito and you make a good team it seems.")
  127. console.log("Doors open and you pass unoticed. Arturito and you make a good team it seems.")}
  128. if(fear<maxFear){
  129. window.alert("The Brute Force is still strong with me. My fear level is"+ fear +".")
  130. console.log("The Brute Force is still strong with me. My fear level is"+ fear +".")
  131. };
  132.  
  133. //Force Task #3
  134. console.log("Force Task #3")
  135.  
  136. //level specific variables
  137. const floors = 3;
  138. let darthHackerSensePower = 1;
  139. let codeForceDisguise = 3;
  140.  
  141. //Action
  142. window.alert("You and Arturito made it through the door, now its time to deactivate the merge conflicts deflective shield. To do so, find the shield's command line located on the 3rd floor and use the Brute Force to trick Darth Hacker's ability to sense your presence.");
  143. console.log("You and Arturito made it through the door, now its time to deactivate the merge conflicts deflective shield. To do so, find the shield's command line located on the 3rd floor and use the Brute Force to trick Darth Hacker's ability to sense your presence.");
  144.  
  145. window.alert("You press the elevator button to go up the floors. As it starts to move up you sense Darth_Hacker power searching for you. You feel fear rising in you as the counter on the elevator moves. Will you be able to control your fear and face Darth_Hacker?");
  146. console.log("You press the elevator button to go up the floors. As it starts to move up you sense Darth_Hacker power searching for you. You feel fear rising in you as the counter on the elevator moves. Will you be able to control your fear and face Darth_Hacker?");
  147.  
  148. for (i=0;i<=floors;i++) {
  149. if(i<=1){
  150. darthHackerSensePower = darthHackerSensePower
  151. codeForceDisguise = codeForceDisguise - (darthHackerSensePower - 1)
  152. console.log (fear);
  153. } else if (i <=floors) {
  154. darthHackerSensePower = darthHackerSensePower + 1;
  155. codeForceDisguise = codeForceDisguise - 1
  156. fear=fear+(darthHackerSensePower-codeForceDisguise);
  157. console.log(fear)
  158. }
  159. console.log("The elevator counter shows level "+i+" Let's see what happens!");
  160. window.alert("The elevator counter shows level "+i+" Let's see what happens!\n\nFear: "+fear+"\nMax Fear: "+maxFear+"\n\nCode Force Disguise: "+codeForceDisguise+"\nDarth Hacker Sense Power: "+darthHackerSensePower);
  161. if (codeForceDisguise<darthHackerSensePower) {
  162. if(fear>=maxFear){
  163. console.log("You have let your fear control you. You turn to the Dark Side of the Code Force.");
  164. window.alert("Your fear takes the best of you. You turn to the Dark Side of the Code Force.\n\nFear: "+fear+"\nMax Fear: "+maxFear+"\n\nCode Force Disguise: "+codeForceDisguise+"\nDarth Hacker Sense Power: "+darthHackerSensePower+"\n\nGAME OVER");
  165. javascript_abort();
  166. }else{
  167. window.alert("Your are getting scared but you remember Yoda saying: 'Fear is the path to the darkside'. You get yourself together and keep going.\n\nThe Brute Force is still strong with me. My fear level is "+fear+"\n\nMax Fear: "+maxFear+"\n\nCode Force Disguise: "+codeForceDisguise+"\nDarth Hacker Sense Power: "+darthHackerSensePower);
  168. };
  169. }
  170. }
  171. //Force Task #4 - The moment of truth.
  172. console.log("Force Task #4 - The moment of truth")
  173. //level specific variables
  174. const charactersArray = [
  175. ['☆','D','a','☆','☆','r'],
  176. ['t','☆','h','☆','H','a'],
  177. ['c','k','☆','e','☆','r'],
  178. ['L','☆','o','o','☆','p'],
  179. ['S','☆','k','y','☆','w'],
  180. ['a','l','☆','k','☆','☆'],
  181. ['☆','e','☆','☆','r','☆']
  182. ];
  183. let wordpressEmperorDefeated = false;
  184.  
  185. //Action
  186. window.alert("We've successfully deactivated Death Star's merge conflicts deflective shield. The Death Star's CPU is now vulnerable and the Rebel Fleet is ready to destroy it! We now have to face your final task:\n Save Darth Hacker (Loop Skywalker's father) and bring him back from the Dark Side of the Brute Force to help you take down the evil Wordpress Emperor!\nIn order for you to succeed, you must not fight Darth Hacker, but talk to him instead. The right conversation must take place...");
  187. console.log("We've successfully deactivated Death Star's merge conflicts deflective shield. The Death Star's CPU is now vulnerable and the Rebel Fleet is ready to destroy it! We now have to face your final task:\n Save Darth Hacker (Loop Skywalker's father) and bring him back from the Dark Side of the Brute Force to help you take down the evil Wordpress Emperor!\nIn order for you to succeed, you must not fight Darth Hacker, but talk to him instead. The right conversation must take place...");
  188.  
  189. var message = '';
  190.  
  191. for(i = 0; i < charactersArray.length; i++){
  192. for(j = 0; j < charactersArray[i].length; j++){
  193. if(charactersArray[i][j] != '☆'){
  194. message += charactersArray[i][j];
  195.  
  196. }
  197. }
  198. }
  199. console.log(message)
  200. window.alert("This is it, this is your moment of truth. \n\nYou look at Darth Hacker and breath deeply twice, hesitating before speaking the words.\n\n"+message+"\n\nthe words come out of your mouth in a rush.\n Will this be the correct way to bring him back?")
  201.  
  202. if(message.length == 24){
  203. wordpressEmperorDefeated = true;
  204. }
  205.  
  206. if(wordpressEmperorDefeated){
  207. console.log('You were right about me. Tell your sister... You were right!');
  208. window.alert('You were right about me. Tell your sister... You were right!');
  209. }else{
  210. fear += 4;
  211. console.log('POWER! UNLIMITED POWER! The Dark Forces of Code are strong within my command line!');
  212. window.alert('POWER! UNLIMITED POWER! The Dark Forces of Code are strong within my command line!');
  213. }
  214.  
  215. window.alert("The Galaxy is finally Wordpress free(*)! But for how long?\n\n(*) \'free\' as in \'free speech\', not as in \'free beer\'.");
  216. console.log("The Galaxy is finally Wordpress free(*)! But for how long?\n\n(*) \'free\' as in \'free speech\', not as in \'free beer\'.");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement