brick-engine-js 1.0.22 → 1.0.23
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/README.adoc +2 -2
- package/dist/docs/index.html +3 -3
- package/dist/docs/jsdoc_standard.html +30 -13
- package/dist/docs/reference/bootstrap.html +556 -0
- package/dist/docs/reference/context/RendererContext.html +19 -9
- package/dist/docs/reference/enums/Color.html +11 -5
- package/dist/docs/reference/enums/ControlEventType.html +7 -5
- package/dist/docs/reference/enums/ControlKey.html +7 -5
- package/dist/docs/reference/enums/EventSuffix.html +7 -5
- package/dist/docs/reference/enums/FontAlignment.html +9 -7
- package/dist/docs/reference/enums/FontSize.html +7 -5
- package/dist/docs/reference/enums/Sound.html +7 -5
- package/dist/docs/reference/enums/StateProperty.html +7 -5
- package/dist/docs/reference/helpers/CellHelper.html +6 -2
- package/dist/docs/reference/helpers/ControlInputHandlerHelper.html +9 -5
- package/dist/docs/reference/helpers/CoordinateHelper.html +14 -10
- package/dist/docs/reference/helpers/RelativeValuesHelper.html +7 -3
- package/dist/docs/reference/interfaces/Debuggable.html +9 -7
- package/dist/docs/reference/interfaces/GameModules.html +7 -5
- package/dist/docs/reference/interfaces/Initializable.html +9 -7
- package/dist/docs/reference/interfaces/RendererInitializable.html +9 -7
- package/dist/docs/reference/interfaces/StateContext.html +7 -5
- package/dist/docs/reference/interfaces/StateSyncable.html +11 -9
- package/dist/docs/reference/interfaces/modules/Control.html +19 -17
- package/dist/docs/reference/interfaces/modules/Grid.html +77 -55
- package/dist/docs/reference/interfaces/modules/Renderer.html +9 -7
- package/dist/docs/reference/interfaces/modules/RendererComposite.html +13 -11
- package/dist/docs/reference/interfaces/modules/Score.html +21 -19
- package/dist/docs/reference/interfaces/modules/Session.html +64 -18
- package/dist/docs/reference/interfaces/modules/State.html +59 -57
- package/dist/docs/reference/interfaces/modules/Text.html +21 -19
- package/dist/docs/reference/interfaces/modules/Time.html +80 -24
- package/dist/docs/reference/modules/Debugger.html +16 -14
- package/dist/docs/reference/modules/DisplayRenderer.html +10 -8
- package/dist/docs/reference/modules/EventEmitter.html +34 -26
- package/dist/docs/reference/modules/Game.html +55 -30
- package/dist/docs/reference/modules/GameControl.html +49 -44
- package/dist/docs/reference/modules/GameEventRegistry.html +17 -34
- package/dist/docs/reference/modules/GameGrid.html +174 -116
- package/dist/docs/reference/modules/GameHudGrid.html +10 -8
- package/dist/docs/reference/modules/GameRenderer.html +14 -12
- package/dist/docs/reference/modules/GameScore.html +36 -34
- package/dist/docs/reference/modules/GameSession.html +37 -19
- package/dist/docs/reference/modules/GameSound.html +20 -18
- package/dist/docs/reference/modules/GameState.html +70 -68
- package/dist/docs/reference/modules/GameText.html +29 -27
- package/dist/docs/reference/modules/GameTime.html +98 -30
- package/dist/docs/reference/modules/HudRenderer.html +10 -8
- package/dist/docs/reference/modules/InitialStateSnapshot.html +13 -11
- package/dist/docs/reference/modules/SessionModal.html +11 -9
- package/dist/docs/reference/types/Axis.html +7 -5
- package/dist/docs/reference/types/Cell.html +7 -5
- package/dist/docs/reference/types/ControlCallback.html +7 -5
- package/dist/docs/reference/types/Coordinate.html +7 -5
- package/dist/docs/reference/types/GameEvent.html +7 -5
- package/dist/docs/reference/types/Piece.html +7 -5
- package/dist/docs/reference/types/RendererMetrics.html +7 -5
- package/dist/docs/reference/types/Vector.html +7 -5
- package/dist/docs/reference/view/GameView.html +29 -21
- package/dist/docs/testing_best_practices.html +2 -2
- package/dist/game.bundle.js +1 -1
- package/dist/types/bootstrap.d.ts +12 -11
- package/dist/types/core/Game.d.ts +46 -39
- package/dist/types/core/InitialStateSnapshot.d.ts +18 -6
- package/dist/types/core/context/RendererContext.d.ts +32 -10
- package/dist/types/core/event/EventEmitter.d.ts +64 -21
- package/dist/types/core/event/GameEventRegistry.d.ts +17 -3
- package/dist/types/core/helpers/CellHelper.d.ts +11 -4
- package/dist/types/core/helpers/ControlInputHandlerHelper.d.ts +20 -11
- package/dist/types/core/helpers/CoordinateHelper.d.ts +28 -23
- package/dist/types/core/helpers/InterfaceIdentifierHelper.d.ts +34 -0
- package/dist/types/core/helpers/RelativeValuesHelper.d.ts +10 -8
- package/dist/types/core/module/control/GameControl.d.ts +26 -14
- package/dist/types/core/module/grid/GameGrid.d.ts +68 -53
- package/dist/types/core/module/grid/GameHudGrid.d.ts +9 -7
- package/dist/types/core/module/grid/engines/GridAnalysisEngine.d.ts +25 -6
- package/dist/types/core/module/grid/engines/GridLineEngine.d.ts +51 -13
- package/dist/types/core/module/grid/engines/GridMovementEngine.d.ts +97 -13
- package/dist/types/core/module/grid/engines/GridRegionEngine.d.ts +24 -5
- package/dist/types/core/module/grid/engines/GridTransformEngine.d.ts +21 -5
- package/dist/types/core/module/renderer/DisplayRenderer.d.ts +27 -15
- package/dist/types/core/module/renderer/GameRenderer.d.ts +20 -13
- package/dist/types/core/module/renderer/HudRenderer.d.ts +27 -19
- package/dist/types/core/module/score/GameScore.d.ts +29 -18
- package/dist/types/core/module/session/GameSession.d.ts +56 -0
- package/dist/types/core/module/sound/GameSound.d.ts +39 -23
- package/dist/types/core/module/state/GameState.d.ts +38 -14
- package/dist/types/core/module/text/GameText.d.ts +40 -25
- package/dist/types/core/module/time/GameTime.d.ts +23 -10
- package/dist/types/core/types/Interfaces.d.ts +15 -0
- package/dist/types/core/types/Types.d.ts +1 -0
- package/dist/types/core/types/enums.d.ts +2 -1
- package/dist/types/core/types/modules.d.ts +193 -43
- package/dist/types/view/Debugger.d.ts +23 -0
- package/dist/types/view/GameView.d.ts +44 -27
- package/dist/types/view/SessionModal.d.ts +24 -0
- package/package.json +1 -1
- package/dist/CNAME +0 -1
|
@@ -1,7 +1,41 @@
|
|
|
1
1
|
import { Debuggable, Initializable, StateSyncable, Serializable } from '../types/Interfaces';
|
|
2
|
+
/**
|
|
3
|
+
* Type guard utility for runtime interface identification of engine modules.
|
|
4
|
+
*
|
|
5
|
+
* TypeScript interfaces are erased at compile-time. This class provides the
|
|
6
|
+
* architectural capability to perform dynamic feature discovery during the
|
|
7
|
+
* engine's bootstrap and serialization phases (e.g. checking if a registered
|
|
8
|
+
* module supports state syncing) by duck-typing the expected method contracts.
|
|
9
|
+
*/
|
|
2
10
|
export default class InterfaceIdentifierHelper {
|
|
11
|
+
/**
|
|
12
|
+
* Determines whether a given module implements the {@link Serializable} interface.
|
|
13
|
+
*
|
|
14
|
+
* @param {object} module - The generic module instance to inspect.
|
|
15
|
+
* @returns {boolean} True if the module fulfills the contract (has `serialize`, `deserialize`, and `serialId`).
|
|
16
|
+
*/
|
|
3
17
|
static isSerializable(module: object): module is Serializable;
|
|
18
|
+
/**
|
|
19
|
+
* Determines whether a given module implements the {@link Initializable} interface.
|
|
20
|
+
*
|
|
21
|
+
* @param {object} module - The generic module instance to inspect.
|
|
22
|
+
* @returns {boolean} True if the module exposes a valid `setup` phase function.
|
|
23
|
+
*/
|
|
4
24
|
static isInitializable(module: object): module is Initializable;
|
|
25
|
+
/**
|
|
26
|
+
* Determines whether a given module implements the {@link StateSyncable} interface.
|
|
27
|
+
*
|
|
28
|
+
* Explicitly ignores the {@link GameState} itself to prevent cyclical sync loops.
|
|
29
|
+
*
|
|
30
|
+
* @param {object} module - The generic module instance to inspect.
|
|
31
|
+
* @returns {boolean} True if the module exposes a `syncState` function and is NOT the core `GameState`.
|
|
32
|
+
*/
|
|
5
33
|
static isStateSyncable(module: object): module is StateSyncable;
|
|
34
|
+
/**
|
|
35
|
+
* Determines whether a given module implements the {@link Debuggable} interface.
|
|
36
|
+
*
|
|
37
|
+
* @param {object} module - The generic module instance to inspect.
|
|
38
|
+
* @returns {boolean} True if the module provides a `getDebugData` function payload.
|
|
39
|
+
*/
|
|
6
40
|
static isDebuggable(module: object): module is Debuggable;
|
|
7
41
|
}
|
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Static utility for calculating pixel values relative to the canvas
|
|
3
|
-
*
|
|
2
|
+
* Static mathematical utility for calculating pixel scalar values relative to the base runtime canvas.
|
|
3
|
+
*
|
|
4
|
+
* Provides isolated layout functions specifically for responsive dimensional
|
|
5
|
+
* generation in drawing or element placement without hardcoding absolute pixels.
|
|
4
6
|
*/
|
|
5
7
|
export default class RelativeValuesHelper {
|
|
6
8
|
/**
|
|
7
|
-
* Calculates
|
|
9
|
+
* Calculates an absolute pixel width length based against the main display context width.
|
|
8
10
|
*
|
|
9
|
-
* @param {number} size - The
|
|
10
|
-
* @returns {number} The absolute width in pixels.
|
|
11
|
+
* @param {number} size - The desired scale fraction bounded between 0.0 and 1.0.
|
|
12
|
+
* @returns {number} The absolute integer or float mapped width scale in physical pixels.
|
|
11
13
|
*/
|
|
12
14
|
static getRelativeWidth(size: number): number;
|
|
13
15
|
/**
|
|
14
|
-
* Calculates
|
|
16
|
+
* Calculates an absolute pixel height length based against the main display context height.
|
|
15
17
|
*
|
|
16
|
-
* @param {number} size - The
|
|
17
|
-
* @returns {number} The absolute height in pixels.
|
|
18
|
+
* @param {number} size - The desired scale fraction bounded between 0.0 and 1.0.
|
|
19
|
+
* @returns {number} The absolute integer or float mapped height scale in physical pixels.
|
|
18
20
|
*/
|
|
19
21
|
static getRelativeHeight(size: number): number;
|
|
20
22
|
}
|
|
@@ -3,30 +3,40 @@ import { Control } from '../../types/modules';
|
|
|
3
3
|
import { Debuggable } from '../../types/Interfaces';
|
|
4
4
|
import { ControlCallback, ControlEventType, GameModules } from '../../types/Types';
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* Central event bus module processing physical hardware inputs into abstract engine events.
|
|
7
|
+
*
|
|
8
|
+
* It establishes a dedicated hub that isolates browser/device specific listeners out from
|
|
9
|
+
* the game domains. It maps normalized key presses directly to {@link ControlKey} abstractions
|
|
10
|
+
* and actively restricts event propagation downstream depending on the core {@link GameState}
|
|
11
|
+
* (e.g. blocking inputs during session modals or paused states).
|
|
8
12
|
*/
|
|
9
13
|
export default class GameControl implements Control, Debuggable {
|
|
10
14
|
private _modules;
|
|
11
15
|
private _keyBinding;
|
|
12
16
|
private _activeListeners;
|
|
13
17
|
/**
|
|
14
|
-
* Initializes the control system.
|
|
15
|
-
*
|
|
18
|
+
* Initializes the central control system and mounts physical browser DOM listeners.
|
|
19
|
+
*
|
|
20
|
+
* @returns {void} Returns nothing.
|
|
16
21
|
*/
|
|
17
22
|
setup(): void;
|
|
18
23
|
/**
|
|
19
|
-
* Unbinds all control event listeners.
|
|
24
|
+
* Unbinds all control event listeners and detaches physical DOM bindings.
|
|
25
|
+
*
|
|
26
|
+
* @returns {void} Returns nothing.
|
|
20
27
|
*/
|
|
21
28
|
unbindControls(): void;
|
|
22
29
|
/**
|
|
23
|
-
*
|
|
30
|
+
* Re-binds physical control event listeners if detached.
|
|
31
|
+
*
|
|
32
|
+
* @returns {void} Returns nothing.
|
|
24
33
|
*/
|
|
25
34
|
bindControls(): void;
|
|
26
35
|
/**
|
|
27
|
-
* Injects the game modules for
|
|
36
|
+
* Injects the active context game modules needed for state-aware event blocking logic.
|
|
28
37
|
*
|
|
29
|
-
* @param {GameModules} modules - The
|
|
38
|
+
* @param {GameModules} modules - The active registered cluster of generic game modules.
|
|
39
|
+
* @returns {void} Returns nothing.
|
|
30
40
|
*/
|
|
31
41
|
setModules(modules: GameModules): void;
|
|
32
42
|
subscribe(key: ControlKey, type: ControlEventType, callback: ControlCallback): void;
|
|
@@ -42,17 +52,19 @@ export default class GameControl implements Control, Debuggable {
|
|
|
42
52
|
private _subscribe;
|
|
43
53
|
private _unsubscribe;
|
|
44
54
|
/**
|
|
45
|
-
*
|
|
55
|
+
* Natively triggers an abstract game event securely down the core pipeline.
|
|
56
|
+
* Processes strict architectural logic gates (e.g., blocking during modals) before broadcasting.
|
|
46
57
|
*
|
|
47
|
-
* @param {ControlKey} key - The key
|
|
48
|
-
* @param {ControlEventType} type - The
|
|
49
|
-
* @
|
|
58
|
+
* @param {ControlKey} key - The abstract virtual key intent dispatching the signal.
|
|
59
|
+
* @param {ControlEventType} type - The behavior suffix (e.g. PRESSED vs HELD).
|
|
60
|
+
* @returns {void} Returns nothing.
|
|
61
|
+
* @throws {Error} Immediately if the foundational context modules have not yet been initialized.
|
|
50
62
|
*/
|
|
51
63
|
notify(key: ControlKey, type: ControlEventType): void;
|
|
52
64
|
/**
|
|
53
|
-
*
|
|
65
|
+
* Calculates debug metadata mapping arrays for the live diagnostics monitor.
|
|
54
66
|
*
|
|
55
|
-
* @returns {Record<string, string | number | boolean>}
|
|
67
|
+
* @returns {Record<string, string | number | boolean>} A shallow payload of the list length sizes.
|
|
56
68
|
*/
|
|
57
69
|
getDebugData(): Record<string, string | number | boolean>;
|
|
58
70
|
}
|
|
@@ -4,10 +4,12 @@ import { Debuggable } from '../../types/Interfaces';
|
|
|
4
4
|
import { Grid } from '../../types/modules';
|
|
5
5
|
import { Serializable } from '../../types/Interfaces';
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Core module responsible for managing the logical 2D grid matrix and spatial states.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
9
|
+
* It serves as the authoritative boundary for all coordinate mathematics,
|
|
10
|
+
* cell modifications, and collision detection logic, completely agnostic
|
|
11
|
+
* to the physical rendering loop. It ensures no pieces can mathematically
|
|
12
|
+
* step out of bounds or override occupied spaces incorrectly.
|
|
11
13
|
*/
|
|
12
14
|
export default class GameGrid implements Grid, Debuggable, Serializable {
|
|
13
15
|
/**
|
|
@@ -66,7 +68,7 @@ export default class GameGrid implements Grid, Debuggable, Serializable {
|
|
|
66
68
|
/**
|
|
67
69
|
* Initializes the grid by resetting its content to an empty state.
|
|
68
70
|
*
|
|
69
|
-
* @returns {void}
|
|
71
|
+
* @returns {void} Returns nothing.
|
|
70
72
|
*/
|
|
71
73
|
setup(): void;
|
|
72
74
|
/**
|
|
@@ -74,14 +76,14 @@ export default class GameGrid implements Grid, Debuggable, Serializable {
|
|
|
74
76
|
*
|
|
75
77
|
* Populates the grid with empty cells using {@link CellHelper.emptyCell}.
|
|
76
78
|
*
|
|
77
|
-
* @returns {void}
|
|
79
|
+
* @returns {void} Returns nothing.
|
|
78
80
|
*/
|
|
79
81
|
resetGrid(): void;
|
|
80
82
|
/**
|
|
81
83
|
* Iterates over every cell in the grid and executes a callback.
|
|
82
84
|
*
|
|
83
85
|
* @param {function(Cell): void} callback - The function to execute for each cell.
|
|
84
|
-
* @returns {void}
|
|
86
|
+
* @returns {void} Returns nothing.
|
|
85
87
|
*/
|
|
86
88
|
forEach(callback: (cell: Cell) => void): void;
|
|
87
89
|
/**
|
|
@@ -103,7 +105,7 @@ export default class GameGrid implements Grid, Debuggable, Serializable {
|
|
|
103
105
|
*
|
|
104
106
|
* @param {Coordinate} coordinate - The target coordinate.
|
|
105
107
|
* @param {number} value - The new value (e.g., 0 for inactive, >0 for active).
|
|
106
|
-
* @returns {void}
|
|
108
|
+
* @returns {void} Returns nothing.
|
|
107
109
|
*/
|
|
108
110
|
setCellValue(coordinate: Coordinate, value: number): void;
|
|
109
111
|
/**
|
|
@@ -111,23 +113,23 @@ export default class GameGrid implements Grid, Debuggable, Serializable {
|
|
|
111
113
|
*
|
|
112
114
|
* @param {Coordinate} coordinate - The target coordinate.
|
|
113
115
|
* @param {Color} color - The new color enum value.
|
|
114
|
-
* @returns {void}
|
|
116
|
+
* @returns {void} Returns nothing.
|
|
115
117
|
*/
|
|
116
118
|
setCellColor(coordinate: Coordinate, color: Color): void;
|
|
117
119
|
/**
|
|
118
|
-
* Checks if a cell
|
|
120
|
+
* Checks if a cell is active (value > 0).
|
|
119
121
|
*
|
|
120
|
-
* @param {
|
|
122
|
+
* @param {Cell} cell - The cell to check.
|
|
121
123
|
* @returns {boolean} True if active, false otherwise.
|
|
122
124
|
*/
|
|
123
|
-
isCellActive(
|
|
125
|
+
isCellActive(cell: Cell): boolean;
|
|
124
126
|
/**
|
|
125
|
-
* Checks if a cell
|
|
127
|
+
* Checks if a cell is inactive (value === 0).
|
|
126
128
|
*
|
|
127
|
-
* @param {
|
|
129
|
+
* @param {Cell} cell - The cell to check.
|
|
128
130
|
* @returns {boolean} True if inactive, false otherwise.
|
|
129
131
|
*/
|
|
130
|
-
isCellInactive(
|
|
132
|
+
isCellInactive(cell: Cell): boolean;
|
|
131
133
|
/**
|
|
132
134
|
* Checks if every cell in a specific row is active.
|
|
133
135
|
*
|
|
@@ -146,7 +148,7 @@ export default class GameGrid implements Grid, Debuggable, Serializable {
|
|
|
146
148
|
* Resets all cells in a specific row to their default empty state.
|
|
147
149
|
*
|
|
148
150
|
* @param {number} y - The row index to clear.
|
|
149
|
-
* @returns {void}
|
|
151
|
+
* @returns {void} Returns nothing.
|
|
150
152
|
*/
|
|
151
153
|
clearRow(y: number): void;
|
|
152
154
|
/**
|
|
@@ -155,7 +157,7 @@ export default class GameGrid implements Grid, Debuggable, Serializable {
|
|
|
155
157
|
* Clears the top-most row after shifting.
|
|
156
158
|
*
|
|
157
159
|
* @param {number} fromY - The starting row index for the shift down.
|
|
158
|
-
* @returns {void}
|
|
160
|
+
* @returns {void} Returns nothing.
|
|
159
161
|
*/
|
|
160
162
|
shiftRowsDown(fromY: number): void;
|
|
161
163
|
/**
|
|
@@ -164,7 +166,7 @@ export default class GameGrid implements Grid, Debuggable, Serializable {
|
|
|
164
166
|
* Clears the bottom-most row after shifting.
|
|
165
167
|
*
|
|
166
168
|
* @param {number} fromY - The starting row index for the shift up.
|
|
167
|
-
* @returns {void}
|
|
169
|
+
* @returns {void} Returns nothing.
|
|
168
170
|
*/
|
|
169
171
|
shiftRowsUp(fromY: number): void;
|
|
170
172
|
/**
|
|
@@ -193,7 +195,7 @@ export default class GameGrid implements Grid, Debuggable, Serializable {
|
|
|
193
195
|
* Resets all cells in a specific column to their default empty state.
|
|
194
196
|
*
|
|
195
197
|
* @param {number} x - The column index to clear.
|
|
196
|
-
* @returns {void}
|
|
198
|
+
* @returns {void} Returns nothing.
|
|
197
199
|
*/
|
|
198
200
|
clearColumn(x: number): void;
|
|
199
201
|
/**
|
|
@@ -202,7 +204,7 @@ export default class GameGrid implements Grid, Debuggable, Serializable {
|
|
|
202
204
|
* Clears the left-most column (index 0) after shifting.
|
|
203
205
|
*
|
|
204
206
|
* @param {number} fromX - The starting column index for the shift right.
|
|
205
|
-
* @returns {void}
|
|
207
|
+
* @returns {void} Returns nothing.
|
|
206
208
|
*/
|
|
207
209
|
shiftColumnsRight(fromX: number): void;
|
|
208
210
|
/**
|
|
@@ -211,7 +213,7 @@ export default class GameGrid implements Grid, Debuggable, Serializable {
|
|
|
211
213
|
* Clears the right-most column after shifting.
|
|
212
214
|
*
|
|
213
215
|
* @param {number} fromX - The starting column index for the shift left.
|
|
214
|
-
* @returns {void}
|
|
216
|
+
* @returns {void} Returns nothing.
|
|
215
217
|
*/
|
|
216
218
|
shiftColumnsLeft(fromX: number): void;
|
|
217
219
|
/**
|
|
@@ -236,7 +238,7 @@ export default class GameGrid implements Grid, Debuggable, Serializable {
|
|
|
236
238
|
* @param {Coordinate} end - The opposite corner of the rectangle.
|
|
237
239
|
* @param {number} value - The cell status value to apply.
|
|
238
240
|
* @param {Color} color - The color to apply.
|
|
239
|
-
* @returns {void}
|
|
241
|
+
* @returns {void} Returns nothing.
|
|
240
242
|
*/
|
|
241
243
|
fillArea(start: Coordinate, end: Coordinate, value: number, color: Color): void;
|
|
242
244
|
/**
|
|
@@ -244,15 +246,15 @@ export default class GameGrid implements Grid, Debuggable, Serializable {
|
|
|
244
246
|
*
|
|
245
247
|
* Effectively "stamps" a piece's shape onto the static grid.
|
|
246
248
|
*
|
|
247
|
-
* @param {Piece} piece - The collection of cells to stamp.
|
|
248
|
-
* @returns {void}
|
|
249
|
+
* @param {Piece | Cell[]} piece - The collection of cells to stamp.
|
|
250
|
+
* @returns {void} Returns nothing.
|
|
249
251
|
*/
|
|
250
|
-
stampPiece(piece: Piece): void;
|
|
252
|
+
stampPiece(piece: Piece | Cell[]): void;
|
|
251
253
|
/**
|
|
252
254
|
* Updates a single coordinate with a specific value and color from a Cell.
|
|
253
255
|
*
|
|
254
256
|
* @param {Cell} cell - The cell containing coordinate, value and color.
|
|
255
|
-
* @returns {void}
|
|
257
|
+
* @returns {void} Returns nothing.
|
|
256
258
|
*/
|
|
257
259
|
stampCell(cell: Cell): void;
|
|
258
260
|
/**
|
|
@@ -261,35 +263,35 @@ export default class GameGrid implements Grid, Debuggable, Serializable {
|
|
|
261
263
|
* Validates that all new positions are within grid boundaries and are not
|
|
262
264
|
* occupied by other active cells (excluding the cells that are part of the original piece).
|
|
263
265
|
*
|
|
264
|
-
* @param {Piece} piece - The current piece (collection of cells).
|
|
266
|
+
* @param {Piece | Cell[]} piece - The current piece (collection of cells).
|
|
265
267
|
* @param {Vector} direction - The movement vector (e.g., {x: -1, y: 0} for left).
|
|
266
|
-
* @returns {Piece
|
|
268
|
+
* @returns {Piece} The new piece with updated coordinates if the move is valid, or the original piece if blocked.
|
|
267
269
|
*/
|
|
268
|
-
movePiece(piece: Piece, direction: Vector): Piece
|
|
270
|
+
movePiece(piece: Piece | Cell[], direction: Vector): Piece;
|
|
269
271
|
/**
|
|
270
272
|
* Alias for {@link movePiece} shifting one unit to the left.
|
|
271
|
-
* @param {Piece} piece - The current piece.
|
|
272
|
-
* @returns {Piece
|
|
273
|
+
* @param {Piece | Cell[]} piece - The current piece.
|
|
274
|
+
* @returns {Piece}
|
|
273
275
|
*/
|
|
274
|
-
movePieceLeft(piece: Piece): Piece
|
|
276
|
+
movePieceLeft(piece: Piece | Cell[]): Piece;
|
|
275
277
|
/**
|
|
276
278
|
* Alias for {@link movePiece} shifting one unit to the right.
|
|
277
|
-
* @param {Piece} piece - The current piece.
|
|
278
|
-
* @returns {Piece
|
|
279
|
+
* @param {Piece | Cell[]} piece - The current piece.
|
|
280
|
+
* @returns {Piece}
|
|
279
281
|
*/
|
|
280
|
-
movePieceRight(piece: Piece): Piece
|
|
282
|
+
movePieceRight(piece: Piece | Cell[]): Piece;
|
|
281
283
|
/**
|
|
282
284
|
* Alias for {@link movePiece} shifting one unit up.
|
|
283
|
-
* @param {Piece} piece - The current piece.
|
|
284
|
-
* @returns {Piece
|
|
285
|
+
* @param {Piece | Cell[]} piece - The current piece.
|
|
286
|
+
* @returns {Piece}
|
|
285
287
|
*/
|
|
286
|
-
movePieceUp(piece: Piece): Piece
|
|
288
|
+
movePieceUp(piece: Piece | Cell[]): Piece;
|
|
287
289
|
/**
|
|
288
290
|
* Alias for {@link movePiece} shifting one unit down.
|
|
289
|
-
* @param {Piece} piece - The current piece.
|
|
290
|
-
* @returns {Piece
|
|
291
|
+
* @param {Piece | Cell[]} piece - The current piece.
|
|
292
|
+
* @returns {Piece}
|
|
291
293
|
*/
|
|
292
|
-
movePieceDown(piece: Piece): Piece
|
|
294
|
+
movePieceDown(piece: Piece | Cell[]): Piece;
|
|
293
295
|
/**
|
|
294
296
|
* Attempts to shift a single cell in a given direction.
|
|
295
297
|
*
|
|
@@ -297,42 +299,42 @@ export default class GameGrid implements Grid, Debuggable, Serializable {
|
|
|
297
299
|
*
|
|
298
300
|
* @param {Cell} cell - The current cell.
|
|
299
301
|
* @param {Vector} direction - The movement vector.
|
|
300
|
-
* @returns {Cell
|
|
302
|
+
* @returns {Cell} The new cell with updated coordinate if the move is valid, or the original cell if blocked.
|
|
301
303
|
*/
|
|
302
|
-
moveCell(cell: Cell, direction: Vector): Cell
|
|
304
|
+
moveCell(cell: Cell, direction: Vector): Cell;
|
|
303
305
|
/**
|
|
304
306
|
* Alias for {@link moveCell} shifting one unit to the left.
|
|
305
307
|
* @param {Cell} cell - The current cell.
|
|
306
|
-
* @returns {Cell
|
|
308
|
+
* @returns {Cell}
|
|
307
309
|
*/
|
|
308
|
-
moveCellLeft(cell: Cell): Cell
|
|
310
|
+
moveCellLeft(cell: Cell): Cell;
|
|
309
311
|
/**
|
|
310
312
|
* Alias for {@link moveCell} shifting one unit to the right.
|
|
311
313
|
* @param {Cell} cell - The current cell.
|
|
312
|
-
* @returns {Cell
|
|
314
|
+
* @returns {Cell}
|
|
313
315
|
*/
|
|
314
|
-
moveCellRight(cell: Cell): Cell
|
|
316
|
+
moveCellRight(cell: Cell): Cell;
|
|
315
317
|
/**
|
|
316
318
|
* Alias for {@link moveCell} shifting one unit up.
|
|
317
319
|
* @param {Cell} cell - The current cell.
|
|
318
|
-
* @returns {Cell
|
|
320
|
+
* @returns {Cell}
|
|
319
321
|
*/
|
|
320
|
-
moveCellUp(cell: Cell): Cell
|
|
322
|
+
moveCellUp(cell: Cell): Cell;
|
|
321
323
|
/**
|
|
322
324
|
* Alias for {@link moveCell} shifting one unit down.
|
|
323
325
|
* @param {Cell} cell - The current cell.
|
|
324
|
-
* @returns {Cell
|
|
326
|
+
* @returns {Cell}
|
|
325
327
|
*/
|
|
326
|
-
moveCellDown(cell: Cell): Cell
|
|
328
|
+
moveCellDown(cell: Cell): Cell;
|
|
327
329
|
/**
|
|
328
330
|
* Attempts to rotate a piece 90 degrees around a specific origin.
|
|
329
331
|
*
|
|
330
332
|
* @param {Piece} piece - The current piece.
|
|
331
333
|
* @param {Coordinate} origin - The center of rotation.
|
|
332
334
|
* @param {boolean} [clockwise=true] - Direction of rotation.
|
|
333
|
-
* @returns {Piece
|
|
335
|
+
* @returns {Piece} The new piece if rotation is valid, or the original piece if blocked.
|
|
334
336
|
*/
|
|
335
|
-
rotatePiece(piece: Piece, origin: Coordinate, clockwise?: boolean): Piece
|
|
337
|
+
rotatePiece(piece: Piece, origin: Coordinate, clockwise?: boolean): Piece;
|
|
336
338
|
/**
|
|
337
339
|
* Identifies all rows that are completely filled with active cells.
|
|
338
340
|
*
|
|
@@ -402,7 +404,7 @@ export default class GameGrid implements Grid, Debuggable, Serializable {
|
|
|
402
404
|
*
|
|
403
405
|
* @param {Coordinate} a - First coordinate.
|
|
404
406
|
* @param {Coordinate} b - Second coordinate.
|
|
405
|
-
* @returns {void}
|
|
407
|
+
* @returns {void} Returns nothing.
|
|
406
408
|
*/
|
|
407
409
|
swapCells(a: Coordinate, b: Coordinate): void;
|
|
408
410
|
/**
|
|
@@ -418,6 +420,19 @@ export default class GameGrid implements Grid, Debuggable, Serializable {
|
|
|
418
420
|
* @returns {Record<string, string | number | boolean>} Technical debugging data.
|
|
419
421
|
*/
|
|
420
422
|
getDebugData(): Record<string, string | number | boolean>;
|
|
423
|
+
/**
|
|
424
|
+
* Extracts and converts the internal 2D grid matrix into a flat string payload limit.
|
|
425
|
+
* Required by the Engine's {@link Session} component for persisting cross-session layouts.
|
|
426
|
+
*
|
|
427
|
+
* @returns {string} The JSON stringified representation of the dynamic objects mapped.
|
|
428
|
+
*/
|
|
421
429
|
serialize(): string;
|
|
430
|
+
/**
|
|
431
|
+
* Hydrates the grid layout from a previously frozen flat string blob.
|
|
432
|
+
* Executes dynamically during engine session recovery.
|
|
433
|
+
*
|
|
434
|
+
* @param {string} data - The compacted JSON representation resolving back to standard Cell instances.
|
|
435
|
+
* @returns {void} Returns nothing.
|
|
436
|
+
*/
|
|
422
437
|
deserialize(data: string): void;
|
|
423
438
|
}
|
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
import { Serializable } from '../../types/Interfaces';
|
|
2
2
|
import GameGrid from './GameGrid';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* It
|
|
4
|
+
* Specialized engine module isolating the visual preview logic for upcoming pieces.
|
|
5
|
+
*
|
|
6
|
+
* It statically overrides the fluid grid dimensions strictly to a 4x4 coordinate plane.
|
|
7
|
+
* By extending the core {@link GameGrid}, it transparently inherits all complex collision
|
|
8
|
+
* and stamping logic without polluting the global game field with temporary shapes.
|
|
7
9
|
*/
|
|
8
10
|
export default class GameHudGrid extends GameGrid implements Serializable {
|
|
9
11
|
serialId: string;
|
|
10
12
|
/**
|
|
11
|
-
*
|
|
13
|
+
* Statically overrides the dynamic configuration to enforce a perfect 4x4 box.
|
|
12
14
|
*
|
|
13
|
-
* @returns {number}
|
|
15
|
+
* @returns {number} The strict integer width threshold (always 4).
|
|
14
16
|
*/
|
|
15
17
|
get width(): number;
|
|
16
18
|
/**
|
|
17
|
-
*
|
|
19
|
+
* Statically overrides the dynamic configuration to enforce a perfect 4x4 box.
|
|
18
20
|
*
|
|
19
|
-
* @returns {number}
|
|
21
|
+
* @returns {number} The strict integer height threshold (always 4).
|
|
20
22
|
*/
|
|
21
23
|
get height(): number;
|
|
22
24
|
serialize(): string;
|
|
@@ -1,29 +1,48 @@
|
|
|
1
1
|
import { Cell, Coordinate, Piece } from '../../../types/Types';
|
|
2
2
|
import { Grid } from '../../../types/modules';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Engineering sub-module providing structural data mapping and traversal logic.
|
|
5
|
+
*
|
|
6
|
+
* Implements the {@link Grid} analytical operations. It specializes in read-only iterations,
|
|
7
|
+
* like returning complete line matrices, verifying connected graph components (via logic like BFS),
|
|
8
|
+
* and securely interacting with cell metadata without persisting changes automatically.
|
|
5
9
|
*/
|
|
6
10
|
export default class GridAnalysisEngine {
|
|
7
11
|
private grid;
|
|
8
12
|
constructor(grid: Grid);
|
|
9
13
|
/**
|
|
10
|
-
*
|
|
14
|
+
* Sweeps horizontally evaluating grid integrity across specific vertical line coordinates.
|
|
15
|
+
*
|
|
16
|
+
* @returns {number[]} An array mapping integer strings to valid completed row limits.
|
|
11
17
|
*/
|
|
12
18
|
getFullRows(): number[];
|
|
13
19
|
/**
|
|
14
|
-
*
|
|
20
|
+
* Sweeps vertically evaluating grid integrity across specific horizontal line coordinates.
|
|
21
|
+
*
|
|
22
|
+
* @returns {number[]} An array mapping integer strings to valid completed column limits.
|
|
15
23
|
*/
|
|
16
24
|
getFullColumns(): number[];
|
|
17
25
|
/**
|
|
18
|
-
*
|
|
26
|
+
* Inspects surrounding spaces around a central anchor leveraging specific pixel offsets.
|
|
27
|
+
*
|
|
28
|
+
* @param {Coordinate} coord - The central coordinate checking all immediate directions.
|
|
29
|
+
* @param {boolean} [includeDiagonal=false] - Broadens strict 4-neighbor searches to all corners.
|
|
30
|
+
* @returns {Cell[]} Array of loaded grid cells directly interfacing the starting point.
|
|
19
31
|
*/
|
|
20
32
|
getNeighbors(coord: Coordinate, includeDiagonal?: boolean): Cell[];
|
|
21
33
|
/**
|
|
22
|
-
*
|
|
34
|
+
* Orchestrates a Breadth-First Search (BFS) algorithm chaining adjacent blocks with identical density signatures.
|
|
35
|
+
*
|
|
36
|
+
* @param {Coordinate} coord - The starting block containing the desired active target density.
|
|
37
|
+
* @returns {Piece} An aggregated piece matching every adjacent cell linked continuously.
|
|
23
38
|
*/
|
|
24
39
|
findConnectedCells(coord: Coordinate): Piece;
|
|
25
40
|
/**
|
|
26
|
-
*
|
|
41
|
+
* Executes an encapsulated memory exchange operation overriding values safely between two points.
|
|
42
|
+
*
|
|
43
|
+
* @param {Coordinate} a - First point target.
|
|
44
|
+
* @param {Coordinate} b - Second point target.
|
|
45
|
+
* @returns {void} Returns nothing.
|
|
27
46
|
*/
|
|
28
47
|
swapCells(a: Coordinate, b: Coordinate): void;
|
|
29
48
|
}
|
|
@@ -1,56 +1,94 @@
|
|
|
1
1
|
import { Grid } from '../../../types/modules';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Engineering sub-module handling comprehensive shifting row operations and grid clearance.
|
|
4
|
+
*
|
|
5
|
+
* Implements the {@link Grid} structural line shifts. It drives heavy multi-cell displacement,
|
|
6
|
+
* manipulating memory locations explicitly when the engine demands sweeping block changes
|
|
7
|
+
* to simulate gravity or clean completely occupied board bounds.
|
|
4
8
|
*/
|
|
5
9
|
export default class GridLineEngine {
|
|
6
10
|
private grid;
|
|
7
11
|
constructor(grid: Grid);
|
|
8
12
|
/**
|
|
9
|
-
*
|
|
13
|
+
* Executes horizontal sweeping verifying no static empty elements disrupt a physical row footprint.
|
|
14
|
+
*
|
|
15
|
+
* @param {number} y - The integer declaring the horizontal map layer mapped to height.
|
|
16
|
+
* @returns {boolean} A boolean true if density confirms completely loaded limits.
|
|
10
17
|
*/
|
|
11
18
|
isRowFull(y: number): boolean;
|
|
12
19
|
/**
|
|
13
|
-
*
|
|
20
|
+
* Executes horizontal sweeping verifying no active elements exist across a physical row footprint.
|
|
21
|
+
*
|
|
22
|
+
* @param {number} y - The integer declaring the horizontal map layer mapped to height.
|
|
23
|
+
* @returns {boolean} A boolean true if all limits check out completely zeroed out.
|
|
14
24
|
*/
|
|
15
25
|
isRowEmpty(y: number): boolean;
|
|
16
26
|
/**
|
|
17
|
-
*
|
|
27
|
+
* Purges specific memory instances mapping empty metadata objects identically across a row length.
|
|
28
|
+
*
|
|
29
|
+
* @param {number} y - The integer mapped horizontally mapping height to wipe.
|
|
30
|
+
* @returns {void} Returns nothing.
|
|
18
31
|
*/
|
|
19
32
|
clearRow(y: number): void;
|
|
20
33
|
/**
|
|
21
|
-
*
|
|
34
|
+
* Transplants memory contents shifting row sequences securely down one numerical grid measure.
|
|
35
|
+
*
|
|
36
|
+
* @param {number} fromY - The explicit target line evaluating continuous transfers upwards.
|
|
37
|
+
* @returns {void} Returns nothing.
|
|
22
38
|
*/
|
|
23
39
|
shiftRowsDown(fromY: number): void;
|
|
24
40
|
/**
|
|
25
|
-
*
|
|
41
|
+
* Transplants memory contents shifting row sequences securely up one numerical grid measure.
|
|
42
|
+
*
|
|
43
|
+
* @param {number} fromY - The explicit target line evaluating continuous transfers downwards.
|
|
44
|
+
* @returns {void} Returns nothing.
|
|
26
45
|
*/
|
|
27
46
|
shiftRowsUp(fromY: number): void;
|
|
28
47
|
/**
|
|
29
|
-
*
|
|
48
|
+
* Orchestrates comprehensive cascading block removal across multiple overlapping frame steps.
|
|
49
|
+
*
|
|
50
|
+
* @returns {number} The integer metric mapping strictly deleted physical bounds.
|
|
30
51
|
*/
|
|
31
52
|
clearFullRows(): number;
|
|
32
53
|
/**
|
|
33
|
-
*
|
|
54
|
+
* Executes vertical sweeping verifying no static empty elements disrupt a physical column footprint.
|
|
55
|
+
*
|
|
56
|
+
* @param {number} x - The integer declaring the vertical map layer mapped to width.
|
|
57
|
+
* @returns {boolean} A boolean true if density confirms completely loaded limits.
|
|
34
58
|
*/
|
|
35
59
|
isColumnFull(x: number): boolean;
|
|
36
60
|
/**
|
|
37
|
-
*
|
|
61
|
+
* Executes vertical sweeping verifying no active elements exist across a physical column footprint.
|
|
62
|
+
*
|
|
63
|
+
* @param {number} x - The integer declaring the vertical map layer mapped to width.
|
|
64
|
+
* @returns {boolean} A boolean true if all limits check out completely zeroed out.
|
|
38
65
|
*/
|
|
39
66
|
isColumnEmpty(x: number): boolean;
|
|
40
67
|
/**
|
|
41
|
-
*
|
|
68
|
+
* Purges specific memory instances mapping empty metadata objects identically across a column length.
|
|
69
|
+
*
|
|
70
|
+
* @param {number} x - The integer mapped vertically mapping width to wipe.
|
|
71
|
+
* @returns {void} Returns nothing.
|
|
42
72
|
*/
|
|
43
73
|
clearColumn(x: number): void;
|
|
44
74
|
/**
|
|
45
|
-
*
|
|
75
|
+
* Transplants memory contents shifting column sequences securely right one numerical grid measure.
|
|
76
|
+
*
|
|
77
|
+
* @param {number} fromX - The explicit target line evaluating continuous transfers.
|
|
78
|
+
* @returns {void} Returns nothing.
|
|
46
79
|
*/
|
|
47
80
|
shiftColumnsRight(fromX: number): void;
|
|
48
81
|
/**
|
|
49
|
-
*
|
|
82
|
+
* Transplants memory contents shifting column sequences securely left one numerical grid measure.
|
|
83
|
+
*
|
|
84
|
+
* @param {number} fromX - The explicit target line evaluating continuous transfers.
|
|
85
|
+
* @returns {void} Returns nothing.
|
|
50
86
|
*/
|
|
51
87
|
shiftColumnsLeft(fromX: number): void;
|
|
52
88
|
/**
|
|
53
|
-
*
|
|
89
|
+
* Orchestrates comprehensive cascading block removal across multiple overlapping frame steps on columns.
|
|
90
|
+
*
|
|
91
|
+
* @returns {number} The integer metric mapping strictly deleted physical bounds.
|
|
54
92
|
*/
|
|
55
93
|
clearFullColumns(): number;
|
|
56
94
|
}
|