From 900ba8b00ce6b3125de45547da5d290ce513c343 Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Mon, 12 Mar 2018 23:02:47 -0400 Subject: [PATCH] Fixed Object shadowing...Object. maxHealth is a getter. Added the Nature Trail --- combat.js | 2 -- dialog.js | 36 ++++++++++++++++++++++++++++++++++++ objects.js | 30 +++++++++++++++++++++--------- vore.js | 21 +++++++++++---------- world.js | 19 +++++++++++++++++++ 5 files changed, 87 insertions(+), 21 deletions(-) diff --git a/combat.js b/combat.js index fc48cb1..cb44b69 100644 --- a/combat.js +++ b/combat.js @@ -221,8 +221,6 @@ function poke(attacker) { }; } - - function digestPlayerStomach(predator,damage=20) { return { digest: function(player) { diff --git a/dialog.js b/dialog.js index 38712fb..5139577 100644 --- a/dialog.js +++ b/dialog.js @@ -81,3 +81,39 @@ function FallenFoe(foe) { nodeSpare.text = "You decide to leave your foe uneaten."; } } + +function NatureExercise() { + DialogNode.call(this); + + this.text = "What do you want to do?"; + + { + let nodeStrength = new DialogNode(); + this.addChoice("Rock Climbing (+STR)", nodeStrength); + nodeStrength.text = "You clamber up walls for a while. You feel a little stronger."; + nodeStrength.hooks.push(function() { + player.str += 1; + advanceTime(60*30); + }); + } + + { + let nodeDexterity = new DialogNode(); + this.addChoice("Jogging (+DEX)", nodeDexterity); + nodeDexterity.text = "You go run for a run around the three-mile-long trail. You feel a little more agile."; + nodeDexterity.hooks.push(function() { + player.dex += 1; + advanceTime(60*30); + }); + } + + { + let nodeConstitution = new DialogNode(); + this.addChoice("Bang your head on a tree (+CON)", nodeConstitution); + nodeConstitution.text = "You bash your face on a tree for half an hour. I guess that helps."; + nodeConstitution.hooks.push(function() { + player.con += 1; + advanceTime(60*30); + }); + } +} diff --git a/objects.js b/objects.js index b1551ef..1119428 100644 --- a/objects.js +++ b/objects.js @@ -1,10 +1,12 @@ -function Object(name="Potato") { +"use strict"; + +function GameObject(name="Potato") { this.name = name; this.actions = []; } function Burger() { - Object.call(this, "Burger"); + GameObject.call(this, "Burger"); this.actions.push({ "name": "Punch Burger", "action": function() { @@ -15,7 +17,7 @@ function Burger() { } function Nerd() { - Object.call(this, "Nerd"); + GameObject.call(this, "Nerd"); this.actions.push({ "name": "Eat Nerd", "action": function() { @@ -25,7 +27,7 @@ function Nerd() { } function Toilet() { - Object.call(this, "Toilet"); + GameObject.call(this, "Toilet"); this.actions.push({ "name": "Admire toilet", "action": function() { @@ -35,7 +37,7 @@ function Toilet() { } function TV() { - Object.call(this, "TV"); + GameObject.call(this, "TV"); this.actions.push({ "name": "Watch TV", "action": function() { @@ -45,7 +47,7 @@ function TV() { } function Phone() { - Object.call(this, "Phone"); + GameObject.call(this, "Phone"); this.actions.push({ "name": "Use phone", "action": function() { @@ -55,7 +57,7 @@ function Phone() { } function Bed() { - Object.call(this, "Bed"); + GameObject.call(this, "Bed"); this.actions.push({ "name": "Sleep", "action": function() { @@ -67,11 +69,21 @@ function Bed() { } function Sofa() { - Object.call(this, "Sofa"); + GameObject.call(this, "Sofa"); this.actions.push({ "name": "Sit on sofa", "action": function(){ startDialog(SofaSit()); } - }) + }); +} + +function NatureTrailExercise() { + GameObject.call(this, "Exercise"); + this.actions.push({ + "name": "Exercise", + "action": function() { + startDialog(new NatureExercise()); + } + }); } diff --git a/vore.js b/vore.js index b203afb..547f206 100644 --- a/vore.js +++ b/vore.js @@ -1,3 +1,5 @@ +"use strict"; + function pick(list) { if (list.length == 0) return null; @@ -5,23 +7,25 @@ function pick(list) { return list[Math.floor(Math.random()*list.length)]; } -function Creature(name = "Creature") { +function Creature(name = "Creature", str=10, dex=10, con=10) { this.name = name; - this.health = 100; - this.maxHealth = 100; + this.mass = 80; this.bowels = new Bowels(); this.stomach = new Stomach(this.bowels); this.butt = new Butt(this.bowels,this.stomach); this.attacks = []; - this.str = 10; - this.dex = 10; - this.con = 10; + this.str = str; + this.dex = dex; + this.con = con; + + Object.defineProperty(this, "maxHealth", {get: function() { return this.con * 10 }}); + this.health = this.maxHealth; } function Player(name = "Player") { - Creature.call(this, name); + Creature.call(this, name, 15, 15, 15); this.fullness = function() { return this.stomach.fullness() + this.butt.fullness(); @@ -38,9 +42,6 @@ function Player(name = "Player") { this.attacks.push(new grappledStruggle(this)); this.backupAttack = new pass(this); - this.str = 15; - this.dex = 15; - this.con = 15; } function Anthro() { diff --git a/world.js b/world.js index c6de1a2..06c91f7 100644 --- a/world.js +++ b/world.js @@ -150,9 +150,28 @@ let locationsSrc = [ "name": "Crossroads", "dir": NORTH, "desc": "You walk to the crossroads" + }, + { + "name": "Nature Trail", + "dir": SOUTH, + "desc": "You head out into the woods" } ] }, + { + "name": "Nature Trail", + "desc": "A winding train cutting through a thick forest", + "conn": [ + { + "name": "South Street", + "dir": NORTH, + "desc": "You return to town." + } + ], + "objs": [ + NatureTrailExercise + ] + }, { "name": "DANGER ZONE", "desc": "THE DANGER ZONE",