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

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