| @@ -267,6 +267,24 @@ function shrunkSwallow(attacker) { | |||||
| }; | }; | ||||
| } | } | ||||
| function shrunkStomp(attacker) { | |||||
| return { | |||||
| name: "Stomp", | |||||
| desc: "Stomp on your shrunken prey", | |||||
| attack: function(defender) { | |||||
| let success = statCheck(attacker, defender, "dex") || statCheck(attacker, defender, "dex") || defender.stamina == 0; | |||||
| defender.stamina = 0; | |||||
| defender.health = Math.max(0, defender.health - 50); | |||||
| return "Your paw comes crashing down on " + defender.description("the") + ", burying them under your heavy toes and pinning them down hard."; | |||||
| }, | |||||
| requirements: [ | |||||
| function(attacker, defender) { | |||||
| return isNormal(attacker) && defender.flags.grappled != true && defender.flags.shrunk == true; | |||||
| } | |||||
| ] | |||||
| }; | |||||
| } | |||||
| function flee(attacker) { | function flee(attacker) { | ||||
| return { | return { | ||||
| name: "Flee", | name: "Flee", | ||||
| @@ -139,7 +139,7 @@ function getaStomp(attacker) { | |||||
| if (success) { | if (success) { | ||||
| defender.health = Math.max(-100, defender.health - 50 - Math.round(Math.random() * 25)); | defender.health = Math.max(-100, defender.health - 50 - Math.round(Math.random() * 25)); | ||||
| defender.stamina = 0; | defender.stamina = 0; | ||||
| return attacker.description() + "'s paws comes crashing down on your little body, smashing you into the dirt."; | |||||
| return attacker.description() + "'s paw comes crashing down on your little body, smashing you into the dirt."; | |||||
| } else { | } else { | ||||
| return "You dive away as " + attacker.description() + "'s paw slams down, narrowly missing your little body."; | return "You dive away as " + attacker.description() + "'s paw slams down, narrowly missing your little body."; | ||||
| } | } | ||||
| @@ -4,6 +4,8 @@ function DialogNode() { | |||||
| this.text = "Foo bar baz."; | this.text = "Foo bar baz."; | ||||
| this.hooks = []; | this.hooks = []; | ||||
| this.requirements = []; | |||||
| this.visit = function() { | this.visit = function() { | ||||
| for (let i=0; i<this.hooks.length; i++) | for (let i=0; i<this.hooks.length; i++) | ||||
| this.hooks[i](); | this.hooks[i](); | ||||
| @@ -80,6 +82,15 @@ function FallenFoe(foe) { | |||||
| this.addChoice("Spare",nodeSpare); | this.addChoice("Spare",nodeSpare); | ||||
| nodeSpare.text = "You decide to leave your foe uneaten."; | nodeSpare.text = "You decide to leave your foe uneaten."; | ||||
| } | } | ||||
| { | |||||
| let nodeCrush = new DialogNode(); | |||||
| this.addChoice("Crush",nodeCrush); | |||||
| nodeCrush.text = "You slam your paw down hard, crushing " + foe.description("the") + " like a bug"; | |||||
| nodeCrush.requirements.push( function(attacker, defender) { | |||||
| return defender.flags.shrunk == true; | |||||
| }); | |||||
| } | |||||
| } | } | ||||
| function NatureExercise() { | function NatureExercise() { | ||||
| @@ -163,11 +163,16 @@ function updateDialog() { | |||||
| } | } | ||||
| for (let i = 0; i < currentDialog.choices.length; i++) { | for (let i = 0; i < currentDialog.choices.length; i++) { | ||||
| let activated = currentDialog.choices[i].node.requirements == undefined || currentDialog.choices[i].node.requirements.reduce((result, test) => result && test(player, currentFoe), true); | |||||
| let li = document.createElement("li"); | let li = document.createElement("li"); | ||||
| let button = document.createElement("button"); | let button = document.createElement("button"); | ||||
| button.classList.add("dialog-button"); | button.classList.add("dialog-button"); | ||||
| button.innerHTML = currentDialog.choices[i].text; | button.innerHTML = currentDialog.choices[i].text; | ||||
| button.addEventListener("click", function() { dialogClicked(i); }); | button.addEventListener("click", function() { dialogClicked(i); }); | ||||
| if (!activated) { | |||||
| button.classList.add("disabled-button"); | |||||
| button.disabled = true; | |||||
| } | |||||
| li.appendChild(button); | li.appendChild(button); | ||||
| list.appendChild(li); | list.appendChild(li); | ||||
| } | } | ||||
| @@ -416,7 +421,7 @@ function struggleClicked(index) { | |||||
| if (result.escape) { | if (result.escape) { | ||||
| changeMode("explore"); | changeMode("explore"); | ||||
| } else { | } else { | ||||
| let digest = pick(filterValid(currentFoe.digests, FurrentFoe, player), currentFoe, player); | |||||
| let digest = pick(filterValid(currentFoe.digests, currentFoe, player), currentFoe, player); | |||||
| if (digest == null) { | if (digest == null) { | ||||
| digest = currentFoe.backupDigest; | digest = currentFoe.backupDigest; | ||||
| @@ -65,6 +65,7 @@ function Player(name = "Player") { | |||||
| this.attacks.push(new shrunkGrapple(this)); | this.attacks.push(new shrunkGrapple(this)); | ||||
| this.attacks.push(new shrunkSwallow(this)); | this.attacks.push(new shrunkSwallow(this)); | ||||
| this.attacks.push(new shrunkStomp(this)); | |||||
| this.attacks.push(new flee(this)); | this.attacks.push(new flee(this)); | ||||