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.
Files changed (98) hide show
  1. package/README.adoc +2 -2
  2. package/dist/docs/index.html +3 -3
  3. package/dist/docs/jsdoc_standard.html +30 -13
  4. package/dist/docs/reference/bootstrap.html +556 -0
  5. package/dist/docs/reference/context/RendererContext.html +19 -9
  6. package/dist/docs/reference/enums/Color.html +11 -5
  7. package/dist/docs/reference/enums/ControlEventType.html +7 -5
  8. package/dist/docs/reference/enums/ControlKey.html +7 -5
  9. package/dist/docs/reference/enums/EventSuffix.html +7 -5
  10. package/dist/docs/reference/enums/FontAlignment.html +9 -7
  11. package/dist/docs/reference/enums/FontSize.html +7 -5
  12. package/dist/docs/reference/enums/Sound.html +7 -5
  13. package/dist/docs/reference/enums/StateProperty.html +7 -5
  14. package/dist/docs/reference/helpers/CellHelper.html +6 -2
  15. package/dist/docs/reference/helpers/ControlInputHandlerHelper.html +9 -5
  16. package/dist/docs/reference/helpers/CoordinateHelper.html +14 -10
  17. package/dist/docs/reference/helpers/RelativeValuesHelper.html +7 -3
  18. package/dist/docs/reference/interfaces/Debuggable.html +9 -7
  19. package/dist/docs/reference/interfaces/GameModules.html +7 -5
  20. package/dist/docs/reference/interfaces/Initializable.html +9 -7
  21. package/dist/docs/reference/interfaces/RendererInitializable.html +9 -7
  22. package/dist/docs/reference/interfaces/StateContext.html +7 -5
  23. package/dist/docs/reference/interfaces/StateSyncable.html +11 -9
  24. package/dist/docs/reference/interfaces/modules/Control.html +19 -17
  25. package/dist/docs/reference/interfaces/modules/Grid.html +77 -55
  26. package/dist/docs/reference/interfaces/modules/Renderer.html +9 -7
  27. package/dist/docs/reference/interfaces/modules/RendererComposite.html +13 -11
  28. package/dist/docs/reference/interfaces/modules/Score.html +21 -19
  29. package/dist/docs/reference/interfaces/modules/Session.html +64 -18
  30. package/dist/docs/reference/interfaces/modules/State.html +59 -57
  31. package/dist/docs/reference/interfaces/modules/Text.html +21 -19
  32. package/dist/docs/reference/interfaces/modules/Time.html +80 -24
  33. package/dist/docs/reference/modules/Debugger.html +16 -14
  34. package/dist/docs/reference/modules/DisplayRenderer.html +10 -8
  35. package/dist/docs/reference/modules/EventEmitter.html +34 -26
  36. package/dist/docs/reference/modules/Game.html +55 -30
  37. package/dist/docs/reference/modules/GameControl.html +49 -44
  38. package/dist/docs/reference/modules/GameEventRegistry.html +17 -34
  39. package/dist/docs/reference/modules/GameGrid.html +174 -116
  40. package/dist/docs/reference/modules/GameHudGrid.html +10 -8
  41. package/dist/docs/reference/modules/GameRenderer.html +14 -12
  42. package/dist/docs/reference/modules/GameScore.html +36 -34
  43. package/dist/docs/reference/modules/GameSession.html +37 -19
  44. package/dist/docs/reference/modules/GameSound.html +20 -18
  45. package/dist/docs/reference/modules/GameState.html +70 -68
  46. package/dist/docs/reference/modules/GameText.html +29 -27
  47. package/dist/docs/reference/modules/GameTime.html +98 -30
  48. package/dist/docs/reference/modules/HudRenderer.html +10 -8
  49. package/dist/docs/reference/modules/InitialStateSnapshot.html +13 -11
  50. package/dist/docs/reference/modules/SessionModal.html +11 -9
  51. package/dist/docs/reference/types/Axis.html +7 -5
  52. package/dist/docs/reference/types/Cell.html +7 -5
  53. package/dist/docs/reference/types/ControlCallback.html +7 -5
  54. package/dist/docs/reference/types/Coordinate.html +7 -5
  55. package/dist/docs/reference/types/GameEvent.html +7 -5
  56. package/dist/docs/reference/types/Piece.html +7 -5
  57. package/dist/docs/reference/types/RendererMetrics.html +7 -5
  58. package/dist/docs/reference/types/Vector.html +7 -5
  59. package/dist/docs/reference/view/GameView.html +29 -21
  60. package/dist/docs/testing_best_practices.html +2 -2
  61. package/dist/game.bundle.js +1 -1
  62. package/dist/types/bootstrap.d.ts +12 -11
  63. package/dist/types/core/Game.d.ts +46 -39
  64. package/dist/types/core/InitialStateSnapshot.d.ts +18 -6
  65. package/dist/types/core/context/RendererContext.d.ts +32 -10
  66. package/dist/types/core/event/EventEmitter.d.ts +64 -21
  67. package/dist/types/core/event/GameEventRegistry.d.ts +17 -3
  68. package/dist/types/core/helpers/CellHelper.d.ts +11 -4
  69. package/dist/types/core/helpers/ControlInputHandlerHelper.d.ts +20 -11
  70. package/dist/types/core/helpers/CoordinateHelper.d.ts +28 -23
  71. package/dist/types/core/helpers/InterfaceIdentifierHelper.d.ts +34 -0
  72. package/dist/types/core/helpers/RelativeValuesHelper.d.ts +10 -8
  73. package/dist/types/core/module/control/GameControl.d.ts +26 -14
  74. package/dist/types/core/module/grid/GameGrid.d.ts +68 -53
  75. package/dist/types/core/module/grid/GameHudGrid.d.ts +9 -7
  76. package/dist/types/core/module/grid/engines/GridAnalysisEngine.d.ts +25 -6
  77. package/dist/types/core/module/grid/engines/GridLineEngine.d.ts +51 -13
  78. package/dist/types/core/module/grid/engines/GridMovementEngine.d.ts +97 -13
  79. package/dist/types/core/module/grid/engines/GridRegionEngine.d.ts +24 -5
  80. package/dist/types/core/module/grid/engines/GridTransformEngine.d.ts +21 -5
  81. package/dist/types/core/module/renderer/DisplayRenderer.d.ts +27 -15
  82. package/dist/types/core/module/renderer/GameRenderer.d.ts +20 -13
  83. package/dist/types/core/module/renderer/HudRenderer.d.ts +27 -19
  84. package/dist/types/core/module/score/GameScore.d.ts +29 -18
  85. package/dist/types/core/module/session/GameSession.d.ts +56 -0
  86. package/dist/types/core/module/sound/GameSound.d.ts +39 -23
  87. package/dist/types/core/module/state/GameState.d.ts +38 -14
  88. package/dist/types/core/module/text/GameText.d.ts +40 -25
  89. package/dist/types/core/module/time/GameTime.d.ts +23 -10
  90. package/dist/types/core/types/Interfaces.d.ts +15 -0
  91. package/dist/types/core/types/Types.d.ts +1 -0
  92. package/dist/types/core/types/enums.d.ts +2 -1
  93. package/dist/types/core/types/modules.d.ts +193 -43
  94. package/dist/types/view/Debugger.d.ts +23 -0
  95. package/dist/types/view/GameView.d.ts +44 -27
  96. package/dist/types/view/SessionModal.d.ts +24 -0
  97. package/package.json +1 -1
  98. package/dist/CNAME +0 -1
