aboutsummaryrefslogtreecommitdiff
path: root/src/Tile/TileOnBoard.ts
diff options
context:
space:
mode:
authoreug-vs <eugene@eug-vs.xyz>2022-03-14 20:52:08 +0300
committereug-vs <eugene@eug-vs.xyz>2022-03-14 20:52:08 +0300
commitd64c44c432ccb5574909edd77b8b882e8543ef1b (patch)
treefeb4035bf7301f9b627634695b7650027e5eecc4 /src/Tile/TileOnBoard.ts
parent9cf681ff497150e4d56b13bde4f57f4f0e9633c0 (diff)
downloadcarcassonne-engine-ts-d64c44c432ccb5574909edd77b8b882e8543ef1b.tar.gz
refactor!: change internal edge representation
Diffstat (limited to 'src/Tile/TileOnBoard.ts')
-rw-r--r--src/Tile/TileOnBoard.ts51
1 files changed, 0 insertions, 51 deletions
diff --git a/src/Tile/TileOnBoard.ts b/src/Tile/TileOnBoard.ts
deleted file mode 100644
index 0fa8005..0000000
--- a/src/Tile/TileOnBoard.ts
+++ /dev/null
@@ -1,51 +0,0 @@
-import _ from 'lodash';
-import Tile, { Feature, Direction } from './Tile';
-
-export interface Attachment {
- attachTo: TileOnBoard;
- side: Direction;
- tile: Tile;
- orientation: number; // Clockwise rotation of a tile
-}
-
-export default class TileOnBoard extends Tile {
- orientation: number; // amount of 90-degree clockwise rotations from original orientation
- position: {
- x: number;
- y: number;
- }
-
- constructor(
- center: Feature,
- sides: [Feature, Feature, Feature, Feature],
- shield = false,
- position = { x: 0, y: 0 },
- orientation = 0
- ) {
- super(center, sides, shield);
- this.position = position;
- this.orientation = orientation;
- }
-
- getSide(direction: Direction) {
- return super.getSide(direction - this.orientation);
- }
-
- rotate(rotation = 1) {
- this.orientation += rotation;
- }
-
- getAttachments(tile: Tile): Attachment[] {
- return _.flatten([0, 1, 2, 3].map(side => {
- const item = this.getSide(side);
- return [0, 1, 2, 3]
- .filter(orientation => tile.getSide(side - orientation + 2) === item)
- .map(orientation => ({
- tile,
- orientation,
- side,
- attachTo: this as Tile
- }))
- }));
- }
-}