aboutsummaryrefslogtreecommitdiff
path: root/src/Board/Board.test.ts
diff options
context:
space:
mode:
authoreug-vs <eugene@eug-vs.xyz>2022-03-13 14:05:22 +0300
committereug-vs <eugene@eug-vs.xyz>2022-03-13 14:05:22 +0300
commite30259bb228ff5011998b1b9dbaf2508b0047425 (patch)
treeff516f889a697b8e464b0aa11629eaf22f730781 /src/Board/Board.test.ts
parent1d6519f9f97e1d6d4046e2caf21b81dfe277992d (diff)
downloadcarcassonne-engine-ts-e30259bb228ff5011998b1b9dbaf2508b0047425.tar.gz
feat: add test to manually verify attachments
Diffstat (limited to 'src/Board/Board.test.ts')
-rw-r--r--src/Board/Board.test.ts35
1 files changed, 30 insertions, 5 deletions
diff --git a/src/Board/Board.test.ts b/src/Board/Board.test.ts
index 349a4aa..5023f0b 100644
--- a/src/Board/Board.test.ts
+++ b/src/Board/Board.test.ts
@@ -1,10 +1,11 @@
+import _ from 'lodash';
import assert from 'assert';
import Tile, { Feature, Direction } from '../Tile/Tile';
import TileOnBoard from '../Tile/TileOnBoard';
import Board from './Board';
const { Road, Town, Grass } = Feature;
-const { North } = Direction;
+const { North, East } = Direction;
describe('Board', () => {
describe('constructor', () => {
@@ -23,10 +24,33 @@ describe('Board', () => {
const legalMoves = board.getAttachments(tile);
assert.strictEqual(legalMoves.length, 4);
- assert.deepStrictEqual(legalMoves[0], { side: 0, rotation: 1, attachTo, tile });
- assert.deepStrictEqual(legalMoves[1], { side: 0, rotation: 3, attachTo, tile });
- assert.deepStrictEqual(legalMoves[2], { side: 2, rotation: 0, attachTo, tile });
- assert.deepStrictEqual(legalMoves[3], { side: 2, rotation: 2, attachTo, tile });
+ 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 });
+ });
+
+ it.skip('Have a look at my nice attachments manually bro', () => {
+ const board = new Board();
+
+ board.attach({
+ tile: new Tile(Town, [Town, Grass, Town, Grass]),
+ attachTo: board.tiles[0],
+ orientation: 0,
+ side: North,
+ });
+
+ board.attach({
+ tile: new Tile(Town, [Road, Town, Town, Road]),
+ attachTo: board.tiles[0],
+ orientation: 0,
+ side: East,
+ });
+
+ const tile = new Tile(Grass, [Town, Grass, Grass, Grass]);
+
+ const attachments = board.getAttachments(tile);
+ attachments.forEach(attachment => board.previewAttachment(attachment));
});
});
@@ -50,6 +74,7 @@ describe('Board', () => {
);
board.attach(attachment);
+
assert.strictEqual(board.tiles.length, 2);
assert.deepStrictEqual(board.tiles[1], expectedTileOnBoard);
});