@gamepark/rules-api 6.25.0 → 6.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/utils/grid.hex.util.d.ts +115 -0
- package/dist/utils/grid.hex.util.js +197 -0
- package/dist/utils/grid.hex.util.js.map +1 -0
- package/dist/utils/grid.util.d.ts +9 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { Location } from '../material';
|
|
2
|
+
import { XYCoordinates } from './grid.util';
|
|
3
|
+
/**
|
|
4
|
+
* The different coordinates systems available to describe a Hexagonal Grid.
|
|
5
|
+
* See https://www.redblobgames.com/grids/hexagons/#coordinates
|
|
6
|
+
*/
|
|
7
|
+
export declare enum HexGridSystem {
|
|
8
|
+
Axial = 0,
|
|
9
|
+
OddQ = 1,
|
|
10
|
+
EvenQ = 2,
|
|
11
|
+
OddR = 3,
|
|
12
|
+
EvenR = 4
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Converts {@link HexGridSystem.OddQ} coordinates into {@link HexGridSystem.Axial} coordinates
|
|
16
|
+
*/
|
|
17
|
+
export declare const oddQToAxial: ({ x, y }: XYCoordinates) => {
|
|
18
|
+
x: number;
|
|
19
|
+
y: number;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Converts {@link HexGridSystem.Axial} coordinates into {@link HexGridSystem.OddQ} coordinates
|
|
23
|
+
*/
|
|
24
|
+
export declare const axialToOddQ: ({ x, y }: XYCoordinates) => {
|
|
25
|
+
x: number;
|
|
26
|
+
y: number;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Converts {@link HexGridSystem.EvenQ} coordinates into {@link HexGridSystem.Axial} coordinates
|
|
30
|
+
*/
|
|
31
|
+
export declare const evenQToAxial: ({ x, y }: XYCoordinates) => {
|
|
32
|
+
x: number;
|
|
33
|
+
y: number;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Converts {@link HexGridSystem.Axial} coordinates into {@link HexGridSystem.EvenQ} coordinates
|
|
37
|
+
*/
|
|
38
|
+
export declare const axialToEvenQ: ({ x, y }: XYCoordinates) => {
|
|
39
|
+
x: number;
|
|
40
|
+
y: number;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Converts {@link HexGridSystem.OddR} coordinates into {@link HexGridSystem.Axial} coordinates
|
|
44
|
+
*/
|
|
45
|
+
export declare const oddRToAxial: ({ x, y }: XYCoordinates) => {
|
|
46
|
+
y: number;
|
|
47
|
+
x: number;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Converts {@link HexGridSystem.Axial} coordinates into {@link HexGridSystem.OddR} coordinates
|
|
51
|
+
*/
|
|
52
|
+
export declare const axialToOddR: ({ x, y }: XYCoordinates) => {
|
|
53
|
+
y: number;
|
|
54
|
+
x: number;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Converts {@link HexGridSystem.EvenR} coordinates into {@link HexGridSystem.Axial} coordinates
|
|
58
|
+
*/
|
|
59
|
+
export declare const evenRToAxial: ({ x, y }: XYCoordinates) => {
|
|
60
|
+
y: number;
|
|
61
|
+
x: number;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Converts {@link HexGridSystem.Axial} coordinates into {@link HexGridSystem.EvenR} coordinates
|
|
65
|
+
*/
|
|
66
|
+
export declare const axialToEvenR: ({ x, y }: XYCoordinates) => {
|
|
67
|
+
y: number;
|
|
68
|
+
x: number;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Convert any {@link HexGridSystem} coordinates to {@link HexGridSystem.Axial}
|
|
72
|
+
* @param hex Coordinates to convert
|
|
73
|
+
* @param system System of the coordinates
|
|
74
|
+
* @return Coordinates in {@link HexGridSystem.Axial}
|
|
75
|
+
*/
|
|
76
|
+
export declare function hexToAxial(hex: XYCoordinates, system: HexGridSystem): XYCoordinates;
|
|
77
|
+
/**
|
|
78
|
+
* Convert {@link HexGridSystem.Axial} coordinates to any other {@link HexGridSystem}
|
|
79
|
+
* @param hex Axial coordinates to convert
|
|
80
|
+
* @param system Destination coordinates system
|
|
81
|
+
* @return Coordinates converted in the description system
|
|
82
|
+
*/
|
|
83
|
+
export declare function hexFromAxial(hex: XYCoordinates, system: HexGridSystem): XYCoordinates;
|
|
84
|
+
/**
|
|
85
|
+
* Rotate hexagonal coordinates.
|
|
86
|
+
* @param vector Vector to rotate
|
|
87
|
+
* @param rotation Number of 60 degrees rotations to apply (1 = 60°, 2 = 120°...)
|
|
88
|
+
* @param system The coordinates system used
|
|
89
|
+
* @return the rotated vector
|
|
90
|
+
*/
|
|
91
|
+
export declare function hexRotate(vector: XYCoordinates, rotation?: number, system?: HexGridSystem): XYCoordinates;
|
|
92
|
+
/**
|
|
93
|
+
* Get the distance between 2 hexagons, i.e. the minimum number of hexagons to cross to got from hex1 to hex2.
|
|
94
|
+
* @param hex1 First hexagon coordinates
|
|
95
|
+
* @param hex2 Second hexagon coordinates
|
|
96
|
+
* @param system The coordinates system used
|
|
97
|
+
* @return the distance between the hexagons
|
|
98
|
+
*/
|
|
99
|
+
export declare function getDistanceBetweenHex(hex1: XYCoordinates, hex2: XYCoordinates, system?: HexGridSystem): number;
|
|
100
|
+
/**
|
|
101
|
+
* Translate hexagonal coordinates by a vector.
|
|
102
|
+
* @param hex Coordinates of the hexagon to translate
|
|
103
|
+
* @param vector Vector of the translation
|
|
104
|
+
* @param system The coordinates system used
|
|
105
|
+
* @return The coordinates of the hexagon after the translation
|
|
106
|
+
*/
|
|
107
|
+
export declare function hexTranslate(hex: XYCoordinates, vector: XYCoordinates, system?: HexGridSystem): XYCoordinates;
|
|
108
|
+
/**
|
|
109
|
+
* Get the coordinates that will be covered by a polyhex tile when at a specific grid location.
|
|
110
|
+
* @param polyhex Coordinates occupied by the polyhex without any rotation in given coordinates system
|
|
111
|
+
* @param location Location of the polyhex on the grid (x, y, and rotation)
|
|
112
|
+
* @param system The coordinates system used for the polyhex description and the location
|
|
113
|
+
* @return coordinates in the grid covered when the polyhex has this location
|
|
114
|
+
*/
|
|
115
|
+
export declare function getPolyhexSpaces(polyhex: XYCoordinates[], location: Partial<Location>, system?: HexGridSystem): XYCoordinates[];
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPolyhexSpaces = exports.hexTranslate = exports.getDistanceBetweenHex = exports.hexRotate = exports.hexFromAxial = exports.hexToAxial = exports.axialToEvenR = exports.evenRToAxial = exports.axialToOddR = exports.oddRToAxial = exports.axialToEvenQ = exports.evenQToAxial = exports.axialToOddQ = exports.oddQToAxial = exports.HexGridSystem = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The different coordinates systems available to describe a Hexagonal Grid.
|
|
6
|
+
* See https://www.redblobgames.com/grids/hexagons/#coordinates
|
|
7
|
+
*/
|
|
8
|
+
var HexGridSystem;
|
|
9
|
+
(function (HexGridSystem) {
|
|
10
|
+
HexGridSystem[HexGridSystem["Axial"] = 0] = "Axial";
|
|
11
|
+
HexGridSystem[HexGridSystem["OddQ"] = 1] = "OddQ";
|
|
12
|
+
HexGridSystem[HexGridSystem["EvenQ"] = 2] = "EvenQ";
|
|
13
|
+
HexGridSystem[HexGridSystem["OddR"] = 3] = "OddR";
|
|
14
|
+
HexGridSystem[HexGridSystem["EvenR"] = 4] = "EvenR";
|
|
15
|
+
})(HexGridSystem || (exports.HexGridSystem = HexGridSystem = {}));
|
|
16
|
+
/**
|
|
17
|
+
* Converts {@link HexGridSystem.OddQ} coordinates into {@link HexGridSystem.Axial} coordinates
|
|
18
|
+
*/
|
|
19
|
+
var oddQToAxial = function (_a) {
|
|
20
|
+
var x = _a.x, y = _a.y;
|
|
21
|
+
return ({ x: x, y: y - (x - (x & 1)) / 2 });
|
|
22
|
+
};
|
|
23
|
+
exports.oddQToAxial = oddQToAxial;
|
|
24
|
+
/**
|
|
25
|
+
* Converts {@link HexGridSystem.Axial} coordinates into {@link HexGridSystem.OddQ} coordinates
|
|
26
|
+
*/
|
|
27
|
+
var axialToOddQ = function (_a) {
|
|
28
|
+
var x = _a.x, y = _a.y;
|
|
29
|
+
return ({ x: x, y: y + (x - (x & 1)) / 2 });
|
|
30
|
+
};
|
|
31
|
+
exports.axialToOddQ = axialToOddQ;
|
|
32
|
+
/**
|
|
33
|
+
* Converts {@link HexGridSystem.EvenQ} coordinates into {@link HexGridSystem.Axial} coordinates
|
|
34
|
+
*/
|
|
35
|
+
var evenQToAxial = function (_a) {
|
|
36
|
+
var x = _a.x, y = _a.y;
|
|
37
|
+
return ({ x: x, y: y - (x + (x & 1)) / 2 });
|
|
38
|
+
};
|
|
39
|
+
exports.evenQToAxial = evenQToAxial;
|
|
40
|
+
/**
|
|
41
|
+
* Converts {@link HexGridSystem.Axial} coordinates into {@link HexGridSystem.EvenQ} coordinates
|
|
42
|
+
*/
|
|
43
|
+
var axialToEvenQ = function (_a) {
|
|
44
|
+
var x = _a.x, y = _a.y;
|
|
45
|
+
return ({ x: x, y: y + (x + (x & 1)) / 2 });
|
|
46
|
+
};
|
|
47
|
+
exports.axialToEvenQ = axialToEvenQ;
|
|
48
|
+
/**
|
|
49
|
+
* Converts {@link HexGridSystem.OddR} coordinates into {@link HexGridSystem.Axial} coordinates
|
|
50
|
+
*/
|
|
51
|
+
var oddRToAxial = function (_a) {
|
|
52
|
+
var x = _a.x, y = _a.y;
|
|
53
|
+
return ({ y: y, x: x - (y - (y & 1)) / 2 });
|
|
54
|
+
};
|
|
55
|
+
exports.oddRToAxial = oddRToAxial;
|
|
56
|
+
/**
|
|
57
|
+
* Converts {@link HexGridSystem.Axial} coordinates into {@link HexGridSystem.OddR} coordinates
|
|
58
|
+
*/
|
|
59
|
+
var axialToOddR = function (_a) {
|
|
60
|
+
var x = _a.x, y = _a.y;
|
|
61
|
+
return ({ y: y, x: x + (y - (y & 1)) / 2 });
|
|
62
|
+
};
|
|
63
|
+
exports.axialToOddR = axialToOddR;
|
|
64
|
+
/**
|
|
65
|
+
* Converts {@link HexGridSystem.EvenR} coordinates into {@link HexGridSystem.Axial} coordinates
|
|
66
|
+
*/
|
|
67
|
+
var evenRToAxial = function (_a) {
|
|
68
|
+
var x = _a.x, y = _a.y;
|
|
69
|
+
return ({ y: y, x: x - (y + (y & 1)) / 2 });
|
|
70
|
+
};
|
|
71
|
+
exports.evenRToAxial = evenRToAxial;
|
|
72
|
+
/**
|
|
73
|
+
* Converts {@link HexGridSystem.Axial} coordinates into {@link HexGridSystem.EvenR} coordinates
|
|
74
|
+
*/
|
|
75
|
+
var axialToEvenR = function (_a) {
|
|
76
|
+
var x = _a.x, y = _a.y;
|
|
77
|
+
return ({ y: y, x: x + (y + (y & 1)) / 2 });
|
|
78
|
+
};
|
|
79
|
+
exports.axialToEvenR = axialToEvenR;
|
|
80
|
+
/**
|
|
81
|
+
* Convert any {@link HexGridSystem} coordinates to {@link HexGridSystem.Axial}
|
|
82
|
+
* @param hex Coordinates to convert
|
|
83
|
+
* @param system System of the coordinates
|
|
84
|
+
* @return Coordinates in {@link HexGridSystem.Axial}
|
|
85
|
+
*/
|
|
86
|
+
function hexToAxial(hex, system) {
|
|
87
|
+
switch (system) {
|
|
88
|
+
case HexGridSystem.OddQ:
|
|
89
|
+
return (0, exports.oddQToAxial)(hex);
|
|
90
|
+
case HexGridSystem.EvenQ:
|
|
91
|
+
return (0, exports.evenQToAxial)(hex);
|
|
92
|
+
case HexGridSystem.OddR:
|
|
93
|
+
return (0, exports.oddRToAxial)(hex);
|
|
94
|
+
case HexGridSystem.EvenR:
|
|
95
|
+
return (0, exports.evenRToAxial)(hex);
|
|
96
|
+
default:
|
|
97
|
+
return hex;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
exports.hexToAxial = hexToAxial;
|
|
101
|
+
/**
|
|
102
|
+
* Convert {@link HexGridSystem.Axial} coordinates to any other {@link HexGridSystem}
|
|
103
|
+
* @param hex Axial coordinates to convert
|
|
104
|
+
* @param system Destination coordinates system
|
|
105
|
+
* @return Coordinates converted in the description system
|
|
106
|
+
*/
|
|
107
|
+
function hexFromAxial(hex, system) {
|
|
108
|
+
switch (system) {
|
|
109
|
+
case HexGridSystem.OddQ:
|
|
110
|
+
return (0, exports.axialToOddQ)(hex);
|
|
111
|
+
case HexGridSystem.EvenQ:
|
|
112
|
+
return (0, exports.axialToEvenQ)(hex);
|
|
113
|
+
case HexGridSystem.OddR:
|
|
114
|
+
return (0, exports.axialToOddR)(hex);
|
|
115
|
+
case HexGridSystem.EvenR:
|
|
116
|
+
return (0, exports.axialToEvenR)(hex);
|
|
117
|
+
default:
|
|
118
|
+
return hex;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
exports.hexFromAxial = hexFromAxial;
|
|
122
|
+
/**
|
|
123
|
+
* Rotate hexagonal coordinates.
|
|
124
|
+
* @param vector Vector to rotate
|
|
125
|
+
* @param rotation Number of 60 degrees rotations to apply (1 = 60°, 2 = 120°...)
|
|
126
|
+
* @param system The coordinates system used
|
|
127
|
+
* @return the rotated vector
|
|
128
|
+
*/
|
|
129
|
+
function hexRotate(vector, rotation, system) {
|
|
130
|
+
if (rotation === void 0) { rotation = 0; }
|
|
131
|
+
if (system === void 0) { system = HexGridSystem.Axial; }
|
|
132
|
+
if (system !== HexGridSystem.Axial)
|
|
133
|
+
return hexFromAxial(hexRotate(hexToAxial(vector, system), rotation), system);
|
|
134
|
+
switch (rotation % 6) {
|
|
135
|
+
case 1:
|
|
136
|
+
return { x: -vector.y, y: vector.x + vector.y };
|
|
137
|
+
case 2:
|
|
138
|
+
// noinspection JSSuspiciousNameCombination
|
|
139
|
+
return { x: -vector.x - vector.y, y: vector.x };
|
|
140
|
+
case 3:
|
|
141
|
+
return { x: -vector.x, y: -vector.y };
|
|
142
|
+
case 4:
|
|
143
|
+
// noinspection JSSuspiciousNameCombination
|
|
144
|
+
return { x: vector.y, y: -vector.x - vector.y };
|
|
145
|
+
case 5:
|
|
146
|
+
return { x: vector.x + vector.y, y: -vector.x };
|
|
147
|
+
default:
|
|
148
|
+
return vector;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
exports.hexRotate = hexRotate;
|
|
152
|
+
/**
|
|
153
|
+
* Get the distance between 2 hexagons, i.e. the minimum number of hexagons to cross to got from hex1 to hex2.
|
|
154
|
+
* @param hex1 First hexagon coordinates
|
|
155
|
+
* @param hex2 Second hexagon coordinates
|
|
156
|
+
* @param system The coordinates system used
|
|
157
|
+
* @return the distance between the hexagons
|
|
158
|
+
*/
|
|
159
|
+
function getDistanceBetweenHex(hex1, hex2, system) {
|
|
160
|
+
if (system === void 0) { system = HexGridSystem.Axial; }
|
|
161
|
+
if (system !== HexGridSystem.Axial) {
|
|
162
|
+
return getDistanceBetweenHex(hexToAxial(hex1, system), hexToAxial(hex2, system));
|
|
163
|
+
}
|
|
164
|
+
return (Math.abs(hex1.x - hex2.x) + Math.abs(hex1.x - hex2.x + hex1.y - hex2.y) + Math.abs(hex1.y - hex2.y)) / 2;
|
|
165
|
+
}
|
|
166
|
+
exports.getDistanceBetweenHex = getDistanceBetweenHex;
|
|
167
|
+
/**
|
|
168
|
+
* Translate hexagonal coordinates by a vector.
|
|
169
|
+
* @param hex Coordinates of the hexagon to translate
|
|
170
|
+
* @param vector Vector of the translation
|
|
171
|
+
* @param system The coordinates system used
|
|
172
|
+
* @return The coordinates of the hexagon after the translation
|
|
173
|
+
*/
|
|
174
|
+
function hexTranslate(hex, vector, system) {
|
|
175
|
+
if (system === void 0) { system = HexGridSystem.Axial; }
|
|
176
|
+
if (system !== HexGridSystem.Axial)
|
|
177
|
+
return hexFromAxial(hexTranslate(hexToAxial(hex, system), hexToAxial(vector, system)), system);
|
|
178
|
+
return ({ x: hex.x + vector.x, y: hex.y + vector.y });
|
|
179
|
+
}
|
|
180
|
+
exports.hexTranslate = hexTranslate;
|
|
181
|
+
/**
|
|
182
|
+
* Get the coordinates that will be covered by a polyhex tile when at a specific grid location.
|
|
183
|
+
* @param polyhex Coordinates occupied by the polyhex without any rotation in given coordinates system
|
|
184
|
+
* @param location Location of the polyhex on the grid (x, y, and rotation)
|
|
185
|
+
* @param system The coordinates system used for the polyhex description and the location
|
|
186
|
+
* @return coordinates in the grid covered when the polyhex has this location
|
|
187
|
+
*/
|
|
188
|
+
function getPolyhexSpaces(polyhex, location, system) {
|
|
189
|
+
var _a, _b;
|
|
190
|
+
if (system === void 0) { system = HexGridSystem.Axial; }
|
|
191
|
+
var vector = { x: (_a = location.x) !== null && _a !== void 0 ? _a : 0, y: (_b = location.y) !== null && _b !== void 0 ? _b : 0 };
|
|
192
|
+
return polyhex
|
|
193
|
+
.map(function (hex) { var _a; return hexRotate(hex, (_a = location.rotation) !== null && _a !== void 0 ? _a : 0, system); })
|
|
194
|
+
.map(function (hex) { return hexTranslate(hex, vector, system); });
|
|
195
|
+
}
|
|
196
|
+
exports.getPolyhexSpaces = getPolyhexSpaces;
|
|
197
|
+
//# sourceMappingURL=grid.hex.util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grid.hex.util.js","sourceRoot":"","sources":["../../src/utils/grid.hex.util.ts"],"names":[],"mappings":";;;AAGA;;;GAGG;AACH,IAAY,aAEX;AAFD,WAAY,aAAa;IACvB,mDAAK,CAAA;IAAE,iDAAI,CAAA;IAAE,mDAAK,CAAA;IAAE,iDAAI,CAAA;IAAE,mDAAK,CAAA;AACjC,CAAC,EAFW,aAAa,6BAAb,aAAa,QAExB;AAED;;GAEG;AACI,IAAM,WAAW,GAAG,UAAC,EAAuB;QAArB,CAAC,OAAA,EAAE,CAAC,OAAA;IAAsB,OAAA,CAAC,EAAE,CAAC,GAAA,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;AAAj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AC,YAAY,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAA;IAClI,OAAO,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,CAAC,CAAA;AACvD,CAAC;AAHD,oCAGC;AAED;;;;;;GAMG;AACH,SAAgB,gBAAgB,CAAC,OAAwB,EAAE,QAA2B,EAAE,MAA4B;;IAA5B,uBAAA,EAAA,SAAS,aAAa,CAAC,KAAK;IAClH,IAAM,MAAM,GAAG,EAAE,CAAC,EAAE,MAAA,QAAQ,CAAC,CAAC,mCAAI,CAAC,EAAE,CAAC,EAAE,MAAA,QAAQ,CAAC,CAAC,mCAAI,CAAC,EAAE,CAAA;IACzD,OAAO,OAAO;SACX,GAAG,CAAC,UAAA,GAAG,YAAI,OAAA,SAAS,CAAC,GAAG,EAAE,MAAA,QAAQ,CAAC,QAAQ,mCAAI,CAAC,EAAE,MAAM,CAAC,CAAA,EAAA,CAAC;SAC1D,GAAG,CAAC,UAAA,GAAG,IAAI,OAAA,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAjC,CAAiC,CAAC,CAAA;AAClD,CAAC;AALD,4CAKC"}
|
|
@@ -11,3 +11,12 @@ export type XYCoordinates = {
|
|
|
11
11
|
* @returns true if coordinates is a {@link XYCoordinates}
|
|
12
12
|
*/
|
|
13
13
|
export declare const isXYCoordinates: (coordinates: any) => coordinates is XYCoordinates;
|
|
14
|
+
/**
|
|
15
|
+
* Boundaries for a two dimension grid
|
|
16
|
+
*/
|
|
17
|
+
export type GridBoundaries = {
|
|
18
|
+
xMin: number;
|
|
19
|
+
xMax: number;
|
|
20
|
+
yMin: number;
|
|
21
|
+
yMax: number;
|
|
22
|
+
};
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from './automatic-moves.util';
|
|
|
4
4
|
export * from './enum.util';
|
|
5
5
|
export * from './game-view.util';
|
|
6
6
|
export * from './grid.util';
|
|
7
|
+
export * from './grid.hex.util';
|
|
7
8
|
export * from './grid.squares.util';
|
|
8
9
|
export * from './listing.util';
|
|
9
10
|
export * from './loops.util';
|
package/dist/utils/index.js
CHANGED
|
@@ -20,6 +20,7 @@ __exportStar(require("./automatic-moves.util"), exports);
|
|
|
20
20
|
__exportStar(require("./enum.util"), exports);
|
|
21
21
|
__exportStar(require("./game-view.util"), exports);
|
|
22
22
|
__exportStar(require("./grid.util"), exports);
|
|
23
|
+
__exportStar(require("./grid.hex.util"), exports);
|
|
23
24
|
__exportStar(require("./grid.squares.util"), exports);
|
|
24
25
|
__exportStar(require("./listing.util"), exports);
|
|
25
26
|
__exportStar(require("./loops.util"), exports);
|
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA6B;AAC7B,qDAAkC;AAClC,yDAAsC;AACtC,8CAA2B;AAC3B,mDAAgC;AAChC,8CAA2B;AAC3B,sDAAmC;AACnC,iDAA8B;AAC9B,+CAA4B;AAC5B,+CAA4B;AAC5B,gDAA6B;AAC7B,8CAA2B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA6B;AAC7B,qDAAkC;AAClC,yDAAsC;AACtC,8CAA2B;AAC3B,mDAAgC;AAChC,8CAA2B;AAC3B,kDAA+B;AAC/B,sDAAmC;AACnC,iDAA8B;AAC9B,+CAA4B;AAC5B,+CAA4B;AAC5B,gDAA6B;AAC7B,8CAA2B"}
|