aboutsummaryrefslogtreecommitdiff
path: root/src/Board/Board.ts
blob: 59afd3178fabba56891b6b9e568d04965b93a9ee (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
27
import _ from 'lodash';
import Tile, { Feature } from '../Tile/Tile';
import TileOnBoard from '../Tile/TileOnBoard';

const { Road, Town, Empty } = Feature;

export default class Board {
  tiles: TileOnBoard[];

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

  print() {
    this.tiles.forEach(tile => tile.print());
  }

  getAttachments(tile: Tile) {
    return _.flatten(this.tiles.map(attachTo => attachTo.getAttachments(tile)));
  }

  getLegalMoves(tile: Tile) {
    const attachments = this.getAttachments(tile);
    console.log(attachments);
  }
}