diff options
Diffstat (limited to 'src/Board/Board.ts')
-rw-r--r-- | src/Board/Board.ts | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/Board/Board.ts b/src/Board/Board.ts new file mode 100644 index 0000000..c511e89 --- /dev/null +++ b/src/Board/Board.ts @@ -0,0 +1,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); + } +} |