brick-engine-js 1.0.21 → 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 +92 -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 +52 -18
  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 +214 -45
  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,56 +1,94 @@
1
1
  import { Grid } from '../../../types/modules';
2
2
  /**
3
- * Handles line-based operations (rows and columns) on the grid.
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
- * Checks if every cell in a specific row is active.
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
- * Checks if every cell in a specific row is inactive.
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
- * Resets all cells in a specific row to their default empty state.
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
- * Shifts all rows above a certain index down by one position.
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
- * Shifts all rows below a certain index up by one position.
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
- * Scans for full rows, clears them, and shifts remaining rows down.
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
- * Checks if every cell in a specific column is active.
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
- * Checks if every cell in a specific column is inactive.
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
- * Resets all cells in a specific column to their default empty state.
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
- * Shifts all columns to the left of a certain index one position to the right.
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
- * Shifts all columns to the right of a certain index one position to the left.
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
- * Scans for full columns, clears them, and shifts remaining columns right.
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
  }
@@ -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
  }