crunch
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

298 line
6.4 KiB

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