From: Carl Worth Date: Sat, 6 Jun 2020 11:17:53 +0000 (-0700) Subject: Be more selective about when to display buttons for joining a team X-Git-Url: https://git.cworth.org/git?p=lmno.games;a=commitdiff_plain;h=9848e7d60b7ad9153b5763801382b880535e8cc6 Be more selective about when to display buttons for joining a team Specifically, before the first move, we never want any buttons, (instead, the first player will commit to a team by making a move). After the first move, there are two cases: 1. A player is already on a team: In this case we want only one button, labeled "Switch" to change to the other team. 2. A player is just spectating: This is the only case where we need to display two buttons, one labeled "Join X" and one labeled "Join O". --- diff --git a/tictactoe/tictactoe.jsx b/tictactoe/tictactoe.jsx index 49c6005..ca0bce3 100644 --- a/tictactoe/tictactoe.jsx +++ b/tictactoe/tictactoe.jsx @@ -91,15 +91,52 @@ function GameInfo(props) { ); } +function TeamButton(props) { + return ; +} + +function TeamChoices(props) { + let other_team; + if (props.player.team === "X") + other_team = "O"; + else + other_team = "X"; + + if (props.player.team === "") { + if (props.first_move) { + return null; + } else { + return [ + , + " ", + + ]; + } + } else { + return ; + } +} + function PlayerInfo(props) { if (! props.player.id) return null; + const choices = ; + return (

Players

{props.player.name} {props.player.team ? ` (${props.player.team})` : ""} + {props.first_move ? "" : " "} + {choices} {props.opponents.map(opponent => ( {", "} @@ -332,15 +369,12 @@ class Game extends React.Component { />, ,
- - {" "} -
{status}