From 77b2f09883d4144c01802c5c75622e28f3864ca0 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Sat, 12 Mar 2022 15:28:19 +0300 Subject: refactor: separate TileOnBoard class --- src/Board/Board.ts | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src/Board/Board.ts') diff --git a/src/Board/Board.ts b/src/Board/Board.ts index f1aa45b..59afd31 100644 --- a/src/Board/Board.ts +++ b/src/Board/Board.ts @@ -1,26 +1,27 @@ import _ from 'lodash'; -import Tile, { Feature } from "../Tile/Tile"; +import Tile, { Feature } from '../Tile/Tile'; +import TileOnBoard from '../Tile/TileOnBoard'; const { Road, Town, Empty } = Feature; export default class Board { - cells: Tile[]; + tiles: TileOnBoard[]; - constructor(cells?: Tile[]) { - if (cells) this.cells = cells; - else this.cells = [new Tile(Road, [Town, Road, Empty, Road])] + constructor(tiles?: TileOnBoard[]) { + if (tiles) this.tiles = tiles; + else this.tiles = [new TileOnBoard(Road, [Town, Road, Empty, Road])] } print() { - this.cells.forEach(cell => cell.print()); + this.tiles.forEach(tile => tile.print()); } - getAttachments(cell: Tile) { - return _.flatten(this.cells.map(attachTo => attachTo.getAttachments(cell))); + getAttachments(tile: Tile) { + return _.flatten(this.tiles.map(attachTo => attachTo.getAttachments(tile))); } - getLegalMoves(cell: Tile) { - const attachments = this.getAttachments(cell); + getLegalMoves(tile: Tile) { + const attachments = this.getAttachments(tile); console.log(attachments); } } -- cgit v1.2.3