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
@@ -2,28 +2,29 @@ import p5 from 'p5';
2
2
  import Game from './core/Game';
3
3
  import GameView from './view/GameView';
4
4
  /**
5
- * Represents a constructor for a game class.
5
+ * Defines the strict constructor signature for Client games booting via the Engine.
6
6
  *
7
7
  * @callback ClientGameConstructor
8
- * @param {p5} p - The p5 instance.
9
- * @param {GameView} view - The game view instance.
10
- * @returns {Game} A new game instance.
8
+ * @param {p5} p - The core rendering context pointer injected at runtime.
9
+ * @param {GameView} view - The specifically built UI configuration context.
10
+ * @returns {Game} A newly instantiated concrete subclass encompassing all module logic.
11
11
  */
12
12
  type ClientGameConstructor = new (view: GameView) => Game;
13
13
  /**
14
- * Updates the currently active game in the engine's execution loop.
14
+ * Hotswaps the persistent engine tracking pointer dictating logic execution loops.
15
15
  *
16
- * @param {Game} game - The new game instance to become active.
16
+ * @param {Game} game - The fully instantiated class implementing custom module rules.
17
+ * @returns {void} Returns nothing.
17
18
  */
18
19
  export declare function setActiveGame(game: Game): void;
19
20
  /**
20
- * Bootstraps the brick engine and initializes the game.
21
+ * Orchestrating structural point of initialization isolating strict client code execution.
21
22
  *
22
- * This is the main entry point for the engine's execution. It creates a new p5 instance,
23
- * initializes the view, and sets up the initial game provided by the caller.
23
+ * Acts as the absolute architectural start for the engine lifecycle. It isolates complex P5.js
24
+ * canvas injection, internal context caching, and DOM viewport creation away from actual Game logic.
24
25
  *
25
- * @param {ClientGameConstructor} ClientGame - The constructor of the game to be loaded.
26
- * @returns {p5} The p5 instance.
26
+ * @param {ClientGameConstructor} ClientGame - The non-instantiated class definition targeted.
27
+ * @returns {p5} The successfully built processing sketch mapping logic safely onto the web document.
27
28
  */
28
29
  export declare function bootstrap(ClientGame: ClientGameConstructor): p5;
29
30
  export {};
@@ -3,10 +3,11 @@ import { Initializable } from './types/Interfaces';
3
3
  import { GameModules } from './types/Types';
4
4
  import p5 from 'p5';
5
5
  /**
6
- * Base abstract class for the game.
6
+ * The Central integration boundary encapsulating physical logic away from native visual outputs.
7
7
  *
8
- * It manages the game loop, initialization of core modules, and integration with p5.js.
9
- * All game logic should be implemented in subclasses by overriding `processTick` and `processFrame`.
8
+ * Implements the {@link Initializable} configuration pipeline orchestrating completely synchronous
9
+ * frame drawing metrics while processing isolated state iterations without corrupting data models
10
+ * dynamically mapped across various internal UI states.
10
11
  */
