diff options
author | eug-vs <eugene@eug-vs.xyz> | 2022-03-12 15:28:19 +0300 |
---|---|---|
committer | eug-vs <eugene@eug-vs.xyz> | 2022-03-12 15:28:19 +0300 |
commit | 77b2f09883d4144c01802c5c75622e28f3864ca0 (patch) | |
tree | 5f6297e83295de990fd916b55e76af27e5a86a73 /src/Board/Board.ts | |
parent | 2e6a4a8761bf037283f7eb8dbfd57ab7b9e977a9 (diff) | |
download | carcassonne-engine-ts-77b2f09883d4144c01802c5c75622e28f3864ca0.tar.gz |
refactor: separate TileOnBoard class
Diffstat (limited to 'src/Board/Board.ts')
-rw-r--r-- | src/Board/Board.ts | 21 |
1 files changed, 11 insertions, 10 deletions
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); } } |