react-native-games 1.0.0 → 1.2.0
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.md +80 -368
- package/lib/module/games/balloon-blaster/BalloonBlaster.js +1 -167
- package/lib/module/games/balloon-blaster/BalloonBlaster.js.map +1 -1
- package/lib/module/games/balloon-blaster/BalloonBlasterConstants.js +1 -182
- package/lib/module/games/balloon-blaster/BalloonBlasterConstants.js.map +1 -1
- package/lib/module/games/balloon-blaster/BalloonBlasterService.js +1 -318
- package/lib/module/games/balloon-blaster/BalloonBlasterStore.js +1 -183
- package/lib/module/games/balloon-blaster/components/BalloonComponent.js +1 -237
- package/lib/module/games/balloon-blaster/components/GameArea.js +1 -156
- package/lib/module/games/balloon-blaster/components/GameBackground.js +1 -476
- package/lib/module/games/balloon-blaster/components/ScoreBoard.js +1 -112
- package/lib/module/games/balloon-blaster/components/ScoreBoard.js.map +1 -1
- package/lib/module/games/balloon-blaster/components/index.js +1 -7
- package/lib/module/games/candy-crush/CandyCrush.js +1 -131
- package/lib/module/games/candy-crush/CandyCrush.js.map +1 -1
- package/lib/module/games/candy-crush/CandyCrushConstants.js +1 -125
- package/lib/module/games/candy-crush/CandyCrushConstants.js.map +1 -1
- package/lib/module/games/candy-crush/CandyCrushService.js +1 -370
- package/lib/module/games/candy-crush/CandyCrushStore.js +1 -303
- package/lib/module/games/candy-crush/components/CandyItem.js +1 -191
- package/lib/module/games/candy-crush/components/GameBackground.js +1 -85
- package/lib/module/games/candy-crush/components/GameGrid.js +1 -314
- package/lib/module/games/candy-crush/components/ScoreBoard.js +1 -79
- package/lib/module/games/candy-crush/components/index.js +1 -7
- package/lib/module/games/candy-crush/index.js +1 -6
- package/lib/module/games/colors-sort/ColorsSort.js +1 -143
- package/lib/module/games/colors-sort/ColorsSort.js.map +1 -1
- package/lib/module/games/colors-sort/ColorsSortConstants.js +1 -72
- package/lib/module/games/colors-sort/ColorsSortConstants.js.map +1 -1
- package/lib/module/games/colors-sort/ColorsSortService.js +1 -255
- package/lib/module/games/colors-sort/ColorsSortStore.js +1 -257
- package/lib/module/games/colors-sort/ColorsSortStore.js.map +1 -1
- package/lib/module/games/colors-sort/components/ColorContainer.js +1 -140
- package/lib/module/games/colors-sort/components/GameBackground.js +1 -135
- package/lib/module/games/colors-sort/components/ScoreBoard.js +1 -70
- package/lib/module/games/colors-sort/components/index.js +1 -6
- package/lib/module/games/dino-jump/DinoJump.js +1 -209
- package/lib/module/games/dino-jump/DinoJump.js.map +1 -1
- package/lib/module/games/dino-jump/DinoJumpConstants.js +1 -189
- package/lib/module/games/dino-jump/DinoJumpConstants.js.map +1 -1
- package/lib/module/games/dino-jump/DinoJumpService.js +1 -270
- package/lib/module/games/dino-jump/DinoJumpStore.js +1 -381
- package/lib/module/games/dino-jump/components/DinoSprite.js +1 -418
- package/lib/module/games/dino-jump/components/DinoSprite.js.map +1 -1
- package/lib/module/games/dino-jump/components/GameArea.js +1 -68
- package/lib/module/games/dino-jump/components/GameBackground.js +1 -444
- package/lib/module/games/dino-jump/components/ObstacleSprite.js +1 -306
- package/lib/module/games/dino-jump/components/ScoreBoard.js +1 -105
- package/lib/module/games/dino-jump/components/ScoreBoard.js.map +1 -1
- package/lib/module/games/dino-jump/components/StarSprite.js +1 -45
- package/lib/module/games/dino-jump/components/index.js +1 -9
- package/lib/module/games/flappy-bird/FlappyBird.js +1 -126
- package/lib/module/games/flappy-bird/FlappyBird.js.map +1 -1
- package/lib/module/games/flappy-bird/FlappyBirdConstants.js +1 -90
- package/lib/module/games/flappy-bird/FlappyBirdConstants.js.map +1 -1
- package/lib/module/games/flappy-bird/FlappyBirdStore.js +1 -300
- package/lib/module/games/flappy-bird/components/Bird.js +1 -87
- package/lib/module/games/flappy-bird/components/GameArea.js +1 -87
- package/lib/module/games/flappy-bird/components/GameBackground.js +1 -79
- package/lib/module/games/flappy-bird/components/Pipes.js +1 -172
- package/lib/module/games/flappy-bird/components/ScoreBoard.js +1 -73
- package/lib/module/games/flappy-bird/components/index.js +1 -8
- package/lib/module/games/fruit-merger/FruitMerger.js +1 -120
- package/lib/module/games/fruit-merger/FruitMerger.js.map +1 -1
- package/lib/module/games/fruit-merger/FruitMergerConstants.js +1 -119
- package/lib/module/games/fruit-merger/FruitMergerConstants.js.map +1 -1
- package/lib/module/games/fruit-merger/FruitMergerService.js +1 -13
- package/lib/module/games/fruit-merger/FruitMergerStore.js +1 -315
- package/lib/module/games/fruit-merger/components/FruitItem.js +1 -102
- package/lib/module/games/fruit-merger/components/GameArea.js +1 -103
- package/lib/module/games/fruit-merger/components/GameBackground.js +1 -498
- package/lib/module/games/fruit-merger/components/ScoreBoard.js +1 -58
- package/lib/module/games/fruit-merger/components/index.js +1 -7
- package/lib/module/games/fruit-ninja/FruitNinja.js +1 -134
- package/lib/module/games/fruit-ninja/FruitNinja.js.map +1 -1
- package/lib/module/games/fruit-ninja/FruitNinjaConstants.js +1 -148
- package/lib/module/games/fruit-ninja/FruitNinjaConstants.js.map +1 -1
- package/lib/module/games/fruit-ninja/FruitNinjaService.js +1 -311
- package/lib/module/games/fruit-ninja/FruitNinjaStore.js +1 -191
- package/lib/module/games/fruit-ninja/FruitNinjaStore.js.map +1 -1
- package/lib/module/games/fruit-ninja/components/FruitComponent.js +1 -99
- package/lib/module/games/fruit-ninja/components/GameArea.js +1 -215
- package/lib/module/games/fruit-ninja/components/GameBackground.js +1 -1267
- package/lib/module/games/fruit-ninja/components/ScoreBoard.js +1 -92
- package/lib/module/games/fruit-ninja/components/ScoreBoard.js.map +1 -1
- package/lib/module/games/fruit-ninja/components/index.js +1 -7
- package/lib/module/games/game-2048/Game2048.js +1 -149
- package/lib/module/games/game-2048/Game2048.js.map +1 -1
- package/lib/module/games/game-2048/Game2048Constants.js +1 -263
- package/lib/module/games/game-2048/Game2048Constants.js.map +1 -1
- package/lib/module/games/game-2048/Game2048Service.js +1 -457
- package/lib/module/games/game-2048/Game2048Store.js +1 -236
- package/lib/module/games/game-2048/components/GameBackground.js +1 -247
- package/lib/module/games/game-2048/components/GameGrid.js +1 -139
- package/lib/module/games/game-2048/components/GameTile.js +1 -72
- package/lib/module/games/game-2048/components/ScoreBoard.js +1 -52
- package/lib/module/games/game-2048/components/index.js +1 -7
- package/lib/module/games/maze-runner/MazeRunner.js +1 -267
- package/lib/module/games/maze-runner/MazeRunner.js.map +1 -1
- package/lib/module/games/maze-runner/MazeRunnerConstants.js +1 -100
- package/lib/module/games/maze-runner/MazeRunnerConstants.js.map +1 -1
- package/lib/module/games/maze-runner/MazeRunnerService.js +1 -586
- package/lib/module/games/maze-runner/components/EnhancedBallComponent.js +1 -150
- package/lib/module/games/maze-runner/components/EnhancedGameArea.js +1 -370
- package/lib/module/games/maze-runner/components/GameBackground.js +1 -175
- package/lib/module/games/maze-runner/components/ScoreBoard.js +1 -61
- package/lib/module/games/maze-runner/components/SkiaPipeComponent.js +1 -209
- package/lib/module/games/maze-runner/components/StaticGameBackground.js +1 -169
- package/lib/module/games/maze-runner/components/WallComponent.js +1 -91
- package/lib/module/games/maze-runner/components/index.js +1 -8
- package/lib/module/games/popit-fidget/PopitFidget.js +1 -285
- package/lib/module/games/popit-fidget/PopitFidget.js.map +1 -1
- package/lib/module/games/popit-fidget/PopitFidgetConstants.js +1 -113
- package/lib/module/games/popit-fidget/PopitFidgetConstants.js.map +1 -1
- package/lib/module/games/popit-fidget/PopitFidgetService.js +1 -132
- package/lib/module/games/popit-fidget/PopitFidgetStore.js +1 -125
- package/lib/module/games/popit-fidget/components/BubbleComponent.js +1 -198
- package/lib/module/games/popit-fidget/components/FidgetGrid.js +1 -165
- package/lib/module/games/popit-fidget/components/GameBackground.js +1 -177
- package/lib/module/games/popit-fidget/components/ScoreBoard.js +1 -61
- package/lib/module/games/popit-fidget/components/index.js +1 -7
- package/lib/module/games/sliding-numbers/SlidingNumbers.js +1 -159
- package/lib/module/games/sliding-numbers/SlidingNumbers.js.map +1 -1
- package/lib/module/games/sliding-numbers/SlidingNumbersConstants.js +1 -207
- package/lib/module/games/sliding-numbers/SlidingNumbersConstants.js.map +1 -1
- package/lib/module/games/sliding-numbers/SlidingNumbersService.js +1 -248
- package/lib/module/games/sliding-numbers/SlidingNumbersStore.js +1 -274
- package/lib/module/games/sliding-numbers/components/GameBackground.js +1 -259
- package/lib/module/games/sliding-numbers/components/NumbersGrid.js +1 -174
- package/lib/module/games/sliding-numbers/components/NumbersTile.js +1 -116
- package/lib/module/games/sliding-numbers/components/ScoreBoard.js +1 -64
- package/lib/module/games/sliding-numbers/components/index.js +1 -7
- package/lib/module/games/snake/Snake.js +1 -189
- package/lib/module/games/snake/Snake.js.map +1 -1
- package/lib/module/games/snake/SnakeConstants.js +1 -138
- package/lib/module/games/snake/SnakeConstants.js.map +1 -1
- package/lib/module/games/snake/SnakeService.js +1 -148
- package/lib/module/games/snake/SnakeStore.js +1 -182
- package/lib/module/games/snake/components/GameBackground.js +1 -221
- package/lib/module/games/snake/components/GameGrid.js +1 -153
- package/lib/module/games/snake/components/ScoreBoard.js +1 -51
- package/lib/module/games/snake/components/index.js +1 -6
- package/lib/module/games/snake/index.js +1 -6
- package/lib/module/games/space-fighter/SpaceFighter.js +1 -165
- package/lib/module/games/space-fighter/SpaceFighter.js.map +1 -1
- package/lib/module/games/space-fighter/SpaceFighterConstants.js +1 -108
- package/lib/module/games/space-fighter/SpaceFighterConstants.js.map +1 -1
- package/lib/module/games/space-fighter/SpaceFighterService.js +1 -326
- package/lib/module/games/space-fighter/SpaceFighterStore.js +1 -209
- package/lib/module/games/space-fighter/components/AsteroidComponent.js +1 -113
- package/lib/module/games/space-fighter/components/GameArea.js +1 -289
- package/lib/module/games/space-fighter/components/GameBackground.js +1 -239
- package/lib/module/games/space-fighter/components/ScoreBoard.js +1 -136
- package/lib/module/games/space-fighter/components/Spacecraft3D.js +1 -202
- package/lib/module/games/space-fighter/components/SpacecraftPath.js +1 -52
- package/lib/module/games/space-fighter/components/index.js +1 -9
- package/lib/module/games/whack-a-mole/WhackAMole.js +1 -270
- package/lib/module/games/whack-a-mole/WhackAMole.js.map +1 -1
- package/lib/module/games/whack-a-mole/WhackAMoleConstants.js +1 -115
- package/lib/module/games/whack-a-mole/WhackAMoleConstants.js.map +1 -1
- package/lib/module/games/whack-a-mole/WhackAMoleService.js +1 -120
- package/lib/module/games/whack-a-mole/WhackAMoleStore.js +1 -172
- package/lib/module/games/whack-a-mole/components/GameBackground.js +1 -477
- package/lib/module/games/whack-a-mole/components/GameGrid.js +1 -97
- package/lib/module/games/whack-a-mole/components/GameHole.js +1 -196
- package/lib/module/games/whack-a-mole/components/MoleCharacter.js +1 -241
- package/lib/module/games/whack-a-mole/components/ScoreBoard.js +1 -67
- package/lib/module/games/whack-a-mole/components/ScoreBoard.js.map +1 -1
- package/lib/module/games/whack-a-mole/components/index.js +1 -8
- package/lib/module/helpers/AnimationFrame.js +1 -120
- package/lib/module/helpers/AnimationTracker.js +1 -89
- package/lib/module/helpers/ErrorHandler.js +1 -269
- package/lib/module/helpers/GameControlButton.js +1 -219
- package/lib/module/helpers/GameOverModal.js +1 -144
- package/lib/module/helpers/GameOverModal.js.map +1 -1
- package/lib/module/helpers/GameSettingsModal.js +1 -287
- package/lib/module/helpers/ParticleBlast.js +1 -134
- package/lib/module/helpers/ScoreBoardContainer.js +1 -34
- package/lib/module/helpers/index.js +1 -12
- package/lib/module/index.js +1 -22
- package/lib/module/services/GamesConstants.js +1 -178
- package/lib/module/services/GamesService.js +1 -112
- package/lib/module/services/GamesService.js.map +1 -1
- package/lib/module/services/HapticsService.js +1 -77
- package/lib/module/services/SoundsService.js +1 -302
- package/lib/module/services/UtilsService.js +1 -32
- package/lib/typescript/src/games/balloon-blaster/BalloonBlaster.d.ts.map +1 -1
- package/lib/typescript/src/games/balloon-blaster/BalloonBlasterConstants.d.ts +1 -1
- package/lib/typescript/src/games/balloon-blaster/components/ScoreBoard.d.ts.map +1 -1
- package/lib/typescript/src/games/candy-crush/CandyCrushConstants.d.ts +7 -7
- package/lib/typescript/src/games/colors-sort/ColorsSort.d.ts.map +1 -1
- package/lib/typescript/src/games/colors-sort/ColorsSortStore.d.ts.map +1 -1
- package/lib/typescript/src/games/dino-jump/DinoJump.d.ts.map +1 -1
- package/lib/typescript/src/games/dino-jump/components/DinoSprite.d.ts.map +1 -1
- package/lib/typescript/src/games/flappy-bird/FlappyBird.d.ts.map +1 -1
- package/lib/typescript/src/games/flappy-bird/FlappyBirdConstants.d.ts.map +1 -1
- package/lib/typescript/src/games/fruit-merger/FruitMerger.d.ts.map +1 -1
- package/lib/typescript/src/games/fruit-merger/FruitMergerConstants.d.ts.map +1 -1
- package/lib/typescript/src/games/fruit-ninja/FruitNinja.d.ts.map +1 -1
- package/lib/typescript/src/games/fruit-ninja/components/ScoreBoard.d.ts.map +1 -1
- package/lib/typescript/src/games/game-2048/Game2048.d.ts.map +1 -1
- package/lib/typescript/src/games/maze-runner/MazeRunner.d.ts.map +1 -1
- package/lib/typescript/src/games/popit-fidget/PopitFidget.d.ts.map +1 -1
- package/lib/typescript/src/games/sliding-numbers/SlidingNumbers.d.ts.map +1 -1
- package/lib/typescript/src/games/space-fighter/SpaceFighter.d.ts.map +1 -1
- package/lib/typescript/src/games/whack-a-mole/WhackAMole.d.ts.map +1 -1
- package/lib/typescript/src/games/whack-a-mole/WhackAMoleConstants.d.ts +1 -1
- package/lib/typescript/src/games/whack-a-mole/components/ScoreBoard.d.ts.map +1 -1
- package/lib/typescript/src/helpers/GameOverModal.d.ts +3 -0
- package/lib/typescript/src/helpers/GameOverModal.d.ts.map +1 -1
- package/lib/typescript/src/services/GamesConstants.d.ts +7 -7
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Dimensions","width","get","SLIDING_NUMBERS_CONSTANTS","gridSize","easy","medium","hard","maxNumbers","baseScore","scoreMultiplier","SLIDING_NUMBERS_GAME_CONFIG","TILE_SIZE","Math","min","TILE_GAP","GRID_PADDING","GAME_DURATION","SHUFFLE_MOVES","ANIMATION_DURATION","SLIDING_NUMBERS_ANIMATION_CONFIG","TILE_SLIDE","damping","stiffness","mass","restDisplacementThreshold","restSpeedThreshold","TILE_PRESS","GESTURE","activeScale","snapThreshold","velocityThreshold","COMPLETION_CELEBRATION","duration","SLIDING_NUMBERS_COLORS","BACKGROUND","GRID_BACKGROUND","GRID_BORDER","TILE_COLORS","TILE_BORDER","TILE_SHADOW","NUMBER_TEXT","WORD_TEXT","EMPTY_TILE","SCORE_BOARD","SCORE_TEXT","TIMER_TEXT","UI","BUTTON_ACTIVE","BUTTON_INACTIVE","TEXT_PRIMARY","TEXT_SECONDARY","WHITE","START_BUTTON","COMPLETION_OVERLAY","BUTTON_BORDER","NUMBER_WORDS","SLIDING_NUMBERS_THEME","backgroundColor","headerBackgroundColor","headerTextColor","sectionBackgroundColor","sectionTitleColor","buttonSelectedColor","buttonUnselectedColor","buttonSelectedTextColor","buttonUnselectedTextColor","switchTrackColorFalse","switchTrackColorTrue","switchThumbColor","infoTextColor","SLIDING_NUMBERS_DIFFICULTY_DESCRIPTIONS"],"sourceRoot":"../../../../src","sources":["games/sliding-numbers/SlidingNumbersConstants.ts"],"mappings":";;AAAA,SAASA,UAAU,QAAQ,cAAc;AAGzC;AACA,MAAM;EAAEC;AAAM,CAAC,GAAGD,UAAU,CAACE,GAAG,CAAC,QAAQ,CAAC;;AAE1C;AACA,OAAO,MAAMC,yBAAyB,GAAG;EACvCC,QAAQ,EAAE;IACRC,IAAI,EAAE,CAAC;IAAE;IACTC,MAAM,EAAE,CAAC;IAAE;IACXC,IAAI,EAAE,CAAC,CAAE;EACX,CAAC;EACDC,UAAU,EAAE;IACVH,IAAI,EAAE,CAAC;IAAE;IACTC,MAAM,EAAE,EAAE;IAAE;IACZC,IAAI,EAAE,EAAE,CAAE;EACZ,CAAC;EACDE,SAAS,EAAE;IACTJ,IAAI,EAAE,IAAI;IACVC,MAAM,EAAE,IAAI;IACZC,IAAI,EAAE;EACR,CAAC;EACD;EACAG,eAAe,EAAE;IACfL,IAAI,E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AEV;AACA,OAAO,MAAMC,qBAAwC,GAAG;EACtDC,eAAe,EAAE,
|
|
1
|
+
{"version":3,"names":["Dimensions","width","get","SLIDING_NUMBERS_CONSTANTS","gridSize","easy","medium","hard","maxNumbers","baseScore","scoreMultiplier","SLIDING_NUMBERS_GAME_CONFIG","TILE_SIZE","Math","min","TILE_GAP","GRID_PADDING","GAME_DURATION","SHUFFLE_MOVES","ANIMATION_DURATION","SLIDING_NUMBERS_ANIMATION_CONFIG","TILE_SLIDE","damping","stiffness","mass","restDisplacementThreshold","restSpeedThreshold","TILE_PRESS","GESTURE","activeScale","snapThreshold","velocityThreshold","COMPLETION_CELEBRATION","duration","SLIDING_NUMBERS_COLORS","BACKGROUND","GRID_BACKGROUND","GRID_BORDER","TILE_COLORS","TILE_BORDER","TILE_SHADOW","NUMBER_TEXT","WORD_TEXT","EMPTY_TILE","SCORE_BOARD","SCORE_TEXT","TIMER_TEXT","UI","BUTTON_ACTIVE","BUTTON_INACTIVE","TEXT_PRIMARY","TEXT_SECONDARY","WHITE","START_BUTTON","COMPLETION_OVERLAY","BUTTON_BORDER","NUMBER_WORDS","SLIDING_NUMBERS_THEME","backgroundColor","headerBackgroundColor","headerTextColor","sectionBackgroundColor","sectionTitleColor","buttonSelectedColor","buttonUnselectedColor","buttonSelectedTextColor","buttonUnselectedTextColor","switchTrackColorFalse","switchTrackColorTrue","switchThumbColor","infoTextColor","SLIDING_NUMBERS_DIFFICULTY_DESCRIPTIONS"],"sourceRoot":"../../../../src","sources":["games/sliding-numbers/SlidingNumbersConstants.ts"],"mappings":";;AAAA,SAASA,UAAU,QAAQ,cAAc;AAGzC;AACA,MAAM;EAAEC;AAAM,CAAC,GAAGD,UAAU,CAACE,GAAG,CAAC,QAAQ,CAAC;;AAE1C;AACA,OAAO,MAAMC,yBAAyB,GAAG;EACvCC,QAAQ,EAAE;IACRC,IAAI,EAAE,CAAC;IAAE;IACTC,MAAM,EAAE,CAAC;IAAE;IACXC,IAAI,EAAE,CAAC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UAAU;EACd,EAAE,EAAE,UAAU;EACd,EAAE,EAAE,SAAS;EACb,EAAE,EAAE,SAAS;EACb,EAAE,EAAE,WAAW;EACf,EAAE,EAAE,UAAU;EACd,EAAE,EAAE,UAAU;EACd,EAAE,EAAE,QAAQ;EACZ,EAAE,EAAE,YAAY;EAChB,EAAE,EAAE,YAAY;EAChB,EAAE,EAAE,cAAc;EAClB,EAAE,EAAE;AACN,CAAU;;AAEV;AACA,OAAO,MAAMC,qBAAwC,GAAG;EACtDC,eAAe,EAAE,oBAAoB;EAAE;EACvCC,qBAAqB,EAAE,SAAS;EAAE;EAClCC,eAAe,EAAE,SAAS;EAC1BC,sBAAsB,EAAE,0BAA0B;EAAE;EACpDC,iBAAiB,EAAE,SAAS;EAAE;EAC9BC,mBAAmB,EAAE,SAAS;EAAE;EAChCC,qBAAqB,EAAE,0BAA0B;EACjDC,uBAAuB,EAAE,SAAS;EAClCC,yBAAyB,EAAE,0BAA0B;EAAE;EACvDC,qBAAqB,EAAE,yBAAyB;EAChDC,oBAAoB,EAAE,SAAS;EAAE;EACjCC,gBAAgB,EAAE,SAAS;EAC3BC,aAAa,EAAE,0BAA0B,CAAE;AAC7C,CAAC;;AAED;AACA,OAAO,MAAMC,uCAAuC,GAAG;EACrDlE,IAAI,EAAE,kDAAkD;EACxDC,MAAM,EAAE,gDAAgD;EACxDC,IAAI,EAAE;AACR,CAAU","ignoreList":[]}
|
|
@@ -1,248 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { SLIDING_NUMBERS_CONSTANTS } from "./SlidingNumbersConstants.js";
|
|
4
|
-
export class SlidingNumbersService {
|
|
5
|
-
gameTimer = null;
|
|
6
|
-
|
|
7
|
-
// Initialize a solved puzzle
|
|
8
|
-
createSolvedPuzzle(gridSize) {
|
|
9
|
-
const tiles = [];
|
|
10
|
-
const totalTiles = gridSize * gridSize;
|
|
11
|
-
for (let i = 0; i < totalTiles; i++) {
|
|
12
|
-
const row = Math.floor(i / gridSize);
|
|
13
|
-
const col = i % gridSize;
|
|
14
|
-
const value = i === totalTiles - 1 ? 0 : i + 1; // Last tile is empty (0)
|
|
15
|
-
|
|
16
|
-
tiles.push({
|
|
17
|
-
id: i,
|
|
18
|
-
value,
|
|
19
|
-
position: {
|
|
20
|
-
row,
|
|
21
|
-
col
|
|
22
|
-
},
|
|
23
|
-
isCorrect: true
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
return tiles;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// Check if a tile can be moved (is adjacent to empty space)
|
|
30
|
-
canMoveTile(tile, emptyPosition) {
|
|
31
|
-
const rowDiff = Math.abs(tile.position.row - emptyPosition.row);
|
|
32
|
-
const colDiff = Math.abs(tile.position.col - emptyPosition.col);
|
|
33
|
-
return rowDiff === 1 && colDiff === 0 || rowDiff === 0 && colDiff === 1;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// Get all tiles that can be moved (adjacent to empty space)
|
|
37
|
-
getMovableTiles(tiles, emptyPosition) {
|
|
38
|
-
return tiles.filter(tile => tile.value !== 0 && this.canMoveTile(tile, emptyPosition));
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// Check if puzzle is solvable using inversion count
|
|
42
|
-
isPuzzleSolvable(tiles, gridSize) {
|
|
43
|
-
const flatArray = [];
|
|
44
|
-
let emptyRow = 0;
|
|
45
|
-
|
|
46
|
-
// Create flat array and find empty tile row
|
|
47
|
-
for (let row = 0; row < gridSize; row++) {
|
|
48
|
-
for (let col = 0; col < gridSize; col++) {
|
|
49
|
-
const tile = tiles.find(t => t.position.row === row && t.position.col === col);
|
|
50
|
-
if (tile) {
|
|
51
|
-
if (tile.value === 0) {
|
|
52
|
-
emptyRow = row;
|
|
53
|
-
} else {
|
|
54
|
-
flatArray.push(tile.value);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Count inversions
|
|
61
|
-
let inversions = 0;
|
|
62
|
-
for (let i = 0; i < flatArray.length - 1; i++) {
|
|
63
|
-
for (let j = i + 1; j < flatArray.length; j++) {
|
|
64
|
-
if ((flatArray[i] || 0) > (flatArray[j] || 0)) {
|
|
65
|
-
inversions++;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// For odd grid size, puzzle is solvable if inversions are even
|
|
71
|
-
if (gridSize % 2 === 1) {
|
|
72
|
-
return inversions % 2 === 0;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// For even grid size, puzzle is solvable if:
|
|
76
|
-
// - Empty tile is on even row from bottom and inversions are odd
|
|
77
|
-
// - Empty tile is on odd row from bottom and inversions are even
|
|
78
|
-
const emptyRowFromBottom = gridSize - emptyRow;
|
|
79
|
-
if (emptyRowFromBottom % 2 === 0) {
|
|
80
|
-
return inversions % 2 === 1;
|
|
81
|
-
} else {
|
|
82
|
-
return inversions % 2 === 0;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// Shuffle puzzle ensuring it remains solvable
|
|
87
|
-
shufflePuzzle(tiles, gridSize) {
|
|
88
|
-
const shuffledTiles = [...tiles];
|
|
89
|
-
let attempts = 0;
|
|
90
|
-
const maxAttempts = 100;
|
|
91
|
-
do {
|
|
92
|
-
// Fisher-Yates shuffle for positions
|
|
93
|
-
const positions = [];
|
|
94
|
-
for (let row = 0; row < gridSize; row++) {
|
|
95
|
-
for (let col = 0; col < gridSize; col++) {
|
|
96
|
-
positions.push({
|
|
97
|
-
row,
|
|
98
|
-
col
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
for (let i = positions.length - 1; i > 0; i--) {
|
|
103
|
-
const j = Math.floor(Math.random() * (i + 1));
|
|
104
|
-
const posI = positions[i];
|
|
105
|
-
const posJ = positions[j];
|
|
106
|
-
if (posI && posJ) {
|
|
107
|
-
[positions[i], positions[j]] = [posJ, posI];
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// Assign shuffled positions to tiles
|
|
112
|
-
shuffledTiles.forEach((tile, index) => {
|
|
113
|
-
const position = positions[index];
|
|
114
|
-
if (position) {
|
|
115
|
-
tile.position = position;
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
attempts++;
|
|
119
|
-
} while (!this.isPuzzleSolvable(shuffledTiles, gridSize) && attempts < maxAttempts);
|
|
120
|
-
|
|
121
|
-
// If we couldn't find a solvable configuration, use a simple swap method
|
|
122
|
-
if (attempts >= maxAttempts) {
|
|
123
|
-
return this.shuffleWithValidMoves(tiles, gridSize);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// Update correctness after shuffle
|
|
127
|
-
shuffledTiles.forEach((tile, index) => {
|
|
128
|
-
const correctRow = Math.floor(index / gridSize);
|
|
129
|
-
const correctCol = index % gridSize;
|
|
130
|
-
tile.isCorrect = tile.position.row === correctRow && tile.position.col === correctCol;
|
|
131
|
-
});
|
|
132
|
-
return shuffledTiles;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// Alternative shuffle method using valid moves
|
|
136
|
-
shuffleWithValidMoves(tiles, gridSize) {
|
|
137
|
-
const shuffledTiles = [...tiles];
|
|
138
|
-
let emptyPosition = {
|
|
139
|
-
row: gridSize - 1,
|
|
140
|
-
col: gridSize - 1
|
|
141
|
-
};
|
|
142
|
-
const shuffleMoves = 1000;
|
|
143
|
-
for (let i = 0; i < shuffleMoves; i++) {
|
|
144
|
-
const movableTiles = this.getMovableTiles(shuffledTiles, emptyPosition);
|
|
145
|
-
if (movableTiles.length > 0) {
|
|
146
|
-
const randomTile = movableTiles[Math.floor(Math.random() * movableTiles.length)];
|
|
147
|
-
const emptyTile = shuffledTiles.find(t => t.value === 0);
|
|
148
|
-
if (emptyTile && randomTile) {
|
|
149
|
-
// Swap positions
|
|
150
|
-
const tilePos = randomTile.position;
|
|
151
|
-
randomTile.position = emptyPosition;
|
|
152
|
-
emptyTile.position = tilePos;
|
|
153
|
-
emptyPosition = tilePos;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
// Update correctness after shuffle
|
|
159
|
-
shuffledTiles.forEach((tile, index) => {
|
|
160
|
-
const correctRow = Math.floor(index / gridSize);
|
|
161
|
-
const correctCol = index % gridSize;
|
|
162
|
-
tile.isCorrect = tile.position.row === correctRow && tile.position.col === correctCol;
|
|
163
|
-
});
|
|
164
|
-
return shuffledTiles;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
// Check if puzzle is completed
|
|
168
|
-
isPuzzleCompleted(tiles, gridSize) {
|
|
169
|
-
return tiles.every((tile, index) => {
|
|
170
|
-
const correctRow = Math.floor(index / gridSize);
|
|
171
|
-
const correctCol = index % gridSize;
|
|
172
|
-
return tile.position.row === correctRow && tile.position.col === correctCol;
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
// Calculate score based on time elapsed
|
|
177
|
-
calculateScore(timeElapsed, difficulty) {
|
|
178
|
-
const baseScore = SLIDING_NUMBERS_CONSTANTS.baseScore[difficulty];
|
|
179
|
-
const multiplier = SLIDING_NUMBERS_CONSTANTS.scoreMultiplier[difficulty];
|
|
180
|
-
const timeScore = Math.max(0, baseScore - timeElapsed * multiplier);
|
|
181
|
-
return timeScore;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
// Get optimal move count for difficulty (for scoring reference)
|
|
185
|
-
getOptimalMoveCount(difficulty) {
|
|
186
|
-
switch (difficulty) {
|
|
187
|
-
case 'easy':
|
|
188
|
-
return 50;
|
|
189
|
-
// 3x3 puzzle
|
|
190
|
-
case 'medium':
|
|
191
|
-
return 100;
|
|
192
|
-
// 4x4 puzzle
|
|
193
|
-
case 'hard':
|
|
194
|
-
return 200;
|
|
195
|
-
// 5x5 puzzle
|
|
196
|
-
default:
|
|
197
|
-
return 50;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
// Start game timer
|
|
202
|
-
startTimer(onTick) {
|
|
203
|
-
this.stopTimer();
|
|
204
|
-
this.gameTimer = setInterval(onTick, 1000);
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
// Stop game timer
|
|
208
|
-
stopTimer() {
|
|
209
|
-
if (this.gameTimer) {
|
|
210
|
-
clearInterval(this.gameTimer);
|
|
211
|
-
this.gameTimer = null;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
// Get hint for next best move
|
|
216
|
-
getHint(tiles, emptyPosition) {
|
|
217
|
-
// Simple heuristic: find a tile that's not in correct position and can be moved
|
|
218
|
-
const movableTiles = this.getMovableTiles(tiles, emptyPosition);
|
|
219
|
-
const incorrectMovableTiles = movableTiles.filter(tile => !tile.isCorrect);
|
|
220
|
-
if (incorrectMovableTiles.length > 0) {
|
|
221
|
-
return incorrectMovableTiles[0] || null;
|
|
222
|
-
}
|
|
223
|
-
return movableTiles.length > 0 ? movableTiles[0] || null : null;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
// Format time for display
|
|
227
|
-
formatTime(seconds) {
|
|
228
|
-
const minutes = Math.floor(seconds / 60);
|
|
229
|
-
const remainingSeconds = seconds % 60;
|
|
230
|
-
return `${minutes}:${remainingSeconds.toString().padStart(2, '0')}`;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
// Get difficulty settings
|
|
234
|
-
getDifficultySettings(difficulty) {
|
|
235
|
-
return {
|
|
236
|
-
gridSize: SLIDING_NUMBERS_CONSTANTS.gridSize[difficulty],
|
|
237
|
-
maxNumbers: SLIDING_NUMBERS_CONSTANTS.maxNumbers[difficulty],
|
|
238
|
-
baseScore: SLIDING_NUMBERS_CONSTANTS.baseScore[difficulty],
|
|
239
|
-
scoreMultiplier: SLIDING_NUMBERS_CONSTANTS.scoreMultiplier[difficulty]
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
// Clean up resources
|
|
244
|
-
cleanup() {
|
|
245
|
-
this.stopTimer();
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
//# sourceMappingURL=SlidingNumbersService.js.map
|
|
1
|
+
"use strict";import{SLIDING_NUMBERS_CONSTANTS}from "./SlidingNumbersConstants.js";export class SlidingNumbersService{gameTimer = null;createSolvedPuzzle(gridSize){const tiles = [];const totalTiles = gridSize * gridSize;for(let i = 0;i < totalTiles;i++){const row = Math.floor(i / gridSize);const col = i % gridSize;const value = i === totalTiles - 1 ? 0:i + 1;tiles.push({id:i,value,position:{row,col},isCorrect:true});}return tiles;}canMoveTile(tile,emptyPosition){const rowDiff = Math.abs(tile.position.row - emptyPosition.row);const colDiff = Math.abs(tile.position.col - emptyPosition.col);return rowDiff === 1 && colDiff === 0 || rowDiff === 0 && colDiff === 1;}getMovableTiles(tiles,emptyPosition){return tiles.filter(tile => tile.value !== 0 && this.canMoveTile(tile,emptyPosition));}isPuzzleSolvable(tiles,gridSize){const flatArray = [];let emptyRow = 0;for(let row = 0;row < gridSize;row++){for(let col = 0;col < gridSize;col++){const tile = tiles.find(t => t.position.row === row && t.position.col === col);if(tile){if(tile.value === 0){emptyRow = row;}else{flatArray.push(tile.value);}}}}let inversions = 0;for(let i = 0;i < flatArray.length - 1;i++){for(let j = i + 1;j < flatArray.length;j++){if((flatArray[i] || 0)>(flatArray[j] || 0)){inversions++;}}}if(gridSize % 2 === 1){return inversions % 2 === 0;}const emptyRowFromBottom = gridSize - emptyRow;if(emptyRowFromBottom % 2 === 0){return inversions % 2 === 1;}else{return inversions % 2 === 0;}}shufflePuzzle(tiles,gridSize){const shuffledTiles = [...tiles];let attempts = 0;const maxAttempts = 100;do{const positions = [];for(let row = 0;row < gridSize;row++){for(let col = 0;col < gridSize;col++){positions.push({row,col});}}for(let i = positions.length - 1;i > 0;i--){const j = Math.floor(Math.random()*(i + 1));const posI = positions[i];const posJ = positions[j];if(posI && posJ){[positions[i],positions[j]] = [posJ,posI];}}shuffledTiles.forEach((tile,index)=>{const position = positions[index];if(position){tile.position = position;}});attempts++;}while(!this.isPuzzleSolvable(shuffledTiles,gridSize)&& attempts < maxAttempts);if(attempts >= maxAttempts){return this.shuffleWithValidMoves(tiles,gridSize);}shuffledTiles.forEach((tile,index)=>{const correctRow = Math.floor(index / gridSize);const correctCol = index % gridSize;tile.isCorrect = tile.position.row === correctRow && tile.position.col === correctCol;});return shuffledTiles;}shuffleWithValidMoves(tiles,gridSize){const shuffledTiles = [...tiles];let emptyPosition ={row:gridSize - 1,col:gridSize - 1};const shuffleMoves = 1000;for(let i = 0;i < shuffleMoves;i++){const movableTiles = this.getMovableTiles(shuffledTiles,emptyPosition);if(movableTiles.length > 0){const randomTile = movableTiles[Math.floor(Math.random()* movableTiles.length)];const emptyTile = shuffledTiles.find(t => t.value === 0);if(emptyTile && randomTile){const tilePos = randomTile.position;randomTile.position = emptyPosition;emptyTile.position = tilePos;emptyPosition = tilePos;}}}shuffledTiles.forEach((tile,index)=>{const correctRow = Math.floor(index / gridSize);const correctCol = index % gridSize;tile.isCorrect = tile.position.row === correctRow && tile.position.col === correctCol;});return shuffledTiles;}isPuzzleCompleted(tiles,gridSize){return tiles.every((tile,index)=>{const correctRow = Math.floor(index / gridSize);const correctCol = index % gridSize;return tile.position.row === correctRow && tile.position.col === correctCol;});}calculateScore(timeElapsed,difficulty){const baseScore = SLIDING_NUMBERS_CONSTANTS.baseScore[difficulty];const multiplier = SLIDING_NUMBERS_CONSTANTS.scoreMultiplier[difficulty];const timeScore = Math.max(0,baseScore - timeElapsed * multiplier);return timeScore;}getOptimalMoveCount(difficulty){switch(difficulty){case 'easy':return 50;case 'medium':return 100;case 'hard':return 200;default:return 50;}}startTimer(onTick){this.stopTimer();this.gameTimer = setInterval(onTick,1000);}stopTimer(){if(this.gameTimer){clearInterval(this.gameTimer);this.gameTimer = null;}}getHint(tiles,emptyPosition){const movableTiles = this.getMovableTiles(tiles,emptyPosition);const incorrectMovableTiles = movableTiles.filter(tile => !tile.isCorrect);if(incorrectMovableTiles.length > 0){return incorrectMovableTiles[0] || null;}return movableTiles.length > 0 ? movableTiles[0] || null:null;}formatTime(seconds){const minutes = Math.floor(seconds / 60);const remainingSeconds = seconds % 60;return `${minutes}:${remainingSeconds.toString().padStart(2,'0')}`;}getDifficultySettings(difficulty){return{gridSize:SLIDING_NUMBERS_CONSTANTS.gridSize[difficulty],maxNumbers:SLIDING_NUMBERS_CONSTANTS.maxNumbers[difficulty],baseScore:SLIDING_NUMBERS_CONSTANTS.baseScore[difficulty],scoreMultiplier:SLIDING_NUMBERS_CONSTANTS.scoreMultiplier[difficulty]};}cleanup(){this.stopTimer();}}
|
|
@@ -1,274 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { create } from 'zustand';
|
|
4
|
-
import { subscribeWithSelector } from 'zustand/middleware';
|
|
5
|
-
import { immerMiddleware } from "../../services/UtilsService.js";
|
|
6
|
-
export const useSlidingNumbersStore = create()(subscribeWithSelector(immerMiddleware((set, get) => ({
|
|
7
|
-
// Initial state
|
|
8
|
-
isPlaying: false,
|
|
9
|
-
isCompleted: false,
|
|
10
|
-
tiles: [],
|
|
11
|
-
gridSize: 3,
|
|
12
|
-
emptyPosition: {
|
|
13
|
-
row: 2,
|
|
14
|
-
col: 2
|
|
15
|
-
},
|
|
16
|
-
score: 0,
|
|
17
|
-
timeLeft: 600,
|
|
18
|
-
timeElapsed: 0,
|
|
19
|
-
startTime: null,
|
|
20
|
-
// Initialize puzzle with given grid size
|
|
21
|
-
initializePuzzle: gridSize => {
|
|
22
|
-
set(state => {
|
|
23
|
-
const tiles = [];
|
|
24
|
-
const totalTiles = gridSize * gridSize;
|
|
25
|
-
|
|
26
|
-
// Create tiles (0 represents empty tile)
|
|
27
|
-
for (let i = 0; i < totalTiles; i++) {
|
|
28
|
-
const row = Math.floor(i / gridSize);
|
|
29
|
-
const col = i % gridSize;
|
|
30
|
-
const value = i === totalTiles - 1 ? 0 : i + 1; // Last tile is empty (0)
|
|
31
|
-
|
|
32
|
-
tiles.push({
|
|
33
|
-
id: i,
|
|
34
|
-
value,
|
|
35
|
-
position: {
|
|
36
|
-
row,
|
|
37
|
-
col
|
|
38
|
-
},
|
|
39
|
-
isCorrect: true // Initially all tiles are in correct position
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
state.tiles = tiles;
|
|
43
|
-
state.gridSize = gridSize;
|
|
44
|
-
state.emptyPosition = {
|
|
45
|
-
row: gridSize - 1,
|
|
46
|
-
col: gridSize - 1
|
|
47
|
-
};
|
|
48
|
-
state.score = 0;
|
|
49
|
-
state.timeLeft = 600; // 10 minutes
|
|
50
|
-
state.timeElapsed = 0;
|
|
51
|
-
state.isCompleted = false;
|
|
52
|
-
state.isPlaying = false;
|
|
53
|
-
state.startTime = null;
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
// Automatically shuffle the puzzle after initialization
|
|
57
|
-
get().shufflePuzzle();
|
|
58
|
-
},
|
|
59
|
-
// Move a tile if it's adjacent to empty space
|
|
60
|
-
moveTile: tileId => {
|
|
61
|
-
const state = get();
|
|
62
|
-
if (!state.isPlaying || state.isCompleted) return false;
|
|
63
|
-
const tile = state.tiles[tileId];
|
|
64
|
-
const emptyPos = state.emptyPosition;
|
|
65
|
-
|
|
66
|
-
// Check if tile is adjacent to empty space
|
|
67
|
-
const rowDiff = Math.abs(tile.position.row - emptyPos.row);
|
|
68
|
-
const colDiff = Math.abs(tile.position.col - emptyPos.col);
|
|
69
|
-
const isAdjacent = rowDiff === 1 && colDiff === 0 || rowDiff === 0 && colDiff === 1;
|
|
70
|
-
if (!isAdjacent) return false;
|
|
71
|
-
set(state => {
|
|
72
|
-
// Swap tile with empty space
|
|
73
|
-
const tile = state.tiles[tileId];
|
|
74
|
-
if (!tile) return;
|
|
75
|
-
const tilePos = tile.position;
|
|
76
|
-
const emptyTileId = state.tiles.findIndex(t => t.value === 0);
|
|
77
|
-
const emptyTile = state.tiles[emptyTileId];
|
|
78
|
-
if (!emptyTile) return;
|
|
79
|
-
|
|
80
|
-
// Update positions
|
|
81
|
-
tile.position = state.emptyPosition;
|
|
82
|
-
emptyTile.position = tilePos;
|
|
83
|
-
state.emptyPosition = tilePos;
|
|
84
|
-
|
|
85
|
-
// Update time elapsed for scoring
|
|
86
|
-
if (state.startTime) {
|
|
87
|
-
state.timeElapsed = Math.floor((Date.now() - state.startTime) / 1000);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// Check if tiles are in correct positions
|
|
91
|
-
state.tiles.forEach((tile, index) => {
|
|
92
|
-
const correctRow = Math.floor(index / state.gridSize);
|
|
93
|
-
const correctCol = index % state.gridSize;
|
|
94
|
-
tile.isCorrect = tile.position.row === correctRow && tile.position.col === correctCol;
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
// Completion will be checked by the component
|
|
99
|
-
return true;
|
|
100
|
-
},
|
|
101
|
-
// Move tile in specific direction (for gesture handling)
|
|
102
|
-
moveTileInDirection: (tileId, direction) => {
|
|
103
|
-
const state = get();
|
|
104
|
-
if (!state.isPlaying || state.isCompleted) return false;
|
|
105
|
-
const tile = state.tiles[tileId];
|
|
106
|
-
if (!tile) return false;
|
|
107
|
-
const emptyPos = state.emptyPosition;
|
|
108
|
-
let expectedEmptyPos;
|
|
109
|
-
|
|
110
|
-
// Calculate where empty space should be for this direction
|
|
111
|
-
switch (direction) {
|
|
112
|
-
case 'up':
|
|
113
|
-
expectedEmptyPos = {
|
|
114
|
-
row: tile.position.row - 1,
|
|
115
|
-
col: tile.position.col
|
|
116
|
-
};
|
|
117
|
-
break;
|
|
118
|
-
case 'down':
|
|
119
|
-
expectedEmptyPos = {
|
|
120
|
-
row: tile.position.row + 1,
|
|
121
|
-
col: tile.position.col
|
|
122
|
-
};
|
|
123
|
-
break;
|
|
124
|
-
case 'left':
|
|
125
|
-
expectedEmptyPos = {
|
|
126
|
-
row: tile.position.row,
|
|
127
|
-
col: tile.position.col - 1
|
|
128
|
-
};
|
|
129
|
-
break;
|
|
130
|
-
case 'right':
|
|
131
|
-
expectedEmptyPos = {
|
|
132
|
-
row: tile.position.row,
|
|
133
|
-
col: tile.position.col + 1
|
|
134
|
-
};
|
|
135
|
-
break;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// Check if empty space is in the expected position
|
|
139
|
-
if (emptyPos.row !== expectedEmptyPos.row || emptyPos.col !== expectedEmptyPos.col) {
|
|
140
|
-
return false;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// Use existing moveTile logic
|
|
144
|
-
return get().moveTile(tileId);
|
|
145
|
-
},
|
|
146
|
-
// Shuffle puzzle by making random valid moves
|
|
147
|
-
shufflePuzzle: () => {
|
|
148
|
-
const shuffleMoves = 100;
|
|
149
|
-
set(state => {
|
|
150
|
-
for (let i = 0; i < shuffleMoves; i++) {
|
|
151
|
-
const emptyPos = state.emptyPosition;
|
|
152
|
-
const possibleMoves = [];
|
|
153
|
-
|
|
154
|
-
// Find tiles adjacent to empty space
|
|
155
|
-
state.tiles.forEach((tile, index) => {
|
|
156
|
-
if (tile.value === 0) return; // Skip empty tile
|
|
157
|
-
|
|
158
|
-
const rowDiff = Math.abs(tile.position.row - emptyPos.row);
|
|
159
|
-
const colDiff = Math.abs(tile.position.col - emptyPos.col);
|
|
160
|
-
const isAdjacent = rowDiff === 1 && colDiff === 0 || rowDiff === 0 && colDiff === 1;
|
|
161
|
-
if (isAdjacent) {
|
|
162
|
-
possibleMoves.push(index);
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
if (possibleMoves.length > 0) {
|
|
166
|
-
const randomTileIndex = Math.floor(Math.random() * possibleMoves.length);
|
|
167
|
-
const randomTileId = possibleMoves[randomTileIndex];
|
|
168
|
-
if (randomTileId !== undefined) {
|
|
169
|
-
const tile = state.tiles[randomTileId];
|
|
170
|
-
const emptyTileId = state.tiles.findIndex(t => t.value === 0);
|
|
171
|
-
const emptyTile = state.tiles[emptyTileId];
|
|
172
|
-
if (tile && emptyTile) {
|
|
173
|
-
// Swap positions
|
|
174
|
-
const tilePos = tile.position;
|
|
175
|
-
tile.position = state.emptyPosition;
|
|
176
|
-
emptyTile.position = tilePos;
|
|
177
|
-
state.emptyPosition = tilePos;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
// Update correctness after shuffle
|
|
184
|
-
state.tiles.forEach((tile, index) => {
|
|
185
|
-
const correctRow = Math.floor(index / state.gridSize);
|
|
186
|
-
const correctCol = index % state.gridSize;
|
|
187
|
-
tile.isCorrect = tile.position.row === correctRow && tile.position.col === correctCol;
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
// Reset score after shuffle
|
|
191
|
-
state.score = 0;
|
|
192
|
-
state.timeElapsed = 0;
|
|
193
|
-
});
|
|
194
|
-
},
|
|
195
|
-
// Start the game
|
|
196
|
-
startGame: () => {
|
|
197
|
-
set(state => {
|
|
198
|
-
state.isPlaying = true;
|
|
199
|
-
state.isCompleted = false;
|
|
200
|
-
state.startTime = Date.now();
|
|
201
|
-
});
|
|
202
|
-
},
|
|
203
|
-
// Stop the game
|
|
204
|
-
stopGame: () => {
|
|
205
|
-
const state = get();
|
|
206
|
-
// Reset the game instead of showing game over modal
|
|
207
|
-
state.resetGame();
|
|
208
|
-
},
|
|
209
|
-
// Reset the game (difficulty will be passed from component)
|
|
210
|
-
resetGame: () => {
|
|
211
|
-
set(state => {
|
|
212
|
-
state.isPlaying = false;
|
|
213
|
-
state.isCompleted = false;
|
|
214
|
-
state.score = 0;
|
|
215
|
-
state.timeLeft = 600;
|
|
216
|
-
state.timeElapsed = 0;
|
|
217
|
-
state.startTime = null;
|
|
218
|
-
});
|
|
219
|
-
// Puzzle will be re-initialized by the component with current difficulty
|
|
220
|
-
},
|
|
221
|
-
// Decrement time
|
|
222
|
-
decrementTime: () => {
|
|
223
|
-
set(state => {
|
|
224
|
-
if (state.timeLeft > 0) {
|
|
225
|
-
state.timeLeft--;
|
|
226
|
-
if (state.startTime) {
|
|
227
|
-
state.timeElapsed = Math.floor((Date.now() - state.startTime) / 1000);
|
|
228
|
-
}
|
|
229
|
-
} else {
|
|
230
|
-
state.isPlaying = false;
|
|
231
|
-
state.startTime = null;
|
|
232
|
-
}
|
|
233
|
-
});
|
|
234
|
-
},
|
|
235
|
-
// Check if puzzle is completed
|
|
236
|
-
checkCompletion: difficulty => {
|
|
237
|
-
const state = get();
|
|
238
|
-
const allCorrect = state.tiles.every(tile => tile.isCorrect);
|
|
239
|
-
if (allCorrect && state.isPlaying) {
|
|
240
|
-
set(state => {
|
|
241
|
-
state.isCompleted = true;
|
|
242
|
-
state.isPlaying = false;
|
|
243
|
-
|
|
244
|
-
// Calculate time-based score (faster completion = higher score)
|
|
245
|
-
const baseScore = difficulty === 'easy' ? 1000 : difficulty === 'medium' ? 2000 : 3000;
|
|
246
|
-
const multiplier = difficulty === 'easy' ? 5 : difficulty === 'medium' ? 10 : 15;
|
|
247
|
-
|
|
248
|
-
// Score decreases with time elapsed, bonus for remaining time
|
|
249
|
-
const timeScore = Math.max(0, baseScore - state.timeElapsed * multiplier);
|
|
250
|
-
const remainingTimeBonus = state.timeLeft * multiplier;
|
|
251
|
-
state.score = timeScore + remainingTimeBonus;
|
|
252
|
-
});
|
|
253
|
-
}
|
|
254
|
-
},
|
|
255
|
-
// Update score
|
|
256
|
-
updateScore: points => {
|
|
257
|
-
set(state => {
|
|
258
|
-
state.score += points;
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
}))));
|
|
262
|
-
|
|
263
|
-
// Selectors for performance optimization
|
|
264
|
-
export const useGameState = () => useSlidingNumbersStore(state => ({
|
|
265
|
-
isPlaying: state.isPlaying,
|
|
266
|
-
isCompleted: state.isCompleted
|
|
267
|
-
}));
|
|
268
|
-
export const useScore = () => useSlidingNumbersStore(state => state.score);
|
|
269
|
-
export const useTimeLeft = () => useSlidingNumbersStore(state => state.timeLeft);
|
|
270
|
-
export const useTimeElapsed = () => useSlidingNumbersStore(state => state.timeElapsed);
|
|
271
|
-
export const useTiles = () => useSlidingNumbersStore(state => state.tiles);
|
|
272
|
-
export const useGridSize = () => useSlidingNumbersStore(state => state.gridSize);
|
|
273
|
-
export const useEmptyPosition = () => useSlidingNumbersStore(state => state.emptyPosition);
|
|
274
|
-
//# sourceMappingURL=SlidingNumbersStore.js.map
|
|
1
|
+
"use strict";import{create}from 'zustand';import{subscribeWithSelector}from 'zustand/middleware';import{immerMiddleware}from "../../services/UtilsService.js";export const useSlidingNumbersStore = create()(subscribeWithSelector(immerMiddleware((set,get)=>({isPlaying:false,isCompleted:false,tiles:[],gridSize:3,emptyPosition:{row:2,col:2},score:0,timeLeft:600,timeElapsed:0,startTime:null,initializePuzzle:gridSize =>{set(state =>{const tiles = [];const totalTiles = gridSize * gridSize;for(let i = 0;i < totalTiles;i++){const row = Math.floor(i / gridSize);const col = i % gridSize;const value = i === totalTiles - 1 ? 0:i + 1;tiles.push({id:i,value,position:{row,col},isCorrect:true});}state.tiles = tiles;state.gridSize = gridSize;state.emptyPosition ={row:gridSize - 1,col:gridSize - 1};state.score = 0;state.timeLeft = 600;state.timeElapsed = 0;state.isCompleted = false;state.isPlaying = false;state.startTime = null;});get().shufflePuzzle();},moveTile:tileId =>{const state = get();if(!state.isPlaying || state.isCompleted)return false;const tile = state.tiles[tileId];const emptyPos = state.emptyPosition;const rowDiff = Math.abs(tile.position.row - emptyPos.row);const colDiff = Math.abs(tile.position.col - emptyPos.col);const isAdjacent = rowDiff === 1 && colDiff === 0 || rowDiff === 0 && colDiff === 1;if(!isAdjacent)return false;set(state =>{const tile = state.tiles[tileId];if(!tile)return;const tilePos = tile.position;const emptyTileId = state.tiles.findIndex(t => t.value === 0);const emptyTile = state.tiles[emptyTileId];if(!emptyTile)return;tile.position = state.emptyPosition;emptyTile.position = tilePos;state.emptyPosition = tilePos;if(state.startTime){state.timeElapsed = Math.floor((Date.now()- state.startTime)/ 1000);}state.tiles.forEach((tile,index)=>{const correctRow = Math.floor(index / state.gridSize);const correctCol = index % state.gridSize;tile.isCorrect = tile.position.row === correctRow && tile.position.col === correctCol;});});return true;},moveTileInDirection:(tileId,direction)=>{const state = get();if(!state.isPlaying || state.isCompleted)return false;const tile = state.tiles[tileId];if(!tile)return false;const emptyPos = state.emptyPosition;let expectedEmptyPos;switch(direction){case 'up':expectedEmptyPos ={row:tile.position.row - 1,col:tile.position.col};break;case 'down':expectedEmptyPos ={row:tile.position.row + 1,col:tile.position.col};break;case 'left':expectedEmptyPos ={row:tile.position.row,col:tile.position.col - 1};break;case 'right':expectedEmptyPos ={row:tile.position.row,col:tile.position.col + 1};break;}if(emptyPos.row !== expectedEmptyPos.row || emptyPos.col !== expectedEmptyPos.col){return false;}return get().moveTile(tileId);},shufflePuzzle:()=>{const shuffleMoves = 100;set(state =>{for(let i = 0;i < shuffleMoves;i++){const emptyPos = state.emptyPosition;const possibleMoves = [];state.tiles.forEach((tile,index)=>{if(tile.value === 0)return;const rowDiff = Math.abs(tile.position.row - emptyPos.row);const colDiff = Math.abs(tile.position.col - emptyPos.col);const isAdjacent = rowDiff === 1 && colDiff === 0 || rowDiff === 0 && colDiff === 1;if(isAdjacent){possibleMoves.push(index);}});if(possibleMoves.length > 0){const randomTileIndex = Math.floor(Math.random()* possibleMoves.length);const randomTileId = possibleMoves[randomTileIndex];if(randomTileId !== undefined){const tile = state.tiles[randomTileId];const emptyTileId = state.tiles.findIndex(t => t.value === 0);const emptyTile = state.tiles[emptyTileId];if(tile && emptyTile){const tilePos = tile.position;tile.position = state.emptyPosition;emptyTile.position = tilePos;state.emptyPosition = tilePos;}}}}state.tiles.forEach((tile,index)=>{const correctRow = Math.floor(index / state.gridSize);const correctCol = index % state.gridSize;tile.isCorrect = tile.position.row === correctRow && tile.position.col === correctCol;});state.score = 0;state.timeElapsed = 0;});},startGame:()=>{set(state =>{state.isPlaying = true;state.isCompleted = false;state.startTime = Date.now();});},stopGame:()=>{const state = get();state.resetGame();},resetGame:()=>{set(state =>{state.isPlaying = false;state.isCompleted = false;state.score = 0;state.timeLeft = 600;state.timeElapsed = 0;state.startTime = null;});},decrementTime:()=>{set(state =>{if(state.timeLeft > 0){state.timeLeft--;if(state.startTime){state.timeElapsed = Math.floor((Date.now()- state.startTime)/ 1000);}}else{state.isPlaying = false;state.startTime = null;}});},checkCompletion:difficulty =>{const state = get();const allCorrect = state.tiles.every(tile => tile.isCorrect);if(allCorrect && state.isPlaying){set(state =>{state.isCompleted = true;state.isPlaying = false;const baseScore = difficulty === 'easy' ? 1000:difficulty === 'medium' ? 2000:3000;const multiplier = difficulty === 'easy' ? 5:difficulty === 'medium' ? 10:15;const timeScore = Math.max(0,baseScore - state.timeElapsed * multiplier);const remainingTimeBonus = state.timeLeft * multiplier;state.score = timeScore + remainingTimeBonus;});}},updateScore:points =>{set(state =>{state.score += points;});}}))));export const useGameState =()=> useSlidingNumbersStore(state =>({isPlaying:state.isPlaying,isCompleted:state.isCompleted}));export const useScore =()=> useSlidingNumbersStore(state => state.score);export const useTimeLeft =()=> useSlidingNumbersStore(state => state.timeLeft);export const useTimeElapsed =()=> useSlidingNumbersStore(state => state.timeElapsed);export const useTiles =()=> useSlidingNumbersStore(state => state.tiles);export const useGridSize =()=> useSlidingNumbersStore(state => state.gridSize);export const useEmptyPosition =()=> useSlidingNumbersStore(state => state.emptyPosition);
|