-
-
Save morintd/23d5d88f269f4343557a25fcb081d80b 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 { IGamePresenter, Input } from "../ports/game-presenter.port"; | |
export class GamePresenter implements IGamePresenter { | |
format(input: Input) { | |
const moves = input.history.map((_, move: number) => { | |
return { | |
move, | |
description: move > 0 ? "Go to move #" + move : "Go to game start", | |
}; | |
}); | |
const status = input.winner | |
? input.winner === "draw" | |
? "Draw" | |
: "Winner: " + input.winner | |
: "Next player: " + (input.xIsNext ? "X" : "O"); | |
return { | |
moves, | |
status, | |
squares: input.history[input.step], | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment