diff options
author | eug-vs <eugene@eug-vs.xyz> | 2022-03-13 01:26:21 +0300 |
---|---|---|
committer | eug-vs <eugene@eug-vs.xyz> | 2022-03-13 01:26:21 +0300 |
commit | 93379c8826034601bbaad017366ddd2e484574e3 (patch) | |
tree | 927e3ea802dea68c47a7ee49acf0943a64dcef25 /src/Tile/TileOnBoard.ts | |
parent | edb54e7cc773d1b9485171e37f59296de52f2031 (diff) | |
download | carcassonne-engine-ts-93379c8826034601bbaad017366ddd2e484574e3.tar.gz |
feat: add position calculation on attach
Diffstat (limited to 'src/Tile/TileOnBoard.ts')
-rw-r--r-- | src/Tile/TileOnBoard.ts | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/src/Tile/TileOnBoard.ts b/src/Tile/TileOnBoard.ts index 374ae95..bc1e66d 100644 --- a/src/Tile/TileOnBoard.ts +++ b/src/Tile/TileOnBoard.ts @@ -2,14 +2,13 @@ import _ from 'lodash'; import Tile, { Feature, Direction } from './Tile'; export interface Attachment { - attachTo: Tile; + attachTo: TileOnBoard; side: Direction; tile: Tile; - rotation: number; // Clockwise rotation of a tile + orientation: number; // Clockwise rotation of a tile } export default class TileOnBoard extends Tile { - neighbors: [Tile, Tile, Tile, Tile]; orientation: number; // amount of 90-degree counter-clockwise rotations from original orientation position: { x: number; @@ -26,7 +25,6 @@ export default class TileOnBoard extends Tile { super(center, sides, shield); this.position = position; this.orientation = orientation; - this.neighbors = [null, null, null, null]; } getSide(direction: Direction) { @@ -52,9 +50,4 @@ export default class TileOnBoard extends Tile { })) })); } - - attach(tile: Tile, side: Direction) { - if (this.neighbors[side]) throw new Error('There is something already attached to this side!'); - this.neighbors[side] = tile; - } } |