11
12
  export default abstract class Game implements Initializable {
12
13
  protected _view: GameView;
@@ -14,91 +15,97 @@ export default abstract class Game implements Initializable {
14
15
  private _initialStateSnapshot;
15
16
  private _gameId;
16
17
  /**
17
- * Gets the game ID
18
+ * Returns the strict string identifier binding data persistently.
19
+ *
20
+ * @returns {string} The namespace mapped internally.
18
21
  */
19
22
  get gameId(): string;
20
23
  /**
21
- * Sets the game ID
24
+ * Sets the application ID establishing persistent memory keys.
25
+ *
26
+ * @param {string} id - The string namespace saving bounds.
27
+ * @returns {void} Returns nothing.
22
28
  */
23
29
  set gameId(id: string);
24
30
  /**
25
- * Creates an instance of the Game.
31
+ * Constructs the primary controller wrapping native rendering canvases into controlled pipelines.
26
32
  *
27
- * @param {p5} p - The p5 instance.
28
- * @param {GameView} view - The view strategy associated with this game.
33
+ * @param {GameView} view - The securely decoupled graphical pointer rendering the root body.
29
34
  */
30
35
  constructor(view: GameView);
31
36
  /**
32
- * Gets the game view.
37
+ * Yields strictly controlled visibility access to layout injections.
33
38
  *
34
- * @returns {GameView} The game view instance.
39
+ * @returns {GameView} The configured view instance formatting user HTML constraints.
35
40
  */
36
41
  get view(): GameView;
37
42
  /**
38
- * Gets the game modules.
43
+ * Yields fully configured physics, inputs, and drawing context tools dynamically mapped.
39
44
  *
40
- * @returns {GameModules} The collection of initialized game modules.
45
+ * @returns {GameModules} A secure aggregate object pointer.
41
46
  */
42
47
  get modules(): GameModules;
43
48
  /**
44
- * Gets the p5 instance.
49
+ * Exposes hardware-accelerated processing calls indirectly via Context bounds.
45
50
  *
46
- * @returns {p5} The p5 instance.
51
+ * @returns {p5} The active executing instance map.
47
52
  */
48
53
  get p(): p5;
49
54
  /**
50
- * Sets up the game, initializing all modules and viewing components.
51
- * Called automatically by the engine key sequence.
55
+ * Triggers sequential logic parsing across dynamically subscribed execution containers internally.
56
+ *
57
+ * Internally synchronizes active memory payloads tracking initialization boundaries automatically.
52
58
  *
53
- * Internally calls `setupGame()` and then `captureInitialState()`.
54
- * This means that all subclass properties (including those initialized in `setupGame`)
55
- * are captured as the initial state for the resetting mechanism.
59
+ * @returns {void} Returns nothing.
56
60
  */
57
61
  setup(): void;
58
62
  /**
59
- * Main draw loop, called by p5.js.
60
- * Handles time updates, logic ticks, and rendering.
63
+ * Loops mathematically calculating pixel mutations exactly and logically evaluating system limits.
64
+ *
65
+ * @returns {void} Returns nothing.
61
66
  */
62
67
  draw(): void;
63
68
  /**
64
- * Destroys the game instance, cleaning up all event listeners and stopping the loop.
65
- * Call this before switching to another game or when the game is no longer needed.
69
+ * Orchestrates destruction callbacks erasing references blocking memory sweeps globally.
70
+ *
71
+ * @returns {void} Returns nothing.
66
72
  */
67
73
  destroy(): void;
68
74
  /**
69
- * Resets the game to its initial state.
70
- * This method is called by the reset event handler and should be used to restore the game to its initial state.
75
+ * Fires internal overrides mutating internal physics states towards a neutral base metric safely.
76
+ *
77
+ * @returns {void} Returns nothing.
71
78
  */
72
79
  reset(): void;
73
80
  /**
74
- * Abstract method for processing game logic.
75
- * Called every tick, but ONLY when the game is in the 'playing' state.
81
+ * Subclass abstract delegator resolving physics mathematically based directly on relative speeds.
76
82
  *
77
- * @param {number} deltaTime - Time elapsed since last tick.
83
+ * @param {number} deltaTime - Fast ticking number representation capturing elapsed frametimes safely.
84
+ * @returns {void} Returns nothing.
78
85
  */
79
86
  abstract update(deltaTime: number): void;
80
87
  /**
81
- * Abstract method for processing visual frames.
82
- * Called every frame (depending on frameInterval).
88
+ * Subclass abstract delegator dispatching independent geometry outputs onto the physical UI constraints.
89
+ *
90
+ * @returns {void} Returns nothing.
83
91
  */
84
92
  abstract render(): void;
85
93
  /**
86
- * Abstract method for setting up the game specific logic.
87
- * Called after the game modules are initialized.
94
+ * Subclass abstract delegator establishing customized rules tracking specific bounds mathematically.
88
95
  *
89
- * Note: All initial properties should be fully assigned here,
90
- * as `captureInitialState()` is invoked immediately after this method,
91
- * taking a snapshot for the reset mechanism.
96
+ * @returns {void} Returns nothing.
92
97
  */
93
98
  abstract setupGame(): void;
94
99
  /**
95
- * Abstract method for drawing the Title Screen (Welcome).
96
- * Called when the game is ON but not yet STARTED.
100
+ * Subclass abstract delegator dispatching independent UI strings safely evaluating un-started limits.
101
+ *
102
+ * @returns {void} Returns nothing.
97
103
  */
98
104
  abstract drawTitleScreen(): void;
99
105
  /**
100
- * Abstract method for drawing the Game Over Screen.
101
- * Called when the game is in GAME OVER state.
106
+ * Subclass abstract delegator dispatching independent UI strings safely evaluating finished bounds.
107
+ *
108
+ * @returns {void} Returns nothing.
102
109
  */
103
110
  abstract drawGameOverScreen(): void;
104
111
  }
@@ -1,19 +1,31 @@
1
+ /**
2
+ * Architectural utility strictly handling transparent auto-save points for custom class boundaries.
3
+ *
4
+ * Acts as an agnostic cloning proxy safely evaluating and storing external state payloads without
5
+ * developers writing boilerplate serialization functions inside native subclasses each time.
6
+ */
1
7
  export default class InitialStateSnapshot {
2
8
  private _initialState;
3
9
  private _baseProperties;
4
10
  /**
5
- * Captures the base properties of the instance before any custom client properties are added.
6
- * @param instance The object instance to extract keys from.
11
+ * Caches native structure references dictating immutable engine properties to ignore visually.
12
+ *
13
+ * @param {object} instance - The internal unpopulated layout.
14
+ * @returns {void} Returns nothing.
7
15
  */
8
16
  captureBaseProperties(instance: object): void;
9
17
  /**
10
- * Stores the initial state of custom client properties.
11
- * @param instance The object instance containing custom properties.
18
+ * Caches a fully deep-cloned structural reference encapsulating foreign client properties exactly.
19
+ *
20
+ * @param {object} instance - The populated concrete object class.
21
+ * @returns {void} Returns nothing.
12
22
  */
13
23
  captureInitialState(instance: object): void;
14
24
  /**
15
- * Restores the captured custom properties back to the instance.
16
- * @param instance The object instance to restore properties onto.
25
+ * Re-assigns the securely cloned caching snapshot values strictly bypassing getter mutation restrictions.
26
+ *
27
+ * @param {object} instance - The active object intended to be hard reset entirely.
28
+ * @returns {void} Returns nothing.
17
29
  */
18
30
  restoreInitialState(instance: object): void;
19
31
  }
@@ -1,25 +1,47 @@
1
1
  import p5 from 'p5';
2
2
  /**
3
- * Global singleton context for the Brick Engine.
4
- * Provides read-only access to the p5 instance across the application.
3
+ * Global singleton context responsible for exposing the rendering engine instance.
4
+ *
5
+ * Designed to decouple the rendering logic from the core game state and input
6
+ * processing. By providing a centralized, read-only access point to the `p5`
7
+ * instance, it eliminates the need to pass the `p5` object via dependency
8
+ * injection down to every component, view, and layout throughout the architecture.
5
9
  */
6
10
  export default class RendererContext {
7
11
  private static _p;
8
12
  /**
9
- * Initializes the RendererContext with a p5 instance.
10
- * Should only be called once, typically during Game initialization.
11
- * @param pInstance The active p5 instance.
12
- * @throws Error if the context has already been initialized.
13
+ * Initializes the global renderer context with the active p5 instance.
14
+ *
15
+ * This method is designed to be called exactly once during the application
16
+ * startup lifecycle, typically by the engine's entry point. It stores the
17
+ * `p5` object internally. If called multiple times, it safely ignores subsequent
18
+ * calls and emits a console warning to prevent accidental overwrites of the
19
+ * core rendering capabilities.
20
+ *
21
+ * @param {p5} pInstance - The active, initialized `p5` instance that will be shared across the application.
22
+ * @returns {void} Returns nothing.
13
23
  */
14
24
  static init(pInstance: p5): void;
15
25
  /**
16
- * Gets the globally available p5 instance.
17
- * @throws Error if the context has not been initialized yet.
26
+ * Retrieves the globally available p5 instance.
27
+ *
28
+ * Acts as the primary access point for any drawing or rendering operation across
29
+ * the application ecosystem. UI Components and Renderers should access `p` from
30
+ * this context to perform canvas updates safely.
31
+ *
32
+ * @throws {Error} Thrown if this getter is accessed before the `init` method has been successfully executed, preventing silent failures during render cycles.
33
+ * @returns {p5} The active, initialized `p5` instance.
18
34
  */
19
35
  static get p(): p5;
20
36
  /**
21
- * Resets the context.
22
- * Primarily used for unit testing to clear the singleton state.
37
+ * Resets the safely stored global p5 context.
38
+ *
39
+ * Used strictly to support test isolation. It clears the singleton state
40
+ * internally to ensure that unit tests utilizing virtual `p5` mock instances
41
+ * can be created and torn down reliably across test suites without retaining
42
+ * state from previous executions.
43
+ *
44
+ * @returns {void} Returns nothing.
23
45
  */
24
46
  static reset(): void;
25
47
  }
@@ -1,6 +1,10 @@
1
1
  type EventCallback<T = any> = (payload?: T) => void;
2
2
  /**
3
3
  * Narrow interface representing the engine state context required for contextual notifications.
4
+ *
5
+ * Designed to decouple the {@link EventEmitter} from the full `GameState` module.
6
+ * It allows the emitter to query specific state properties without creating
7
+ * circular dependencies, enabling dynamic routing of events into state-specific channels.
4
8
  */
5
9
  export interface StateContext {
6
10
  isPlaying(): boolean;
@@ -11,6 +15,10 @@ export interface StateContext {
11
15
  }
12
16
  /**
13
17
  * Valid event suffixes for contextual dispatch.
18
+ *
19
+ * Defines the strict set of string identifiers appended to base events to
20
+ * create state-specific subscription channels. This guarantees type safety
21
+ * when modules choose to listen only during specific game lifecycles.
14
22
  */
15
23
  export declare enum EventSuffix {
16
24
  TITLE = "title",
@@ -20,51 +28,86 @@ export declare enum EventSuffix {
20
28
  }
21
29
  /**
22
30
  * Static event emitter for global pub/sub communication across the engine.
31
+ *
32
+ * Acts as the centralized communication backbone of the engine reactor,
33
+ * allowing entirely decoupled modules to hook into each other's lifecycles.
34
+ * By preventing tight coupling and direct method calls, it enables highly
35
+ * scalable logic flow where input events or state changes can be broadcasted
36
+ * to any interested subsystem dynamically.
23
37
  */
24
38
  export default class EventEmitter {
25
39
  private static _events;
26
40
  /**
27
- * Subscribes to an event.
41
+ * Subscribes a listener callback to an event channel.
28
42
  *
29
- * @param eventName The name of the event to listen for.
30
- * @param callback The function to execute when the event is emitted.
31
- * @param suffix The optional context suffix.
43
+ * Registers a callback function to be executed whenever the specified event
44
+ * is emitted. If a {@link EventSuffix} is provided, it subscribes to the
45
+ * contextual sub-channel (e.g. `UP:playing`) instead of the base channel.
46
+ *
47
+ * @param {string} eventName - The base string identifier of the event to listen for.
48
+ * @param {EventCallback<T>} callback - The function to execute when the event triggers. Receives the payload if applicable.
49
+ * @param {EventSuffix} [suffix] - The optional modifier to listen only on state-restricted channels.
50
+ * @returns {void} Returns nothing.
32
51
  */
33
52
  static subscribe<T>(eventName: string, callback: EventCallback<T>, suffix?: EventSuffix): void;
34
53
  /**
35
- * Unsubscribes from an event.
54
+ * Unsubscribes an existing listener from an event channel.
55
+ *
56
+ * Safely removes the provided callback from the notification queue.
57
+ * If the event was subscribed with a suffix, the same {@link EventSuffix}
58
+ * must be provided here to target the correct sub-channel.
36
59
  *
37
- * @param eventName The name of the event.
38
- * @param callback The specific callback function to remove.
39
- * @param suffix The optional context suffix.
60
+ * @param {string} eventName - The base string identifier of the event.
61
+ * @param {EventCallback<T>} callback - The exact function reference previously passed to `subscribe`.
62
+ * @param {EventSuffix} [suffix] - The optional context restricted modifier previously utilized.
63
+ * @returns {void} Returns nothing.
40
64
  */
41
65
  static unsubscribe<T>(eventName: string, callback: EventCallback<T>, suffix?: EventSuffix): void;
42
66
  /**
43
- * Emits an event, triggering all registered callbacks with the provided payload.
67
+ * Emits a standard event, triggering all registered standard callbacks.
44
68
  *
45
- * @param eventName The name of the event to emit.
46
- * @param payload Optional data to pass to the callbacks.
69
+ * Iterates over all callbacks associated with the given channel key and
70
+ * invokes them sequentially with the provided payload. This acts strictly
71
+ * on the base channel without evaluating current game states.
72
+ *
73
+ * @param {string} eventName - The precise name of the channel to broadcast on.
74
+ * @param {T} [payload] - The optional contextual data payload passed structurally to each callback.
75
+ * @returns {void} Returns nothing.
47
76
  */
48
77
  static notify<T>(eventName: string, payload?: T): void;
49
78
  /**
50
- * Dispatches an event to the base channel and automatically to contextual channels
51
- * (:playing, :title, :gameover, :paused) based on the provided state context.
79
+ * Dispatches an event to the base channel and evaluates contextual channels.
80
+ *
81
+ * Performs a standard notify on the base `eventName`, and then evaluates
82
+ * the provided {@link StateContext} to decide which secondary {@link EventSuffix}
83
+ * channel should also receive the payload. This enables multi-cast
84
+ * signals where listeners can opt into receiving only under certain states.
52
85
  *
53
- * @param eventName The base name of the event.
54
- * @param payload Optional data to pass to the callbacks.
55
- * @param context The engine state context.
86
+ * @param {string} eventName - The core string identifier of the event broadcast.
87
+ * @param {T} payload - The required event data to be passed to callbacks in both base and context channels.
88
+ * @param {StateContext} context - The engine state provider used to determine applicable conditions (Playing, Paused, Title, Gameover).
89
+ * @returns {void} Returns nothing.
56
90
  */
57
91
  static notifyContextual<T>(eventName: string, payload: T, context: StateContext): void;
58
92
  /**
59
- * Formats an event name with an optional suffix.
93
+ * Formats an event name with an optional localized suffix string.
60
94
  *
61
- * @param base The base event name.
62
- * @param suffix The optional context suffix.
63
- * @returns The formatted event string.
95
+ * Used internally to guarantee uniform string keys when registering or
96
+ * triggering targeted contextual communication channels.
97
+ *
98
+ * @param {string} base - The fundamental event identifier string.
99
+ * @param {EventSuffix} [suffix] - The specific contextual modifier enum to append.
100
+ * @returns {string} The fully combined and formatted channel key suitable for indexing the internal registry.
64
101
  */
65
102
  private static _formatName;
66
103
  /**
67
- * Clears all registered events and listeners. Useful for cleanup or testing.
104
+ * Clears all universally registered events and listener channels.
105
+ *
106
+ * Highly destructive, this function wipes the entire internal communications
107
+ * map. Primarily purposed for unit testing workflows to ensure zero listener
108
+ * contamination across differing test cases.
109
+ *
110
+ * @returns {void} Returns nothing.
68
111
  */
69
112
  static clear(): void;
70
113
  }
@@ -1,20 +1,34 @@
1
1
  import { GameModules } from '../types/Types';
2
2
  /**
3
3
  * Registry for system-level game events.
4
+ *
4
5
  * Centralizes the logic for power, reset, and state-based notifications.
6
+ * By moving these registrations out of the core Game class, it maintains
7
+ * a clean startup sequence and ensures that all modules remain decoupled
8
+ * while still reacting to global lifecycle changes like turning on/off or Game Over.
5
9
  */
6
10
  export default class GameEventRegistry {
7
11
  /**
8
12
  * Sets up all system-level control event subscriptions.
9
13
  *
10
- * @param modules - The collection of game modules.
11
- * @param onReset - Callback to restore the initial state of the game instance.
14
+ * Injects handlers for core game hardware button mappings like power cycling,
15
+ * resetting the active game, unpausing, or modifying hardware toggles like
16
+ * sound and color.
17
+ *
18
+ * @param {GameModules} modules - The collection of initialized game modules to bind.
19
+ * @param {() => void} onReset - Callback to be executed immediately to restore the initial properties of the game instance during soft resets.
20
+ * @returns {void} Returns nothing.
12
21
  */
13
22
  static setupControlEvents(modules: GameModules, onReset: () => void): void;
14
23
  /**
15
24
  * Sets up all system-level state property subscriptions.
16
25
  *
17
- * @param modules - The collection of game modules.
26
+ * Binds lifecycle behaviors to state property changes, such as clearing
27
+ * current session data upon encountering Game Over, or fully purging
28
+ * rendering/grid variables when the system is virtually powered down.
29
+ *
30
+ * @param {GameModules} modules - The structured collection of engine modules.
31
+ * @returns {void} Returns nothing.
18
32
  */
19
33
  static setupStateEvents(modules: GameModules): void;
20
34
  }
@@ -1,13 +1,20 @@
1
1
  import { Cell, Coordinate } from '../types/Types';
2
2
  /**
3
- * Utility class for creating and managing grid cells.
3
+ * Static factory utility class for creating and initializing Cell objects.
4
+ *
5
+ * Provides a reliable and centralized mechanism to instantiate default grid
6
+ * cells. This ensures that every cell generated across the engine instances
7
+ * starts with identical baseline properties, preventing inconsistent state setup.
4
8
  */
5
9
  export default class CellHelper {
6
10
  /**
7
- * Creates a new empty cell at the specified coordinate.
11
+ * Creates a new empty cell structure at the specified coordinate.
8
12
  *
9
- * @param {Coordinate} coordinate - The location of the new cell.
10
- * @returns {Cell} A new cell object initialized with value 0 and default color.
13
+ * Constructs a baseline entity used primarily by the `GameGrid` to populate
14
+ * its internal matrix during allocation or when a row/column is cleared.
15
+ *
16
+ * @param {Coordinate} coordinate - The precise `{x, y}` grid location to assign to the new cell.
17
+ * @returns {Cell} A new cell object strictly initialized with a `value` of 0 and the `Color.DEFAULT` assignment.
11
18
  */
12
19
  static emptyCell(coordinate: Coordinate): Cell;
13
20
  }
@@ -1,32 +1,41 @@
1
1
  import { ControlKey } from '../types/Types';
2
2
  import { Control } from '../types/modules';
3
3
  /**
4
- * Helper class that standardizes input handling logic.
5
- * It manages the distinction between single 'press' events and continuous 'hold' events
6
- * for both keyboard and UI button inputs.
4
+ * Utility responsible for standardizing input lifecycle and event dispatching.
5
+ *
6
+ * Normalizes raw hardware keyboard events or UI button clicks into abstract
7
+ * {@link ControlKey} actions. It handles the complexity of identifying the
8
+ * nuance between a quick "press" and a sustained "hold", offloading this
9
+ * timer logic from the core {@link GameControl} module.
7
10
  */
8
11
  export default class ControlInputHandlerHelper {
9
12
  private _control;
10
13
  private _activeKeys;
11
14
  /**
12
- * Creates an instance of the input handler.
15
+ * Instantiates an active input loop handler context.
13
16
  *
14
- * @param {Control} control - The control module instance to notify.
17
+ * @param {Control} control - The parent control module instance used to notify normalized events.
15
18
  */
16
19
  constructor(control: Control);
17
20
  /**
18
- * Processes a key down or button press action.
21
+ * Processes a new physical key down or virtual button press interaction.
22
+ *
19
23
  * Triggers an immediate {@link ControlEventType.PRESSED} event, and schedules
20
- * a {@link ControlEventType.HELD} loop if the key remains active.
24
+ * a continuous {@link ControlEventType.HELD} loop interval if the key remains
25
+ * actively depressed past the configuration threshold.
21
26
  *
22
- * @param {ControlKey} key - The identity of the control key being pressed.
27
+ * @param {ControlKey} key - The identity of the abstract control key being activated.
28
+ * @returns {void} Returns nothing.
23
29
  */
24
30
  handlePress(key: ControlKey): void;
25
31
  /**
26
- * Processes a key up or button release action.
27
- * Cancels any pending hold timers and cleans up the active key state.
32
+ * Stops tracking an active key interaction upon physical or virtual release.
33
+ *
34
+ * Cancels any pending hold delay timers and cleanly wipes the active key
35
+ * state from memory to stop {@link ControlEventType.HELD} events from firing.
28
36
  *
29
- * @param {ControlKey} key - The identity of the control key being released.
37
+ * @param {ControlKey} key - The identity of the abstract control key being released.
38
+ * @returns {void} Returns nothing.
30
39
  */
31
40
  handleRelease(key: ControlKey): void;
32
41
  }
@@ -1,48 +1,53 @@
1
1
  import { Coordinate } from '../types/Types';
2
2
  /**
3
- * Static utility class for coordinate transformations.
4
- * Handles conversions between relative (0-1) coordinates and absolute pixel positions
5
- * for both the main display and the HUD.
3
+ * Static mathematical utility class for coordinate transformations and translations.
4
+ *
5
+ * Centralizes the logic to transition between abstract engine logical models (e.g.
6
+ * the relative 0.0-1.0 coordinate plane or abstract {@link GameGrid} spaces) and
7
+ * the absolute physical layout on screen. It ensures consistency in calculating
8
+ * element sizes dynamically, keeping UI layouts natively responsive to canvas bounds.
6
9
  */
7
10
  export default class CoordinateHelper {
8
11
  /**
9
- * Converts a simplified coordinate object to relative screen dimensions.
12
+ * Converts a flat abstract coordinate object into relative screen dimensional scaling.
10
13
  *
11
- * @param {Coordinate} coordinate - The normal coordinate.
12
- * @returns {Coordinate} A new coordinate scaled to the canvas width/height.
14
+ * @param {Coordinate} coordinate - The input logical coordinate structure (x, y).
15
+ * @returns {Coordinate} A new coordinate scaled proportionately to the physical base canvas width/height.
13
16
  */
14
17
  static getRelativeCoordinate(coordinate: Coordinate): Coordinate;
15
18
  /**
16
- * Calculates the absolute X pixel position for an element on the Main Display.
19
+ * Calculates the absolute `X` pixel position for an element rendered on the Main Display.
17
20
  *
18
- * @param {number} x - The relative or normalized X position.
19
- * @param {number} displayWidth - The calculated width of the display area.
20
- * @returns {number} The absolute X pixel coordinate.
21
+ * @param {number} x - The relative or normalized input X horizontal position.
22
+ * @param {number} displayWidth - The dynamically calculated width of the central display area.
23
+ * @returns {number} The absolute horizontal offset pixel coordinate formatted for `p5` rendering functions.
21
24
  */
22
25
  static getDisplayPosX(x: number, displayWidth: number): number;
23
26
  /**
24
- * Calculates the absolute Y pixel position for an element on the Main Display.
27
+ * Calculates the absolute `Y` pixel position for an element rendered on the Main Display.
25
28
  *
26
- * @param {number} y - The relative or normalized Y position.
27
- * @param {number} displayHeight - The calculated height of the display area.
28
- * @returns {number} The absolute Y pixel coordinate.
29
+ * @param {number} y - The relative or normalized input Y vertical position.
30
+ * @param {number} displayHeight - The dynamically calculated height of the central display area.
31
+ * @returns {number} The absolute vertical offset pixel coordinate formatted for `p5` rendering functions.
29
32
  */
30
33
  static getDisplayPosY(y: number, displayHeight: number): number;
31
34
  /**
32
- * Calculates the absolute X pixel position for an element on the HUD.
33
- * Use this to position elements in the sidebar.
35
+ * Calculates the absolute `X` pixel position for an element docked to the right-side HUD column.
34
36
  *
35
- * @param {number} x - The relative or normalized X position within the HUD.
36
- * @param {number} displayWidth - The width of the main display (used for offset calculation).
37
- * @returns {number} The absolute X pixel coordinate.
37
+ * Automatically adjusts its starting position by determining where the
38
+ * Main Display ends physically, injecting proper UI margin limits dynamically.
39
+ *
40
+ * @param {number} x - The relative or normalized X position specifically within the bounded HUD compartment.
41
+ * @param {number} displayWidth - The total real width of the central display (used for zero-point alignment calculation).
42
+ * @returns {number} The absolute X horizontal pixel coordinate within the application layout scale.
38
43
  */
39
44
  static getHudPosX(x: number, displayWidth: number): number;
40
45
  /**
41
- * Calculates the absolute Y pixel position for an element on the HUD.
46
+ * Calculates the absolute `Y` pixel position for an element docked to the right-side HUD column.
42
47
  *
43
- * @param {number} y - The relative or normalized Y position within the HUD.
44
- * @param {number} displayHeight - The height of the main display (used for scaling).
45
- * @returns {number} The absolute Y pixel coordinate.
48
+ * @param {number} y - The relative or normalized Y position specifically within the bounded HUD compartment.
49
+ * @param {number} displayHeight - The absolute pixel height assigned logically to the central display (used for scaled positioning bounds).
50
+ * @returns {number} The absolute Y vertical pixel coordinate within the application layout scale.
46
51
  */
47
52
  static getHudPosY(y: number, displayHeight: number): number;
48
53
  }