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

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