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.
- package/README.adoc +2 -2
- package/dist/docs/index.html +3 -3
- package/dist/docs/jsdoc_standard.html +30 -13
- package/dist/docs/reference/bootstrap.html +556 -0
- package/dist/docs/reference/context/RendererContext.html +19 -9
- package/dist/docs/reference/enums/Color.html +11 -5
- package/dist/docs/reference/enums/ControlEventType.html +7 -5
- package/dist/docs/reference/enums/ControlKey.html +7 -5
- package/dist/docs/reference/enums/EventSuffix.html +7 -5
- package/dist/docs/reference/enums/FontAlignment.html +9 -7
- package/dist/docs/reference/enums/FontSize.html +7 -5
- package/dist/docs/reference/enums/Sound.html +7 -5
- package/dist/docs/reference/enums/StateProperty.html +7 -5
- package/dist/docs/reference/helpers/CellHelper.html +6 -2
- package/dist/docs/reference/helpers/ControlInputHandlerHelper.html +9 -5
- package/dist/docs/reference/helpers/CoordinateHelper.html +14 -10
- package/dist/docs/reference/helpers/RelativeValuesHelper.html +7 -3
- package/dist/docs/reference/interfaces/Debuggable.html +9 -7
- package/dist/docs/reference/interfaces/GameModules.html +7 -5
- package/dist/docs/reference/interfaces/Initializable.html +9 -7
- package/dist/docs/reference/interfaces/RendererInitializable.html +9 -7
- package/dist/docs/reference/interfaces/StateContext.html +7 -5
- package/dist/docs/reference/interfaces/StateSyncable.html +11 -9
- package/dist/docs/reference/interfaces/modules/Control.html +19 -17
- package/dist/docs/reference/interfaces/modules/Grid.html +77 -55
- package/dist/docs/reference/interfaces/modules/Renderer.html +9 -7
- package/dist/docs/reference/interfaces/modules/RendererComposite.html +13 -11
- package/dist/docs/reference/interfaces/modules/Score.html +21 -19
- package/dist/docs/reference/interfaces/modules/Session.html +64 -18
- package/dist/docs/reference/interfaces/modules/State.html +59 -57
- package/dist/docs/reference/interfaces/modules/Text.html +21 -19
- package/dist/docs/reference/interfaces/modules/Time.html +80 -24
- package/dist/docs/reference/modules/Debugger.html +16 -14
- package/dist/docs/reference/modules/DisplayRenderer.html +10 -8
- package/dist/docs/reference/modules/EventEmitter.html +34 -26
- package/dist/docs/reference/modules/Game.html +55 -30
- package/dist/docs/reference/modules/GameControl.html +49 -44
- package/dist/docs/reference/modules/GameEventRegistry.html +17 -34
- package/dist/docs/reference/modules/GameGrid.html +174 -116
- package/dist/docs/reference/modules/GameHudGrid.html +10 -8
- package/dist/docs/reference/modules/GameRenderer.html +14 -12
- package/dist/docs/reference/modules/GameScore.html +36 -34
- package/dist/docs/reference/modules/GameSession.html +37 -19
- package/dist/docs/reference/modules/GameSound.html +20 -18
- package/dist/docs/reference/modules/GameState.html +70 -68
- package/dist/docs/reference/modules/GameText.html +29 -27
- package/dist/docs/reference/modules/GameTime.html +98 -30
- package/dist/docs/reference/modules/HudRenderer.html +10 -8
- package/dist/docs/reference/modules/InitialStateSnapshot.html +13 -11
- package/dist/docs/reference/modules/SessionModal.html +11 -9
- package/dist/docs/reference/types/Axis.html +7 -5
- package/dist/docs/reference/types/Cell.html +7 -5
- package/dist/docs/reference/types/ControlCallback.html +7 -5
- package/dist/docs/reference/types/Coordinate.html +7 -5
- package/dist/docs/reference/types/GameEvent.html +7 -5
- package/dist/docs/reference/types/Piece.html +7 -5
- package/dist/docs/reference/types/RendererMetrics.html +7 -5
- package/dist/docs/reference/types/Vector.html +7 -5
- package/dist/docs/reference/view/GameView.html +29 -21
- package/dist/docs/testing_best_practices.html +2 -2
- package/dist/game.bundle.js +1 -1
- package/dist/types/bootstrap.d.ts +12 -11
- package/dist/types/core/Game.d.ts +46 -39
- package/dist/types/core/InitialStateSnapshot.d.ts +18 -6
- package/dist/types/core/context/RendererContext.d.ts +32 -10
- package/dist/types/core/event/EventEmitter.d.ts +64 -21
- package/dist/types/core/event/GameEventRegistry.d.ts +17 -3
- package/dist/types/core/helpers/CellHelper.d.ts +11 -4
- package/dist/types/core/helpers/ControlInputHandlerHelper.d.ts +20 -11
- package/dist/types/core/helpers/CoordinateHelper.d.ts +28 -23
- package/dist/types/core/helpers/InterfaceIdentifierHelper.d.ts +34 -0
- package/dist/types/core/helpers/RelativeValuesHelper.d.ts +10 -8
- package/dist/types/core/module/control/GameControl.d.ts +26 -14
- package/dist/types/core/module/grid/GameGrid.d.ts +92 -53
- package/dist/types/core/module/grid/GameHudGrid.d.ts +9 -7
- package/dist/types/core/module/grid/engines/GridAnalysisEngine.d.ts +25 -6
- package/dist/types/core/module/grid/engines/GridLineEngine.d.ts +51 -13
- package/dist/types/core/module/grid/engines/GridMovementEngine.d.ts +97 -13
- package/dist/types/core/module/grid/engines/GridRegionEngine.d.ts +24 -5
- package/dist/types/core/module/grid/engines/GridTransformEngine.d.ts +21 -5
- package/dist/types/core/module/renderer/DisplayRenderer.d.ts +27 -15
- package/dist/types/core/module/renderer/GameRenderer.d.ts +20 -13
- package/dist/types/core/module/renderer/HudRenderer.d.ts +27 -19
- package/dist/types/core/module/score/GameScore.d.ts +29 -18
- package/dist/types/core/module/session/GameSession.d.ts +56 -0
- package/dist/types/core/module/sound/GameSound.d.ts +39 -23
- package/dist/types/core/module/state/GameState.d.ts +38 -14
- package/dist/types/core/module/text/GameText.d.ts +40 -25
- package/dist/types/core/module/time/GameTime.d.ts +52 -18
- package/dist/types/core/types/Interfaces.d.ts +15 -0
- package/dist/types/core/types/Types.d.ts +1 -0
- package/dist/types/core/types/enums.d.ts +2 -1
- package/dist/types/core/types/modules.d.ts +214 -45
- package/dist/types/view/Debugger.d.ts +23 -0
- package/dist/types/view/GameView.d.ts +44 -27
- package/dist/types/view/SessionModal.d.ts +24 -0
- package/package.json +1 -1
- package/dist/CNAME +0 -1
|
@@ -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
|
-
*
|
|
5
|
+
* Defines the strict constructor signature for Client games booting via the Engine.
|
|
6
6
|
*
|
|
7
7
|
* @callback ClientGameConstructor
|
|
8
|
-
* @param {p5} p - The
|
|
9
|
-
* @param {GameView} view - The
|
|
10
|
-
* @returns {Game} A
|
|
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
|
-
*
|
|
14
|
+
* Hotswaps the persistent engine tracking pointer dictating logic execution loops.
|
|
15
15
|
*
|
|
16
|
-
* @param {Game} game - The
|
|
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
|
-
*
|
|
21
|
+
* Orchestrating structural point of initialization isolating strict client code execution.
|
|
21
22
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
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
|
|
26
|
-
* @returns {p5} The
|
|
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
|
-
*
|
|
6
|
+
* The Central integration boundary encapsulating physical logic away from native visual outputs.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
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
|
-
*
|
|
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
|
|
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
|
-
*
|
|
31
|
+
* Constructs the primary controller wrapping native rendering canvases into controlled pipelines.
|
|
26
32
|
*
|
|
27
|
-
* @param {
|
|
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
|
-
*
|
|
37
|
+
* Yields strictly controlled visibility access to layout injections.
|
|
33
38
|
*
|
|
34
|
-
* @returns {GameView} The
|
|
39
|
+
* @returns {GameView} The configured view instance formatting user HTML constraints.
|
|
35
40
|
*/
|
|
36
41
|
get view(): GameView;
|
|
37
42
|
/**
|
|
38
|
-
*
|
|
43
|
+
* Yields fully configured physics, inputs, and drawing context tools dynamically mapped.
|
|
39
44
|
*
|
|
40
|
-
* @returns {GameModules}
|
|
45
|
+
* @returns {GameModules} A secure aggregate object pointer.
|
|
41
46
|
*/
|
|
42
47
|
get modules(): GameModules;
|
|
43
48
|
/**
|
|
44
|
-
*
|
|
49
|
+
* Exposes hardware-accelerated processing calls indirectly via Context bounds.
|
|
45
50
|
*
|
|
46
|
-
* @returns {p5} The
|
|
51
|
+
* @returns {p5} The active executing instance map.
|
|
47
52
|
*/
|
|
48
53
|
get p(): p5;
|
|
49
54
|
/**
|
|
50
|
-
*
|
|
51
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
60
|
-
*
|
|
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
|
-
*
|
|
65
|
-
*
|
|
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
|
-
*
|
|
70
|
-
*
|
|
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
|
-
*
|
|
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 -
|
|
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
|
-
*
|
|
82
|
-
*
|
|
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
|
-
*
|
|
87
|
-
* Called after the game modules are initialized.
|
|
94
|
+
* Subclass abstract delegator establishing customized rules tracking specific bounds mathematically.
|
|
88
95
|
*
|
|
89
|
-
*
|
|
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
|
-
*
|
|
96
|
-
*
|
|
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
|
-
*
|
|
101
|
-
*
|
|
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
|
-
*
|
|
6
|
-
*
|
|
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
|
-
*
|
|
11
|
-
*
|
|
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
|
-
*
|
|
16
|
-
*
|
|
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
|
|
4
|
-
*
|
|
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
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
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
|
-
*
|
|
17
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
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
|
|
38
|
-
* @param callback The
|
|
39
|
-
* @param suffix The optional context
|
|
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
|
|
67
|
+
* Emits a standard event, triggering all registered standard callbacks.
|
|
44
68
|
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
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
|
|
51
|
-
*
|
|
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
|
|
54
|
-
* @param payload
|
|
55
|
-
* @param context The engine state
|
|
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
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
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
|
|
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
|
-
*
|
|
11
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
10
|
-
*
|
|
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
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
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
|
-
*
|
|
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
|
|
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
|
|
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
|
|
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
|
-
*
|
|
27
|
-
*
|
|
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
|
-
*
|
|
5
|
-
*
|
|
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
|
|
12
|
+
* Converts a flat abstract coordinate object into relative screen dimensional scaling.
|
|
10
13
|
*
|
|
11
|
-
* @param {Coordinate} coordinate - The
|
|
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
|
|
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
|
|
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
|
|
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
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
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
|
|
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
|
|
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
|
}
|