-
-
Save morintd/a931698240eca5bdc7be678968c27be1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { GameDomainModel } from "./game.domain-model"; | |
import { Board } from "./components"; | |
import { useGameController } from "./game-controller"; | |
import "./app.css"; | |
import { GamePresenter } from "./adapters/game.presenter"; | |
type Props = { | |
game: GameDomainModel.GameState; | |
}; | |
const presenter = new GamePresenter(); | |
export function Game(props: Props) { | |
const { game } = props; | |
const controller = useGameController(game, presenter); | |
return ( | |
<div className="game"> | |
<div className="game-board"> | |
<Board | |
squares={controller.squares} | |
onClick={controller.onPlay} | |
status={controller.status} | |
/> | |
</div> | |
<div className="game-info"> | |
<ol> | |
{controller.moves.map(({ move, description }) => ( | |
<li key={move}> | |
<button onClick={() => controller.onJumpTo(move)}> | |
{description} | |
</button> | |
</li> | |
))} | |
</ol> | |
</div> | |
</div> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment