Skip to content

Commit

Permalink
don't hightlight player name after game end
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinsung committed May 17, 2021
1 parent c7925dc commit 0395d40
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/components/HexGame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ interface WinnerAnnouncementProps {
winningComponent: Array<Array<number>>;
}

interface PlayerNamesProps {
winningComponent: Array<Array<number>>;
}

const COORDINATE_LETTERS = 'ABCDEFGHJKLMNOPQRST';

function NewGameButton(props: NewGameButtonProps) {
Expand Down Expand Up @@ -493,7 +497,8 @@ function ConnectionStatus() {
);
}

function PlayerNames() {
function PlayerNames(props: PlayerNamesProps) {
const { winningComponent } = props;
const isBlackTurn = useSelector(selectIsBlackTurn);
const { active: netplayActive, hosting, isBlack } = useSelector(
selectNetplayState
Expand All @@ -505,7 +510,10 @@ function PlayerNames() {
className={classnames(
{ black: playerOneIsBlack },
{ white: !playerOneIsBlack },
{ partialOpacity: playerOneIsBlack !== isBlackTurn }
{
partialOpacity:
playerOneIsBlack !== isBlackTurn || winningComponent.length,
}
)}
>
Player 1
Expand All @@ -514,7 +522,10 @@ function PlayerNames() {
className={classnames(
{ black: !playerOneIsBlack },
{ white: playerOneIsBlack },
{ partialOpacity: playerOneIsBlack === isBlackTurn }
{
partialOpacity:
playerOneIsBlack === isBlackTurn || winningComponent.length,
}
)}
>
Player 2
Expand Down Expand Up @@ -557,7 +568,7 @@ export default function HexGame() {
<SwapDialog />
<UndoDialog />
</div>
<PlayerNames />
<PlayerNames winningComponent={winningComponent} />
</div>
<HexBoard
boardState={boardState}
Expand Down

0 comments on commit 0395d40

Please sign in to comment.