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,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
  }
@@ -2,8 +2,12 @@ import { Sound } from '../../types/enums';
2
2
  import { Debuggable, StateSyncable } from '../../types/Interfaces';
3
3
  import { SoundModule, State } from '../../types/modules';
4
4
  /**
5
- * Manages audio playback and sound effects.
6
- * Handles the Web Audio API context, loading sound buffers, and managing volume/muting.
5
+ * Module responsible for managing non-blocking audio playback and preloading sound effects.
6
+ *
7
+ * It decouples the raw Web Audio API context management away from generic gameplay
8
+ * components. By abstracting buffer decoding, volume/gain adjustments, and muting, it
9
+ * allows systems to simply request `play(Sound.BEEP)` without managing individual audio nodes.
10
+ * Implements {@link StateSyncable} to actively listen to mute changes from the global state.
7
11
  */
8
12
  export default class GameSound implements SoundModule, StateSyncable, Debuggable {
9
13
  muted: boolean;
@@ -30,56 +34,68 @@ export default class GameSound implements SoundModule, StateSyncable, Debuggable
30
34
  private _volume;
31
35
  _state: State;
32
36
  /**
33
- * Initializes the sound system.
34
- * Creates the AudioContext, sets up the master gain node, and starts loading sounds.
37
+ * Initializes the sound system and buffer caching.
38
+ * Creates the core standard `AudioContext`, sets up the master audio routing
39
+ * `GainNode` for volume adjustment, and kicks off asynchronous background downloading
40
+ * of all game sound assets.
41
+ *
42
+ * @returns {void} Returns nothing.
35
43
  */
36
44
  setup(): void;
37
45
  /**
38
- * Plays a specific sound effect.
39
- * Creates a new source node for each playback instance.
46
+ * Instantiates an active playback stream for a specific preloaded sound effect.
47
+ *
48
+ * To prevent overlapping audio collision, this creates a new `BufferSource` node
49
+ * for every individual playback call.
40
50
  *
41
- * @param {Sound} sound - The sound identifier/URL to play.
42
- * @returns {Promise<void>}
51
+ * @param {Sound} sound - The precise enum identity of the targeted soundtrack/effect file to trigger.
52
+ * @returns {Promise<void>} An asynchronous void promise that resolves immediately upon commanding the API.
43
53
  */
44
54
  play(sound: Sound): Promise<void>;
45
55
  /**
46
- * Stops all instances of a specific sound.
56
+ * Purges and forcefully stops all active playback instances of a specific sound.
47
57
  *
48
- * @param {Sound} sound - The sound to stop.
49
- * @returns {Promise<void>}
58
+ * @param {Sound} sound - The exact enum identity of the looping audio channel to abruptly halt.
59
+ * @returns {Promise<void>} An asynchronous void promise resolving upon completion.
50
60
  */
51
61
  stop(sound: Sound): Promise<void>;
52
62
  /**
53
- * Stops all currently playing sounds.
63
+ * A global panic method that physically stops every localized sound immediately
64
+ * looping in the actively managed list.
54
65
  *
55
- * @returns {Promise<void>}
66
+ * @returns {Promise<void>} An asynchronous void promise resolving after mass stopping concludes.
56
67
  */
57
68
  stopAll(): Promise<void>;
58
69
  /**
59
- * Updates the master volume based on the muted state.
70
+ * Internal utility to update the master audio routing node based on active configuration limits.
71
+ *
72
+ * @returns {void} Returns nothing.
60
73
  */
61
74
  private _updateGain;
62
75
  /**
63
- * Loads all sound assets defined in the Sound enum.
64
- * Fetches, buffers, and decodes the audio data.
76
+ * Preloads and decodes binary chunks for all physical asset bundles defined in the `Sound` configuration.
77
+ *
78
+ * @returns {Promise<void>} An asynchronous void promise resolving upon resolving all fetch requests.
65
79
  */
66
80
  private _loadAll;
67
81
  /**
68
- * Toggles the mute state of the game.
69
- * Updates the state module and the audio gain.
82
+ * Public proxy bound cleanly to the internal UI to swap the active muting preference stringent rule.
83
+ *
84
+ * @returns {void} Returns nothing.
70
85
  */
71
86
  toggleMute(): void;
72
87
  /**
73
- * Receives the shared game state module.
74
- * Subscribes to mute state changes.
88
+ * Hook implemented to attach contextual state triggers immediately after standard `setup` completes.
89
+ * Subscribes to the single source of truth {@link GameState} to actively track the `MUTED` flag.
75
90
  *
76
- * @param {State} state - The game state module.
91
+ * @param {State} state - The injected active singleton logic state context instance to observe securely.
92
+ * @returns {void} Returns nothing.
77
93
  */
78
94
  syncState(state: State): void;
79
95
  /**
80
- * Retrieves debug information about the audio system.
96
+ * Collects and exposes internal mapping metrics required by the Engine's Real-time Development Monitor.
81
97
  *
82
- * @returns {Record<string, string | number | boolean>} The debug data.
98
+ * @returns {Record<string, string | number | boolean>} A shallow payload containing current buffering counts and audio scaling rules.
83
99
  */
84
100
  getDebugData(): Record<string, string | number | boolean>;
85
101
  }
