crunch
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

196 行
5.4 KiB

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