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

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