Procházet zdrojové kódy

Only create stats once for a room and clear room stats first

tags/v0.1.2
Fen Dweller před 6 roky
rodič
revize
1518d2c6eb
2 změnil soubory, kde provedl 7 přidání a 3 odebrání
  1. +3
    -1
      game.js
  2. +4
    -2
      world.js

+ 3
- 1
game.js Zobrazit soubor

@@ -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") {


+ 4
- 2
world.js Zobrazit soubor

@@ -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] = {};


Načítá se…
Zrušit
Uložit