1 const express = require("express");
2 const Game = require("./game.js");
4 class TicTacToe extends Game {
9 board: Array(9).fill(""),
14 /* Returns true if move was legal and added, false otherwise. */
16 /* Cannot move to an occupied square. */
17 if (this.state.board[square])
18 return { legal: false, message: "Square is already occupied" };
20 this.state.board[square] = this.state.next_player;
21 this.state.moves.push(square);
23 if (this.state.next_player === "X")
24 this.state.next_player = "O";
26 this.state.next_player = "X";
28 return { legal: true };
32 TicTacToe.router = express.Router();
36 identifier: "tictactoe"
39 exports.Game = TicTacToe;