crunch
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

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