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.
 
 
 

323 lines
7.1 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. this.digests = [];
  50. this.digests.push(new digestPlayerStomach(this,20));
  51. this.backupDigest = new digestPlayerStomach(this,20);
  52. }
  53. function Fen() {
  54. Anthro.call(this, name);
  55. this.build = "loomy";
  56. this.species = "crux";
  57. this.attacks = [];
  58. this.attacks.push(new devourPlayer(this));
  59. this.attacks.push(new leer(this));
  60. this.backupAttack = new poke(this);
  61. this.struggles = [];
  62. this.struggles.push(new rub(this));
  63. this.digests = [];
  64. this.digests.push(new digestPlayerStomach(this,50));
  65. this.backupDigest = new digestPlayerStomach(this,50);
  66. }
  67. function Micro() {
  68. Creature.call(this, name);
  69. this.health = 5;
  70. this.mass = 0.1 * (Math.random()/2 - 0.25 + 1);
  71. this.species = pick(["dog","cat","lizard","deer","wolf","fox"]);
  72. this.description = function() {
  73. return "micro " + this.species;
  74. };
  75. }
  76. // vore stuff here
  77. class Container {
  78. constructor(name) {
  79. this.name = name;
  80. this.contents = [];
  81. // health/sec
  82. this.damageRate = 15*100/86400;
  83. // kg/sec
  84. this.digestRate = 80/8640;
  85. }
  86. digest(time) {
  87. let lines = [];
  88. this.contents.forEach(function(prey) {
  89. if (prey.health > 0) {
  90. let damage = Math.min(prey.health, this.damageRate * time);
  91. prey.health -= damage;
  92. time -= damage / this.damageRate;
  93. if (prey.health + damage > 50 && prey.health <= 50) {
  94. lines.push(this.describeDamage(prey));
  95. }
  96. if (prey.health <= 0) {
  97. lines.push(this.describeKill(prey));
  98. }
  99. }
  100. if (prey.health <= 0) {
  101. let digested = Math.min(prey.mass, this.digestRate * time);
  102. prey.mass -= digested;
  103. this.fill(digested);
  104. }
  105. if (prey.mass <= 0) {
  106. lines.push(this.describeFinish(prey));
  107. this.finish(prey);
  108. }
  109. }, this);
  110. this.contents = this.contents.filter(function(prey) {
  111. return prey.mass > 0;
  112. });
  113. return lines;
  114. }
  115. feed(prey) {
  116. this.contents.push(prey);
  117. }
  118. fullness() {
  119. return this.contents.reduce((total, prey) => total + prey.mass, 0);
  120. }
  121. }
  122. class Stomach extends Container {
  123. constructor(bowels) {
  124. super();
  125. this.bowels = bowels;
  126. }
  127. describeDamage(prey) {
  128. return "Your guts gurgle and churn, slowly wearing down the " + prey.description() + " trapped within.";
  129. }
  130. describeKill(prey) {
  131. return "The " + prey.description() + "'s struggles wane as your stomach overpowers them.";
  132. }
  133. describeFinish(prey) {
  134. return "Your churning guts have reduced a " + prey.description() + " to meaty chyme.";
  135. }
  136. fill(amount) {
  137. this.bowels.add(amount);
  138. }
  139. finish(prey) {
  140. this.bowels.finish(prey);
  141. }
  142. }
  143. class Butt extends Container {
  144. constructor(bowels, stomach) {
  145. super();
  146. this.bowels = bowels;
  147. this.stomach = stomach;
  148. }
  149. digest(time) {
  150. this.contents.forEach(function (x) {
  151. x.timeInButt += time;
  152. });
  153. let lines = super.digest(time);
  154. let pushed = this.contents.filter(prey => prey.timeInButt >= 60 * 30);
  155. pushed.forEach(function(x) {
  156. this.stomach.feed(x);
  157. lines.push("Your winding guts squeeze the " + x.description() + " into your stomach.");
  158. },this);
  159. this.contents = this.contents.filter(prey => prey.timeInButt < 60 * 30);
  160. return lines;
  161. }
  162. describeDamage(prey) {
  163. return "Your bowels gurgle and squeeze, working to wear down the " + prey.description() + " trapped in those musky confines.";
  164. }
  165. describeKill(prey) {
  166. return "The " + prey.description() + " abruptly stops struggling, overpowered by your winding intestines.";
  167. }
  168. describeFinish(prey) {
  169. return "That delicious " + prey.description() + " didn't even make it to your stomach...now they're gone.";
  170. }
  171. feed(prey) {
  172. prey.timeInButt = 0;
  173. super.feed(prey);
  174. }
  175. fill(amount) {
  176. this.bowels.add(amount);
  177. }
  178. finish(prey) {
  179. this.bowels.finish(prey);
  180. }
  181. }
  182. function WasteContainer(name) {
  183. this.name = name;
  184. this.fullness = 0;
  185. this.contents = [];
  186. this.add = function(amount) {
  187. this.fullness += amount;
  188. };
  189. this.finish = function(prey) {
  190. this.contents.push(prey);
  191. };
  192. }
  193. function Bowels() {
  194. WasteContainer.call(this, "Bowels");
  195. }
  196. // PLAYER PREY
  197. function plead(predator) {
  198. return {
  199. name: "Plead",
  200. desc: "Ask very, very nicely for the predator to let you go. More effective if you haven't hurt your predator.",
  201. struggle: function(player) {
  202. let escape = Math.random() < predator.health / predator.maxHealth;
  203. if (escape) {
  204. return {
  205. "escape": escape,
  206. "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"]
  207. };
  208. } else {
  209. return {
  210. "escape": escape,
  211. "lines": ["You plead with the " + predator.description() + " to let you go, but they refuse."]
  212. };
  213. }
  214. }
  215. };
  216. }
  217. function struggle(predator) {
  218. return {
  219. name: "Struggle",
  220. desc: "Try to squirm free. More effective if you've hurt your predator.",
  221. struggle: function(player) {
  222. let escape = Math.random() > predator.health / predator.maxHealth;
  223. if (escape) {
  224. return {
  225. "escape": escape,
  226. "lines": ["You struggle and squirm, forcing the " + predator.description() + " to hork you up. They groan and stumble away, exhausted by your efforts."]
  227. };
  228. } else {
  229. return {
  230. "escape": escape,
  231. "lines": ["You squirm and writhe within the " + predator.description() + " to no avail."]
  232. };
  233. }
  234. }
  235. };
  236. }
  237. function rub(predator) {
  238. return {
  239. name: "Rub",
  240. desc: "Rub rub rub",
  241. struggle: function(player) {
  242. return {
  243. "escape": false,
  244. "lines": ["You rub the walls of your predator's belly. At least the " + predator.description() + " is getting something out of this."]
  245. };
  246. }
  247. };
  248. }