Merge pull request #12 from jhalitaksoy/fix/user-turn-issue

fix user turn issue in infopanel
This commit is contained in:
Halit Aksoy 2022-07-09 13:23:31 +03:00 committed by GitHub
commit 905e45c7ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -41,9 +41,11 @@ function getInfoPanelTextByGameState(params: {
} }
return context.texts.GameEnded + " " + whoWon; return context.texts.GameEnded + " " + whoWon;
} else { } else {
return game?.checkIsPlayerTurn(userKey) if (game) {
? context.texts.YourTurn return game.checkIsPlayerTurn(userKey)
: context.texts.OpponentTurn; ? context.texts.YourTurn
: context.texts.OpponentTurn;
}
} }
return undefined; return undefined;
} }
@ -81,29 +83,34 @@ const InfoPanel: FunctionComponent<{
userKeyWhoLeave, userKeyWhoLeave,
searchingOpponent, searchingOpponent,
}) => { }) => {
const isUserTurn = game?.checkIsPlayerTurn(userKey); const isUserTurn = game?.checkIsPlayerTurn(userKey);
const containerColor = isUserTurn const containerColor = isUserTurn
? context.themeManager.theme.playerTurnColor ? context.themeManager.theme.playerTurnColor
: context.themeManager.theme.holeColor; : context.themeManager.theme.holeColor;
const textColor = getColorByLuminance( const textColor = getColorByLuminance(
containerColor, containerColor,
context.themeManager.theme.primary, context.themeManager.theme.primary,
context.themeManager.theme.primaryLight context.themeManager.theme.primaryLight
); );
return ( const text = getInfoPanelTextByGameState({
<InfoPanelContainer context={context} color={containerColor}> context,
<h4 style={{ margin: "0", color: textColor }}> game,
{getInfoPanelTextByGameState({ crashMessage,
context, userKey,
game, userKeyWhoLeave,
crashMessage, searchingOpponent,
userKey, });
userKeyWhoLeave, if (text) {
searchingOpponent, return (
})} <InfoPanelContainer context={context} color={containerColor}>
</h4> <h4 style={{ margin: "0", color: textColor }}>
</InfoPanelContainer> {text}
); </h4>
}; </InfoPanelContainer>
);
} else {
return (<div></div>)
}
};
export default InfoPanel; export default InfoPanel;