]> git.cworth.org Git - lmno.games/commitdiff
Rename "opponent" in both the interface and the code
authorCarl Worth <cworth@cworth.org>
Sat, 6 Jun 2020 12:02:08 +0000 (05:02 -0700)
committerCarl Worth <cworth@cworth.org>
Sat, 6 Jun 2020 12:02:08 +0000 (05:02 -0700)
The code was incorrect, since what was called "opponent_info" was
really just a list of other players (some of which could be on the
same team rather than an opposing team) so the new name of
"other_players" is more accurate.

In the UI, we also now use "another player" instead of "opponent" to
just be more friendly I suppose.

tictactoe/tictactoe.jsx

index 3e75573ee2d872f31bef1084ec0a48c2f1d78245..dbfc5ef93e9ba41d21f026a14653e179828fbd4a 100644 (file)
@@ -47,7 +47,7 @@ events.addEventListener("player-info", event => {
 events.addEventListener("player-enter", event => {
   const info = JSON.parse(event.data);
 
 events.addEventListener("player-enter", event => {
   const info = JSON.parse(event.data);
 
-  window.game.set_opponent_info(info);
+  window.game.set_other_player_info(info);
 });
 
 events.addEventListener("player-update", event => {
 });
 
 events.addEventListener("player-update", event => {
@@ -56,7 +56,7 @@ events.addEventListener("player-update", event => {
   if (info.id === window.game.state.player_info.id)
     window.game.set_player_info(info);
   else
   if (info.id === window.game.state.player_info.id)
     window.game.set_player_info(info);
   else
-    window.game.set_opponent_info(info);
+    window.game.set_other_player_info(info);
 });
 
 events.addEventListener("move", event => {
 });
 
 events.addEventListener("move", event => {
@@ -137,11 +137,11 @@ function PlayerInfo(props) {
       {props.player.team ? ` (${props.player.team})` : ""}
       {props.first_move ? "" : " "}
       {choices}
       {props.player.team ? ` (${props.player.team})` : ""}
       {props.first_move ? "" : " "}
       {choices}
-      {props.opponents.map(opponent => (
-        <span key={opponent.id}>
+      {props.other_players.map(other => (
+        <span key={other.id}>
           {", "}
           {", "}
-          {opponent.name}
-          {opponent.team ? ` (${opponent.team})` : ""}
+          {other.name}
+          {other.team ? ` (${other.team})` : ""}
         </span>
       ))}
     </div>
         </span>
       ))}
     </div>
@@ -227,7 +227,7 @@ class Game extends React.Component {
     this.state = {
       game_info: {},
       player_info: {},
     this.state = {
       game_info: {},
       player_info: {},
-      opponent_info: [],
+      other_players: [],
       history: [
         {
           squares: Array(9).fill(null)
       history: [
         {
           squares: Array(9).fill(null)
@@ -250,16 +250,16 @@ class Game extends React.Component {
     });
   }
 
     });
   }
 
-  set_opponent_info(info) {
-    const new_opponents = [...this.state.opponent_info];
-    const idx = new_opponents.findIndex(o => o.id === info.id);
+  set_other_player_info(info) {
+    const other_players_copy = [...this.state.other_players];
+    const idx = other_players_copy.findIndex(o => o.id === info.id);
     if (idx >= 0) {
     if (idx >= 0) {
-      new_opponents[idx] = info;
+      other_players_copy[idx] = info;
     } else {
     } else {
-      new_opponents.push(info);
+      other_players_copy.push(info);
     }
     this.setState({
     }
     this.setState({
-      opponent_info: new_opponents
+      other_players: other_players_copy
     });
   }
 
     });
   }
 
@@ -342,11 +342,11 @@ class Game extends React.Component {
     }
     else if (first_move)
     {
     }
     else if (first_move)
     {
-      if (state.opponent_info.length == 0) {
-        status = "You can make the first move or wait for an opponent to join.";
+      if (state.other_players.length == 0) {
+        status = "You can move or wait for another player to join.";
       } else {
         let qualifier;
       } else {
         let qualifier;
-        if (state.opponent_info.length == 1) {
+        if (state.other_players.length == 1) {
           qualifier = "Either";
         } else {
           qualifier = "Any";
           qualifier = "Either";
         } else {
           qualifier = "Any";
@@ -367,8 +367,8 @@ class Game extends React.Component {
     }
     else
     {
     }
     else
     {
-      status = "Waiting for your opponent to ";
-      if (state.opponent_info.length == 0) {
+      status = "Waiting for another player to ";
+      if (state.other_players.length == 0) {
         status += "join.";
       } else {
         status += "move.";
         status += "join.";
       } else {
         status += "move.";
@@ -387,7 +387,7 @@ class Game extends React.Component {
         game={this}
         first_move={first_move}
         player={state.player_info}
         game={this}
         first_move={first_move}
         player={state.player_info}
-        opponents={state.opponent_info}
+        other_players={state.other_players}
       />,
       <div key="game" className="game">
         <div>{status}</div>
       />,
       <div key="game" className="game">
         <div>{status}</div>