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

204 行
4.0 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.str = 10;
  13. this.dex = 10;
  14. this.con = 10;
  15. }
  16. function Player(name = "Player") {
  17. Creature.call(this, name);
  18. this.fullness = function() {
  19. return this.stomach.fullness();
  20. }
  21. }
  22. function Anthro() {
  23. Creature.call(this, name);
  24. this.mass = 80 * (Math.random()/2 - 0.25 + 1);
  25. this.build = "ordinary";
  26. if (this.mass < 70) {
  27. this.build = "skinny";
  28. } else if (this.mass > 90) {
  29. this.build = "fat";
  30. }
  31. this.species = pick(["dog","cat","lizard","deer","wolf","fox"]);
  32. this.description = function() {
  33. return this.build + " " + this.species;
  34. };
  35. }
  36. function Micro() {
  37. Creature.call(this, name);
  38. this.health = 5;
  39. this.mass = 0.1 * (Math.random()/2 - 0.25 + 1);
  40. this.species = pick(["dog","cat","lizard","deer","wolf","fox"]);
  41. this.description = function() {
  42. return "micro " + this.species;
  43. };
  44. }
  45. // vore stuff here
  46. class Container {
  47. constructor(name) {
  48. this.name = name;
  49. this.contents = [];
  50. // health/sec
  51. this.damageRate = 15*100/86400;
  52. // kg/sec
  53. this.digestRate = 80/8640;
  54. }
  55. digest(time) {
  56. let lines = [];
  57. this.contents.forEach(function(prey) {
  58. if (prey.health > 0) {
  59. let damage = Math.min(prey.health, this.damageRate * time);
  60. prey.health -= damage;
  61. time -= damage / this.damageRate;
  62. if (prey.health <= 0) {
  63. lines.push(this.describeKill(prey));
  64. }
  65. }
  66. if (prey.health <= 0) {
  67. let digested = Math.min(prey.mass, this.digestRate * time);
  68. prey.mass -= digested;
  69. this.fill(digested);
  70. }
  71. if (prey.mass <= 0) {
  72. lines.push(this.describeFinish(prey));
  73. this.finish(prey);
  74. }
  75. }, this);
  76. this.contents = this.contents.filter(function(prey) {
  77. return prey.mass > 0;
  78. });
  79. return lines;
  80. }
  81. feed(prey) {
  82. this.contents.push(prey);
  83. }
  84. fullness() {
  85. return this.contents.reduce((total, prey) => total + prey.mass, 0);
  86. }
  87. }
  88. class Stomach extends Container {
  89. constructor(bowels) {
  90. super();
  91. this.bowels = bowels;
  92. }
  93. describeKill(prey) {
  94. return "The " + prey.description() + "'s struggles wane as your stomach overpowers them.";
  95. }
  96. describeFinish(prey) {
  97. return "Your churning guts have reduced a " + prey.description() + " to meaty chyme.";
  98. }
  99. fill(amount) {
  100. this.bowels.add(amount);
  101. }
  102. finish(prey) {
  103. this.bowels.finish(prey);
  104. }
  105. }
  106. class Butt extends Container {
  107. constructor(bowels, stomach) {
  108. super();
  109. this.bowels = bowels;
  110. this.stomach = stomach;
  111. }
  112. digest(time) {
  113. this.contents.forEach(function (x) {
  114. x.timeInButt += time;
  115. });
  116. let lines = super.digest(time);
  117. let pushed = this.contents.filter(prey => prey.timeInButt >= 60 * 30);
  118. pushed.forEach(function(x) {
  119. this.stomach.feed(x);
  120. lines.push("Your winding guts squeeze the " + x.description() + " into your stomach.");
  121. },this);
  122. this.contents = this.contents.filter(prey => prey.timeInButt < 60 * 30);
  123. return lines;
  124. }
  125. describeKill(prey) {
  126. return "The " + prey.description() + " abruptly stops struggling, overpowered by your winding intestines.";
  127. }
  128. describeFinish(prey) {
  129. return "That delicious " + prey.description() + " didn't even make it to your stomach...now they're gone.";
  130. }
  131. feed(prey) {
  132. prey.timeInButt = 0;
  133. super.feed(prey);
  134. }
  135. fill(amount) {
  136. this.bowels.add(amount);
  137. }
  138. finish(prey) {
  139. this.bowels.finish(prey);
  140. }
  141. }
  142. function WasteContainer(name) {
  143. this.name = name;
  144. this.fullness = 0;
  145. this.contents = [];
  146. this.add = function(amount) {
  147. this.fullness += amount;
  148. };
  149. this.finish = function(prey) {
  150. this.contents.push(prey);
  151. };
  152. }
  153. function Bowels() {
  154. WasteContainer.call(this, "Bowels");
  155. }