1 const express = require("express");
2 const Game = require("./game.js");
4 class TicTacToe extends Game {
9 board: Array(9).fill(""),
12 this.teams = ["X", "O"];
15 /* Returns true if move was legal and added, false otherwise. */
17 /* Cannot move to an occupied square. */
18 if (this.state.board[square])
19 return { legal: false, message: "Square is already occupied" };
21 this.state.board[square] = this.state.next_player;
22 this.state.moves.push(square);
24 if (this.state.next_player === "X")
25 this.state.next_player = "O";
27 this.state.next_player = "X";
29 return { legal: true };
33 TicTacToe.router = express.Router();
37 identifier: "tictactoe"
40 exports.Game = TicTacToe;