crunch
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 

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