munch
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 

93 satır
1.8 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.stomach = new Stomach();
  10. }
  11. function Player(name = "Player") {
  12. Creature.call(this, name);
  13. this.fullness = 100;
  14. this.maxFullness = 200;
  15. }
  16. function Anthro() {
  17. this.mass = 80 * (Math.random()/2 - 0.25 + 1);
  18. this.build = "ordinary";
  19. if (this.mass < 70) {
  20. this.build = "skinny";
  21. } else if (this.mass > 90) {
  22. this.build = "fat";
  23. }
  24. this.species = pick(["dog","cat","lizard","deer","wolf","fox"]);
  25. Creature.call(this, name);
  26. this.description = function() {
  27. return this.build + " " + this.species;
  28. };
  29. }
  30. // vore stuff here
  31. function Container(name = "stomach") {
  32. this.name = name;
  33. this.contents = [];
  34. this.digested = [];
  35. this.digest = function(time) {
  36. };
  37. this.feed = function(prey) {
  38. this.contents.push(prey);
  39. };
  40. }
  41. function Stomach() {
  42. Container.call(this, "stomach");
  43. // health/sec
  44. this.damageRate = 15*100/86400;
  45. // kg/sec
  46. this.digestRate = 80/8640;
  47. this.digest = function(time) {
  48. let lines = [];
  49. this.contents.forEach(function(prey) {
  50. if (prey.health > 0) {
  51. let damage = Math.min(prey.health, this.damageRate * time);
  52. prey.health -= damage;
  53. time -= damage / this.damageRate;
  54. }
  55. if (prey.health <= 0) {
  56. let digested = Math.min(prey.mass, this.digestRate * time);
  57. prey.mass -= digested;
  58. }
  59. if (prey.mass <= 0) {
  60. lines.push("Your churning guts have reduced a " + prey.description() + " to meaty chyme.");
  61. this.digested.push(prey);
  62. }
  63. }, this);
  64. this.contents.filter(function(prey) {
  65. return prey.mass > 0;
  66. });
  67. return lines;
  68. };
  69. }