From 7e9fdb3af529c3bfd82a15a5ffd877ab4334af70 Mon Sep 17 00:00:00 2001 From: Luna <luna@kitty.lgbt> Date: Fri, 9 Jul 2021 13:57:51 -0700 Subject: [PATCH] nyan --- index.html | 3 ++- index.js | 9 +-------- locations.json => locations.js | 17 +++++++++-------- 3 files changed, 12 insertions(+), 17 deletions(-) rename locations.json => locations.js (76%) diff --git a/index.html b/index.html index e8b1884..3280f70 100644 --- a/index.html +++ b/index.html @@ -8,6 +8,7 @@ </div> <p id="command">></p><input type="text" id="userInput" name="inputBox"> <script src="verbhandler.js"></script> - <script src="index.js"></script> <script src="inventory.js"></script> + <script src="locations.js"></script> + <script src="index.js"></script> </body> \ No newline at end of file diff --git a/index.js b/index.js index 3581d0f..7a1a8e2 100644 --- a/index.js +++ b/index.js @@ -1,15 +1,8 @@ const userInput = document.getElementById("userInput"); -var locations; var currentLocation; let gameOver; -async function parseJson() { - const result = await fetch("./locations.json") - locations = await result.json() -} - -async function main() { - await parseJson(); +function main() { currentLocation = Object.keys(locations)[0] printBold(locations[currentLocation].onEntry) } diff --git a/locations.json b/locations.js similarity index 76% rename from locations.json rename to locations.js index 79e0c9f..e19dd90 100644 --- a/locations.json +++ b/locations.js @@ -1,3 +1,4 @@ +let locations = { "Computer Room": { "objects": { @@ -6,22 +7,22 @@ }, "Northern Door": { "interactable": true, - "gotoroom": "hallway" + "gotoroom": "hallway" } }, "verbs": { - "go north": { - + "go north": function(inventory, currentLocation, etc) { + printBold("uwu"); }, - "use computer": { - + "go east": function(inventory, currentLocation, etc) { + printBold("uwuwu"); } - }, + }, "onEntry": "You are in a dark room. With only a COMPUTER, and a monitor dimly illuminating the room. Type LOOK to see your surroundings." }, - + "hallway": { "objects": { "Northern Door": { @@ -32,7 +33,7 @@ }, "Vase": { "interactable": true, - "contains": { + "contains": { "key": { "grabable": true }