summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
8f6bf9e)
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.
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 => {
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 => {
{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})` : ""}
this.state = {
game_info: {},
player_info: {},
this.state = {
game_info: {},
player_info: {},
history: [
{
squares: Array(9).fill(null)
history: [
{
squares: Array(9).fill(null)
- 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);
- new_opponents[idx] = info;
+ other_players_copy[idx] = info;
- new_opponents.push(info);
+ other_players_copy.push(info);
- opponent_info: new_opponents
+ other_players: other_players_copy
- 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.";
- if (state.opponent_info.length == 1) {
+ if (state.other_players.length == 1) {
qualifier = "Either";
} else {
qualifier = "Any";
qualifier = "Either";
} else {
qualifier = "Any";
- 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.";
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>