crunch
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 

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