@@ -1,29 +1,113 @@
1
1
  import { Cell, Vector, Piece } from '../../../types/Types';
2
2
  import { Grid } from '../../../types/modules';
3
3
  /**
4
- * Handles movement and projection logic for the game grid.
4
+ * Engineering sub-module providing single and multi-cell velocity behaviors.
5
+ *
6
+ * Implements the {@link Grid} physical positioning operations. It resolves vector translations
7
+ * against the static cell board, mapping out exact placement steps or rejecting invalid logic
8
+ * before game states have a chance to falsely render overlaps.
5
9
  */
6
10
  export default class GridMovementEngine {
7
11
  private grid;
8
12
  constructor(grid: Grid);
9
13
  /**
10
- * Attempts to shift a collection of cells (a piece) in a given direction.
14
+ * Modifies the piece footprint iterating all target cells mathematically towards a given offset.
15
+ *
16
+ * @param {Piece} piece - The original collection of dynamically bound target cells.
17
+ * @param {Vector} direction - The spatial translation array declaring x/y offset integers.
18
+ * @returns {Piece} A new piece copy reflecting changes, or the old identical piece if restricted.
11
19
  */
12
- movePiece(piece: Piece, direction: Vector): Piece | null;
13
- movePieceLeft(piece: Piece): Piece | null;
14
- movePieceRight(piece: Piece): Piece | null;
15
- movePieceUp(piece: Piece): Piece | null;
16
- movePieceDown(piece: Piece): Piece | null;
20
+ movePiece(piece: Piece, direction: Vector): Piece;
17
21
  /**
18
- * Attempts to shift a single cell in a given direction.
22
+ * Alias for {@link movePiece} shifting one unit left continuously.
23
+ *
24
+ * @param {Piece} piece - The specific piece payload shifting.
25
+ * @returns {Piece} The new valid piece output.
26
+ */
27
+ movePieceLeft(piece: Piece): Piece;
28
+ /**
29
+ * Alias for {@link movePiece} shifting one unit right continuously.
30
+ *
31
+ * @param {Piece} piece - The specific piece payload shifting.
32
+ * @returns {Piece} The new valid piece output.
33
+ */
34
+ movePieceRight(piece: Piece): Piece;
35
+ /**
36
+ * Alias for {@link movePiece} shifting one unit up continuously.
37
+ *
38
+ * @param {Piece} piece - The specific piece payload shifting.
39
+ * @returns {Piece} The new valid piece output.
40
+ */
41
+ movePieceUp(piece: Piece): Piece;
42
+ /**
43
+ * Alias for {@link movePiece} shifting one unit down continuously.
44
+ *
45
+ * @param {Piece} piece - The specific piece payload shifting.
46
+ * @returns {Piece} The new valid piece output.
47
+ */
48
+ movePieceDown(piece: Piece): Piece;
49
+ /**
50
+ * Modifies a single cell footprint moving it mathematically towards a given offset.
51
+ *
52
+ * @param {Cell} cell - The original single target cell.
53
+ * @param {Vector} direction - The spatial translation array declaring x/y offset integers.
54
+ * @returns {Cell} A new cell copy reflecting changes, or the old identical cell if restricted.
55
+ */
56
+ moveCell(cell: Cell, direction: Vector): Cell;
57
+ /**
58
+ * Alias for {@link moveCell} shifting one unit left continuously.
59
+ *
60
+ * @param {Cell} cell - The specific cell shifting.
61
+ * @returns {Cell} The new valid cell output.
62
+ */
63
+ moveCellLeft(cell: Cell): Cell;
64
+ /**
65
+ * Alias for {@link moveCell} shifting one unit right continuously.
66
+ *
67
+ * @param {Cell} cell - The specific cell shifting.
68
+ * @returns {Cell} The new valid cell output.
69
+ */
70
+ moveCellRight(cell: Cell): Cell;
71
+ /**
72
+ * Alias for {@link moveCell} shifting one unit up continuously.
73
+ *
74
+ * @param {Cell} cell - The specific cell shifting.
75
+ * @returns {Cell} The new valid cell output.
76
+ */
77
+ moveCellUp(cell: Cell): Cell;
78
+ /**
79
+ * Alias for {@link moveCell} shifting one unit down continuously.
80
+ *
81
+ * @param {Cell} cell - The specific cell shifting.
82
+ * @returns {Cell} The new valid cell output.
83
+ */
84
+ moveCellDown(cell: Cell): Cell;
85
+ /**
86
+ * Implements a while-loop simulation repeatedly pushing a piece down until a collision is recorded.
87
+ *
88
+ * @param {Piece} piece - The piece footprint to analyze.
89
+ * @returns {Piece} A modified piece reflecting the absolute lowest valid coordinate alignment.
19
90
  */
20
- moveCell(cell: Cell, direction: Vector): Cell | null;
21
- moveCellLeft(cell: Cell): Cell | null;
22
- moveCellRight(cell: Cell): Cell | null;
23
- moveCellUp(cell: Cell): Cell | null;
24
- moveCellDown(cell: Cell): Cell | null;
25
91
  getDropPath(piece: Piece): Piece;
92
+ /**
93
+ * Implements a while-loop simulation repeatedly pushing a piece up until a collision is recorded.
94
+ *
95
+ * @param {Piece} piece - The piece footprint to analyze.
96
+ * @returns {Piece} A modified piece reflecting the absolute highest valid coordinate alignment.
97
+ */
26
98
  getRisePath(piece: Piece): Piece;
99
+ /**
100
+ * Implements a while-loop simulation repeatedly pushing a piece left until a collision is recorded.
101
+ *
102
+ * @param {Piece} piece - The piece footprint to analyze.
103
+ * @returns {Piece} A modified piece reflecting the absolute furthest left valid coordinate alignment.
104
+ */
27
105
  getReachPathLeft(piece: Piece): Piece;
106
+ /**
107
+ * Implements a while-loop simulation repeatedly pushing a piece right until a collision is recorded.
108
+ *
109
+ * @param {Piece} piece - The piece footprint to analyze.
110
+ * @returns {Piece} A modified piece reflecting the absolute furthest right valid coordinate alignment.
111
+ */
28
112
  getReachPathRight(piece: Piece): Piece;
29
113
  }
