From 9ce067fb19cd651cbd1e109a9f332488a5d9c12c Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Sun, 29 Apr 2018 14:12:45 -0400 Subject: [PATCH] Started anaconda --- forest.js | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) diff --git a/forest.js b/forest.js index 4061704..9fdf9f7 100644 --- a/forest.js +++ b/forest.js @@ -14,6 +14,8 @@ function ForestExplore() { startCombat(new Wolf()); } else if (outcome < 0.6) { startCombat(new AlphaWolf()); + } else if (outcome < 0.75) { + startCombat(new Anaconda()); } else { update(["You explore the forest for a while, but don't find anything."]); } @@ -302,3 +304,100 @@ function wolfBelch(attacker) { gameover: function() { return "Reduced to a belch by " + attacker.description("a"); } }; } + +function Anaconda() { + Creature.call(this, "Anaconda", 30, 10, 20); + + this.hasName = false; + + this.description = function(prefix) { return prefix + " anaconda"; }; + + this.flags.state = "combat"; + + this.flags.oral = {}; + + this.flags.grapple = {}; + + let attacker = this; + + this.attacks = []; + + // hiss at player + this.attacks.push({ + attackPlayer: function(defender) { + return pickRandom([ + ["The anaconda raises its head and hisses"], + ["The hulking serpent narrows its eyes and hisses at you"] + ]); + }, + requirements: [ + function(attacker, defender) { + return attacker.flags.state == "combat"; + } + ], + priority: 1, + weight: function(attacker, defender) { return 1; } + }); + + // slap player with tail + this.attacks.push({ + attackPlayer: function(defender) { + if (statHealthCheck(attacker, defender, "dex")) { + let damage = attack(attacker, defender, "str"); + return ["The snake's tail whips around, smacking you for " + damage + " damage!"]; + } else { + return ["The serpent's tail lashes at you, but you manage to stay out of its way."]; + } + }, + requirements: [ + function(attacker, defender) { + return attacker.flags.state == "combat"; + } + ], + priority: 1, + weight: function(attacker, defender) { return 1; } + }); + + // grab player with tail + this.attacks.push({ + attackPlayer: function(defender) { + if (statHealthCheck(attacker, defender, "dex")) { + let damage = attack(attacker, defender, "str"); + return ["The snake's tail whips around and grabs you! A tight embrace of smooth, cold scales grips your entire upper body, a lazy clench of muscle suppressing your meek struggles."]; + } else { + return ["The anaconda tries to snatch you up in its tail. You dodge out of the way."]; + } + }, + requirements: [ + function(attacker, defender) { + return attacker.flags.state == "combat"; + } + ], + priority: 1, + weight: function(attacker, defender) { return 4 - 4 * defender.healthPercentage(); } + }); + + // + + /** PLAYER ATTACKS **/ + + this.playerAttacks = []; + + // pass in combat + this.playerAttacks.push( + function(attacker) { + return { + name: "Pass", + desc: "Do nothing", + attack: function(defender) { + return ["You do nothing."]; + }, + requirements: [ + function(attacker, defender) { + return defender.flags.state == "combat"; + } + ] + }; + } + ); +}