1 const express = require("express");
2 const Game = require("./game.js");
4 class Scribe extends Game {
7 this.teams = [{id:0, name:"+"}, {id:1, name:"o"}];
10 squares: Array(9).fill(null).map(() => Array(9).fill(null)),
11 team_to_play: this.teams[0],
15 /* Returns true if move was legal and added, false otherwise. */
16 add_move(player, move) {
18 const state = this.state;
21 const result = super.add_move(player, move);
23 /* If the generic Game class can reject this move, then we don't
24 * need to look at it any further. */
28 /* TODO: Need to enforce super-square matching mini-square from
29 * previous move (if given super-square isn't full already). */
31 /* Cannot move to an occupied square. */
32 if (state.squares[i][j])
34 return { legal: false,
35 message: "Square is already occupied" };
38 state.squares[i][j] = state.team_to_play;
39 state.moves.push(move);
41 if (state.team_to_play.id === 0)
42 state.team_to_play = this.teams[1];
44 state.team_to_play = this.teams[0];
46 return { legal: true };
50 Scribe.router = express.Router();
60 exports.Game = Scribe;