crunch
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 

299 řádky
6.4 KiB

  1. function pick(list) {
  2. if (list.length == 0)
  3. return null;
  4. else
  5. return list[Math.floor(Math.random()*list.length)];
  6. }
  7. function Creature(name = "Creature") {
  8. this.name = name;
  9. this.health = 100;
  10. this.maxHealth = 100;
  11. this.mass = 80;
  12. this.bowels = new Bowels();
  13. this.stomach = new Stomach(this.bowels);
  14. this.butt = new Butt(this.bowels,this.stomach);
  15. this.attacks = [];
  16. this.str = 10;
  17. this.dex = 10;
  18. this.con = 10;
  19. }
  20. function Player(name = "Player") {
  21. Creature.call(this, name);
  22. this.fullness = function() {
  23. return this.stomach.fullness();
  24. };
  25. this.attacks.push(new punchAttack(this));
  26. this.attacks.push(new flankAttack(this));
  27. this.str = 15;
  28. this.dex = 15;
  29. this.con = 15;
  30. }
  31. function Anthro() {
  32. Creature.call(this, name);
  33. this.mass = 80 * (Math.random()/2 - 0.25 + 1);
  34. this.build = "ordinary";
  35. if (this.mass < 70) {
  36. this.build = "skinny";
  37. } else if (this.mass > 90) {
  38. this.build = "fat";
  39. }
  40. this.species = pick(["dog","cat","lizard","deer","wolf","fox"]);
  41. this.description = function() {
  42. return this.build + " " + this.species;
  43. };
  44. this.attacks.push(new punchAttack(this));
  45. this.attacks.push(new flankAttack(this));
  46. this.struggles = [];
  47. this.struggles.push(new plead(this));
  48. this.struggles.push(new struggle(this));
  49. }
  50. function Fen() {
  51. Anthro.call(this, name);
  52. this.build = "loomy";
  53. this.species = "crux";
  54. this.attacks = [];
  55. this.attacks.push(new devourPlayer(this));
  56. this.backupAttack = new poke(this);
  57. this.struggles = [];
  58. this.struggles.push(new rub(this));
  59. }
  60. function Micro() {
  61. Creature.call(this, name);
  62. this.health = 5;
  63. this.mass = 0.1 * (Math.random()/2 - 0.25 + 1);
  64. this.species = pick(["dog","cat","lizard","deer","wolf","fox"]);
  65. this.description = function() {
  66. return "micro " + this.species;
  67. };
  68. }
  69. // vore stuff here
  70. class Container {
  71. constructor(name) {
  72. this.name = name;
  73. this.contents = [];
  74. // health/sec
  75. this.damageRate = 15*100/86400;
  76. // kg/sec
  77. this.digestRate = 80/8640;
  78. }
  79. digest(time) {
  80. let lines = [];
  81. this.contents.forEach(function(prey) {
  82. if (prey.health > 0) {
  83. let damage = Math.min(prey.health, this.damageRate * time);
  84. prey.health -= damage;
  85. time -= damage / this.damageRate;
  86. if (prey.health <= 0) {
  87. lines.push(this.describeKill(prey));
  88. }
  89. }
  90. if (prey.health <= 0) {
  91. let digested = Math.min(prey.mass, this.digestRate * time);
  92. prey.mass -= digested;
  93. this.fill(digested);
  94. }
  95. if (prey.mass <= 0) {
  96. lines.push(this.describeFinish(prey));
  97. this.finish(prey);
  98. }
  99. }, this);
  100. this.contents = this.contents.filter(function(prey) {
  101. return prey.mass > 0;
  102. });
  103. return lines;
  104. }
  105. feed(prey) {
  106. this.contents.push(prey);
  107. }
  108. fullness() {
  109. return this.contents.reduce((total, prey) => total + prey.mass, 0);
  110. }
  111. }
  112. class Stomach extends Container {
  113. constructor(bowels) {
  114. super();
  115. this.bowels = bowels;
  116. }
  117. describeKill(prey) {
  118. return "The " + prey.description() + "'s struggles wane as your stomach overpowers them.";
  119. }
  120. describeFinish(prey) {
  121. return "Your churning guts have reduced a " + prey.description() + " to meaty chyme.";
  122. }
  123. fill(amount) {
  124. this.bowels.add(amount);
  125. }
  126. finish(prey) {
  127. this.bowels.finish(prey);
  128. }
  129. }
  130. class Butt extends Container {
  131. constructor(bowels, stomach) {
  132. super();
  133. this.bowels = bowels;
  134. this.stomach = stomach;
  135. }
  136. digest(time) {
  137. this.contents.forEach(function (x) {
  138. x.timeInButt += time;
  139. });
  140. let lines = super.digest(time);
  141. let pushed = this.contents.filter(prey => prey.timeInButt >= 60 * 30);
  142. pushed.forEach(function(x) {
  143. this.stomach.feed(x);
  144. lines.push("Your winding guts squeeze the " + x.description() + " into your stomach.");
  145. },this);
  146. this.contents = this.contents.filter(prey => prey.timeInButt < 60 * 30);
  147. return lines;
  148. }
  149. describeKill(prey) {
  150. return "The " + prey.description() + " abruptly stops struggling, overpowered by your winding intestines.";
  151. }
  152. describeFinish(prey) {
  153. return "That delicious " + prey.description() + " didn't even make it to your stomach...now they're gone.";
  154. }
  155. feed(prey) {
  156. prey.timeInButt = 0;
  157. super.feed(prey);
  158. }
  159. fill(amount) {
  160. this.bowels.add(amount);
  161. }
  162. finish(prey) {
  163. this.bowels.finish(prey);
  164. }
  165. }
  166. function WasteContainer(name) {
  167. this.name = name;
  168. this.fullness = 0;
  169. this.contents = [];
  170. this.add = function(amount) {
  171. this.fullness += amount;
  172. };
  173. this.finish = function(prey) {
  174. this.contents.push(prey);
  175. };
  176. }
  177. function Bowels() {
  178. WasteContainer.call(this, "Bowels");
  179. }
  180. // PLAYER PREY
  181. function plead(predator) {
  182. return {
  183. name: "Plead",
  184. desc: "Ask very, very nicely for the predator to let you go. More effective if you haven't hurt your predator.",
  185. struggle: function(player) {
  186. let escape = Math.random() < predator.health / predator.maxHealth;
  187. if (escape) {
  188. return {
  189. "escape": escape,
  190. "lines": ["You plead for the " + predator.description() + " to let you free, and they begrudingly agree, horking you up and leaving you shivering on the ground"]
  191. };
  192. } else {
  193. return {
  194. "escape": escape,
  195. "lines": ["You plead with the " + predator.description() + " to let you go, but they refuse."]
  196. };
  197. }
  198. }
  199. };
  200. }
  201. function struggle(predator) {
  202. return {
  203. name: "Struggle",
  204. desc: "Try to squirm free. More effective if you've hurt your predator.",
  205. struggle: function(player) {
  206. let escape = Math.random() > predator.health / predator.maxHealth;
  207. if (escape) {
  208. return {
  209. "escape": escape,
  210. "lines": ["You struggle and squirm, forcing the " + predator.description() + " to hork you up. They groan and stumble away, exhausted by your efforts."]
  211. };
  212. } else {
  213. return {
  214. "escape": escape,
  215. "lines": ["You squirm and writhe within the " + predator.description() + " to no avail."]
  216. };
  217. }
  218. }
  219. };
  220. }
  221. function rub(predator) {
  222. return {
  223. name: "Rub",
  224. desc: "Rub rub rub",
  225. struggle: function(player) {
  226. return {
  227. "escape": false,
  228. "lines": ["You rub the walls of your predator's belly. At least the " + predator.description() + " is getting something out of this."]
  229. };
  230. }
  231. };
  232. }