diff --git a/game.js b/game.js index 5183331..d11aed8 100644 --- a/game.js +++ b/game.js @@ -18,7 +18,9 @@ function initGame(story, state) { } function createStatDisplays(stats, statType) { - const holder = document.querySelector("#" + statType + "-info") + const holder = document.querySelector("#" + statType + "-info"); + holder.innerHTML = ""; + Object.entries(stats).forEach(([key, val]) => { if (val.type == "meter") { diff --git a/world.js b/world.js index 4d2cde0..7d77724 100644 --- a/world.js +++ b/world.js @@ -111,6 +111,8 @@ function moveToRoom(src, exit, dest, state) { resetControls(state); + createStatDisplays(room.data.stats, "area"); + refresh(); } @@ -136,14 +138,14 @@ function goToRoom(dest, state) { resetControls(state); + createStatDisplays(room.data.stats, "area"); + refresh(); } function updateRoom(state) { const name = state.player.location; const room = state.world[name]; - - createStatDisplays(room.data.stats, "area"); if (!state.player.rooms[room.id]) { state.player.rooms[room.id] = {};