X-Git-Url: https://git.cworth.org/git?p=lmno.games;a=blobdiff_plain;f=empires%2Fgame.js;h=05b801e352d0e6c0c51e84cfc157e43162024f50;hp=8043d32dc281799adf2734c3ce1306bd50168617;hb=HEAD;hpb=5bcc934af2effc02ea873e847bf564bbc6b61125 diff --git a/empires/game.js b/empires/game.js index 8043d32..05b801e 100644 --- a/empires/game.js +++ b/empires/game.js @@ -75,8 +75,6 @@ function register(form) { function toggle_host_tools() { const host_tools = document.getElementById("host-tools"); - console.log("Toggling, host_tools.style.display is '" + host_tools.style.display + "'"); - if (host_tools.style.display === "block") host_tools.style.display = "none"; else @@ -195,28 +193,28 @@ function spectator_on_load() { state.spectator_id = JSON.parse(this.response); } -events.addEventListener("game-state", function(event) { +events.addEventListener("game-phase", function(event) { const data = JSON.parse(event.data); - const old_state = data.old_state; - const new_state = data.new_state; + const old_phase = data.old_phase; + const new_phase = data.new_phase; - const hide_selector = ".show-state-" +old_state+ ",.hide-state-" +new_state; - const show_selector = ".hide-state-" +old_state+ ",.show-state-" +new_state; + const hide_selector = ".show-phase-" +old_phase+ ",.hide-phase-" +new_phase; + const show_selector = ".hide-phase-" +old_phase+ ",.show-phase-" +new_phase; - /* Hide all elements based on the state transition. */ + /* Hide all elements based on the phase transition. */ var elts = document.querySelectorAll(hide_selector); for (const elt of elts) { elt.style.display = "none"; } - /* And show all elements based on the same state transition. */ + /* And show all elements based on the same phase transition. */ elts = document.querySelectorAll(show_selector); for (const elt of elts) { elt.style.display = "block"; } - /* Whenever the game enters the "join" state, add ourselves as a spectator. */ - if (new_state === "join") { + /* Whenever the game enters the "join" phase, add ourselves as a spectator. */ + if (new_phase === "join") { const request = new XMLHttpRequest(); request.addEventListener("load", spectator_on_load);