fix user turn issue in infopanel

This commit is contained in:
Halit Aksoy 2022-07-09 13:12:22 +03:00
parent eb1a51c41f
commit 6f96842a87

View File

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