Преглед на файлове

Eating works properly now

tags/v0.2.8
Fen Dweller преди 7 години
родител
ревизия
1847ed2691
променени са 3 файла, в които са добавени 59 реда и са изтрити 9 реда
  1. +4
    -2
      dialog.js
  2. +1
    -0
      feast.js
  3. +54
    -7
      vore.js

+ 4
- 2
dialog.js Целия файл

@@ -20,12 +20,14 @@ function DialogNode() {
function EatDude() {
DialogNode.call(this);

this.text = "You approach the nerd.";
let nerd = new Anthro();

this.text = "You approach the " + nerd.description();

let eatHim = new DialogNode();

eatHim.text = "You eat the nerd. Burp.";
eatHim.hooks.push(function() { player.health += 100 } );
eatHim.hooks.push(function() { player.stomach.feed(nerd); });

let dontEatHim = new DialogNode();
dontEatHim.text = "You don't eat the nerd.";


+ 1
- 0
feast.js Целия файл

@@ -108,6 +108,7 @@ function updateDisplay() {

function advanceTime(amount) {
time = (time + amount) % 86400;
update(player.stomach.digest(amount));
}

function renderTime(time) {


+ 54
- 7
vore.js Целия файл

@@ -7,7 +7,7 @@ function Creature(name = "Creature") {
this.health = 100;
this.maxHealth = 100;
this.mass = 80;
this.stomach = Stomach();
this.stomach = new Stomach();
}

function Player(name = "Player") {
@@ -18,28 +18,75 @@ function Player(name = "Player") {
}

function Anthro() {
let species = pick(["dog","cat","lizard","deer","wolf","fox"]);
this.mass = 80 * (Math.random()/2 - 0.25 + 1);
this.build = "ordinary";
if (this.mass < 70) {
this.build = "skinny";
} else if (this.mass > 90) {
this.build = "fat";
}

this.species = pick(["dog","cat","lizard","deer","wolf","fox"]);

Creature.call(this, name);

this.description = function() {
return this.build + " " + this.species;
};
}

// vore stuff here

function Container(name = "stomach") {
this.name = name;
this.contents = [];
this.digest = function() {
this.digested = [];
this.digest = function(time) {

};

this.feed = function(prey) {
this.contents.push(prey);
};
}

function Stomach() {
Container.call(this, "stomach");

this.digest = function() {
// health/sec
this.damageRate = 15*100/86400;

// kg/sec
this.digestRate = 80/8640;

this.digest = function(time) {
let lines = [];
this.contents.forEach(function (prey) {
lines.push("Something is digesting!");
this.contents.forEach(function(prey) {
if (prey.health > 0) {
let damage = Math.min(prey.health, this.damageRate * time);
prey.health -= damage;
time -= damage / this.damageRate;
}

if (prey.health <= 0) {
let digested = Math.min(prey.mass, this.digestRate * time);

prey.mass -= digested;
}

if (prey.mass <= 0) {
lines.push("Your churning guts have reduced a " + prey.description() + " to meaty chyme.");
this.digested.push(prey);
}

}, this);

this.contents.filter(function(prey) {
return prey.mass > 0;
});

return lines;
}
};


}

Loading…
Отказ
Запис