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

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