brick-engine-js 1.0.1
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/.env.local.example +2 -0
- package/.github/workflows/publish.yml +73 -0
- package/.prettierignore +2 -0
- package/.prettierrc.json +8 -0
- package/README.adoc +84 -0
- package/dist/8e23286c2fdf41fd795f.svg +32 -0
- package/dist/CNAME +1 -0
- package/dist/app.js +2 -0
- package/dist/app.js.map +1 -0
- package/dist/brick-engine.js +2 -0
- package/dist/brick-engine.js.map +1 -0
- package/dist/config/configs.d.ts +180 -0
- package/dist/config/configs.test.d.ts +1 -0
- package/dist/config/env.d.ts +2 -0
- package/dist/config/env.test.d.ts +1 -0
- package/dist/config/styles.d.ts +0 -0
- package/dist/core/Game.d.ts +107 -0
- package/dist/core/Game.test.d.ts +1 -0
- package/dist/core/InitialStateSnapshot.d.ts +19 -0
- package/dist/core/InitialStateSnapshot.test.d.ts +1 -0
- package/dist/core/helpers/CellHelper.d.ts +13 -0
- package/dist/core/helpers/CellHelper.test.d.ts +1 -0
- package/dist/core/helpers/ControlInputHandlerHelper.d.ts +32 -0
- package/dist/core/helpers/ControlInputHandlerHelper.test.d.ts +1 -0
- package/dist/core/helpers/CoordinateHelper.d.ts +54 -0
- package/dist/core/helpers/CoordinateHelper.test.d.ts +1 -0
- package/dist/core/helpers/InterfaceIdentifierHelper.d.ts +7 -0
- package/dist/core/helpers/InterfaceIdentifierHelper.test.d.ts +1 -0
- package/dist/core/helpers/RelativeValuesHelper.d.ts +23 -0
- package/dist/core/helpers/RelativeValuesHelper.test.d.ts +1 -0
- package/dist/core/module/control/GameControl.d.ts +62 -0
- package/dist/core/module/control/GameControl.test.d.ts +1 -0
- package/dist/core/module/control/GameControlKeyBinding.d.ts +36 -0
- package/dist/core/module/control/GameControlKeyBinding.test.d.ts +1 -0
- package/dist/core/module/grid/GameGrid.d.ts +399 -0
- package/dist/core/module/grid/GameGrid.test.d.ts +1 -0
- package/dist/core/module/grid/GameHudGrid.d.ts +24 -0
- package/dist/core/module/grid/GameHudGrid.test.d.ts +1 -0
- package/dist/core/module/grid/engines/GridAnalysisEngine.d.ts +29 -0
- package/dist/core/module/grid/engines/GridAnalysisEngine.test.d.ts +1 -0
- package/dist/core/module/grid/engines/GridLineEngine.d.ts +56 -0
- package/dist/core/module/grid/engines/GridLineEngine.test.d.ts +1 -0
- package/dist/core/module/grid/engines/GridMovementEngine.d.ts +29 -0
- package/dist/core/module/grid/engines/GridMovementEngine.test.d.ts +1 -0
- package/dist/core/module/grid/engines/GridRegionEngine.d.ts +26 -0
- package/dist/core/module/grid/engines/GridRegionEngine.test.d.ts +1 -0
- package/dist/core/module/grid/engines/GridTransformEngine.d.ts +24 -0
- package/dist/core/module/grid/engines/GridTransformEngine.test.d.ts +1 -0
- package/dist/core/module/renderer/DisplayRenderer.d.ts +51 -0
- package/dist/core/module/renderer/DisplayRenderer.test.d.ts +1 -0
- package/dist/core/module/renderer/GameRenderer.d.ts +59 -0
- package/dist/core/module/renderer/GameRenderer.test.d.ts +1 -0
- package/dist/core/module/renderer/HudRenderer.d.ts +56 -0
- package/dist/core/module/renderer/HudRenderer.test.d.ts +1 -0
- package/dist/core/module/score/GameScore.d.ts +117 -0
- package/dist/core/module/score/GameScore.test.d.ts +1 -0
- package/dist/core/module/session/GameSession.d.ts +20 -0
- package/dist/core/module/session/GameSession.test.d.ts +1 -0
- package/dist/core/module/sound/GameSound.d.ts +85 -0
- package/dist/core/module/sound/GameSound.test.d.ts +1 -0
- package/dist/core/module/state/GameState.d.ts +172 -0
- package/dist/core/module/state/GameState.test.d.ts +1 -0
- package/dist/core/module/text/GameText.d.ts +87 -0
- package/dist/core/module/text/GameText.test.d.ts +1 -0
- package/dist/core/module/time/GameTime.d.ts +76 -0
- package/dist/core/module/time/GameTime.test.d.ts +1 -0
- package/dist/core/types/Interfaces.d.ts +53 -0
- package/dist/core/types/Types.d.ts +114 -0
- package/dist/core/types/enums.d.ts +106 -0
- package/dist/core/types/modules.d.ts +723 -0
- package/dist/css/app.743066d8e4172b0e73f9.css +824 -0
- package/dist/css/app.743066d8e4172b0e73f9.css.map +1 -0
- package/dist/docs/GAME_DEVELOPER_GUIDE.html +727 -0
- package/dist/docs/brick-engine-guide.html +610 -0
- package/dist/docs/diagrams/lifecycle.mmd +19 -0
- package/dist/docs/documentation_style_guide.html +994 -0
- package/dist/docs/getting-started.html +648 -0
- package/dist/docs/images/lifecycle.svg +1 -0
- package/dist/docs/index.html +593 -0
- package/dist/docs/jsdoc_standard.html +656 -0
- package/dist/docs/publishing.html +573 -0
- package/dist/docs/reference/enums/Color.html +533 -0
- package/dist/docs/reference/enums/ControlEventType.html +505 -0
- package/dist/docs/reference/enums/ControlKey.html +529 -0
- package/dist/docs/reference/enums/FontAlignment.html +545 -0
- package/dist/docs/reference/enums/FontSize.html +517 -0
- package/dist/docs/reference/enums/Sound.html +558 -0
- package/dist/docs/reference/enums/StateProperty.html +525 -0
- package/dist/docs/reference/helpers/CellHelper.html +520 -0
- package/dist/docs/reference/helpers/ControlInputHandlerHelper.html +569 -0
- package/dist/docs/reference/helpers/CoordinateHelper.html +703 -0
- package/dist/docs/reference/helpers/RelativeValuesHelper.html +560 -0
- package/dist/docs/reference/interfaces/Debuggable.html +501 -0
- package/dist/docs/reference/interfaces/GameModules.html +544 -0
- package/dist/docs/reference/interfaces/Initializable.html +495 -0
- package/dist/docs/reference/interfaces/RendererInitializable.html +517 -0
- package/dist/docs/reference/interfaces/StateSyncable.html +542 -0
- package/dist/docs/reference/interfaces/modules/Control.html +648 -0
- package/dist/docs/reference/interfaces/modules/Grid.html +1256 -0
- package/dist/docs/reference/interfaces/modules/Renderer.html +522 -0
- package/dist/docs/reference/interfaces/modules/RendererComposite.html +577 -0
- package/dist/docs/reference/interfaces/modules/Score.html +669 -0
- package/dist/docs/reference/interfaces/modules/Session.html +585 -0
- package/dist/docs/reference/interfaces/modules/State.html +897 -0
- package/dist/docs/reference/interfaces/modules/Text.html +668 -0
- package/dist/docs/reference/interfaces/modules/Time.html +684 -0
- package/dist/docs/reference/modules/Debugger.html +579 -0
- package/dist/docs/reference/modules/DisplayRenderer.html +557 -0
- package/dist/docs/reference/modules/Game.html +909 -0
- package/dist/docs/reference/modules/GameControl.html +716 -0
- package/dist/docs/reference/modules/GameGrid.html +1910 -0
- package/dist/docs/reference/modules/GameHudGrid.html +508 -0
- package/dist/docs/reference/modules/GameMenu.html +538 -0
- package/dist/docs/reference/modules/GameRenderer.html +589 -0
- package/dist/docs/reference/modules/GameScore.html +664 -0
- package/dist/docs/reference/modules/GameSession.html +533 -0
- package/dist/docs/reference/modules/GameSound.html +636 -0
- package/dist/docs/reference/modules/GameState.html +922 -0
- package/dist/docs/reference/modules/GameText.html +701 -0
- package/dist/docs/reference/modules/GameTime.html +696 -0
- package/dist/docs/reference/modules/HudRenderer.html +568 -0
- package/dist/docs/reference/modules/InitialStateSnapshot.html +557 -0
- package/dist/docs/reference/modules/SessionModal.html +520 -0
- package/dist/docs/reference/types/Axis.html +505 -0
- package/dist/docs/reference/types/Cell.html +514 -0
- package/dist/docs/reference/types/ControlCallback.html +488 -0
- package/dist/docs/reference/types/Coordinate.html +510 -0
- package/dist/docs/reference/types/GameEntry.html +514 -0
- package/dist/docs/reference/types/GameEvent.html +514 -0
- package/dist/docs/reference/types/Piece.html +506 -0
- package/dist/docs/reference/types/RendererMetrics.html +514 -0
- package/dist/docs/reference/types/Vector.html +509 -0
- package/dist/docs/testing_best_practices.html +770 -0
- package/dist/favicon.ico +0 -0
- package/dist/fonts/digital-7.monoitalic.ttf +0 -0
- package/dist/images/cell.svg +32 -0
- package/dist/images/close.png +0 -0
- package/dist/images/games.png +0 -0
- package/dist/images/github.png +0 -0
- package/dist/images/letter-a.png +0 -0
- package/dist/images/letter-d.png +0 -0
- package/dist/images/letter-j.png +0 -0
- package/dist/images/letter-s.png +0 -0
- package/dist/images/letter-w.png +0 -0
- package/dist/images/meta-image.png +0 -0
- package/dist/images/number-1.png +0 -0
- package/dist/images/number-2.png +0 -0
- package/dist/images/number-3.png +0 -0
- package/dist/images/number-4.png +0 -0
- package/dist/images/number-5.png +0 -0
- package/dist/images/number-6.png +0 -0
- package/dist/images/splash.gif +0 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.html +1 -0
- package/dist/index.test.d.ts +1 -0
- package/dist/main.d.ts +3 -0
- package/dist/main.test.d.ts +1 -0
- package/dist/menu/GameMenu.d.ts +15 -0
- package/dist/menu/GameMenu.test.d.ts +1 -0
- package/dist/menu/GameMenuSingleton.d.ts +6 -0
- package/dist/menu/GameMenuSingleton.test.d.ts +1 -0
- package/dist/menu/GameRepository.d.ts +7 -0
- package/dist/menu/GameRepository.test.d.ts +1 -0
- package/dist/menu/manager/GameManager.d.ts +6 -0
- package/dist/menu/manager/GameManager.test.d.ts +1 -0
- package/dist/sounds/sound_00.wav +0 -0
- package/dist/sounds/sound_01.wav +0 -0
- package/dist/sounds/sound_02.wav +0 -0
- package/dist/sounds/sound_03.wav +0 -0
- package/dist/sounds/sound_04.wav +0 -0
- package/dist/sounds/sound_05.wav +0 -0
- package/dist/sounds/sound_06.wav +0 -0
- package/dist/sounds/sound_07.wav +0 -0
- package/dist/sounds/sound_08.wav +0 -0
- package/dist/sounds/sound_09.wav +0 -0
- package/dist/sounds/sound_10.wav +0 -0
- package/dist/sounds/sound_11.wav +0 -0
- package/dist/sounds/sound_12.wav +0 -0
- package/dist/sounds/sound_13.wav +0 -0
- package/dist/sounds/sound_14.wav +0 -0
- package/dist/sounds/sound_15.wav +0 -0
- package/dist/types/interfaces.d.ts +5 -0
- package/dist/vendor/p5.min.js +1 -0
- package/dist/view/Debugger.d.ts +12 -0
- package/dist/view/Debugger.test.d.ts +1 -0
- package/dist/view/GameView.d.ts +101 -0
- package/dist/view/GameView.test.d.ts +1 -0
- package/dist/view/SessionModal.d.ts +12 -0
- package/dist/view/SessionModal.test.d.ts +4 -0
- package/dist/view/components/layout/ButtonLayout.d.ts +25 -0
- package/dist/view/components/layout/ButtonLayout.test.d.ts +1 -0
- package/dist/view/components/layout/ContainerLayout.d.ts +23 -0
- package/dist/view/components/layout/ContainerLayout.test.d.ts +1 -0
- package/dist/view/components/layout/FrameLayout.d.ts +11 -0
- package/dist/view/components/layout/FrameLayout.test.d.ts +1 -0
- package/dist/view/components/ui/BigButton.d.ts +13 -0
- package/dist/view/components/ui/BigButton.test.d.ts +1 -0
- package/dist/view/components/ui/Button.d.ts +12 -0
- package/dist/view/components/ui/Button.test.d.ts +1 -0
- package/dist/view/components/ui/Canvas.d.ts +22 -0
- package/dist/view/components/ui/Canvas.test.d.ts +1 -0
- package/dist/view/components/ui/SmallButton.d.ts +13 -0
- package/dist/view/components/ui/SmallButton.test.d.ts +1 -0
- package/dist/view/theme/applyColors.d.ts +10 -0
- package/dist/view/theme/applyColors.test.d.ts +1 -0
- package/dist/view/theme/dimensions.d.ts +13 -0
- package/dist/view/theme/dimensions.test.d.ts +1 -0
- package/docs/GAME_DEVELOPER_GUIDE.adoc +167 -0
- package/docs/brick-engine-guide.adoc +87 -0
- package/docs/diagrams/lifecycle.mmd +19 -0
- package/docs/documentation_style_guide.adoc +210 -0
- package/docs/getting-started.adoc +147 -0
- package/docs/images/lifecycle.svg +1 -0
- package/docs/jsdoc_standard.adoc +109 -0
- package/docs/publishing.adoc +58 -0
- package/docs/reference/enums/Color.adoc +35 -0
- package/docs/reference/enums/ControlEventType.adoc +28 -0
- package/docs/reference/enums/ControlKey.adoc +34 -0
- package/docs/reference/enums/FontAlignment.adoc +43 -0
- package/docs/reference/enums/FontSize.adoc +31 -0
- package/docs/reference/enums/Sound.adoc +42 -0
- package/docs/reference/enums/StateProperty.adoc +33 -0
- package/docs/reference/helpers/CellHelper.adoc +37 -0
- package/docs/reference/helpers/ControlInputHandlerHelper.adoc +57 -0
- package/docs/reference/helpers/CoordinateHelper.adoc +118 -0
- package/docs/reference/helpers/RelativeValuesHelper.adoc +53 -0
- package/docs/reference/interfaces/Debuggable.adoc +29 -0
- package/docs/reference/interfaces/GameModules.adoc +35 -0
- package/docs/reference/interfaces/Initializable.adoc +24 -0
- package/docs/reference/interfaces/RendererInitializable.adoc +33 -0
- package/docs/reference/interfaces/StateSyncable.adoc +41 -0
- package/docs/reference/interfaces/modules/Control.adoc +98 -0
- package/docs/reference/interfaces/modules/Grid.adoc +411 -0
- package/docs/reference/interfaces/modules/Renderer.adoc +34 -0
- package/docs/reference/interfaces/modules/RendererComposite.adoc +57 -0
- package/docs/reference/interfaces/modules/Score.adoc +107 -0
- package/docs/reference/interfaces/modules/Session.adoc +66 -0
- package/docs/reference/interfaces/modules/State.adoc +290 -0
- package/docs/reference/interfaces/modules/Text.adoc +110 -0
- package/docs/reference/interfaces/modules/Time.adoc +119 -0
- package/docs/reference/modules/Debugger.adoc +71 -0
- package/docs/reference/modules/DisplayRenderer.adoc +55 -0
- package/docs/reference/modules/Game.adoc +256 -0
- package/docs/reference/modules/GameControl.adoc +139 -0
- package/docs/reference/modules/GameGrid.adoc +794 -0
- package/docs/reference/modules/GameHudGrid.adoc +38 -0
- package/docs/reference/modules/GameMenu.adoc +39 -0
- package/docs/reference/modules/GameRenderer.adoc +79 -0
- package/docs/reference/modules/GameScore.adoc +138 -0
- package/docs/reference/modules/GameSession.adoc +43 -0
- package/docs/reference/modules/GameSound.adoc +111 -0
- package/docs/reference/modules/GameState.adoc +318 -0
- package/docs/reference/modules/GameText.adoc +139 -0
- package/docs/reference/modules/GameTime.adoc +141 -0
- package/docs/reference/modules/HudRenderer.adoc +56 -0
- package/docs/reference/modules/InitialStateSnapshot.adoc +47 -0
- package/docs/reference/modules/SessionModal.adoc +34 -0
- package/docs/reference/types/Axis.adoc +28 -0
- package/docs/reference/types/Cell.adoc +29 -0
- package/docs/reference/types/ControlCallback.adoc +23 -0
- package/docs/reference/types/Coordinate.adoc +29 -0
- package/docs/reference/types/GameEntry.adoc +29 -0
- package/docs/reference/types/GameEvent.adoc +29 -0
- package/docs/reference/types/Piece.adoc +32 -0
- package/docs/reference/types/RendererMetrics.adoc +29 -0
- package/docs/reference/types/Vector.adoc +28 -0
- package/docs/testing_best_practices.adoc +190 -0
- package/eslint.config.mjs +29 -0
- package/package.json +54 -0
- package/public/CNAME +1 -0
- package/public/docs/GAME_DEVELOPER_GUIDE.html +727 -0
- package/public/docs/brick-engine-guide.html +610 -0
- package/public/docs/diagrams/lifecycle.mmd +19 -0
- package/public/docs/documentation_style_guide.html +994 -0
- package/public/docs/getting-started.html +648 -0
- package/public/docs/images/lifecycle.svg +1 -0
- package/public/docs/index.html +593 -0
- package/public/docs/jsdoc_standard.html +656 -0
- package/public/docs/publishing.html +573 -0
- package/public/docs/reference/enums/Color.html +533 -0
- package/public/docs/reference/enums/ControlEventType.html +505 -0
- package/public/docs/reference/enums/ControlKey.html +529 -0
- package/public/docs/reference/enums/FontAlignment.html +545 -0
- package/public/docs/reference/enums/FontSize.html +517 -0
- package/public/docs/reference/enums/Sound.html +558 -0
- package/public/docs/reference/enums/StateProperty.html +525 -0
- package/public/docs/reference/helpers/CellHelper.html +520 -0
- package/public/docs/reference/helpers/ControlInputHandlerHelper.html +569 -0
- package/public/docs/reference/helpers/CoordinateHelper.html +703 -0
- package/public/docs/reference/helpers/RelativeValuesHelper.html +560 -0
- package/public/docs/reference/interfaces/Debuggable.html +501 -0
- package/public/docs/reference/interfaces/GameModules.html +544 -0
- package/public/docs/reference/interfaces/Initializable.html +495 -0
- package/public/docs/reference/interfaces/RendererInitializable.html +517 -0
- package/public/docs/reference/interfaces/StateSyncable.html +542 -0
- package/public/docs/reference/interfaces/modules/Control.html +648 -0
- package/public/docs/reference/interfaces/modules/Grid.html +1256 -0
- package/public/docs/reference/interfaces/modules/Renderer.html +522 -0
- package/public/docs/reference/interfaces/modules/RendererComposite.html +577 -0
- package/public/docs/reference/interfaces/modules/Score.html +669 -0
- package/public/docs/reference/interfaces/modules/Session.html +585 -0
- package/public/docs/reference/interfaces/modules/State.html +897 -0
- package/public/docs/reference/interfaces/modules/Text.html +668 -0
- package/public/docs/reference/interfaces/modules/Time.html +684 -0
- package/public/docs/reference/modules/Debugger.html +579 -0
- package/public/docs/reference/modules/DisplayRenderer.html +557 -0
- package/public/docs/reference/modules/Game.html +909 -0
- package/public/docs/reference/modules/GameControl.html +716 -0
- package/public/docs/reference/modules/GameGrid.html +1910 -0
- package/public/docs/reference/modules/GameHudGrid.html +508 -0
- package/public/docs/reference/modules/GameMenu.html +538 -0
- package/public/docs/reference/modules/GameRenderer.html +589 -0
- package/public/docs/reference/modules/GameScore.html +664 -0
- package/public/docs/reference/modules/GameSession.html +533 -0
- package/public/docs/reference/modules/GameSound.html +636 -0
- package/public/docs/reference/modules/GameState.html +922 -0
- package/public/docs/reference/modules/GameText.html +701 -0
- package/public/docs/reference/modules/GameTime.html +696 -0
- package/public/docs/reference/modules/HudRenderer.html +568 -0
- package/public/docs/reference/modules/InitialStateSnapshot.html +557 -0
- package/public/docs/reference/modules/SessionModal.html +520 -0
- package/public/docs/reference/types/Axis.html +505 -0
- package/public/docs/reference/types/Cell.html +514 -0
- package/public/docs/reference/types/ControlCallback.html +488 -0
- package/public/docs/reference/types/Coordinate.html +510 -0
- package/public/docs/reference/types/GameEntry.html +514 -0
- package/public/docs/reference/types/GameEvent.html +514 -0
- package/public/docs/reference/types/Piece.html +506 -0
- package/public/docs/reference/types/RendererMetrics.html +514 -0
- package/public/docs/reference/types/Vector.html +509 -0
- package/public/docs/testing_best_practices.html +770 -0
- package/public/favicon.ico +0 -0
- package/public/fonts/digital-7.monoitalic.ttf +0 -0
- package/public/images/cell.svg +32 -0
- package/public/images/close.png +0 -0
- package/public/images/games.png +0 -0
- package/public/images/github.png +0 -0
- package/public/images/letter-a.png +0 -0
- package/public/images/letter-d.png +0 -0
- package/public/images/letter-j.png +0 -0
- package/public/images/letter-s.png +0 -0
- package/public/images/letter-w.png +0 -0
- package/public/images/meta-image.png +0 -0
- package/public/images/number-1.png +0 -0
- package/public/images/number-2.png +0 -0
- package/public/images/number-3.png +0 -0
- package/public/images/number-4.png +0 -0
- package/public/images/number-5.png +0 -0
- package/public/images/number-6.png +0 -0
- package/public/images/splash.gif +0 -0
- package/public/index.html +15 -0
- package/public/sounds/sound_00.wav +0 -0
- package/public/sounds/sound_01.wav +0 -0
- package/public/sounds/sound_02.wav +0 -0
- package/public/sounds/sound_03.wav +0 -0
- package/public/sounds/sound_04.wav +0 -0
- package/public/sounds/sound_05.wav +0 -0
- package/public/sounds/sound_06.wav +0 -0
- package/public/sounds/sound_07.wav +0 -0
- package/public/sounds/sound_08.wav +0 -0
- package/public/sounds/sound_09.wav +0 -0
- package/public/sounds/sound_10.wav +0 -0
- package/public/sounds/sound_11.wav +0 -0
- package/public/sounds/sound_12.wav +0 -0
- package/public/sounds/sound_13.wav +0 -0
- package/public/sounds/sound_14.wav +0 -0
- package/public/sounds/sound_15.wav +0 -0
- package/public/style/body.css +86 -0
- package/public/style/buttons.css +233 -0
- package/public/style/debugger.css +117 -0
- package/public/style/sessionModal.css +155 -0
- package/public/style/sourceCodeAndCommands.css +74 -0
- package/public/style/splash.css +13 -0
- package/public/style/theme.css +137 -0
- package/scripts/generate-diagrams.sh +20 -0
- package/scripts/generate-docs.js +111 -0
- package/src/client-game.d.ts +1 -0
- package/src/config/configs.test.ts +20 -0
- package/src/config/configs.ts +197 -0
- package/src/config/env.test.ts +59 -0
- package/src/config/env.ts +7 -0
- package/src/config/styles.ts +5 -0
- package/src/core/Game.test.ts +167 -0
- package/src/core/Game.ts +307 -0
- package/src/core/InitialStateSnapshot.test.ts +51 -0
- package/src/core/InitialStateSnapshot.ts +46 -0
- package/src/core/helpers/CellHelper.test.ts +33 -0
- package/src/core/helpers/CellHelper.ts +21 -0
- package/src/core/helpers/ControlInputHandlerHelper.test.ts +116 -0
- package/src/core/helpers/ControlInputHandlerHelper.ts +68 -0
- package/src/core/helpers/CoordinateHelper.test.ts +113 -0
- package/src/core/helpers/CoordinateHelper.ts +82 -0
- package/src/core/helpers/InterfaceIdentifierHelper.test.ts +122 -0
- package/src/core/helpers/InterfaceIdentifierHelper.ts +43 -0
- package/src/core/helpers/RelativeValuesHelper.test.ts +47 -0
- package/src/core/helpers/RelativeValuesHelper.ts +29 -0
- package/src/core/module/control/GameControl.test.ts +82 -0
- package/src/core/module/control/GameControl.ts +142 -0
- package/src/core/module/control/GameControlKeyBinding.test.ts +59 -0
- package/src/core/module/control/GameControlKeyBinding.ts +92 -0
- package/src/core/module/grid/GameGrid.test.ts +83 -0
- package/src/core/module/grid/GameGrid.ts +610 -0
- package/src/core/module/grid/GameHudGrid.test.ts +22 -0
- package/src/core/module/grid/GameHudGrid.ts +40 -0
- package/src/core/module/grid/engines/GridAnalysisEngine.test.ts +157 -0
- package/src/core/module/grid/engines/GridAnalysisEngine.ts +124 -0
- package/src/core/module/grid/engines/GridLineEngine.test.ts +132 -0
- package/src/core/module/grid/engines/GridLineEngine.ts +165 -0
- package/src/core/module/grid/engines/GridMovementEngine.test.ts +125 -0
- package/src/core/module/grid/engines/GridMovementEngine.ts +113 -0
- package/src/core/module/grid/engines/GridRegionEngine.test.ts +136 -0
- package/src/core/module/grid/engines/GridRegionEngine.ts +52 -0
- package/src/core/module/grid/engines/GridTransformEngine.test.ts +98 -0
- package/src/core/module/grid/engines/GridTransformEngine.ts +70 -0
- package/src/core/module/renderer/DisplayRenderer.test.ts +86 -0
- package/src/core/module/renderer/DisplayRenderer.ts +152 -0
- package/src/core/module/renderer/GameRenderer.test.ts +103 -0
- package/src/core/module/renderer/GameRenderer.ts +144 -0
- package/src/core/module/renderer/HudRenderer.test.ts +108 -0
- package/src/core/module/renderer/HudRenderer.ts +203 -0
- package/src/core/module/score/GameScore.test.ts +71 -0
- package/src/core/module/score/GameScore.ts +188 -0
- package/src/core/module/session/GameSession.test.ts +176 -0
- package/src/core/module/session/GameSession.ts +103 -0
- package/src/core/module/sound/GameSound.test.ts +117 -0
- package/src/core/module/sound/GameSound.ts +229 -0
- package/src/core/module/state/GameState.test.ts +101 -0
- package/src/core/module/state/GameState.ts +339 -0
- package/src/core/module/text/GameText.test.ts +87 -0
- package/src/core/module/text/GameText.ts +150 -0
- package/src/core/module/time/GameTime.test.ts +86 -0
- package/src/core/module/time/GameTime.ts +144 -0
- package/src/core/types/Interfaces.ts +59 -0
- package/src/core/types/Types.ts +124 -0
- package/src/core/types/enums.ts +113 -0
- package/src/core/types/modules.ts +841 -0
- package/src/index.test.ts +15 -0
- package/src/index.ts +9 -0
- package/src/main.test.ts +137 -0
- package/src/main.ts +77 -0
- package/src/menu/GameMenu.test.ts +157 -0
- package/src/menu/GameMenu.ts +124 -0
- package/src/menu/GameMenuSingleton.test.ts +26 -0
- package/src/menu/GameMenuSingleton.ts +13 -0
- package/src/menu/GameRepository.test.ts +46 -0
- package/src/menu/GameRepository.ts +47 -0
- package/src/menu/manager/GameManager.test.ts +68 -0
- package/src/menu/manager/GameManager.ts +50 -0
- package/src/types/global.d.ts +8 -0
- package/src/types/interfaces.ts +5 -0
- package/src/view/Debugger.test.ts +152 -0
- package/src/view/Debugger.ts +124 -0
- package/src/view/GameView.test.ts +95 -0
- package/src/view/GameView.ts +244 -0
- package/src/view/SessionModal.test.ts +141 -0
- package/src/view/SessionModal.ts +73 -0
- package/src/view/components/layout/ButtonLayout.test.ts +28 -0
- package/src/view/components/layout/ButtonLayout.ts +63 -0
- package/src/view/components/layout/ContainerLayout.test.ts +48 -0
- package/src/view/components/layout/ContainerLayout.ts +50 -0
- package/src/view/components/layout/FrameLayout.test.ts +24 -0
- package/src/view/components/layout/FrameLayout.ts +25 -0
- package/src/view/components/ui/BigButton.test.ts +28 -0
- package/src/view/components/ui/BigButton.ts +31 -0
- package/src/view/components/ui/Button.test.ts +30 -0
- package/src/view/components/ui/Button.ts +30 -0
- package/src/view/components/ui/Canvas.test.ts +32 -0
- package/src/view/components/ui/Canvas.ts +34 -0
- package/src/view/components/ui/SmallButton.test.ts +48 -0
- package/src/view/components/ui/SmallButton.ts +32 -0
- package/src/view/theme/applyColors.test.ts +47 -0
- package/src/view/theme/applyColors.ts +38 -0
- package/src/view/theme/dimensions.test.ts +34 -0
- package/src/view/theme/dimensions.ts +53 -0
- package/tsconfig.json +16 -0
- package/vitest.config.ts +14 -0
- package/webpack.config.js +133 -0
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
/** Colors used for styling the game interface. */
|
|
3
|
+
colors: {
|
|
4
|
+
/** Primary background color for the game screen. */
|
|
5
|
+
background: 'rgb(172, 189, 173)',
|
|
6
|
+
/** Active Font/Cell color. */
|
|
7
|
+
active: 'rgb(19, 26, 18)',
|
|
8
|
+
/** Inactive Font/Cell color. */
|
|
9
|
+
inactive: 'rgba(161, 178, 160, 1)',
|
|
10
|
+
|
|
11
|
+
/** Main theme color for the game device body. */
|
|
12
|
+
bodyMain: 'rgb(0, 68, 187)',
|
|
13
|
+
/** Secondary theme color for the buttons on the device body. */
|
|
14
|
+
bodyButton: 'rgb(247, 222, 57)',
|
|
15
|
+
},
|
|
16
|
+
/** Screen layout configurations. */
|
|
17
|
+
screenLayout: {
|
|
18
|
+
/** Main game grid dimensions. */
|
|
19
|
+
grid: {
|
|
20
|
+
columns: 11,
|
|
21
|
+
rows: 18,
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
/** Head-Up Display (HUD) grid dimensions. */
|
|
25
|
+
hudGrid: {
|
|
26
|
+
columns: 4,
|
|
27
|
+
rows: 4,
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
/** Logical display settings within the container. */
|
|
31
|
+
display: {
|
|
32
|
+
width: 0.65,
|
|
33
|
+
height: 0.956,
|
|
34
|
+
margin: 0.022,
|
|
35
|
+
borderWeight: 0.0075,
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
/** Predefined font scale factors relative to container size. */
|
|
39
|
+
fontSize: {
|
|
40
|
+
extraSmall: 0.05,
|
|
41
|
+
small: 0.065,
|
|
42
|
+
medium: 0.1,
|
|
43
|
+
large: 0.125,
|
|
44
|
+
extraLarge: 0.15,
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
/** Sizing and spacing for individual grid cells. */
|
|
48
|
+
cell: {
|
|
49
|
+
margin: 0.1,
|
|
50
|
+
padding: 0.3,
|
|
51
|
+
strokeWeight: 0.075,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
/** View layout configurations. */
|
|
55
|
+
viewLayout: {
|
|
56
|
+
/** Aspect ratio multiplier for the device body height relative to width. */
|
|
57
|
+
bodyHeightWidthMultiplier: 1.9,
|
|
58
|
+
|
|
59
|
+
/** Screen width threshold for switching to mobile layout (in pixels). */
|
|
60
|
+
mobileBreakpoint: 600,
|
|
61
|
+
|
|
62
|
+
/** Responsive canvas scaling and aspect ratio settings. */
|
|
63
|
+
canvas: {
|
|
64
|
+
widthRatio: 0.7,
|
|
65
|
+
aspectRatio: 1.114, // Height relative to width
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
/** Delay before hiding the splash screen after initialization (in milliseconds). */
|
|
69
|
+
splashHideDelayMs: 250,
|
|
70
|
+
|
|
71
|
+
/** Dimensions and ratios for the game interface. */
|
|
72
|
+
dimensions: {
|
|
73
|
+
/** Border radius as a ratio of container width. */
|
|
74
|
+
borderRadiusRatio: 0.05,
|
|
75
|
+
/** Border width as a ratio of container width. */
|
|
76
|
+
borderWidthRatio: 0.006,
|
|
77
|
+
|
|
78
|
+
/** Button-specific scaling factors. */
|
|
79
|
+
button: {
|
|
80
|
+
/** Small button size ratio. */
|
|
81
|
+
smSizeRatio: 0.08,
|
|
82
|
+
/** Medium/Standard button size ratio. */
|
|
83
|
+
mdSizeRatio: 0.18,
|
|
84
|
+
/** Large action button size ratio. */
|
|
85
|
+
lgSizeRatio: 0.25,
|
|
86
|
+
|
|
87
|
+
/** Scaling factors specifically for mobile viewports. */
|
|
88
|
+
mobile: {
|
|
89
|
+
/** Mobile small button size ratio. */
|
|
90
|
+
smSizeRatio: 0.13,
|
|
91
|
+
/** Mobile medium/standard button size ratio. */
|
|
92
|
+
mdSizeRatio: 0.26,
|
|
93
|
+
/** Mobile large action button size ratio. */
|
|
94
|
+
lgSizeRatio: 0.35,
|
|
95
|
+
/** Standard font ratio for mobile buttons. */
|
|
96
|
+
fontRatio: 0.05,
|
|
97
|
+
/** Small font ratio for mobile buttons. */
|
|
98
|
+
smFontRatio: 0.04,
|
|
99
|
+
/** Large font ratio for mobile buttons. */
|
|
100
|
+
lgFontRatio: 0.055,
|
|
101
|
+
/** Spacing ratio between mobile buttons. */
|
|
102
|
+
spacingRatio: 0.018,
|
|
103
|
+
},
|
|
104
|
+
/** Button border width as a ratio of container width. */
|
|
105
|
+
borderRatio: 0.0045,
|
|
106
|
+
/** Duration for button press animations. */
|
|
107
|
+
animationDuration: '0.15s',
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
|
|
111
|
+
/** Standard shadow dispersion size for UI depth. */
|
|
112
|
+
shadowDispersion: '3px',
|
|
113
|
+
},
|
|
114
|
+
/** Input query parameters. */
|
|
115
|
+
inputQueryParams: {
|
|
116
|
+
/** Key for customizing the device body main color. */
|
|
117
|
+
mainColor: 'body-color',
|
|
118
|
+
/** Key for customizing the device body button color. */
|
|
119
|
+
buttonColor: 'button-color',
|
|
120
|
+
/** Key for detecting if the game is running on a mobile app wrapper. */
|
|
121
|
+
runningOnApp: 'mobile',
|
|
122
|
+
},
|
|
123
|
+
/** Selectors for DOM elements. */
|
|
124
|
+
selectors: {
|
|
125
|
+
/** Root container where the p5 instance is attached. */
|
|
126
|
+
parent: '#brick-game',
|
|
127
|
+
|
|
128
|
+
/** Splash screen shown during initial load. */
|
|
129
|
+
splash: '#splash',
|
|
130
|
+
|
|
131
|
+
/** Modal IDs used for session continuation. */
|
|
132
|
+
modalIds: {
|
|
133
|
+
/** Modal shown when continuing a previous session. */
|
|
134
|
+
sessionModal: '#session-modal',
|
|
135
|
+
/** Confirmation button in the session modal. */
|
|
136
|
+
sessionContinueYes: '#session-modal-yes',
|
|
137
|
+
/** Cancellation button in the session modal. */
|
|
138
|
+
sessionContinueNo: '#session-modal-no',
|
|
139
|
+
},
|
|
140
|
+
|
|
141
|
+
/** Explicit IDs assigned to dynamically created DOM elements. */
|
|
142
|
+
viewElementIds: {
|
|
143
|
+
canvas: 'brick-game-canvas',
|
|
144
|
+
container: 'container',
|
|
145
|
+
frame: 'frame',
|
|
146
|
+
buttonContainer: 'button-container',
|
|
147
|
+
smallButtonContainer: 'small-button-container',
|
|
148
|
+
innerButtonContainer: 'inner-button-container',
|
|
149
|
+
mediumButtonContainer: 'medium-button-container',
|
|
150
|
+
directionVerticalContainer: 'direction-vertical-container',
|
|
151
|
+
directionHorizontalContainer: 'direction-horizontal-container',
|
|
152
|
+
largeButtonContainer: 'large-button-container',
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
/** Storage keys for persisting data in LocalStorage. */
|
|
156
|
+
storageKeys: {
|
|
157
|
+
/** Key for audio muting preference. */
|
|
158
|
+
muted: 'STATE.MUTED',
|
|
159
|
+
/** Key for color mode preference. */
|
|
160
|
+
colorEnabled: 'STATE.COLOR_ENABLED',
|
|
161
|
+
|
|
162
|
+
/** Key for the current game grid state. */
|
|
163
|
+
grid: 'GAME.GRID',
|
|
164
|
+
/** Key for the current HUD grid state. */
|
|
165
|
+
hudGrid: 'GAME.HUD_GRID',
|
|
166
|
+
/** Key for the game speed/tick interval. */
|
|
167
|
+
tickInterval: 'GAME.TICK_INTERVAL',
|
|
168
|
+
/** Key for the user's high score. */
|
|
169
|
+
score: 'GAME.SCORE',
|
|
170
|
+
},
|
|
171
|
+
/** Button hold settings. */
|
|
172
|
+
buttonHold: {
|
|
173
|
+
/** Initial delay before a held button starts repeating (in milliseconds). */
|
|
174
|
+
holdDelayMs: 250,
|
|
175
|
+
/** Interval between repeated actions while a button is held (in milliseconds). */
|
|
176
|
+
holdIntervalMs: 50,
|
|
177
|
+
},
|
|
178
|
+
/** Game settings. */
|
|
179
|
+
game: {
|
|
180
|
+
/** Interval between game ticks (in milliseconds). */
|
|
181
|
+
tickInterval: 1000 / 30, // 30 ticks per second
|
|
182
|
+
/** Minimum interval between game ticks (in milliseconds). */
|
|
183
|
+
minTickInterval: 1000 / 60, // 60 ticks per second
|
|
184
|
+
|
|
185
|
+
/** Performance Monitor settings. */
|
|
186
|
+
debugger: {
|
|
187
|
+
/** Number of milliseconds to count before updating the performance. */
|
|
188
|
+
msInterval: 100,
|
|
189
|
+
/** Enable performance overlay. */
|
|
190
|
+
enabled: true,
|
|
191
|
+
},
|
|
192
|
+
|
|
193
|
+
sound: {
|
|
194
|
+
volume: 0.025,
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
} as const;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { describe, it, expect, afterEach } from 'vitest';
|
|
2
|
+
import { isClientMode, isServerMode } from './env';
|
|
3
|
+
|
|
4
|
+
describe('env configuration', () => {
|
|
5
|
+
const originalEnv = process.env;
|
|
6
|
+
|
|
7
|
+
afterEach(() => {
|
|
8
|
+
// Restore original env after each test
|
|
9
|
+
process.env = { ...originalEnv };
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
describe('isClientMode', () => {
|
|
13
|
+
it('should return true when APP_MODE is client', () => {
|
|
14
|
+
// [ARRANGE]
|
|
15
|
+
process.env.APP_MODE = 'client';
|
|
16
|
+
|
|
17
|
+
// [ACT]
|
|
18
|
+
const result = isClientMode();
|
|
19
|
+
|
|
20
|
+
// [ASSERT]
|
|
21
|
+
expect(result).toBe(true);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('should return false when APP_MODE is not client', () => {
|
|
25
|
+
// [ARRANGE]
|
|
26
|
+
process.env.APP_MODE = 'server';
|
|
27
|
+
|
|
28
|
+
// [ACT]
|
|
29
|
+
const result = isClientMode();
|
|
30
|
+
|
|
31
|
+
// [ASSERT]
|
|
32
|
+
expect(result).toBe(false);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
describe('isServerMode', () => {
|
|
37
|
+
it('should return true when APP_MODE is server', () => {
|
|
38
|
+
// [ARRANGE]
|
|
39
|
+
process.env.APP_MODE = 'server';
|
|
40
|
+
|
|
41
|
+
// [ACT]
|
|
42
|
+
const result = isServerMode();
|
|
43
|
+
|
|
44
|
+
// [ASSERT]
|
|
45
|
+
expect(result).toBe(true);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('should return false when APP_MODE is not server', () => {
|
|
49
|
+
// [ARRANGE]
|
|
50
|
+
process.env.APP_MODE = 'client';
|
|
51
|
+
|
|
52
|
+
// [ACT]
|
|
53
|
+
const result = isServerMode();
|
|
54
|
+
|
|
55
|
+
// [ASSERT]
|
|
56
|
+
expect(result).toBe(false);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
});
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/** @vitest-environment jsdom */
|
|
2
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
3
|
+
import Game from './Game';
|
|
4
|
+
import p5 from 'p5';
|
|
5
|
+
import type GameView from '../view/GameView';
|
|
6
|
+
import { ControlEventType, ControlKey } from './types/Types';
|
|
7
|
+
|
|
8
|
+
// Mock localStorage
|
|
9
|
+
const localStorageMock = (() => {
|
|
10
|
+
let store: Record<string, string> = {};
|
|
11
|
+
return {
|
|
12
|
+
getItem: vi.fn((key: string) => store[key] || null),
|
|
13
|
+
setItem: vi.fn((key: string, value: string) => {
|
|
14
|
+
store[key] = value.toString();
|
|
15
|
+
}),
|
|
16
|
+
removeItem: vi.fn((key: string) => {
|
|
17
|
+
delete store[key];
|
|
18
|
+
}),
|
|
19
|
+
clear: vi.fn(() => {
|
|
20
|
+
store = {};
|
|
21
|
+
}),
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
vi.stubGlobal('localStorage', localStorageMock);
|
|
25
|
+
vi.stubGlobal(
|
|
26
|
+
'AudioContext',
|
|
27
|
+
vi.fn().mockImplementation(function () {
|
|
28
|
+
return {
|
|
29
|
+
createGain: vi.fn().mockReturnValue({
|
|
30
|
+
connect: vi.fn(),
|
|
31
|
+
gain: { setValueAtTime: vi.fn() },
|
|
32
|
+
}),
|
|
33
|
+
destination: {},
|
|
34
|
+
};
|
|
35
|
+
}),
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
class MockGame extends Game {
|
|
39
|
+
update = vi.fn();
|
|
40
|
+
render = vi.fn();
|
|
41
|
+
setupGame = vi.fn();
|
|
42
|
+
getPersistenceKey = () => 'test-game';
|
|
43
|
+
drawTitleScreen = vi.fn();
|
|
44
|
+
drawGameOverScreen = vi.fn();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
describe('Game', () => {
|
|
48
|
+
let game: MockGame;
|
|
49
|
+
let mockP5: Record<string, unknown>;
|
|
50
|
+
let mockView: GameView;
|
|
51
|
+
|
|
52
|
+
beforeEach(() => {
|
|
53
|
+
mockP5 = {
|
|
54
|
+
deltaTime: 16.6,
|
|
55
|
+
noLoop: vi.fn(),
|
|
56
|
+
push: vi.fn(),
|
|
57
|
+
pop: vi.fn(),
|
|
58
|
+
translate: vi.fn(),
|
|
59
|
+
strokeWeight: vi.fn(),
|
|
60
|
+
stroke: vi.fn(),
|
|
61
|
+
noFill: vi.fn(),
|
|
62
|
+
rect: vi.fn(),
|
|
63
|
+
fill: vi.fn(),
|
|
64
|
+
text: vi.fn(),
|
|
65
|
+
textFont: vi.fn(),
|
|
66
|
+
textSize: vi.fn(),
|
|
67
|
+
textAlign: vi.fn(),
|
|
68
|
+
image: vi.fn(),
|
|
69
|
+
createGraphics: vi.fn().mockReturnValue({
|
|
70
|
+
background: vi.fn(),
|
|
71
|
+
strokeWeight: vi.fn(),
|
|
72
|
+
noFill: vi.fn(),
|
|
73
|
+
stroke: vi.fn(),
|
|
74
|
+
rect: vi.fn(),
|
|
75
|
+
}),
|
|
76
|
+
};
|
|
77
|
+
mockView = {
|
|
78
|
+
build: vi.fn(),
|
|
79
|
+
bindControls: vi.fn(),
|
|
80
|
+
showSessionModal: vi.fn(),
|
|
81
|
+
onModal: vi.fn(),
|
|
82
|
+
} as unknown as GameView;
|
|
83
|
+
|
|
84
|
+
game = new MockGame(mockP5 as unknown as p5, mockView);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
describe('setup', () => {
|
|
88
|
+
it('should initialize all modules and sync state', () => {
|
|
89
|
+
// [ACT]
|
|
90
|
+
game.setup();
|
|
91
|
+
|
|
92
|
+
// [ASSERT]
|
|
93
|
+
expect(game.modules).toBeDefined();
|
|
94
|
+
expect(game.modules.state).toBeDefined();
|
|
95
|
+
expect(game.modules.grid).toBeDefined();
|
|
96
|
+
expect(mockView.build).toHaveBeenCalled();
|
|
97
|
+
expect(game.setupGame).toHaveBeenCalled();
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
describe('draw', () => {
|
|
102
|
+
beforeEach(() => {
|
|
103
|
+
game.setup();
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it('should render title screen if game is ON but not STARTED', () => {
|
|
107
|
+
// [ARRANGE]
|
|
108
|
+
game.modules.state.turnOn();
|
|
109
|
+
// state.isStarted() is false by default
|
|
110
|
+
|
|
111
|
+
// [ACT]
|
|
112
|
+
game.draw();
|
|
113
|
+
|
|
114
|
+
// [ASSERT]
|
|
115
|
+
expect(game.drawTitleScreen).toHaveBeenCalled();
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it('should update and render if game is PLAYING', () => {
|
|
119
|
+
// [ARRANGE]
|
|
120
|
+
game.modules.state.turnOn();
|
|
121
|
+
game.modules.state.startGame(); // sets started and playing to true
|
|
122
|
+
|
|
123
|
+
// Mock time to trigger tick
|
|
124
|
+
// Tick interval is in configs, let's assume 1000ms
|
|
125
|
+
game.modules.time.update(2000);
|
|
126
|
+
|
|
127
|
+
// [ACT]
|
|
128
|
+
game.draw();
|
|
129
|
+
|
|
130
|
+
// [ASSERT]
|
|
131
|
+
expect(game.update).toHaveBeenCalled();
|
|
132
|
+
expect(game.render).toHaveBeenCalled();
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
describe('System Controls', () => {
|
|
137
|
+
beforeEach(() => {
|
|
138
|
+
game.setup();
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it('should handle POWER button press', () => {
|
|
142
|
+
const control = game.modules.control;
|
|
143
|
+
const state = game.modules.state;
|
|
144
|
+
|
|
145
|
+
// Simulate Power Press
|
|
146
|
+
control.notify(ControlKey.POWER, ControlEventType.PRESSED);
|
|
147
|
+
expect(state.isOn()).toBe(true);
|
|
148
|
+
|
|
149
|
+
control.notify(ControlKey.POWER, ControlEventType.PRESSED);
|
|
150
|
+
expect(state.isOn()).toBe(false);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it('should handle RESET button press', () => {
|
|
154
|
+
const control = game.modules.control;
|
|
155
|
+
const state = game.modules.state;
|
|
156
|
+
const grid = game.modules.grid;
|
|
157
|
+
|
|
158
|
+
state.turnOn();
|
|
159
|
+
const spy = vi.spyOn(grid, 'resetGrid');
|
|
160
|
+
|
|
161
|
+
control.notify(ControlKey.RESET, ControlEventType.PRESSED);
|
|
162
|
+
|
|
163
|
+
expect(spy).toHaveBeenCalled();
|
|
164
|
+
expect(state.isStarted()).toBe(true);
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
});
|