]> git.cworth.org Git - lmno.games/commitdiff
empires: Rename "state" to "phase" for game phase transitions
authorCarl Worth <cworth@cworth.org>
Mon, 1 Jun 2020 05:46:21 +0000 (22:46 -0700)
committerCarl Worth <cworth@cworth.org>
Mon, 1 Jun 2020 05:46:21 +0000 (22:46 -0700)
We're freeing up the term "state" for a more generic, and more
complete description of game state.

empires/game.css
empires/game.js

index 57cd206e989ce20c41288a1d6bb4d1c99b284e6a..bc3340bf2b75d9e0aa99bf6186b50f8c907492ce 100644 (file)
@@ -1,28 +1,28 @@
 /* By default, hide things that are not to be shown
- * until a particular game state is reached. */
-.show-state-join {
+ * until a particular game phase is reached. */
+.show-phase-join {
     display:none;
 }
 
-.show-state-reveal {
+.show-phase-reveal {
     display:none;
 }
 
-.show-state-capture {
+.show-phase-capture {
     display:none;
 }
 
 /* And by default, show things that will be hidden
- * when a particular game state is reached. */
-.hide-state-join {
+ * when a particular game phase is reached. */
+.hide-phase-join {
     display:block;
 }
 
-.hide-state-reveal {
+.hide-phase-reveal {
     display:block;
 }
 
-.hide-state-capture {
+.hide-phase-capture {
     display:block;
 }
 
index 8043d32dc281799adf2734c3ce1306bd50168617..023a31412c1676612b0bd69b82a2aa2d05e0d36c 100644 (file)
@@ -195,28 +195,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);