Merge pull request #12 from jhalitaksoy/fix/user-turn-issue
fix user turn issue in infopanel
This commit is contained in:
commit
905e45c7ca
@ -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;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user