@@ -2,40 +2,46 @@ import { Debuggable } from '../../types/Interfaces';
2
2
  import { State } from '../../types/modules';
3
3
  import { StateProperty } from '../../types/Types';
4
4
  /**
5
- * Manages the core boolean states of the game and handles state-change events.
5
+ * Central module representing the singleton source of truth for the game lifecycle and persistent user preferences.
6
6
  *
7
- * Provides a central hub for tracking game lifecycle states (on, running, gameOver)
8
- * and user preferences (color enabled).
7
+ * Implements the {@link State} and {@link Debuggable} interfaces. Providing a central hub
8
+ * for tracking high-level system states (ON, PLAYING, PAUSED, GAME_OVER) and user
9
+ * configurations (Color and Mute toggles).
9
10
  *
10
- *
11
- * **Persistence Responsibility:**
12
- * This class is the SOLE responsible for persisting and loading generic, cross-session
13
- * player preferences (like mute settings and color toggle) from LocalStorage.
14
- * It does NOT handle transient session data (GameSession) or specific scoring logic (GameScore).
11
+ * It is designated as the sole entity responsible for interacting with the browser's
12
+ * LocalStorage to persist player preferences across distinct engine sessions. It explicitly
13
+ * delegates transient session states to `GameSession`, keeping its scope strictly bounding
14
+ * global lifecycles and physical preferences.
15
15
  */
