import _ from 'lodash'; import Tile, { Feature } from '../Tile/Tile'; import TileOnBoard from '../Tile/TileOnBoard'; const { Road, Town, Grass } = Feature; export default class Board { tiles: TileOnBoard[]; constructor(tiles?: TileOnBoard[]) { if (tiles) this.tiles = tiles; else this.tiles = [new TileOnBoard(Road, [Town, Road, Grass, 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); } }