diff options
author | eug-vs <eugene@eug-vs.xyz> | 2022-03-13 14:48:30 +0300 |
---|---|---|
committer | eug-vs <eugene@eug-vs.xyz> | 2022-03-13 14:48:30 +0300 |
commit | 555d604d1e67ed6eac8c09a8b99c59d342660bb7 (patch) | |
tree | 64b939c610bdf09abe8f30de663f74eefcfa9a9d /src/Board/Board.test.ts | |
parent | e30259bb228ff5011998b1b9dbaf2508b0047425 (diff) | |
download | carcassonne-engine-ts-555d604d1e67ed6eac8c09a8b99c59d342660bb7.tar.gz |
feat: implement correct getAttachments for board
Diffstat (limited to 'src/Board/Board.test.ts')
-rw-r--r-- | src/Board/Board.test.ts | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/src/Board/Board.test.ts b/src/Board/Board.test.ts index 5023f0b..4bd6182 100644 --- a/src/Board/Board.test.ts +++ b/src/Board/Board.test.ts @@ -17,20 +17,20 @@ describe('Board', () => { }); describe('getAttachments', () => { - it('Should correctly determine legal moves for 1-tile board', () => { + it('Should correctly determine legal attachments for 1-tile board', () => { const board = new Board(); const attachTo = board.tiles[0]; const tile = new Tile(Town, [Grass, Town, Grass, Town]); - const legalMoves = board.getAttachments(tile); + const attachments = board.getAttachments(tile); - assert.strictEqual(legalMoves.length, 4); - assert.deepStrictEqual(legalMoves[0], { side: 0, orientation: 1, attachTo, tile }); - assert.deepStrictEqual(legalMoves[1], { side: 0, orientation: 3, attachTo, tile }); - assert.deepStrictEqual(legalMoves[2], { side: 2, orientation: 0, attachTo, tile }); - assert.deepStrictEqual(legalMoves[3], { side: 2, orientation: 2, attachTo, tile }); + assert.strictEqual(attachments.length, 4); + assert.deepStrictEqual(attachments[0], { side: 0, orientation: 1, attachTo, tile }); + assert.deepStrictEqual(attachments[1], { side: 0, orientation: 3, attachTo, tile }); + assert.deepStrictEqual(attachments[2], { side: 2, orientation: 0, attachTo, tile }); + assert.deepStrictEqual(attachments[3], { side: 2, orientation: 2, attachTo, tile }); }); - it.skip('Have a look at my nice attachments manually bro', () => { + it('Should correctly return legal attachments for complex board', () => { const board = new Board(); board.attach({ @@ -50,7 +50,19 @@ describe('Board', () => { const tile = new Tile(Grass, [Town, Grass, Grass, Grass]); const attachments = board.getAttachments(tile); - attachments.forEach(attachment => board.previewAttachment(attachment)); + + // attachments.forEach(attachment => board.previewAttachment(attachment)); + + assert.strictEqual(attachments.length, 9); + assert.deepStrictEqual(attachments[0], { side: 2, orientation: 1, tile, attachTo: board.tiles[0] }); + assert.deepStrictEqual(attachments[1], { side: 2, orientation: 2, tile, attachTo: board.tiles[0] }); + assert.deepStrictEqual(attachments[2], { side: 2, orientation: 3, tile, attachTo: board.tiles[0] }); + assert.deepStrictEqual(attachments[3], { side: 0, orientation: 2, tile, attachTo: board.tiles[1] }); + assert.deepStrictEqual(attachments[4], { side: 3, orientation: 0, tile, attachTo: board.tiles[1] }); + assert.deepStrictEqual(attachments[5], { side: 3, orientation: 2, tile, attachTo: board.tiles[1] }); + assert.deepStrictEqual(attachments[6], { side: 3, orientation: 3, tile, attachTo: board.tiles[1] }); + assert.deepStrictEqual(attachments[7], { side: 1, orientation: 3, tile, attachTo: board.tiles[2] }); + assert.deepStrictEqual(attachments[8], { side: 2, orientation: 0, tile, attachTo: board.tiles[2] }); }); }); |