aboutsummaryrefslogtreecommitdiff
path: root/src/Board/Board.ts
blob: c511e8952257eedf6aec0c317fcd3b94dfc58a80 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import _ from 'lodash';
import Cell, { Item } from "../Cell/Cell";

const { Road, Town, Empty } = Item;

export default class Board {
  cells: Cell[];

  constructor(cells?: Cell[]) {
    if (cells) this.cells = cells;
    else this.cells = [new Cell(Road, [Town, Road, Empty, Road])]
  }

  print() {
    this.cells.forEach(cell => cell.print());
  }

  getAttachments(cell: Cell) {
    return _.flatten(this.cells.map(attachTo => attachTo.getAttachments(cell)));
  }

  getLegalMoves(cell: Cell) {
    const attachments = this.getAttachments(cell);
    console.log(attachments);
  }
}