diff --git a/feast.js b/feast.js index 53dcef9..3fdfef5 100644 --- a/feast.js +++ b/feast.js @@ -1,3 +1,4 @@ +let world = null; let currentRoom = null; let currentDialog = null; @@ -251,6 +252,10 @@ function move(direction) { moveTo(target,currentRoom.exitDescs[direction]); } +function moveToByName(roomName, desc="You go places lol") { + moveTo(world[roomName], desc); +} + function moveTo(room,desc="You go places lol") { actions = []; currentRoom = room; @@ -279,7 +284,8 @@ function start() { loadActions(); loadCompass(); loadDialog(); - currentRoom = createWorld(); + world = createWorld(); + currentRoom = world["Bedroom"]; respawnRoom = currentRoom; moveTo(currentRoom); updateDisplay(); diff --git a/objects.js b/objects.js index 18e6274..1446969 100644 --- a/objects.js +++ b/objects.js @@ -125,3 +125,23 @@ function VendingMachine() { } }); } + +function WildernessExplore(natureTrail) { + GameObject.call(this, "Explore the Wilderness"); + + this.actions.push({ + "name": "Explore", + "action": function() { + let outcome = Math.random(); + advanceTime(60*15); + + if (outcome < 0.25) { + moveToByName("Nature Trail", "You find your way back"); + } else if (outcome < 0.5) { + startCombat(new Anthro()); + } else { + update(["You wander around for a bit, but haven't found anything."]); + } + } + }); +} diff --git a/world.js b/world.js index 41f5c44..70f35f4 100644 --- a/world.js +++ b/world.js @@ -12,8 +12,6 @@ let SOUTH_WEST = 5; let WEST = 6; let NORTH_WEST = 7; -let startLocation = "Bedroom"; - let locations = {}; let locationsSrc = [ @@ -190,6 +188,11 @@ let locationsSrc = [ "name": "South Street", "dir": NORTH, "desc": "You return to town." + }, + { + "name": "Wilderness", + "dir": SOUTH, + "desc": "You wander into the wilderness...and immediately get lost." } ], "objs": [ @@ -197,6 +200,16 @@ let locationsSrc = [ GetaObj ] }, + { + "name": "Wilderness", + "desc": "Pretty spooky", + "conn": [ + + ], + "objs": [ + WildernessExplore + ] + }, { "name": "DANGER ZONE", "desc": "THE DANGER ZONE", @@ -313,5 +326,5 @@ function createWorld() { } } - return locations[startLocation]; + return locations; }