@@ -2,25 +2,44 @@ import { Color } from '../../../types/enums';
2
2
  import { Cell, Coordinate, Piece } from '../../../types/Types';
3
3
  import { Grid } from '../../../types/modules';
4
4
  /**
5
- * Handles region-based operations (areas, stamps, and occupancy) on the grid.
5
+ * Engineering sub-module strictly handling multi-cell batch operations and bounding interactions.
6
+ *
7
+ * Implements the {@link Grid} region processing logic. It aggregates simple cell iterations
8
+ * into unified area bounds to execute high-level game instructions, such as bulk stamping
9
+ * piece shapes or checking broad space availabilities.
6
10
  */
7
11
  export default class GridRegionEngine {
8
12
  private grid;
9
13
  constructor(grid: Grid);
10
14
  /**
11
- * Checks if any of the provided coordinates are already occupied or out of bounds.
15
+ * Extends basic coordinate validation across a multiple-point piece footprint.
16
+ *
17
+ * @param {Coordinate[]} coordinates - The list of point mappings defining the desired area.
18
+ * @returns {boolean} A boolean true if any single piece chunk strikes a grid-wall or populated floor.
12
19
  */
13
20
  isAreaOccupied(coordinates: Coordinate[]): boolean;
14
21
  /**
15
- * Fills a rectangular region defined by two corners with a specific value and color.
22
+ * Implements a generic box-shape overwrite mechanism across given 2D diagonal endpoints.
23
+ *
24
+ * @param {Coordinate} start - The initial boundary corner dictating iteration limits.
25
+ * @param {Coordinate} end - The terminating boundary corner closing the drawn box.
26
+ * @param {number} value - The numeric status assigning logical engine density.
27
+ * @param {Color} color - The specific UI token mapping the region aesthetic details.
28
+ * @returns {void} Returns nothing.
16
29
  */
17
30
  fillArea(start: Coordinate, end: Coordinate, value: number, color: Color): void;
18
31
  /**
19
- * Updates multiple coordinates simultaneously with their specific values and colors.
32
+ * Converts a transient piece's logical blocks fully into permanently anchored static grid spaces.
33
+ *
34
+ * @param {Piece} piece - The collection of logically associated cells ready for injection.
35
+ * @returns {void} Returns nothing.
20
36
  */
21
37
  stampPiece(piece: Piece): void;
22
38
  /**
23
- * Updates a single coordinate with a specific value and color from a Cell.
39
+ * Translates a single transient logical brick strictly into the grid's memory buffer.
40
+ *
41
+ * @param {Cell} cell - The complex type combining grid location, metadata value, and color payload.
42
+ * @returns {void} Returns nothing.
24
43
  */
25
44
  stampCell(cell: Cell): void;
26
45
  }
