crunch
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

216 lines
6.2 KiB

  1. "use strict";
  2. function pickString(...array){
  3. var strings = array;
  4. var pick = strings[~~(Math.random() * strings.length)];
  5. return pick;
  6. }
  7. function pickStringChance(chance, ...array) {
  8. if (Math.random() < chance) {
  9. return pickString(...array);
  10. } else {
  11. return ""
  12. }
  13. }
  14. function DialogNode() {
  15. this.text = [];
  16. this.hooks = [];
  17. this.requirements = [];
  18. this.visit = function() {
  19. for (let i=0; i<this.hooks.length; i++)
  20. this.hooks[i]();
  21. };
  22. this.choices = [];
  23. this.addChoice = function(text,node,tests=[]) {
  24. this.choices.push({"text": text, "node": node, "tests": []});
  25. };
  26. }
  27. function EatDude() {
  28. DialogNode.call(this);
  29. let nerd = new Anthro();
  30. this.text = ["You approach " + nerd.description("the")];
  31. let eatHim = new DialogNode();
  32. eatHim.text = [pickString("You eat the nerd. Burp.","You devour the unsuspecting nerd.")];
  33. eatHim.hooks.push(function() { player.stomach.feed(nerd); });
  34. let dontEatHim = new DialogNode();
  35. dontEatHim.text = ["You don't eat the nerd."];
  36. this.addChoice("Eat him lol",eatHim);
  37. this.addChoice("Actually don't",dontEatHim);
  38. }
  39. function PhoneCall() {
  40. DialogNode.call(this);
  41. this.text = ["You pick up the phone. Who do you want to call?"];
  42. {
  43. let nodeFen = new DialogNode();
  44. this.addChoice("Fen",nodeFen);
  45. nodeFen.text = ["You dial Fen's number. Milliseconds later, he kicks open your front door and dabs on you, then runs away."];
  46. }
  47. {
  48. let nodeNerd = new DialogNode();
  49. this.addChoice("Some nerd",nodeNerd);
  50. nodeNerd.text = ["You dial some nerd. He shows up at your front door."];
  51. nodeNerd.hooks.push(function() { startDialog(new EatDude()); });
  52. }
  53. {
  54. let nodeCrash = new DialogNode();
  55. this.addChoice("Crash the game",nodeCrash);
  56. nodeCrash.text = ["Oh no oops"];
  57. nodeCrash.hooks.push(function() { potato() });
  58. }
  59. }
  60. function FallenFoe(foe) {
  61. DialogNode.call(this);
  62. this.text = [foe.description("The") + " falls to the ground!", newline, "What do you want to do with your enemy?"];
  63. {
  64. let nodeEat = new DialogNode();
  65. this.addChoice("Devour!",nodeEat);
  66. nodeEat.text = [pickString("You grab your helpless prey and force them down your gullet. You hack up their wallet a minute later, finding $" + foe.cash + " inside.","You force them down your maw and while they are going down, you grab their wallet. Once they are safely in your stomach, you open it to find $" + foe.cash + ".","You eat them, but not before taking $" + foe.cash + " from their wallet.")];
  67. nodeEat.requirements.push( function(attacker, defender) {
  68. return defender.prefs.prey;
  69. });
  70. nodeEat.hooks.push(function() {
  71. player.cash += foe.cash;
  72. });
  73. nodeEat.hooks.push(function() {
  74. player.stomach.feed(foe);
  75. })
  76. }
  77. {
  78. let nodeSpare = new DialogNode();
  79. this.addChoice("Spare",nodeSpare);
  80. nodeSpare.text = ["You decide to leave your foe uneaten.", newline, "You do help yourself to the $" + foe.cash + " in their pockets, though."];
  81. nodeSpare.hooks.push(function() {
  82. player.cash += foe.cash;
  83. });
  84. }
  85. {
  86. let nodeCrush = new DialogNode();
  87. this.addChoice("Crush",nodeCrush);
  88. nodeCrush.text = ["You slam your paw down hard, crushing " + foe.description("the") + " like a bug"];
  89. nodeCrush.requirements.push( function(attacker, defender) {
  90. return defender.flags.shrunk == true;
  91. });
  92. }
  93. }
  94. function NatureExercise() {
  95. DialogNode.call(this);
  96. this.text = ["What do you want to do?"];
  97. {
  98. let nodeStrength = new DialogNode();
  99. this.addChoice("Rock Climbing (+STR)", nodeStrength);
  100. nodeStrength.text = ["You clamber up walls for a while. You feel a little stronger."];
  101. nodeStrength.hooks.push(function() {
  102. player.str += 1;
  103. advanceTime(60*30);
  104. });
  105. }
  106. {
  107. let nodeDexterity = new DialogNode();
  108. this.addChoice("Jogging (+DEX)", nodeDexterity);
  109. nodeDexterity.text = ["You go run for a run around the three-mile-long trail. You feel a little more agile."];
  110. nodeDexterity.hooks.push(function() {
  111. player.dex += 1;
  112. advanceTime(60*30);
  113. });
  114. }
  115. {
  116. let nodeConstitution = new DialogNode();
  117. this.addChoice("Bang your head on a tree (+CON)", nodeConstitution);
  118. nodeConstitution.text = ["You bash your face on a tree for half an hour. I guess that helps."];
  119. nodeConstitution.hooks.push(function() {
  120. player.con += 1;
  121. advanceTime(60*30);
  122. });
  123. }
  124. }
  125. function VendingMachinePurchase() {
  126. DialogNode.call(this);
  127. this.text = ["You walk up to the vending machine. A variety of foodstuffs and drinks are on display...along with some more unconventional items."];
  128. {
  129. let nodeCandy = new DialogNode();
  130. this.addChoice("Buy a candy bar ($2, +50 stamina)", nodeCandy);
  131. nodeCandy.text = ["You insert two dollar bills into the machine and select the candy bar. Chocolate and nougat, mmm."];
  132. nodeCandy.hooks.push(function() {
  133. player.cash -= 2;
  134. player.changeStamina(50);
  135. });
  136. nodeCandy.requirements.push(function(player) {
  137. return player.cash >= 2;
  138. });
  139. }
  140. {
  141. let nodeSoda = new DialogNode();
  142. this.addChoice("Buy a soda ($4, +150 stamina)", nodeSoda);
  143. nodeSoda.text = ["You insert a dollar and coins, then select a soda. You're pretty you saw something on the news about it turning people purple, but you can't resist that delicious Citrus Substitute Flavor&trade;"];
  144. nodeSoda.hooks.push(function() {
  145. player.cash -= 2;
  146. player.changeStamina(150);
  147. });
  148. nodeSoda.requirements.push(function(player) {
  149. return player.cash >= 2;
  150. });
  151. }
  152. {
  153. let prey = new Micro();
  154. let nodeMicro = new DialogNode();
  155. this.addChoice("Buy a micro ($10)", nodeMicro);
  156. nodeMicro.text = ["You stuff a wad of bills into the machine. " + prey.description("A") + " tumbles into the vending slot; you scoop them up and stuff them into your jaws without a second thought. Tasty."];
  157. nodeMicro.hooks.push(function() {
  158. player.stomach.feed(prey);
  159. player.cash -= 10;
  160. });
  161. nodeMicro.requirements.push(function(player) {
  162. return player.cash >= 10;
  163. });
  164. }
  165. {
  166. let nodeCancel = new DialogNode();
  167. this.addChoice("Nevermind", nodeCancel);
  168. nodeCancel.text = ["You decide to not purchase anything."];
  169. }
  170. }