aboutsummaryrefslogtreecommitdiffstats
path: root/frontend/ts/gameTable.ts
blob: 94051f8ba96c18482ec1b922174d89c00ceef0b1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { Coordinates } from "../../helpers/helpersBack";

export default class gameTable {
  static numberOfSquaresOnGameBoard = 11;
  static gameTable: HTMLTableElement;

  static drawGameTable(): void {
    for (let i = 0; i < gameTable.numberOfSquaresOnGameBoard; i++) {
      let tr = document.createElement("tr");
      for (let j = 0; j < gameTable.numberOfSquaresOnGameBoard; j++) {
        let td = document.createElement("td");
        td.classList.add("chequer");
        td.dataset.count = '0';
        tr.appendChild(td);
      }
      gameTable.gameTable.appendChild(tr);
    }
  }
  
  static getTd(coords: Coordinates): HTMLElement {
    return gameTable.gameTable.children[coords.y].children[coords.x] as HTMLElement;
  }
}