import * as React from 'react'; import { FunctionComponent } from "react" import { context } from '../context'; import { Game } from '../mancala'; const InfoPanel: FunctionComponent<{ game: Game, crashMessage: string, userKey: string }> = ({ game, crashMessage, userKey }) => { if (crashMessage) { return (

{ context.texts.GameCrashed + " " + crashMessage }

) } if (game) { if (game.state == "ended") { const whoWon = game.getWonPlayer() == userKey ? context.texts.YouWon : context.texts.YouLost return (

{ context.texts.GameEnded + " " + whoWon }

) } else { return (

{game.checkGameTurn(userKey) ? context.texts.YourTurn : context.texts.OpponentTurn}

) } } return

} export default InfoPanel