diff --git a/combat.js b/combat.js index 27194f2..aaff6ef 100644 --- a/combat.js +++ b/combat.js @@ -72,3 +72,14 @@ function poke(attacker) { } }; } + + + +function digestPlayerStomach(predator,damage=20) { + return { + digest: function(player) { + attack(predator, player, damage); + return "The " + predator.description() + "'s stomach grinds over your body, swiftly digesting you."; + } + }; +} diff --git a/feast.js b/feast.js index 2b93743..c9cd4b4 100644 --- a/feast.js +++ b/feast.js @@ -299,6 +299,15 @@ function changeMode(newMode) { updateDisplay(); } + +function respawn(respawnRoom) { + moveTo(respawnRoom,"You drift through space and time..."); + advanceTime(86400/2); + changeMode("explore"); + player.health = 100; + update(["You wake back up in your bed."]); +} + function startCombat(opponent) { changeMode("combat"); currentFoe = opponent; @@ -325,8 +334,11 @@ function attackClicked(index) { if (player.health <= 0) { update(["You fall to the ground..."]); - changeMode("eaten"); - updateDisplay(); + if (prefs.player.prey) { + changeMode("eaten"); + } else { + respawn(respawnRoom); + } } } } @@ -345,15 +357,20 @@ function struggleClicked(index) { if (result.escape) { changeMode("explore"); } else { - player.health -= 20; + let digests = currentFoe.digests.filter(digest => digest.conditions == undefined || digest.conditions.reduce((result, test) => result && test(prefs), true)); + digests = digests.filter(digest => digest.requirements == undefined || digest.requirements.reduce((result, test) => result && test(currentFoe, player), true)); + + let digest = pick(digests); + + if (digest == null) { + digest = currentFoe.backupDigest; + } + + update([digest.digest(player)]); if (player.health <= -100) { update(["You digest in the depths of the " + currentFoe.description()]); - moveTo(respawnRoom,"You drift through space and time..."); - advanceTime(86400/2); - changeMode("explore"); - player.health = 100; - update(["You wake back up in your bed."]); + respawn(respawnRoom); } } } diff --git a/vore.js b/vore.js index 5adb0ef..3ba4a8d 100644 --- a/vore.js +++ b/vore.js @@ -58,6 +58,12 @@ function Anthro() { this.struggles.push(new plead(this)); this.struggles.push(new struggle(this)); + + this.digests = []; + + this.digests.push(new digestPlayerStomach(this,20)); + + this.backupDigest = new digestPlayerStomach(this,20); } function Fen() { @@ -75,6 +81,12 @@ function Fen() { this.struggles = []; this.struggles.push(new rub(this)); + + this.digests = []; + + this.digests.push(new digestPlayerStomach(this,50)); + + this.backupDigest = new digestPlayerStomach(this,50); } function Micro() {