From 8aa2213390e01996e3f9682abfd5910c698df0e2 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Sat, 12 Mar 2022 14:36:31 +0300 Subject: feat: add initial Board class --- src/Board/Board.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/Board/Board.ts (limited to 'src/Board/Board.ts') 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); + } +} -- cgit v1.2.3