diff options
Diffstat (limited to 'src/Board')
-rw-r--r-- | src/Board/Board.test.ts | 8 | ||||
-rw-r--r-- | src/Board/Board.ts | 14 |
2 files changed, 11 insertions, 11 deletions
diff --git a/src/Board/Board.test.ts b/src/Board/Board.test.ts index ad5509f..c4e5ed1 100644 --- a/src/Board/Board.test.ts +++ b/src/Board/Board.test.ts @@ -1,15 +1,15 @@ import assert from 'assert'; -import Cell, { Item } from '../Cell/Cell'; +import Tile, { Feature } from '../Tile/Tile'; import Board from "./Board"; -const { Road, Town, Empty } = Item; +const { Road, Town, Empty } = Feature; describe('Board', () => { describe('constructor', () => { it('Should initialize empty board with a starting cell', () => { const board = new Board(); assert.strictEqual(board.cells.length, 1); - assert.deepStrictEqual(board.cells[0], new Cell(Road, [Town, Road, Empty, Road])); + assert.deepStrictEqual(board.cells[0], new Tile(Road, [Town, Road, Empty, Road])); }); }); @@ -17,7 +17,7 @@ describe('Board', () => { it('Should correctly determine legal moves for 1-cell board', () => { const board = new Board(); const attachTo = board.cells[0]; - const cell = new Cell(Town, [Empty, Town, Empty, Town]); + const cell = new Tile(Town, [Empty, Town, Empty, Town]); const legalMoves = board.getAttachments(cell); assert.strictEqual(legalMoves.length, 4); diff --git a/src/Board/Board.ts b/src/Board/Board.ts index c511e89..f1aa45b 100644 --- a/src/Board/Board.ts +++ b/src/Board/Board.ts @@ -1,25 +1,25 @@ import _ from 'lodash'; -import Cell, { Item } from "../Cell/Cell"; +import Tile, { Feature } from "../Tile/Tile"; -const { Road, Town, Empty } = Item; +const { Road, Town, Empty } = Feature; export default class Board { - cells: Cell[]; + cells: Tile[]; - constructor(cells?: Cell[]) { + constructor(cells?: Tile[]) { if (cells) this.cells = cells; - else this.cells = [new Cell(Road, [Town, Road, Empty, Road])] + else this.cells = [new Tile(Road, [Town, Road, Empty, Road])] } print() { this.cells.forEach(cell => cell.print()); } - getAttachments(cell: Cell) { + getAttachments(cell: Tile) { return _.flatten(this.cells.map(attachTo => attachTo.getAttachments(cell))); } - getLegalMoves(cell: Cell) { + getLegalMoves(cell: Tile) { const attachments = this.getAttachments(cell); console.log(attachments); } |