crunch
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 

126 wiersze
2.4 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. }
  48. if (prey.health <= 0) {
  49. let digested = Math.min(prey.mass, this.digestRate * time);
  50. prey.mass -= digested;
  51. this.fill(digested);
  52. }
  53. if (prey.mass <= 0) {
  54. lines.push(this.describeDigest(prey));
  55. this.finish(prey);
  56. }
  57. }, this);
  58. this.contents = this.contents.filter(function(prey) {
  59. return prey.mass > 0;
  60. });
  61. return lines;
  62. };
  63. this.feed = function(prey) {
  64. this.contents.push(prey);
  65. };
  66. this.fullness = function() {
  67. return this.contents.reduce((total, prey) => total + prey.mass, 0);
  68. }
  69. }
  70. function Stomach(bowels) {
  71. Container.call(this, "stomach");
  72. this.describeDigest = function(prey) {
  73. return "Your churning guts have reduced a " + prey.description() + " to meaty chyme.";
  74. };
  75. this.fill = function(amount) {
  76. bowels.add(amount);
  77. };
  78. this.finish = function(prey) {
  79. bowels.finish(prey);
  80. };
  81. }
  82. function WasteContainer(name) {
  83. this.name = name;
  84. this.fullness = 0;
  85. this.contents = [];
  86. this.add = function(amount) {
  87. this.fullness += amount;
  88. };
  89. this.finish = function(prey) {
  90. this.contents.push(prey);
  91. };
  92. }
  93. function Bowels() {
  94. WasteContainer.call(this, "Bowels");
  95. }