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

134 行
2.6 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. }
  12. function Player(name = "Player") {
  13. Creature.call(this, name);
  14. this.fullness = function() {
  15. return this.stomach.fullness();
  16. }
  17. }
  18. function Anthro() {
  19. this.mass = 80 * (Math.random()/2 - 0.25 + 1);
  20. this.build = "ordinary";
  21. if (this.mass < 70) {
  22. this.build = "skinny";
  23. } else if (this.mass > 90) {
  24. this.build = "fat";
  25. }
  26. this.species = pick(["dog","cat","lizard","deer","wolf","fox"]);
  27. Creature.call(this, name);
  28. this.description = function() {
  29. return this.build + " " + this.species;
  30. };
  31. }
  32. // vore stuff here
  33. function Container(name) {
  34. this.name = name;
  35. this.contents = [];
  36. // health/sec
  37. this.damageRate = 15*100/86400;
  38. // kg/sec
  39. this.digestRate = 80/8640;
  40. this.digest = function(time) {
  41. let lines = [];
  42. this.contents.forEach(function(prey) {
  43. if (prey.health > 0) {
  44. let damage = Math.min(prey.health, this.damageRate * time);
  45. prey.health -= damage;
  46. time -= damage / this.damageRate;
  47. if (prey.health <= 0) {
  48. lines.push(this.describeKill(prey));
  49. }
  50. }
  51. if (prey.health <= 0) {
  52. let digested = Math.min(prey.mass, this.digestRate * time);
  53. prey.mass -= digested;
  54. this.fill(digested);
  55. }
  56. if (prey.mass <= 0) {
  57. lines.push(this.describeFinish(prey));
  58. this.finish(prey);
  59. }
  60. }, this);
  61. this.contents = this.contents.filter(function(prey) {
  62. return prey.mass > 0;
  63. });
  64. return lines;
  65. };
  66. this.feed = function(prey) {
  67. this.contents.push(prey);
  68. };
  69. this.fullness = function() {
  70. return this.contents.reduce((total, prey) => total + prey.mass, 0);
  71. }
  72. }
  73. function Stomach(bowels) {
  74. Container.call(this, "stomach");
  75. this.describeKill = function(prey) {
  76. return "The " + prey.description() + "'s struggles wane as your stomach overpowers them.";
  77. }
  78. this.describeFinish = function(prey) {
  79. return "Your churning guts have reduced a " + prey.description() + " to meaty chyme.";
  80. };
  81. this.fill = function(amount) {
  82. bowels.add(amount);
  83. };
  84. this.finish = function(prey) {
  85. bowels.finish(prey);
  86. };
  87. }
  88. function WasteContainer(name) {
  89. this.name = name;
  90. this.fullness = 0;
  91. this.contents = [];
  92. this.add = function(amount) {
  93. this.fullness += amount;
  94. };
  95. this.finish = function(prey) {
  96. this.contents.push(prey);
  97. };
  98. }
  99. function Bowels() {
  100. WasteContainer.call(this, "Bowels");
  101. }