@@ -1,21 +1,37 @@
1
1
  import { Coordinate, Axis, Piece } from '../../../types/Types';
2
2
  import { Grid } from '../../../types/modules';
3
3
  /**
4
- * Handles geometric transformations for pieces on the grid.
4
+ * Engineering sub-module handling geometric boundary manipulations and complex piece translations.
5
+ *
6
+ * Implements the {@link Grid} transformation behaviors. It acts as an isolated stateless evaluator
7
+ * providing mathematical projections (like rotation or mirroring) independently from the live game
8
+ * state, guaranteeing original piece blocks are unsullied if an attempted projection intersects a wall.
5
9
  */
6
10
  export default class GridTransformEngine {
7
11
  private grid;
8
12
  constructor(grid: Grid);
9
13
  /**
10
- * Attempts to rotate a piece 90 degrees around a specific origin.
14
+ * Attempts to calculate a 90-degree radial offset around a defined center point.
15
+ *
16
+ * @param {Piece} piece - The specific layout array of logical cell metrics.
17
+ * @param {Coordinate} origin - The mathematical center point for the rotational pivot.
18
+ * @param {boolean} [clockwise=true] - The directional toggle controlling coordinate adjustments.
19
+ * @returns {Piece} The modified Piece array or the original Piece if collisions occurred.
11
20
  */
12
- rotatePiece(piece: Piece, origin: Coordinate, clockwise?: boolean): Piece | null;
21
+ rotatePiece(piece: Piece, origin: Coordinate, clockwise?: boolean): Piece;
13
22
  /**
14
- * Mirrors a piece across a specific axis relative to its bounding box.
23
+ * Mirrors a piece mapping its internal locations reversely across a specific median axis.
24
+ *
25
+ * @param {Piece} piece - The specific layout array of logical cells to invert.
26
+ * @param {Axis} axis - The 'x' or 'y' string declaring the geometric flip line.
27
+ * @returns {Piece} The newly formatted piece instance with updated mirrored values.
15
28
  */
16
29
  mirrorPiece(piece: Piece, axis: Axis): Piece;
17
30
  /**
18
- * Calculates the bounding box of a piece.
31
+ * Iterates all block chunks discovering maximum absolute spatial corners to establish a rect-box boundary.
32
+ *
33
+ * @param {Piece} piece - The piece containing scattered cell coordinates.
34
+ * @returns {{min: Coordinate, max: Coordinate}} An object exposing corner extreme bounds.
19
35
  */
20
36
  getPieceBounds(piece: Piece): {
21
37
  min: Coordinate;
@@ -1,43 +1,55 @@
1
1
  import { Cell, GameModules, RendererMetrics } from '../../types/Types';
2
2
  import { Renderer, State } from '../../types/modules';
3
3
  /**
4
- * Responsible for rendering the main game field (the grid where the game is played).
5
- * Handles cell rendering, background drawing, and optimizes static elements using an off-screen buffer.
4
+ * Dedicated visual presentation component isolating grid drawing loops.
5
+ *
6
+ * It decouples the performance-intensive grid enumeration from general game loops.
7
+ * Through pre-compilation (off-screen buffer for background elements) and heavy caching
8
+ * of explicit geometry boundaries (inner offset, padding, strokes), it minimizes real-time
9
+ * calculation depth, effectively stabilizing engine framerate limits.
6
10
  */
7
11
  export default class DisplayRenderer implements Renderer {
8
12
  private _rendererMetrics;
9
13
  private _cellPreCalculatedGeometry;
10
14
  private _staticGraphics;
11
15
  /**
12
- * Initializes the renderer with the calculated metrics.
13
- * Pre-calculates cell geometry for faster rendering.
16
+ * Implements specific internal matrix caches consuming injected absolute layout metrics.
14
17
  *
15
- * @param {RendererMetrics} rendererMetrics - The shared renderer metrics.
18
+ * @param {RendererMetrics} rendererMetrics - The shared pre-compiled dimension dictionaries.
19
+ * @returns {void} Returns nothing.
16
20
  */
17
21
  setup(rendererMetrics: RendererMetrics): void;
18
22
  /**
19
- * Renders the game grid.
20
- * Draws the static background first, then iterates over the grid to draw cells.
23
+ * The continuous execution sequence re-painting the primary logical bounds on-screen.
21
24
  *
22
- * @param {Cell[][]} grid - The current grid state.
25
+ * It efficiently pastes the off-screen cached background texture before procedurally computing
26
+ * transient piece overlay graphics.
27
+ *
28
+ * @param {Cell[][]} grid - The 2D target matrix identifying block coordinates.
29
+ * @param {GameModules} modules - Dynamic context properties passed directly by the Engine.
30
+ * @returns {void} Returns nothing.
23
31
  */
24
32
  render(grid: Cell[][], modules: GameModules): void;
25
33
  /**
26
- * Renders static elements (background and borders) to an off-screen buffer.
27
- * This improves performance by avoiding re-drawing static shapes every frame.
34
+ * Executes the initial setup closure defining fixed off-screen graphics buffer textures.
35
+ *
36
+ * @returns {void} Returns nothing.
28
37
  */
29
38
  private _renderStaticElements;
30
39
  /**
31
- * Renders a single brick at grid coordinates.
32
- * Uses translation matrices to keep drawing logic clean.
40
+ * Processes individual cell geometric construction dynamically translating matrices to prevent nested complex mathematics.
33
41
  *
34
- * @param {Cell} cell - The cell data to render.
42
+ * @param {Cell} cell - The structured data representing logical bounds and status coloring.
43
+ * @param {State} state - Actively running environment configuration (like color schemes or game over logic).
44
+ * @returns {void} Returns nothing.
35
45
  */
36
46
  protected renderCell({ coordinate, color, value }: Cell, state: State): void;
37
47
  /**
38
- * Iterates through the grid and renders each cell.
48
+ * Executes the rapid sequence loop covering the active logic matrix.
39
49
  *
40
- * @param {Cell[][]} grid - The grid to render.
50
+ * @param {Cell[][]} grid - The logical target state collection.
51
+ * @param {State} state - Active environment flags modifying visual styling.
52
+ * @returns {void} Returns nothing.
41
53
  */
42
54
  protected renderGrid(grid: Cell[][], state: State): void;
43
55
  }
@@ -3,9 +3,12 @@ import { Debuggable } from '../../types/Interfaces';
3
3
  import { Renderer } from '../../types/modules';
4
4
  import { RendererComposite } from '../../types/modules';
5
5
  /**
6
- * Composite renderer that manages multiple sub-renderers.
7
- * Orchestrates the rendering of the main display and the HUD.
8
- * Handles the calculation of shared rendering metrics (sizes, positions) to ensure consistency.
6
+ * Orchestrating composite module acting as the visual context manager.
7
+ *
8
+ * Implements the {@link RendererComposite} pattern to aggregate the specific display and HUD
9
+ * pipeline. It bridges the mathematical constraints (e.g. converting a relative 0.0-1.0
10
+ * grid position into strict P5 canvas pixels) and ensures layout recalculations happen exactly
11
+ * once during initialization to avoid expensive bounds-checking inside the main draw loops.
9
12
  */
10
13
  export default class GameRenderer implements RendererComposite, Debuggable {
11
14
  private _renderers;
@@ -13,27 +16,31 @@ export default class GameRenderer implements RendererComposite, Debuggable {
13
16
  private _hudRenderer;
14
17
  private _rendererMetrics;
15
18
  /**
16
- * Adds a sub-renderer to the composition.
19
+ * Injects a sub-renderer routine into the core pipeline queue.
17
20
  *
18
- * @param {Renderer} renderer - The renderer to add.
21
+ * @param {Renderer} renderer - The specific layer or boundary drawer.
22
+ * @returns {void} Returns nothing.
19
23
  */
20
24
  addRenderer(renderer: Renderer): void;
21
25
  /**
22
- * Initializes all sub-renderers and calculates layout metrics.
23
- * This method must be called before rendering begins.
26
+ * Instantiates system geometries and pushes strict calculated metrics down the pipeline.
27
+ * Must be invoked prior to the first rendering frame trigger.
28
+ *
29
+ * @returns {void} Returns nothing.
24
30
  */
25
31
  setup(): void;
26
32
  /**
27
- * Calculates the layout dimensions for the display and HUD.
28
- * Based on screen configuration and relative values.
33
+ * Pre-compiles absolute geometric values resolving relative design layouts against the physical hardware space.
34
+ *
35
+ * @returns {void} Returns nothing.
29
36
  */
30
37
  private _calculateMetrics;
31
38
  /**
32
- * Delegating render method.
33
- * Calls render on all registered sub-renderers.
39
+ * Exposes the single dispatch drawing sequence forwarding contexts down the entire renderer queue.
34
40
  *
35
- * @param {Cell[][]} grid - The main game grid.
36
- * @param {GameModules} modules - The game modules collection.
41
+ * @param {Cell[][]} grid - The logical playfield state matrix.
42
+ * @param {GameModules} modules - The active state containers injected dynamically.
43
+ * @returns {void} Returns nothing.
37
44
  */
38
45
  render(grid: Cell[][], modules: GameModules): void;
39
46
  /**
@@ -1,48 +1,56 @@
1
1
  import { Renderer } from '../../types/modules';
2
2
  import { Cell, GameModules, RendererMetrics } from '../../types/Types';
3
3
  /**
4
- * Responsible for rendering the Heads-Up Display (HUD).
5
- * Displays game information like Score, High Score, Level, and the Next Piece Preview.
4
+ * Dedicated visual presentation component isolating Heads-Up Display (HUD) mechanics.
5
+ *
6
+ * Implements the {@link Renderer} interface to decouple metadata logic (level, scores, Next Piece
7
+ * visuals) away from core game physics. By translating absolute space constraints mapped in
8
+ * `configs.screenLayout`, it creates responsive graphical UI outputs without expensive real-time
9
+ * geometry processing on each execution tick.
6
10
  */
7
11
  export default class HudRenderer implements Renderer {
8
12
  private _gridOrigin;
9
13
  private _cellSize;
10
14
  private _hudBorderRect;
11
15
  /**
12
- * Initializes the HUD with calculated metrics.
13
- * Sets up the grid origin and border rectangle for the "next piece" preview area.
16
+ * Binds strictly defined initial layouts mapping dynamically sized objects over absolute space.
14
17
  *
15
- * @param {RendererMetrics} rendererMetrics - The shared renderer metrics.
18
+ * @param {RendererMetrics} rendererMetrics - Pre-calculated scale components established globally.
19
+ * @returns {void} Returns nothing.
16
20
  */
17
21
  setup(rendererMetrics: RendererMetrics): void;
18
22
  /**
19
- * Renders all HUD elements.
23
+ * Orchestrates the active frame-tick UI compilation logic sequences.
20
24
  *
21
- * @param {Cell[][]} grid - The main game grid (unused in HUD, but required by interface).
22
- * @param {GameModules} modules - The game modules for retrieving state and score.
25
+ * @param {Cell[][]} grid - A standard mapping hook currently unused by this context explicitly.
26
+ * @param {GameModules} modules - The active registry exposing GameScore and GameState values.
27
+ * @returns {void} Returns nothing.
23
28
  */
24
29
  render(grid: Cell[][], modules: GameModules): void;
25
30
  /**
26
- * Renders the text-based HUD elements (Score, Level, Status).
31
+ * Compiles dynamic string payloads over absolute canvas locations tracking user data metrics.
27
32
  *
28
- * @param {GameModules} modules - The game modules.
33
+ * @param {GameModules} modules - Global registry resolving access to the Score system.
34
+ * @returns {void} Returns nothing.
29
35
  */
30
36
  private _renderHud;
31
37
  /**
32
- * Renders the preview grid for the next piece.
38
+ * Maps the static inner-HUD coordinate box defining where piece previews exist natively.
33
39
  *
34
- * @param {GameModules} modules - The game modules.
40
+ * @param {GameModules} modules - Engine registry exposing the `GameHudGrid` explicitly.
41
+ * @returns {void} Returns nothing.
35
42
  */
36
43
  private _drawHudGrid;
37
44
  /**
38
- * Helper method to draw a single cell on the HUD.
39
- * Identical in logic to DisplayRenderer's cell drawing but localized for HUD.
45
+ * Optimized internal draw operation processing graphical offsets for the sub-grid layer.
40
46
  *
41
- * @param {object} params - The drawing parameters.
42
- * @param {number} params.w - Width of the cell.
43
- * @param {number} params.posX - Absolute X position.
44
- * @param {number} params.posY - Absolute Y position.
45
- * @param {Color} params.color - Color of the cell.
47
+ * @param {object} params - Explicit physical boundary configuration dictionary.
48
+ * @param {number} params.w - The scale cell width footprint constraint.
49
+ * @param {number} params.h - The scale cell height footprint constraint.
50
+ * @param {number} params.posX - Translating X absolute starting point coordinate limit.
51
+ * @param {number} params.posY - Translating Y absolute starting point coordinate limit.
52
+ * @param {Color} params.color - The specific string enum resolving rendering palette strokes.
53
+ * @returns {void} Returns nothing.
46
54
  */
47
55
  private drawCellElement;
48
56
  }
@@ -2,9 +2,12 @@ import { Debuggable } from '../../types/Interfaces';
2
2
  import { Score } from '../../types/modules';
3
3
  import { Serializable } from '../../types/Interfaces';
4
4
  /**
5
- * Manages game scoring, levels, and high score tracking.
6
- * Acts as the authority for the game's `highScore`, persisting it directly to `LocalStorage`.
7
- * Handles multipliers and supports Session serialization out of the box.
5
+ * Stateful module dedicated to tracking real-time player performance metrics.
6
+ *
7
+ * Implements the {@link Score} and {@link Serializable} interfaces to provide
8
+ * a centralized authority for maintaining score lines, difficulty levels, and
9
+ * multiplier bonuses. It uniquely tracks the global `highScore` by saving it
10
+ * directly to `LocalStorage` under an isolated `gameId` namespace.
8
11
  */
9
12
  export default class GameScore implements Score, Debuggable, Serializable {
10
13
  private _score;
@@ -15,37 +18,44 @@ export default class GameScore implements Score, Debuggable, Serializable {
15
18
  private _gameId;
16
19
  serialId: string;
17
20
  /**
18
- * Sets up the game high score.
21
+ * Initializes the High Score context using a distinct installation prefix.
19
22
  *
20
- * @param {string} id - The game ID.
23
+ * @param {string} id - The explicit game UUID or namespace string to prevent record collisions.
24
+ * @returns {void} Returns nothing.
21
25
  */
22
26
  setupGameHighScore(id: string): void;
23
27
  /**
24
- * Increases the score by the given amount, applying the current multiplier.
25
- * Automatically checks for high score updates.
28
+ * Increases the score by the given base amount after calculating active multipliers.
29
+ * Automatically assesses if the new score surpasses and replaces the persistent High Score.
26
30
  *
27
- * @param {number} amount - The base amount to increase by.
31
+ * @param {number} amount - The integer base points to add before multipliers.
32
+ * @returns {void} Returns nothing.
28
33
  */
29
34
  increaseScore(amount: number): void;
30
35
  /**
31
- * Resets the current score to 0.
36
+ * Zeroes out the active tracking score.
37
+ *
38
+ * @returns {void} Returns nothing.
32
39
  */
33
40
  resetScore(): void;
34
41
  /**
35
- * Formats the current score as a string with leading zeros.
42
+ * Exports the raw session score as a physically padded string sequence.
36
43
  *
37
- * @param {number} [digits=6] - The total number of digits to display.
38
- * @returns {string} The formatted score string (e.g., "000150").
44
+ * @param {number} [digits=6] - The optional total number of sequence places to output (e.g. 6).
45
+ * @returns {string} The formatted string payload displaying leading zeros (e.g., "000150").
39
46
  */
40
47
  getFormattedScore(digits?: number): string;
41
48
  /**
42
- * Increases the game level by a specific amount.
49
+ * Steps up the active engine difficulty level scaling.
43
50
  *
44
- * @param {number} amount - The number of levels to add.
51
+ * @param {number} amount - The integer step of new levels to jump.
52
+ * @returns {void} Returns nothing.
45
53
  */
46
54
  increaseLevel(amount: number): void;
47
55
  /**
48
- * Resets the game level back to 1.
56
+ * Resets the active difficulty level baseline back to initial 1.
57
+ *
58
+ * @returns {void} Returns nothing.
49
59
  */
50
60
  resetLevel(): void;
51
61
  /**
@@ -110,10 +120,11 @@ export default class GameScore implements Score, Debuggable, Serializable {
110
120
  */
111
121
  serialize(): string;
112
122
  /**
113
- * Restores score and level progress from a serialized JSON string.
114
- * Used by the SessionManager when recovering an active session.
123
+ * Modifies the running variables based on an injected serialized payload.
124
+ * Instructed dynamically by the `SessionManager` during initialization recovery.
115
125
  *
116
- * @param {string} data - The JSON string containing the saved session data.
126
+ * @param {string} data - The packed string blob enclosing the structured saved session.
127
+ * @returns {void} Returns nothing.
117
128
  */
118
129
  deserialize(data: string): void;
119
130
  }
@@ -1,5 +1,14 @@
1
1
  import { Serializable } from '../../types/Interfaces';
2
2
  import { Session, State } from '../../types/modules';
3
+ /**
4
+ * Core module orchestrating state synchronization and transient game data persistence.
5
+ *
6
+ * Implements the {@link Session} interface to establish a single secure boundary
7
+ * between the active engine states and physical local storage limits. It intercepts
8
+ * the startup engine flows to ensure all registered {@link Serializable} modules
9
+ * correctly pause initialization safely inside a modal window until a human resolves
10
+ * the conflict (restoring or clearing).
11
+ */
3
12
  export default class GameSession implements Session {
4
13
  _state: State;
5
14
  gameId: string;
@@ -9,17 +18,64 @@ export default class GameSession implements Session {
9
18
  private _showSessionModal;
10
19
  private _resetFn;
11
20
  private _serializables;
21
+ /**
22
+ * Registers an external module to be actively tracked and persisted during session events.
23
+ *
24
+ * @param {Serializable} serializable - The compliant module instance exposing standard serialization capabilities.
25
+ * @returns {void} Returns nothing.
26
+ */
12
27
  register(serializable: Serializable): void;
28
+ /**
29
+ * Extracts and physically persists the current state payload of all registered modules to browser storage.
30
+ * Silently aborts if the session has not completed the restoration resolution flow or is disabled.
31
+ *
32
+ * @returns {void} Returns nothing.
33
+ */
13
34
  saveSession(): void;
35
+ /**
36
+ * Irreversibly wipes all transient saved module data mapped under this session's namespace.
37
+ *
38
+ * @returns {void} Returns nothing.
39
+ */
14
40
  clearSession(): void;
41
+ /**
42
+ * Injects the visual modal resolution closure implemented upstream.
43
+ *
44
+ * @param {Function} showModal - The asynchronous UI closure designed to ask the player to reload or reset the session.
45
+ * @returns {void} Returns nothing.
46
+ */
15
47
  setShowModalFunction(showModal: (onConfirm: () => void, onCancel: () => void) => void): void;
48
+ /**
49
+ * Injects the explicit game restoration sequence to execute when a session is aborted.
50
+ *
51
+ * @param {Function} resetFn - The recovery routine triggering a clean slate reset.
52
+ * @returns {void} Returns nothing.
53
+ */
16
54
  setResetFunction(resetFn: () => void): void;
55
+ /**
56
+ * Hard-toggles whether the session recovery mechanism evaluates at startup.
57
+ *
58
+ * @param {boolean} enabled - True to enforce session monitoring, false to skip entirely.
59
+ * @returns {void} Returns nothing.
60
+ */
17
61
  setSessionEnabled(enabled: boolean): void;
18
62
  isModalOpen(): boolean;
19
63
  isSessionResolved(): boolean;
20
64
  private _hasSession;
21
65
  private _loadSession;
66
+ /**
67
+ * Hooks into the global single source of truth state listener.
68
+ * Triggers the UI recovery workflow explicitly when the engine switches to the PLAYING state.
69
+ *
70
+ * @param {State} state - The authoritative lifecycle hub object to observe securely.
71
+ * @returns {void} Returns nothing.
72
+ */
22
73
  syncState(state: State): void;
74
+ /**
75
+ * Aggregates live metadata properties intended strictly for Development Dashboards.
76
+ *
77
+ * @returns {Record<string, string | number | boolean>} A shallow payload of the session tracker statuses.
78
+ */
23
79
  getDebugData(): Record<string, string | number | boolean>;
24
80
  private _key;
25
81
  }