16
16
  export default class GameState implements State, Debuggable {
17
17
  private _state;
18
18
  /**
19
19
  * Initializes the state module.
20
- * Sets default values for all state properties and loads persisted data.
20
+ * Sets default values for all {@link StateProperty} elements and loads persisted user settings.
21
+ *
22
+ * @returns {void} Returns nothing.
21
23
  */
22
24
  setup(): void;
23
25
  /**
24
- * Loads persistent state from LocalStorage.
26
+ * Internal utility that loads persistent state configurations directly from `LocalStorage`.
27
+ *
28
+ * @returns {void} Returns nothing.
25
29
  */
26
30
  private _loadPersistentState;
27
31
  /**
28
32
  * Sets a state property value, handling persistence and notification.
29
33
  *
30
- * @param {StateProperty} property - The property to set.
31
- * @param {boolean | number} value - The value to set.
34
+ * @param {StateProperty} property - The exact property enum key to assign.
35
+ * @param {boolean | number} value - The primitive value to set.
36
+ * @returns {void} Returns nothing.
32
37
  */
33
38
  private _set;
34
39
  /**
35
- * Notifies all subscribers of a property change.
40
+ * Notifies all subscribers of a property change via the {@link EventEmitter}.
36
41
  * Dispatches to the base property channel and state-specific context channels.
37
42
  *
38
- * @param {StateProperty} property - The property that changed.
43
+ * @param {StateProperty} property - The property enum string that dictates the notification channel.
44
+ * @returns {void} Returns nothing.
39
45
  */
40
46
  notify(property: StateProperty): void;
41
47
  /**
@@ -78,24 +84,34 @@ export default class GameState implements State, Debuggable {
78
84
  /**
79
85
  * Powers on the game machine.
80
86
  * Resets all session states (start, playing, game over).
87
+ *
88
+ * @returns {void} Returns nothing.
81
89
  */
82
90
  turnOn(): void;
83
91
  /**
84
92
  * Powers off the game machine.
85
93
  * Resets all states.
94
+ *
95
+ * @returns {void} Returns nothing.
86
96
  */
87
97
  turnOff(): void;
88
98
  /**
89
99
  * Starts a new game session.
90
100
  * Only works if the machine is powered on.
101
+ *
102
+ * @returns {void} Returns nothing.
91
103
  */
92
104
  startGame(): void;
93
105
  /**
94
106
  * Resets the game over state and starts the game again.
107
+ *
108
+ * @returns {void} Returns nothing.
95
109
  */
96
110
  resetGameOver(): void;
97
111
  /**
98
112
  * Exits the current game session, returning to the "On" state.
113
+ *
114
+ * @returns {void} Returns nothing.
99
115
  */
100
116
  exitGame(): void;
101
117
  /**
@@ -113,6 +129,8 @@ export default class GameState implements State, Debuggable {
113
129
  triggerGameOver(): void;
114
130
  /**
115
131
  * Resets the game to the initial state (restarts).
132
+ *
133
+ * @returns {void} Returns nothing.
116
134
  */
117
135
  resetGame(): void;
118
136
  /**
@@ -125,6 +143,7 @@ export default class GameState implements State, Debuggable {
125
143
  * Enables or disables color mode.
126
144
  *
127
145
  * @param {boolean} value - True to enable, false to disable.
146
+ * @returns {void} Returns nothing.
128
147
  */
129
148
  setColorEnabled(value: boolean): void;
130
149
  /**
@@ -137,14 +156,19 @@ export default class GameState implements State, Debuggable {
137
156
  * Mutes or unmutes the audio.
138
157
  *
139
158
  * @param {boolean} value - True to mute, false to unmute.
159
+ * @returns {void} Returns nothing.
140
160
  */
141
161
  setMuted(value: boolean): void;
142
162
  /**
143
163
  * Toggles the color enabled state.
164
+ *
165
+ * @returns {void} Returns nothing.
144
166
  */
145
167
  toggleColorEnabled(): void;
146
168
  /**
147
169
  * Toggles the muted state.
170
+ *
171
+ * @returns {void} Returns nothing.
148
172
  */
149
173
  toggleMuted(): void;
150
174
  subscribe(property: StateProperty, callback: (value: boolean | number) => void): void;
@@ -3,10 +3,13 @@ import { Coordinate, RendererMetrics } from '../../types/Types';
3
3
  import { Debuggable } from '../../types/Interfaces';
4
4
  import { Text } from '../../types/modules';
5
5
  /**
6
- * Handles text rendering and font management within the game.
6
+ * Core text rendering module bridging engine abstractions to specific pixel scaling.
7
7
  *
8
- * This class orchestrates font initialization, sizing, alignment, and
9
- * provides methods to render text on specific areas (HUD or Display).
8
+ * Implements the {@link Text} interface to separate font computation logic from
9
+ * actual grid and view rendering processes. By pre-calculating relative font dimensions
10
+ * and actively calculating spatial positions against the display canvas at runtime, it
11
+ * guarantees that all text objects are purely responsive without causing continuous layout
12
+ * recalculations on the primary engine CPU loop.
10
13
  */
11
14
  export default class GameText implements Text, Debuggable {
12
15
  /** The default font family used for game text. */
@@ -16,63 +19,75 @@ export default class GameText implements Text, Debuggable {
16
19
  /** Stores the current display metrics for relative positioning. */
17
20
  private _rendererMetrics;
18
21
  /**
19
- * Setup the font and pre-calculates relative font sizes.
22
+ * Setups the active font-family and pre-calculates the array of relative font sizes.
20
23
  *
21
- * Uses configuration values to define a set of pixel-perfect font sizes
22
- * based on current container width.
24
+ * Extracts values from the local environment to pre-define deterministic font scales
25
+ * based on the container width to eliminate parsing loops later.
26
+ *
27
+ * @returns {void} Returns nothing.
23
28
  */
24
29
  setup(): void;
25
30
  /**
26
- * Sets the display metrics used for relative text positioning.
31
+ * Injects the active bounding box metrics used for relative text alignments.
27
32
  *
28
- * @param {RendererMetrics} rendererMetrics - The current renderer dimensions and origin.
33
+ * @param {RendererMetrics} rendererMetrics - The extracted immutable origin definitions.
34
+ * @returns {void} Returns nothing.
29
35
  */
30
36
  setRendererMetrics(rendererMetrics: RendererMetrics): void;
31
37
  /**
32
- * Sets the fill color of the text based on its state.
38
+ * Internal utility method swapping the drawing context paint buckets directly.
33
39
  *
34
- * @param {boolean} state - Whether the text should use the active or inactive color.
40
+ * @param {boolean} state - Flag evaluating to true for active and false for inactive coloring themes.
41
+ * @returns {void} Returns nothing.
35
42
  */
36
43
  protected setTextState(state: boolean): void;
37
44
  /**
38
- * Sets the text color to the active theme color.
45
+ * Sets the context canvas text stroke/fill strictly to the active color theme.
46
+ *
47
+ * @returns {void} Returns nothing.
39
48
  */
40
49
  setActiveText(): void;
41
50
  /**
42
- * Sets the text color to the inactive theme color.
51
+ * Sets the context canvas text stroke/fill strictly to the inactive/faded color theme.
52
+ *
53
+ * @returns {void} Returns nothing.
43
54
  */
44
55
  setInactiveText(): void;
45
56
  /**
46
- * Sets the current font size from predefined values.
57
+ * Assigns the drawing bounds scalar based on pre-compiled values.
47
58
  *
48
- * @param {FontSize} fontSize - The enum value representing the desired size.
59
+ * @param {FontSize} fontSize - The enum target corresponding to an active dictionary size entry.
60
+ * @returns {void} Returns nothing.
49
61
  */
50
62
  setTextSize(fontSize: FontSize): void;
51
63
  /**
52
- * Configures horizontal and vertical text alignment.
64
+ * Direct wrapper defining the geometric justification rules inside a bounded region.
53
65
  *
54
- * @param {FontAlign} fontAlign - Horizontal alignment value.
55
- * @param {FontVerticalAlign} fontVerticalAlign - Vertical alignment value.
66
+ * @param {FontAlign} fontAlign - Horizontal alignment orientation vector.
67
+ * @param {FontVerticalAlign} fontVerticalAlign - Vertical alignment position plane.
68
+ * @returns {void} Returns nothing.
56
69
  */
57
70
  setTextAlign(fontAlign: FontAlign, fontVerticalAlign: FontVerticalAlign): void;
58
71
  /**
59
- * Renders text on the HUD area using relative coordinates.
72
+ * Calculates relative coordinates and natively projects text bounds towards the HUD zone.
60
73
  *
61
- * @param {string} text - The string to be rendered.
62
- * @param {Coordinate} coordinate - Normalized coordinates (0 to 1) within the HUD area.
74
+ * @param {string} text - The raw formatted string.
75
+ * @param {Coordinate} coordinate - Float coordinate vectors from 0.0 to 1.0 restricted to the HUD bounds.
76
+ * @returns {void} Returns nothing.
63
77
  */
64
78
  textOnHud(text: string, coordinate: Coordinate): void;
65
79
  /**
66
- * Renders text on the main display area using relative coordinates.
80
+ * Calculates relative coordinates and natively projects text bounds towards the Main Display zone.
67
81
  *
68
- * @param {string} text - The string to be rendered.
69
- * @param {Coordinate} coordinate - Normalized coordinates (0 to 1) within the display area.
82
+ * @param {string} text - The raw formatted string sequence.
83
+ * @param {Coordinate} coordinate - Float coordinate vectors from 0.0 to 1.0 referencing the Main Display bounds.
84
+ * @returns {void} Returns nothing.
70
85
  */
71
86
  textOnDisplay(text: string, coordinate: Coordinate): void;
72
87
  /**
73
- * Retrieves debug information about the text system.
88
+ * Aggregates configuration details requested by the engine's Debugging Dashboard hook.
74
89
  *
75
- * @returns {Record<string, string | number | boolean>} The debug data.
90
+ * @returns {Record<string, string | number | boolean>} A shallow payload of visual metrics dictating memory cache state.
76
91
  */
77
92
  getDebugData(): Record<string, string | number | boolean>;
78
93
  }
@@ -2,30 +2,39 @@ import { Debuggable } from '../../types/Interfaces';
2
2
  import { Time } from '../../types/modules';
3
3
  import { Serializable } from '../../types/Interfaces';
4
4
  /**
5
- * Manages game time, frame rates, and tick intervals.
6
- * Handles the game loop timing and debug statistics (FPS, TPS).
5
+ * Module responsible for managing the logical engine clock, hardware frame rates, and tick intervals.
6
+ *
7
+ * It decouples the deterministic game logic "ticks" from the unpredictable visual frame rate
8
+ * of the browser canvas. By separating `update` loops from visual rendering, it ensures
9
+ * consistent gameplay speed calculations (like difficulty progression) regardless of the
10
+ * host device's performance capabilities.
7
11
  */
8
12
  export default class GameTime implements Time, Debuggable, Serializable {
9
- protected _accumulatedTime: number;
13
+ protected _tickAccumulator: number;
10
14
  /** The tick interval at the start of the game session. Used for resets. */
11
- protected _initialTickInterval: number;
12
- protected _minTickInterval: number;
13
- protected _tickInterval: number;
14
- protected _fps: number;
15
- protected _tps: number;
16
- protected _tickCounter: number;
17
- protected _timeSinceLastTpsUpdate: number;
15
+ private _initialTickInterval;
16
+ private _minTickInterval;
17
+ private _tickInterval;
18
+ private _fps;
19
+ private _tps;
20
+ private _tickCounter;
21
+ private _totalTicks;
22
+ private _timeSinceLastTpsUpdate;
23
+ private _totalElapsedTime;
18
24
  serialId: string;
19
25
  /**
20
- * Initializes the time module.
21
- * Resets all timers and counters.
26
+ * Initializes the time module's core state.
27
+ * Resets all internal timers and statistical accumulators securely.
28
+ *
29
+ * @returns {void} Returns nothing.
22
30
  */
23
31
  setup(): void;
24
32
  /**
25
- * Updates the time accumulator and calculates FPS/TPS.
26
- * Should be called once per frame.
33
+ * Updates the internal time accumulator and calculates physical FPS/TPS.
34
+ * Must be invoked strictly once per hardware visual frame.
27
35
  *
28
- * @param {number} deltaTime - Time elapsed since last frame in milliseconds.
36
+ * @param {number} deltaTime - Time physically elapsed since the last rendering frame in milliseconds.
37
+ * @returns {void} Returns nothing.
29
38
  */
30
39
  update(deltaTime: number): void;
31
40
  /**
@@ -36,7 +45,9 @@ export default class GameTime implements Time, Debuggable, Serializable {
36
45
  */
37
46
  shouldTick(): boolean;
38
47
  /**
39
- * Resets the time accumulator and debug counters.
48
+ * Safely resets the time accumulator and all debug statistical counters.
49
+ *
50
+ * @returns {void} Returns nothing.
40
51
  */
41
52
  reset(): void;
42
53
  /**
@@ -75,8 +86,31 @@ export default class GameTime implements Time, Debuggable, Serializable {
75
86
  setTickInterval(interval: number): void;
76
87
  setMinTickInterval(interval: number): void;
77
88
  /**
78
- * Captures the current tick interval as the initial state.
79
- * This is useful for restoring the game speed on reset.
89
+ * Gets the total number of ticks since the game started.
90
+ *
91
+ * @returns {number} Total tick count.
92
+ */
93
+ get totalTicks(): number;
94
+ /**
95
+ * Gets the total elapsed time in milliseconds.
96
+ *
97
+ * @returns {number} Elapsed time in ms.
98
+ */
99
+ get elapsedTime(): number;
100
+ /**
101
+ * Checks if the current total tick count is a multiple of the provided interval.
102
+ *
103
+ * @param {number} interval - The tick interval to check.
104
+ * @returns {boolean} True if the current tick is a multiple of the interval.
105
+ */
106
+ isTickEvery(interval: number): boolean;
107
+ /**
108
+ * Captures the current tick interval as the deterministic initial baseline state.
109
+ *
110
+ * This is useful for restoring the intended baseline game speed on session
111
+ * resets rather than reverting to the engine's hardcoded default.
112
+ *
113
+ * @returns {void} Returns nothing.
80
114
  */
81
115
  captureInitialState(): void;
82
116
  }
@@ -7,6 +7,8 @@ export interface Initializable {
7
7
  /**
8
8
  * Initializes the module.
9
9
  * Should be called after the instance is created and dependencies are injected.
10
+ *
11
+ * @returns {void} Returns nothing.
10
12
  */
11
13
  setup(): void;
12
14
  }
@@ -21,6 +23,7 @@ export interface StateSyncable {
21
23
  * Binds the module to the game state.
22
24
  *
23
25
  * @param {State} state - The game state instance to sync with.
26
+ * @returns {void} Returns nothing.
24
27
  */
25
28
  syncState(state: State): void;
26
29
  }
@@ -32,6 +35,7 @@ export interface RendererInitializable {
32
35
  * Initializes the renderer with calculated screen metrics.
33
36
  *
34
37
  * @param {RendererMetrics} rendererMetrics - The layout metrics (dimensions, origins).
38
+ * @returns {void} Returns nothing.
35
39
  */
36
40
  setup(rendererMetrics: RendererMetrics): void;
37
41
  }
@@ -48,6 +52,17 @@ export interface Debuggable {
48
52
  }
49
53
  export interface Serializable {
50
54
  serialId: string;
55
+ /**
56
+ * Serializes the object state into a string.
57
+ *
58
+ * @returns {string} The serialized string payload.
59
+ */
51
60
  serialize(): string;
61
+ /**
62
+ * Deserializes the object state from a string payload.
63
+ *
64
+ * @param {string} data - The string payload.
65
+ * @returns {void} Returns nothing.
66
+ */
52
67
  deserialize(data: string): void;
53
68
  }
@@ -110,5 +110,6 @@ export interface GameEvent {
110
110
  * Callback function type for handling input events.
111
111
  *
112
112
  * @param {GameEvent} event - The event data containing key, type, and module access.
113
+ * @returns {void} Returns nothing.
113
114
  */
114
115
  export type ControlCallback = (event: GameEvent) => void;
@@ -10,7 +10,8 @@ export declare enum Color {
10
10
  PURPLE = "rgb(128, 0, 128)",
11
11
  RED = "rgb(128, 0, 0)",
12
12
  YELLOW = "rgb(128, 128, 0)",
13
- INACTIVE = "rgb(166, 183, 165)"
13
+ INACTIVE = "rgb(166, 183, 165)",
14
+ SHADOW = "rgb(93, 105, 92)"
14
15
  }
15
16
  /**
16
17
  * Enumerates all available horizontal text alignments.