react-native-games 0.6.0 → 0.8.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 +148 -23
- package/lib/module/games/balloon-blaster/BalloonBlaster.js +5 -8
- package/lib/module/games/balloon-blaster/BalloonBlaster.js.map +1 -1
- package/lib/module/games/candy-crush/CandyCrush.js +121 -0
- package/lib/module/games/candy-crush/CandyCrush.js.map +1 -0
- package/lib/module/games/candy-crush/CandyCrushConstants.js +125 -0
- package/lib/module/games/candy-crush/CandyCrushConstants.js.map +1 -0
- package/lib/module/games/candy-crush/CandyCrushService.js +370 -0
- package/lib/module/games/candy-crush/CandyCrushService.js.map +1 -0
- package/lib/module/games/candy-crush/CandyCrushStore.js +305 -0
- package/lib/module/games/candy-crush/CandyCrushStore.js.map +1 -0
- package/lib/module/games/candy-crush/components/CandyItem.js +191 -0
- package/lib/module/games/candy-crush/components/CandyItem.js.map +1 -0
- package/lib/module/games/candy-crush/components/GameBackground.js +85 -0
- package/lib/module/games/candy-crush/components/GameBackground.js.map +1 -0
- package/lib/module/games/candy-crush/components/GameGrid.js +314 -0
- package/lib/module/games/candy-crush/components/GameGrid.js.map +1 -0
- package/lib/module/games/candy-crush/components/ScoreBoard.js +112 -0
- package/lib/module/games/candy-crush/components/ScoreBoard.js.map +1 -0
- package/lib/module/games/candy-crush/components/index.js +7 -0
- package/lib/module/games/candy-crush/components/index.js.map +1 -0
- package/lib/module/games/candy-crush/index.js +6 -0
- package/lib/module/games/candy-crush/index.js.map +1 -0
- package/lib/module/games/color-sort/ColorSort.js +130 -0
- package/lib/module/games/color-sort/ColorSort.js.map +1 -0
- package/lib/module/games/color-sort/ColorSortConstants.js +68 -0
- package/lib/module/games/color-sort/ColorSortConstants.js.map +1 -0
- package/lib/module/games/color-sort/ColorSortService.js +255 -0
- package/lib/module/games/color-sort/ColorSortService.js.map +1 -0
- package/lib/module/games/color-sort/ColorSortStore.js +258 -0
- package/lib/module/games/color-sort/ColorSortStore.js.map +1 -0
- package/lib/module/games/color-sort/components/ColorContainer.js +140 -0
- package/lib/module/games/color-sort/components/ColorContainer.js.map +1 -0
- package/lib/module/games/color-sort/components/GameBackground.js +135 -0
- package/lib/module/games/color-sort/components/GameBackground.js.map +1 -0
- package/lib/module/games/color-sort/components/ScoreBoard.js +78 -0
- package/lib/module/games/color-sort/components/ScoreBoard.js.map +1 -0
- package/lib/module/games/color-sort/components/index.js +6 -0
- package/lib/module/games/color-sort/components/index.js.map +1 -0
- package/lib/module/games/dino-jump/DinoJump.js +209 -0
- package/lib/module/games/dino-jump/DinoJump.js.map +1 -0
- package/lib/module/games/dino-jump/DinoJumpConstants.js +179 -0
- package/lib/module/games/dino-jump/DinoJumpConstants.js.map +1 -0
- package/lib/module/games/dino-jump/DinoJumpService.js +268 -0
- package/lib/module/games/dino-jump/DinoJumpService.js.map +1 -0
- package/lib/module/games/dino-jump/DinoJumpStore.js +387 -0
- package/lib/module/games/dino-jump/DinoJumpStore.js.map +1 -0
- package/lib/module/games/dino-jump/components/DinoSprite.js +409 -0
- package/lib/module/games/dino-jump/components/DinoSprite.js.map +1 -0
- package/lib/module/games/dino-jump/components/GameArea.js +68 -0
- package/lib/module/games/dino-jump/components/GameArea.js.map +1 -0
- package/lib/module/games/dino-jump/components/GameBackground.js +421 -0
- package/lib/module/games/dino-jump/components/GameBackground.js.map +1 -0
- package/lib/module/games/dino-jump/components/ObstacleSprite.js +306 -0
- package/lib/module/games/dino-jump/components/ObstacleSprite.js.map +1 -0
- package/lib/module/games/dino-jump/components/ScoreBoard.js +107 -0
- package/lib/module/games/dino-jump/components/ScoreBoard.js.map +1 -0
- package/lib/module/games/dino-jump/components/StarSprite.js +45 -0
- package/lib/module/games/dino-jump/components/StarSprite.js.map +1 -0
- package/lib/module/games/dino-jump/components/index.js +9 -0
- package/lib/module/games/dino-jump/components/index.js.map +1 -0
- package/lib/module/games/flappy-bird/FlappyBird.js +131 -0
- package/lib/module/games/flappy-bird/FlappyBird.js.map +1 -0
- package/lib/module/games/flappy-bird/FlappyBirdConstants.js +90 -0
- package/lib/module/games/flappy-bird/FlappyBirdConstants.js.map +1 -0
- package/lib/module/games/flappy-bird/FlappyBirdStore.js +276 -0
- package/lib/module/games/flappy-bird/FlappyBirdStore.js.map +1 -0
- package/lib/module/games/flappy-bird/components/Bird.js +87 -0
- package/lib/module/games/flappy-bird/components/Bird.js.map +1 -0
- package/lib/module/games/flappy-bird/components/GameArea.js +86 -0
- package/lib/module/games/flappy-bird/components/GameArea.js.map +1 -0
- package/lib/module/games/flappy-bird/components/GameBackground.js +112 -0
- package/lib/module/games/flappy-bird/components/GameBackground.js.map +1 -0
- package/lib/module/games/flappy-bird/components/Pipes.js +175 -0
- package/lib/module/games/flappy-bird/components/Pipes.js.map +1 -0
- package/lib/module/games/flappy-bird/components/ScoreBoard.js +72 -0
- package/lib/module/games/flappy-bird/components/ScoreBoard.js.map +1 -0
- package/lib/module/games/flappy-bird/components/index.js +8 -0
- package/lib/module/games/flappy-bird/components/index.js.map +1 -0
- package/lib/module/games/fruit-merger/FruitMerger.js +112 -0
- package/lib/module/games/fruit-merger/FruitMerger.js.map +1 -0
- package/lib/module/games/fruit-merger/FruitMergerConstants.js +119 -0
- package/lib/module/games/fruit-merger/FruitMergerConstants.js.map +1 -0
- package/lib/module/games/fruit-merger/FruitMergerService.js +13 -0
- package/lib/module/games/fruit-merger/FruitMergerService.js.map +1 -0
- package/lib/module/games/fruit-merger/FruitMergerStore.js +318 -0
- package/lib/module/games/fruit-merger/FruitMergerStore.js.map +1 -0
- package/lib/module/games/fruit-merger/components/FruitItem.js +102 -0
- package/lib/module/games/fruit-merger/components/FruitItem.js.map +1 -0
- package/lib/module/games/fruit-merger/components/GameArea.js +123 -0
- package/lib/module/games/fruit-merger/components/GameArea.js.map +1 -0
- package/lib/module/games/fruit-merger/components/GameBackground.js +477 -0
- package/lib/module/games/fruit-merger/components/GameBackground.js.map +1 -0
- package/lib/module/games/fruit-merger/components/ScoreBoard.js +66 -0
- package/lib/module/games/fruit-merger/components/ScoreBoard.js.map +1 -0
- package/lib/module/games/fruit-merger/components/index.js +7 -0
- package/lib/module/games/fruit-merger/components/index.js.map +1 -0
- package/lib/module/games/fruit-ninja/FruitNinja.js +6 -9
- package/lib/module/games/fruit-ninja/FruitNinja.js.map +1 -1
- package/lib/module/games/game-2048/Game2048.js +120 -0
- package/lib/module/games/game-2048/Game2048.js.map +1 -0
- package/lib/module/games/game-2048/Game2048Constants.js +263 -0
- package/lib/module/games/game-2048/Game2048Constants.js.map +1 -0
- package/lib/module/games/game-2048/Game2048Service.js +457 -0
- package/lib/module/games/game-2048/Game2048Service.js.map +1 -0
- package/lib/module/games/game-2048/Game2048Store.js +238 -0
- package/lib/module/games/game-2048/Game2048Store.js.map +1 -0
- package/lib/module/games/game-2048/components/GameBackground.js +247 -0
- package/lib/module/games/game-2048/components/GameBackground.js.map +1 -0
- package/lib/module/games/game-2048/components/GameGrid.js +139 -0
- package/lib/module/games/game-2048/components/GameGrid.js.map +1 -0
- package/lib/module/games/game-2048/components/GameTile.js +72 -0
- package/lib/module/games/game-2048/components/GameTile.js.map +1 -0
- package/lib/module/games/game-2048/components/ScoreBoard.js +70 -0
- package/lib/module/games/game-2048/components/ScoreBoard.js.map +1 -0
- package/lib/module/games/game-2048/components/index.js +7 -0
- package/lib/module/games/game-2048/components/index.js.map +1 -0
- package/lib/module/games/maze-runner/MazeRunner.js +33 -31
- package/lib/module/games/maze-runner/MazeRunner.js.map +1 -1
- package/lib/module/games/popit-fidget/PopitFidget.js +34 -32
- package/lib/module/games/popit-fidget/PopitFidget.js.map +1 -1
- package/lib/module/games/sliding-numbers/SlidingNumbers.js +161 -0
- package/lib/module/games/sliding-numbers/SlidingNumbers.js.map +1 -0
- package/lib/module/games/sliding-numbers/SlidingNumbersConstants.js +207 -0
- package/lib/module/games/sliding-numbers/SlidingNumbersConstants.js.map +1 -0
- package/lib/module/games/sliding-numbers/SlidingNumbersService.js +248 -0
- package/lib/module/games/sliding-numbers/SlidingNumbersService.js.map +1 -0
- package/lib/module/games/sliding-numbers/SlidingNumbersStore.js +275 -0
- package/lib/module/games/sliding-numbers/SlidingNumbersStore.js.map +1 -0
- package/lib/module/games/sliding-numbers/components/GameBackground.js +259 -0
- package/lib/module/games/sliding-numbers/components/GameBackground.js.map +1 -0
- package/lib/module/games/sliding-numbers/components/NumbersGrid.js +174 -0
- package/lib/module/games/sliding-numbers/components/NumbersGrid.js.map +1 -0
- package/lib/module/games/sliding-numbers/components/NumbersTile.js +116 -0
- package/lib/module/games/sliding-numbers/components/NumbersTile.js.map +1 -0
- package/lib/module/games/sliding-numbers/components/ScoreBoard.js +66 -0
- package/lib/module/games/sliding-numbers/components/ScoreBoard.js.map +1 -0
- package/lib/module/games/sliding-numbers/components/index.js +7 -0
- package/lib/module/games/sliding-numbers/components/index.js.map +1 -0
- package/lib/module/games/snake/Snake.js +192 -0
- package/lib/module/games/snake/Snake.js.map +1 -0
- package/lib/module/games/snake/SnakeConstants.js +138 -0
- package/lib/module/games/snake/SnakeConstants.js.map +1 -0
- package/lib/module/games/snake/SnakeService.js +148 -0
- package/lib/module/games/snake/SnakeService.js.map +1 -0
- package/lib/module/games/snake/SnakeStore.js +184 -0
- package/lib/module/games/snake/SnakeStore.js.map +1 -0
- package/lib/module/games/snake/components/GameBackground.js +221 -0
- package/lib/module/games/snake/components/GameBackground.js.map +1 -0
- package/lib/module/games/snake/components/GameGrid.js +153 -0
- package/lib/module/games/snake/components/GameGrid.js.map +1 -0
- package/lib/module/games/snake/components/ScoreBoard.js +57 -0
- package/lib/module/games/snake/components/ScoreBoard.js.map +1 -0
- package/lib/module/games/snake/components/index.js +6 -0
- package/lib/module/games/snake/components/index.js.map +1 -0
- package/lib/module/games/snake/index.js +6 -0
- package/lib/module/games/snake/index.js.map +1 -0
- package/lib/module/games/space-fighter/SpaceFighter.js +7 -10
- package/lib/module/games/space-fighter/SpaceFighter.js.map +1 -1
- package/lib/module/games/whack-a-mole/WhackAMole.js +6 -6
- package/lib/module/games/whack-a-mole/WhackAMole.js.map +1 -1
- package/lib/module/games/whack-a-mole/components/GameBackground.js +7 -8
- package/lib/module/games/whack-a-mole/components/GameBackground.js.map +1 -1
- package/lib/module/index.js +8 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/services/GamesConstants.js +58 -2
- package/lib/module/services/GamesConstants.js.map +1 -1
- package/lib/module/services/GamesService.js +40 -0
- package/lib/module/services/GamesService.js.map +1 -1
- package/lib/module/services/SoundsService.js +132 -1
- package/lib/module/services/SoundsService.js.map +1 -1
- package/lib/module/shared/helpers/GameOverModal.js +6 -3
- package/lib/module/shared/helpers/GameOverModal.js.map +1 -1
- package/lib/module/shared/helpers/GameSettingsModal.js +3 -3
- package/lib/module/shared/helpers/GameSettingsModal.js.map +1 -1
- package/lib/module/shared/helpers/ParticleBlast.js +3 -2
- package/lib/module/shared/helpers/ParticleBlast.js.map +1 -1
- package/lib/typescript/src/games/balloon-blaster/BalloonBlaster.d.ts.map +1 -1
- package/lib/typescript/src/games/candy-crush/CandyCrush.d.ts +4 -0
- package/lib/typescript/src/games/candy-crush/CandyCrush.d.ts.map +1 -0
- package/lib/typescript/src/games/candy-crush/CandyCrushConstants.d.ts +104 -0
- package/lib/typescript/src/games/candy-crush/CandyCrushConstants.d.ts.map +1 -0
- package/lib/typescript/src/games/candy-crush/CandyCrushService.d.ts +40 -0
- package/lib/typescript/src/games/candy-crush/CandyCrushService.d.ts.map +1 -0
- package/lib/typescript/src/games/candy-crush/CandyCrushStore.d.ts +48 -0
- package/lib/typescript/src/games/candy-crush/CandyCrushStore.d.ts.map +1 -0
- package/lib/typescript/src/games/candy-crush/components/CandyItem.d.ts +13 -0
- package/lib/typescript/src/games/candy-crush/components/CandyItem.d.ts.map +1 -0
- package/lib/typescript/src/games/candy-crush/components/GameBackground.d.ts +5 -0
- package/lib/typescript/src/games/candy-crush/components/GameBackground.d.ts.map +1 -0
- package/lib/typescript/src/games/candy-crush/components/GameGrid.d.ts +3 -0
- package/lib/typescript/src/games/candy-crush/components/GameGrid.d.ts.map +1 -0
- package/lib/typescript/src/games/candy-crush/components/ScoreBoard.d.ts +3 -0
- package/lib/typescript/src/games/candy-crush/components/ScoreBoard.d.ts.map +1 -0
- package/lib/typescript/src/games/candy-crush/components/index.d.ts +5 -0
- package/lib/typescript/src/games/candy-crush/components/index.d.ts.map +1 -0
- package/lib/typescript/src/games/candy-crush/index.d.ts +4 -0
- package/lib/typescript/src/games/candy-crush/index.d.ts.map +1 -0
- package/lib/typescript/src/games/color-sort/ColorSort.d.ts +4 -0
- package/lib/typescript/src/games/color-sort/ColorSort.d.ts.map +1 -0
- package/lib/typescript/src/games/color-sort/ColorSortConstants.d.ts +52 -0
- package/lib/typescript/src/games/color-sort/ColorSortConstants.d.ts.map +1 -0
- package/lib/typescript/src/games/color-sort/ColorSortService.d.ts +66 -0
- package/lib/typescript/src/games/color-sort/ColorSortService.d.ts.map +1 -0
- package/lib/typescript/src/games/color-sort/ColorSortStore.d.ts +48 -0
- package/lib/typescript/src/games/color-sort/ColorSortStore.d.ts.map +1 -0
- package/lib/typescript/src/games/color-sort/components/ColorContainer.d.ts +11 -0
- package/lib/typescript/src/games/color-sort/components/ColorContainer.d.ts.map +1 -0
- package/lib/typescript/src/games/color-sort/components/GameBackground.d.ts +7 -0
- package/lib/typescript/src/games/color-sort/components/GameBackground.d.ts.map +1 -0
- package/lib/typescript/src/games/color-sort/components/ScoreBoard.d.ts +3 -0
- package/lib/typescript/src/games/color-sort/components/ScoreBoard.d.ts.map +1 -0
- package/lib/typescript/src/games/color-sort/components/index.d.ts +4 -0
- package/lib/typescript/src/games/color-sort/components/index.d.ts.map +1 -0
- package/lib/typescript/src/games/dino-jump/DinoJump.d.ts +4 -0
- package/lib/typescript/src/games/dino-jump/DinoJump.d.ts.map +1 -0
- package/lib/typescript/src/games/dino-jump/DinoJumpConstants.d.ts +95 -0
- package/lib/typescript/src/games/dino-jump/DinoJumpConstants.d.ts.map +1 -0
- package/lib/typescript/src/games/dino-jump/DinoJumpService.d.ts +40 -0
- package/lib/typescript/src/games/dino-jump/DinoJumpService.d.ts.map +1 -0
- package/lib/typescript/src/games/dino-jump/DinoJumpStore.d.ts +103 -0
- package/lib/typescript/src/games/dino-jump/DinoJumpStore.d.ts.map +1 -0
- package/lib/typescript/src/games/dino-jump/components/DinoSprite.d.ts +3 -0
- package/lib/typescript/src/games/dino-jump/components/DinoSprite.d.ts.map +1 -0
- package/lib/typescript/src/games/dino-jump/components/GameArea.d.ts +8 -0
- package/lib/typescript/src/games/dino-jump/components/GameArea.d.ts.map +1 -0
- package/lib/typescript/src/games/dino-jump/components/GameBackground.d.ts +7 -0
- package/lib/typescript/src/games/dino-jump/components/GameBackground.d.ts.map +1 -0
- package/lib/typescript/src/games/dino-jump/components/ObstacleSprite.d.ts +3 -0
- package/lib/typescript/src/games/dino-jump/components/ObstacleSprite.d.ts.map +1 -0
- package/lib/typescript/src/games/dino-jump/components/ScoreBoard.d.ts +3 -0
- package/lib/typescript/src/games/dino-jump/components/ScoreBoard.d.ts.map +1 -0
- package/lib/typescript/src/games/dino-jump/components/StarSprite.d.ts +3 -0
- package/lib/typescript/src/games/dino-jump/components/StarSprite.d.ts.map +1 -0
- package/lib/typescript/src/games/dino-jump/components/index.d.ts +7 -0
- package/lib/typescript/src/games/dino-jump/components/index.d.ts.map +1 -0
- package/lib/typescript/src/games/flappy-bird/FlappyBird.d.ts +4 -0
- package/lib/typescript/src/games/flappy-bird/FlappyBird.d.ts.map +1 -0
- package/lib/typescript/src/games/flappy-bird/FlappyBirdConstants.d.ts +83 -0
- package/lib/typescript/src/games/flappy-bird/FlappyBirdConstants.d.ts.map +1 -0
- package/lib/typescript/src/games/flappy-bird/FlappyBirdStore.d.ts +53 -0
- package/lib/typescript/src/games/flappy-bird/FlappyBirdStore.d.ts.map +1 -0
- package/lib/typescript/src/games/flappy-bird/components/Bird.d.ts +8 -0
- package/lib/typescript/src/games/flappy-bird/components/Bird.d.ts.map +1 -0
- package/lib/typescript/src/games/flappy-bird/components/GameArea.d.ts +8 -0
- package/lib/typescript/src/games/flappy-bird/components/GameArea.d.ts.map +1 -0
- package/lib/typescript/src/games/flappy-bird/components/GameBackground.d.ts +7 -0
- package/lib/typescript/src/games/flappy-bird/components/GameBackground.d.ts.map +1 -0
- package/lib/typescript/src/games/flappy-bird/components/Pipes.d.ts +8 -0
- package/lib/typescript/src/games/flappy-bird/components/Pipes.d.ts.map +1 -0
- package/lib/typescript/src/games/flappy-bird/components/ScoreBoard.d.ts +3 -0
- package/lib/typescript/src/games/flappy-bird/components/ScoreBoard.d.ts.map +1 -0
- package/lib/typescript/src/games/flappy-bird/components/index.d.ts +6 -0
- package/lib/typescript/src/games/flappy-bird/components/index.d.ts.map +1 -0
- package/lib/typescript/src/games/fruit-merger/FruitMerger.d.ts +4 -0
- package/lib/typescript/src/games/fruit-merger/FruitMerger.d.ts.map +1 -0
- package/lib/typescript/src/games/fruit-merger/FruitMergerConstants.d.ts +115 -0
- package/lib/typescript/src/games/fruit-merger/FruitMergerConstants.d.ts.map +1 -0
- package/lib/typescript/src/games/fruit-merger/FruitMergerService.d.ts +5 -0
- package/lib/typescript/src/games/fruit-merger/FruitMergerService.d.ts.map +1 -0
- package/lib/typescript/src/games/fruit-merger/FruitMergerStore.d.ts +43 -0
- package/lib/typescript/src/games/fruit-merger/FruitMergerStore.d.ts.map +1 -0
- package/lib/typescript/src/games/fruit-merger/components/FruitItem.d.ts +10 -0
- package/lib/typescript/src/games/fruit-merger/components/FruitItem.d.ts.map +1 -0
- package/lib/typescript/src/games/fruit-merger/components/GameArea.d.ts +8 -0
- package/lib/typescript/src/games/fruit-merger/components/GameArea.d.ts.map +1 -0
- package/lib/typescript/src/games/fruit-merger/components/GameBackground.d.ts +7 -0
- package/lib/typescript/src/games/fruit-merger/components/GameBackground.d.ts.map +1 -0
- package/lib/typescript/src/games/fruit-merger/components/ScoreBoard.d.ts +3 -0
- package/lib/typescript/src/games/fruit-merger/components/ScoreBoard.d.ts.map +1 -0
- package/lib/typescript/src/games/fruit-merger/components/index.d.ts +5 -0
- package/lib/typescript/src/games/fruit-merger/components/index.d.ts.map +1 -0
- package/lib/typescript/src/games/fruit-ninja/FruitNinja.d.ts.map +1 -1
- package/lib/typescript/src/games/game-2048/Game2048.d.ts +4 -0
- package/lib/typescript/src/games/game-2048/Game2048.d.ts.map +1 -0
- package/lib/typescript/src/games/game-2048/Game2048Constants.d.ts +163 -0
- package/lib/typescript/src/games/game-2048/Game2048Constants.d.ts.map +1 -0
- package/lib/typescript/src/games/game-2048/Game2048Service.d.ts +113 -0
- package/lib/typescript/src/games/game-2048/Game2048Service.d.ts.map +1 -0
- package/lib/typescript/src/games/game-2048/Game2048Store.d.ts +48 -0
- package/lib/typescript/src/games/game-2048/Game2048Store.d.ts.map +1 -0
- package/lib/typescript/src/games/game-2048/components/GameBackground.d.ts +7 -0
- package/lib/typescript/src/games/game-2048/components/GameBackground.d.ts.map +1 -0
- package/lib/typescript/src/games/game-2048/components/GameGrid.d.ts +7 -0
- package/lib/typescript/src/games/game-2048/components/GameGrid.d.ts.map +1 -0
- package/lib/typescript/src/games/game-2048/components/GameTile.d.ts +13 -0
- package/lib/typescript/src/games/game-2048/components/GameTile.d.ts.map +1 -0
- package/lib/typescript/src/games/game-2048/components/ScoreBoard.d.ts +3 -0
- package/lib/typescript/src/games/game-2048/components/ScoreBoard.d.ts.map +1 -0
- package/lib/typescript/src/games/game-2048/components/index.d.ts +5 -0
- package/lib/typescript/src/games/game-2048/components/index.d.ts.map +1 -0
- 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 +4 -0
- package/lib/typescript/src/games/sliding-numbers/SlidingNumbers.d.ts.map +1 -0
- package/lib/typescript/src/games/sliding-numbers/SlidingNumbersConstants.d.ts +108 -0
- package/lib/typescript/src/games/sliding-numbers/SlidingNumbersConstants.d.ts.map +1 -0
- package/lib/typescript/src/games/sliding-numbers/SlidingNumbersService.d.ts +34 -0
- package/lib/typescript/src/games/sliding-numbers/SlidingNumbersService.d.ts.map +1 -0
- package/lib/typescript/src/games/sliding-numbers/SlidingNumbersStore.d.ts +56 -0
- package/lib/typescript/src/games/sliding-numbers/SlidingNumbersStore.d.ts.map +1 -0
- package/lib/typescript/src/games/sliding-numbers/components/GameBackground.d.ts +7 -0
- package/lib/typescript/src/games/sliding-numbers/components/GameBackground.d.ts.map +1 -0
- package/lib/typescript/src/games/sliding-numbers/components/NumbersGrid.d.ts +7 -0
- package/lib/typescript/src/games/sliding-numbers/components/NumbersGrid.d.ts.map +1 -0
- package/lib/typescript/src/games/sliding-numbers/components/NumbersTile.d.ts +11 -0
- package/lib/typescript/src/games/sliding-numbers/components/NumbersTile.d.ts.map +1 -0
- package/lib/typescript/src/games/sliding-numbers/components/ScoreBoard.d.ts +3 -0
- package/lib/typescript/src/games/sliding-numbers/components/ScoreBoard.d.ts.map +1 -0
- package/lib/typescript/src/games/sliding-numbers/components/index.d.ts +5 -0
- package/lib/typescript/src/games/sliding-numbers/components/index.d.ts.map +1 -0
- package/lib/typescript/src/games/snake/Snake.d.ts +4 -0
- package/lib/typescript/src/games/snake/Snake.d.ts.map +1 -0
- package/lib/typescript/src/games/snake/SnakeConstants.d.ts +93 -0
- package/lib/typescript/src/games/snake/SnakeConstants.d.ts.map +1 -0
- package/lib/typescript/src/games/snake/SnakeService.d.ts +30 -0
- package/lib/typescript/src/games/snake/SnakeService.d.ts.map +1 -0
- package/lib/typescript/src/games/snake/SnakeStore.d.ts +43 -0
- package/lib/typescript/src/games/snake/SnakeStore.d.ts.map +1 -0
- package/lib/typescript/src/games/snake/components/GameBackground.d.ts +5 -0
- package/lib/typescript/src/games/snake/components/GameBackground.d.ts.map +1 -0
- package/lib/typescript/src/games/snake/components/GameGrid.d.ts +3 -0
- package/lib/typescript/src/games/snake/components/GameGrid.d.ts.map +1 -0
- package/lib/typescript/src/games/snake/components/ScoreBoard.d.ts +3 -0
- package/lib/typescript/src/games/snake/components/ScoreBoard.d.ts.map +1 -0
- package/lib/typescript/src/games/snake/components/index.d.ts +4 -0
- package/lib/typescript/src/games/snake/components/index.d.ts.map +1 -0
- package/lib/typescript/src/games/snake/index.d.ts +4 -0
- package/lib/typescript/src/games/snake/index.d.ts.map +1 -0
- 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/components/GameBackground.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +8 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/services/GamesConstants.d.ts +156 -0
- package/lib/typescript/src/services/GamesConstants.d.ts.map +1 -1
- package/lib/typescript/src/services/GamesService.d.ts +10 -2
- package/lib/typescript/src/services/GamesService.d.ts.map +1 -1
- package/lib/typescript/src/services/SoundsService.d.ts +103 -0
- package/lib/typescript/src/services/SoundsService.d.ts.map +1 -1
- package/lib/typescript/src/shared/helpers/GameOverModal.d.ts +2 -0
- package/lib/typescript/src/shared/helpers/GameOverModal.d.ts.map +1 -1
- package/lib/typescript/src/shared/helpers/ParticleBlast.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { Animated } from 'react-native';
|
|
4
|
+
import { CANDY_CRUSH_GAME_CONFIG, CANDY_COLORS, CANDY_TYPES } from "./CandyCrushConstants.js";
|
|
5
|
+
export class CandyCrushService {
|
|
6
|
+
nextCandyId = 1;
|
|
7
|
+
|
|
8
|
+
// Create empty grid
|
|
9
|
+
createGrid() {
|
|
10
|
+
return Array(CANDY_CRUSH_GAME_CONFIG.GRID_SIZE).fill(null).map(() => Array(CANDY_CRUSH_GAME_CONFIG.GRID_SIZE).fill(null));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// Initialize grid with random candies (ensuring no initial matches)
|
|
14
|
+
initializeGrid(candyTypes) {
|
|
15
|
+
const grid = this.createGrid();
|
|
16
|
+
const size = CANDY_CRUSH_GAME_CONFIG.GRID_SIZE;
|
|
17
|
+
for (let row = 0; row < size; row++) {
|
|
18
|
+
for (let col = 0; col < size; col++) {
|
|
19
|
+
let candyType;
|
|
20
|
+
let attempts = 0;
|
|
21
|
+
|
|
22
|
+
// Generate candy type that doesn't create initial matches
|
|
23
|
+
do {
|
|
24
|
+
candyType = Math.floor(Math.random() * candyTypes);
|
|
25
|
+
attempts++;
|
|
26
|
+
} while (attempts < 10 && this.wouldCreateMatch(grid, row, col, candyType));
|
|
27
|
+
const candy = {
|
|
28
|
+
id: this.nextCandyId++,
|
|
29
|
+
row,
|
|
30
|
+
col,
|
|
31
|
+
type: candyType,
|
|
32
|
+
specialType: CANDY_TYPES.NORMAL,
|
|
33
|
+
animatedValue: new Animated.Value(1),
|
|
34
|
+
scaleValue: new Animated.Value(1),
|
|
35
|
+
isMatched: false,
|
|
36
|
+
isFalling: false
|
|
37
|
+
};
|
|
38
|
+
const gridRow = grid[row];
|
|
39
|
+
if (gridRow) {
|
|
40
|
+
gridRow[col] = candy;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return grid;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Check if placing candy would create a match
|
|
48
|
+
wouldCreateMatch(grid, row, col, type) {
|
|
49
|
+
// Check horizontal
|
|
50
|
+
let horizontalCount = 1;
|
|
51
|
+
|
|
52
|
+
// Check left
|
|
53
|
+
for (let c = col - 1; c >= 0; c--) {
|
|
54
|
+
const gridRow = grid[row];
|
|
55
|
+
const candy = gridRow ? gridRow[c] : null;
|
|
56
|
+
if (candy && candy.type === type) {
|
|
57
|
+
horizontalCount++;
|
|
58
|
+
} else {
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Check right
|
|
64
|
+
for (let c = col + 1; c < CANDY_CRUSH_GAME_CONFIG.GRID_SIZE; c++) {
|
|
65
|
+
const gridRow = grid[row];
|
|
66
|
+
const candy = gridRow ? gridRow[c] : null;
|
|
67
|
+
if (candy && candy.type === type) {
|
|
68
|
+
horizontalCount++;
|
|
69
|
+
} else {
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (horizontalCount >= CANDY_CRUSH_GAME_CONFIG.MIN_MATCH) {
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Check vertical
|
|
78
|
+
let verticalCount = 1;
|
|
79
|
+
|
|
80
|
+
// Check up
|
|
81
|
+
for (let r = row - 1; r >= 0; r--) {
|
|
82
|
+
const gridRow = grid[r];
|
|
83
|
+
const candy = gridRow ? gridRow[col] : null;
|
|
84
|
+
if (candy && candy.type === type) {
|
|
85
|
+
verticalCount++;
|
|
86
|
+
} else {
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Check down
|
|
92
|
+
for (let r = row + 1; r < CANDY_CRUSH_GAME_CONFIG.GRID_SIZE; r++) {
|
|
93
|
+
const gridRow = grid[r];
|
|
94
|
+
const candy = gridRow ? gridRow[col] : null;
|
|
95
|
+
if (candy && candy.type === type) {
|
|
96
|
+
verticalCount++;
|
|
97
|
+
} else {
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return verticalCount >= CANDY_CRUSH_GAME_CONFIG.MIN_MATCH;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Check if two candies can be swapped
|
|
105
|
+
canSwap(candy1, candy2) {
|
|
106
|
+
const rowDiff = Math.abs(candy1.row - candy2.row);
|
|
107
|
+
const colDiff = Math.abs(candy1.col - candy2.col);
|
|
108
|
+
|
|
109
|
+
// Must be adjacent (horizontally or vertically)
|
|
110
|
+
return rowDiff === 1 && colDiff === 0 || rowDiff === 0 && colDiff === 1;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Swap two candies
|
|
114
|
+
swapCandies(grid, candy1, candy2) {
|
|
115
|
+
const row1 = candy1.row;
|
|
116
|
+
const col1 = candy1.col;
|
|
117
|
+
const row2 = candy2.row;
|
|
118
|
+
const col2 = candy2.col;
|
|
119
|
+
|
|
120
|
+
// Get references from grid
|
|
121
|
+
const gridRow1 = grid[row1];
|
|
122
|
+
const gridRow2 = grid[row2];
|
|
123
|
+
if (gridRow1 && gridRow2) {
|
|
124
|
+
const temp1 = gridRow1[col1];
|
|
125
|
+
const temp2 = gridRow2[col2];
|
|
126
|
+
|
|
127
|
+
// Swap in grid
|
|
128
|
+
gridRow1[col1] = temp2 || null;
|
|
129
|
+
gridRow2[col2] = temp1 || null;
|
|
130
|
+
|
|
131
|
+
// Update positions (these are mutable in Immer draft)
|
|
132
|
+
if (temp1) {
|
|
133
|
+
temp1.row = row2;
|
|
134
|
+
temp1.col = col2;
|
|
135
|
+
}
|
|
136
|
+
if (temp2) {
|
|
137
|
+
temp2.row = row1;
|
|
138
|
+
temp2.col = col1;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Find all matches in the grid
|
|
144
|
+
findMatches(grid) {
|
|
145
|
+
const matches = [];
|
|
146
|
+
const matchedSet = new Set();
|
|
147
|
+
const size = CANDY_CRUSH_GAME_CONFIG.GRID_SIZE;
|
|
148
|
+
|
|
149
|
+
// Check horizontal matches
|
|
150
|
+
for (let row = 0; row < size; row++) {
|
|
151
|
+
for (let col = 0; col < size - 2; col++) {
|
|
152
|
+
const gridRow = grid[row];
|
|
153
|
+
if (!gridRow) continue;
|
|
154
|
+
const candy1 = gridRow[col];
|
|
155
|
+
const candy2 = gridRow[col + 1];
|
|
156
|
+
const candy3 = gridRow[col + 2];
|
|
157
|
+
if (candy1 && candy2 && candy3 && candy1.type === candy2.type && candy2.type === candy3.type) {
|
|
158
|
+
let matchLength = 3;
|
|
159
|
+
const matchCandies = [candy1, candy2, candy3];
|
|
160
|
+
|
|
161
|
+
// Check for longer matches
|
|
162
|
+
for (let c = col + 3; c < size; c++) {
|
|
163
|
+
const nextCandy = gridRow[c];
|
|
164
|
+
if (nextCandy && nextCandy.type === candy1.type) {
|
|
165
|
+
matchLength++;
|
|
166
|
+
matchCandies.push(nextCandy);
|
|
167
|
+
} else {
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// Add to matches
|
|
173
|
+
matchCandies.forEach(candy => {
|
|
174
|
+
if (!matchedSet.has(candy.id)) {
|
|
175
|
+
matchedSet.add(candy.id);
|
|
176
|
+
matches.push(candy);
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
col += matchLength - 1;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// Check vertical matches
|
|
185
|
+
for (let col = 0; col < size; col++) {
|
|
186
|
+
for (let row = 0; row < size - 2; row++) {
|
|
187
|
+
const gridRow1 = grid[row];
|
|
188
|
+
const gridRow2 = grid[row + 1];
|
|
189
|
+
const gridRow3 = grid[row + 2];
|
|
190
|
+
if (!gridRow1 || !gridRow2 || !gridRow3) continue;
|
|
191
|
+
const candy1 = gridRow1[col];
|
|
192
|
+
const candy2 = gridRow2[col];
|
|
193
|
+
const candy3 = gridRow3[col];
|
|
194
|
+
if (candy1 && candy2 && candy3 && candy1.type === candy2.type && candy2.type === candy3.type) {
|
|
195
|
+
let matchLength = 3;
|
|
196
|
+
const matchCandies = [candy1, candy2, candy3];
|
|
197
|
+
|
|
198
|
+
// Check for longer matches
|
|
199
|
+
for (let r = row + 3; r < size; r++) {
|
|
200
|
+
const nextRow = grid[r];
|
|
201
|
+
const nextCandy = nextRow ? nextRow[col] : null;
|
|
202
|
+
if (nextCandy && nextCandy.type === candy1.type) {
|
|
203
|
+
matchLength++;
|
|
204
|
+
matchCandies.push(nextCandy);
|
|
205
|
+
} else {
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// Add to matches
|
|
211
|
+
matchCandies.forEach(candy => {
|
|
212
|
+
if (!matchedSet.has(candy.id)) {
|
|
213
|
+
matchedSet.add(candy.id);
|
|
214
|
+
matches.push(candy);
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
row += matchLength - 1;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
const score = matches.length * CANDY_CRUSH_GAME_CONFIG.POINTS_PER_CANDY;
|
|
222
|
+
return {
|
|
223
|
+
matches,
|
|
224
|
+
score,
|
|
225
|
+
hasMatches: matches.length > 0
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// Remove matched candies from grid
|
|
230
|
+
removeMatches(grid, matches) {
|
|
231
|
+
matches.forEach(candy => {
|
|
232
|
+
const gridRow = grid[candy.row];
|
|
233
|
+
if (gridRow) {
|
|
234
|
+
gridRow[candy.col] = null;
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// Apply gravity - make candies fall down
|
|
240
|
+
applyGravity(grid) {
|
|
241
|
+
let hasMoved = false;
|
|
242
|
+
const size = CANDY_CRUSH_GAME_CONFIG.GRID_SIZE;
|
|
243
|
+
|
|
244
|
+
// Process from bottom to top
|
|
245
|
+
for (let col = 0; col < size; col++) {
|
|
246
|
+
for (let row = size - 1; row >= 0; row--) {
|
|
247
|
+
const gridRow = grid[row];
|
|
248
|
+
if (!gridRow) continue;
|
|
249
|
+
const candy = gridRow[col];
|
|
250
|
+
if (candy) {
|
|
251
|
+
// Find the lowest empty position below this candy
|
|
252
|
+
let newRow = row;
|
|
253
|
+
for (let r = row + 1; r < size; r++) {
|
|
254
|
+
const checkRow = grid[r];
|
|
255
|
+
if (checkRow && !checkRow[col]) {
|
|
256
|
+
newRow = r;
|
|
257
|
+
} else {
|
|
258
|
+
break;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// Move candy down if there's an empty space
|
|
263
|
+
if (newRow !== row) {
|
|
264
|
+
const targetRow = grid[newRow];
|
|
265
|
+
if (targetRow) {
|
|
266
|
+
targetRow[col] = candy;
|
|
267
|
+
gridRow[col] = null;
|
|
268
|
+
candy.row = newRow;
|
|
269
|
+
candy.isFalling = true;
|
|
270
|
+
hasMoved = true;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
return hasMoved;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// Fill empty spaces with new candies
|
|
280
|
+
fillEmptySpaces(grid, candyTypes) {
|
|
281
|
+
const newCandies = [];
|
|
282
|
+
const size = CANDY_CRUSH_GAME_CONFIG.GRID_SIZE;
|
|
283
|
+
for (let col = 0; col < size; col++) {
|
|
284
|
+
// Count empty spaces in this column
|
|
285
|
+
let emptyCount = 0;
|
|
286
|
+
for (let row = 0; row < size; row++) {
|
|
287
|
+
const gridRow = grid[row];
|
|
288
|
+
if (gridRow && !gridRow[col]) {
|
|
289
|
+
emptyCount++;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// Fill from top
|
|
294
|
+
for (let i = 0; i < emptyCount; i++) {
|
|
295
|
+
const row = i;
|
|
296
|
+
const candy = {
|
|
297
|
+
id: this.nextCandyId++,
|
|
298
|
+
row,
|
|
299
|
+
col,
|
|
300
|
+
type: Math.floor(Math.random() * candyTypes),
|
|
301
|
+
specialType: CANDY_TYPES.NORMAL,
|
|
302
|
+
animatedValue: new Animated.Value(0),
|
|
303
|
+
scaleValue: new Animated.Value(1),
|
|
304
|
+
isMatched: false,
|
|
305
|
+
isFalling: true
|
|
306
|
+
};
|
|
307
|
+
const gridRow = grid[row];
|
|
308
|
+
if (gridRow) {
|
|
309
|
+
gridRow[col] = candy;
|
|
310
|
+
newCandies.push(candy);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
return newCandies;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// Check if there are any possible moves
|
|
318
|
+
hasPossibleMoves(grid) {
|
|
319
|
+
const size = CANDY_CRUSH_GAME_CONFIG.GRID_SIZE;
|
|
320
|
+
for (let row = 0; row < size; row++) {
|
|
321
|
+
for (let col = 0; col < size; col++) {
|
|
322
|
+
const gridRow = grid[row];
|
|
323
|
+
if (!gridRow) continue;
|
|
324
|
+
const candy = gridRow[col];
|
|
325
|
+
if (!candy) continue;
|
|
326
|
+
|
|
327
|
+
// Try swapping with right neighbor
|
|
328
|
+
if (col < size - 1) {
|
|
329
|
+
const rightCandy = gridRow[col + 1];
|
|
330
|
+
if (rightCandy) {
|
|
331
|
+
this.swapCandies(grid, candy, rightCandy);
|
|
332
|
+
const result = this.findMatches(grid);
|
|
333
|
+
this.swapCandies(grid, candy, rightCandy); // Swap back
|
|
334
|
+
|
|
335
|
+
if (result.hasMatches) {
|
|
336
|
+
return true;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
// Try swapping with bottom neighbor
|
|
342
|
+
if (row < size - 1) {
|
|
343
|
+
const bottomRow = grid[row + 1];
|
|
344
|
+
const bottomCandy = bottomRow ? bottomRow[col] : null;
|
|
345
|
+
if (bottomCandy) {
|
|
346
|
+
this.swapCandies(grid, candy, bottomCandy);
|
|
347
|
+
const result = this.findMatches(grid);
|
|
348
|
+
this.swapCandies(grid, candy, bottomCandy); // Swap back
|
|
349
|
+
|
|
350
|
+
if (result.hasMatches) {
|
|
351
|
+
return true;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
return false;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
// Get candy color
|
|
361
|
+
getCandyColor(type) {
|
|
362
|
+
return CANDY_COLORS[type % CANDY_COLORS.length] || CANDY_COLORS[0];
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
// Reset candy ID counter
|
|
366
|
+
resetIdCounter() {
|
|
367
|
+
this.nextCandyId = 1;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
//# sourceMappingURL=CandyCrushService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Animated","CANDY_CRUSH_GAME_CONFIG","CANDY_COLORS","CANDY_TYPES","CandyCrushService","nextCandyId","createGrid","Array","GRID_SIZE","fill","map","initializeGrid","candyTypes","grid","size","row","col","candyType","attempts","Math","floor","random","wouldCreateMatch","candy","id","type","specialType","NORMAL","animatedValue","Value","scaleValue","isMatched","isFalling","gridRow","horizontalCount","c","MIN_MATCH","verticalCount","r","canSwap","candy1","candy2","rowDiff","abs","colDiff","swapCandies","row1","col1","row2","col2","gridRow1","gridRow2","temp1","temp2","findMatches","matches","matchedSet","Set","candy3","matchLength","matchCandies","nextCandy","push","forEach","has","add","gridRow3","nextRow","score","length","POINTS_PER_CANDY","hasMatches","removeMatches","applyGravity","hasMoved","newRow","checkRow","targetRow","fillEmptySpaces","newCandies","emptyCount","i","hasPossibleMoves","rightCandy","result","bottomRow","bottomCandy","getCandyColor","resetIdCounter"],"sourceRoot":"../../../../src","sources":["games/candy-crush/CandyCrushService.ts"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,cAAc;AACvC,SAASC,uBAAuB,EAAEC,YAAY,EAAEC,WAAW,QAAQ,0BAAuB;AA6B1F,OAAO,MAAMC,iBAAiB,CAAC;EACrBC,WAAW,GAAG,CAAC;;EAEvB;EACAC,UAAUA,CAAA,EAAc;IACtB,OAAOC,KAAK,CAACN,uBAAuB,CAACO,SAAS,CAAC,CAC5CC,IAAI,CAAC,IAAI,CAAC,CACVC,GAAG,CAAC,MAAMH,KAAK,CAACN,uBAAuB,CAACO,SAAS,CAAC,CAACC,IAAI,CAAC,I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UAAU,CAAC,CAAC,CAAC;;YAE3C,IAAIC,MAAM,CAACb,UAAU,EAAE;cACrB,OAAO,IAAI;YACb;UACF;QACF;;QAEA;QACA,IAAIxD,GAAG,GAAGD,IAAI,GAAG,CAAC,EAAE;UAClB,MAAMuE,SAAS,GAAGxE,IAAI,CAACE,GAAG,GAAG,CAAC,CAAC;UAC/B,MAAMuE,WAAW,GAAGD,SAAS,GAAGA,SAAS,CAACrE,GAAG,CAAC,GAAG,IAAI;UACrD,IAAIsE,WAAW,EAAE;YACf,IAAI,CAACzC,WAAW,CAAChC,IAAI,EAAEU,KAAK,EAAE+D,WAAW,CAAC;YAC1C,MAAMF,MAAM,GAAG,IAAI,CAAC9B,WAAW,CAACzC,IAAI,CAAC;YACrC,IAAI,CAACgC,WAAW,CAAChC,IAAI,EAAEU,KAAK,EAAE+D,WAAW,CAAC,CAAC,CAAC;;YAE5C,IAAIF,MAAM,CAACb,UAAU,EAAE;cACrB,OAAO,IAAI;YACb;UACF;QACF;MACF;IACF;IAEA,OAAO,KAAK;EACd;;EAEA;EACAgB,aAAaA,CAAC9D,IAAY,EAAU;IAClC,OAAOvB,YAAY,CAACuB,IAAI,GAAGvB,YAAY,CAACmE,MAAM,CAAC,IAAInE,YAAY,CAAC,CAAC,CAAC;EACpE;;EAEA;EACAsF,cAAcA,CAAA,EAAS;IACrB,IAAI,CAACnF,WAAW,GAAG,CAAC;EACtB;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { create } from 'zustand';
|
|
4
|
+
import { subscribeWithSelector } from 'zustand/middleware';
|
|
5
|
+
import { CandyCrushService } from "./CandyCrushService.js";
|
|
6
|
+
import { CANDY_CRUSH_GAME_CONFIG, DIFFICULTY_CONFIG, CANDY_CRUSH_SOUNDS } from "./CandyCrushConstants.js";
|
|
7
|
+
import { immerMiddleware } from "../../services/GamesService.js";
|
|
8
|
+
import { playSound } from "../../services/SoundsService.js";
|
|
9
|
+
import { playHaptic, HapticType } from "../../services/HapticsService.js";
|
|
10
|
+
const gameService = new CandyCrushService();
|
|
11
|
+
export const useCandyCrushStore = create()(subscribeWithSelector(immerMiddleware((set, get) => ({
|
|
12
|
+
// Initial state
|
|
13
|
+
grid: gameService.createGrid(),
|
|
14
|
+
score: 0,
|
|
15
|
+
timeRemaining: 180,
|
|
16
|
+
gameDuration: 180,
|
|
17
|
+
isPlaying: false,
|
|
18
|
+
isGameOver: false,
|
|
19
|
+
selectedCandy: null,
|
|
20
|
+
isProcessing: false,
|
|
21
|
+
difficulty: 'easy',
|
|
22
|
+
candyTypes: 4,
|
|
23
|
+
enableSounds: true,
|
|
24
|
+
enableHaptics: true,
|
|
25
|
+
comboCount: 0,
|
|
26
|
+
gameTimer: null,
|
|
27
|
+
matchedCandyIds: new Set(),
|
|
28
|
+
fallingCandyIds: new Set(),
|
|
29
|
+
startGame: () => {
|
|
30
|
+
const state = get();
|
|
31
|
+
|
|
32
|
+
// Clear any existing timer
|
|
33
|
+
if (state.gameTimer) {
|
|
34
|
+
clearInterval(state.gameTimer);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Play start sound
|
|
38
|
+
playSound(CANDY_CRUSH_SOUNDS.SWAP, state.enableSounds);
|
|
39
|
+
playHaptic(HapticType.MEDIUM, state.enableHaptics);
|
|
40
|
+
|
|
41
|
+
// Start countdown timer
|
|
42
|
+
const timer = setInterval(() => {
|
|
43
|
+
const currentState = get();
|
|
44
|
+
if (currentState.timeRemaining > 0 && currentState.isPlaying) {
|
|
45
|
+
set(draft => {
|
|
46
|
+
draft.timeRemaining--;
|
|
47
|
+
|
|
48
|
+
// Warning sound at 30 seconds
|
|
49
|
+
if (draft.timeRemaining === 30) {
|
|
50
|
+
playSound(CANDY_CRUSH_SOUNDS.SPECIAL, draft.enableSounds);
|
|
51
|
+
playHaptic(HapticType.MEDIUM, draft.enableHaptics);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Warning sound at 10 seconds
|
|
55
|
+
if (draft.timeRemaining === 10) {
|
|
56
|
+
playSound(CANDY_CRUSH_SOUNDS.SPECIAL, draft.enableSounds);
|
|
57
|
+
playHaptic(HapticType.HEAVY, draft.enableHaptics);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Check if time is up
|
|
61
|
+
if (draft.timeRemaining <= 0) {
|
|
62
|
+
draft.isGameOver = true;
|
|
63
|
+
draft.isPlaying = false;
|
|
64
|
+
if (draft.gameTimer) {
|
|
65
|
+
clearInterval(draft.gameTimer);
|
|
66
|
+
draft.gameTimer = null;
|
|
67
|
+
}
|
|
68
|
+
playSound(CANDY_CRUSH_SOUNDS.LOSE, draft.enableSounds);
|
|
69
|
+
playHaptic(HapticType.HEAVY, draft.enableHaptics);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}, 1000);
|
|
74
|
+
set(state => {
|
|
75
|
+
state.isPlaying = true;
|
|
76
|
+
state.gameTimer = timer;
|
|
77
|
+
});
|
|
78
|
+
},
|
|
79
|
+
stopGame: () => {
|
|
80
|
+
const state = get();
|
|
81
|
+
if (state.gameTimer) {
|
|
82
|
+
clearInterval(state.gameTimer);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Play stop sound
|
|
86
|
+
playSound(CANDY_CRUSH_SOUNDS.LOSE, state.enableSounds);
|
|
87
|
+
playHaptic(HapticType.MEDIUM, state.enableHaptics);
|
|
88
|
+
set(state => {
|
|
89
|
+
state.isPlaying = false;
|
|
90
|
+
state.isGameOver = true;
|
|
91
|
+
state.gameTimer = null;
|
|
92
|
+
});
|
|
93
|
+
},
|
|
94
|
+
resetGame: () => {
|
|
95
|
+
const state = get();
|
|
96
|
+
state.initializeGame(state.difficulty);
|
|
97
|
+
state.startGame();
|
|
98
|
+
},
|
|
99
|
+
initializeGame: (difficulty = 'easy') => {
|
|
100
|
+
const state = get();
|
|
101
|
+
if (state.gameTimer) {
|
|
102
|
+
clearInterval(state.gameTimer);
|
|
103
|
+
}
|
|
104
|
+
set(state => {
|
|
105
|
+
const config = DIFFICULTY_CONFIG[difficulty];
|
|
106
|
+
gameService.resetIdCounter();
|
|
107
|
+
state.grid = gameService.initializeGrid(config.candyTypes);
|
|
108
|
+
state.score = 0;
|
|
109
|
+
state.timeRemaining = config.gameDuration;
|
|
110
|
+
state.gameDuration = config.gameDuration;
|
|
111
|
+
state.isPlaying = false;
|
|
112
|
+
state.isGameOver = false;
|
|
113
|
+
state.selectedCandy = null;
|
|
114
|
+
state.isProcessing = false;
|
|
115
|
+
state.difficulty = difficulty;
|
|
116
|
+
state.candyTypes = config.candyTypes;
|
|
117
|
+
state.comboCount = 0;
|
|
118
|
+
state.gameTimer = null;
|
|
119
|
+
state.matchedCandyIds = new Set();
|
|
120
|
+
state.fallingCandyIds = new Set();
|
|
121
|
+
});
|
|
122
|
+
},
|
|
123
|
+
selectCandy: candy => {
|
|
124
|
+
const state = get();
|
|
125
|
+
if (state.isProcessing || !state.isPlaying || state.isGameOver) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
set(draft => {
|
|
129
|
+
if (!draft.selectedCandy) {
|
|
130
|
+
// First candy selected
|
|
131
|
+
draft.selectedCandy = candy;
|
|
132
|
+
playSound(CANDY_CRUSH_SOUNDS.SWAP, draft.enableSounds);
|
|
133
|
+
playHaptic(HapticType.LIGHT, draft.enableHaptics);
|
|
134
|
+
} else if (draft.selectedCandy.id === candy.id) {
|
|
135
|
+
// Deselect same candy
|
|
136
|
+
draft.selectedCandy = null;
|
|
137
|
+
} else if (gameService.canSwap(draft.selectedCandy, candy)) {
|
|
138
|
+
// Valid swap - process it
|
|
139
|
+
const candy1 = draft.selectedCandy;
|
|
140
|
+
const candy2 = candy;
|
|
141
|
+
|
|
142
|
+
// Swap candies
|
|
143
|
+
gameService.swapCandies(draft.grid, candy1, candy2);
|
|
144
|
+
|
|
145
|
+
// Only update affected rows to minimize re-renders
|
|
146
|
+
const affectedRows = new Set([candy1.row, candy2.row]);
|
|
147
|
+
affectedRows.forEach(rowIndex => {
|
|
148
|
+
if (draft.grid[rowIndex]) {
|
|
149
|
+
draft.grid[rowIndex] = [...draft.grid[rowIndex]];
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
// Check for matches
|
|
154
|
+
const matchResult = gameService.findMatches(draft.grid);
|
|
155
|
+
if (matchResult.hasMatches) {
|
|
156
|
+
// Valid move
|
|
157
|
+
draft.selectedCandy = null;
|
|
158
|
+
draft.isProcessing = true;
|
|
159
|
+
playSound(CANDY_CRUSH_SOUNDS.SWAP, draft.enableSounds);
|
|
160
|
+
playHaptic(HapticType.MEDIUM, draft.enableHaptics);
|
|
161
|
+
|
|
162
|
+
// Process matches after animation
|
|
163
|
+
setTimeout(() => {
|
|
164
|
+
get().processMatches();
|
|
165
|
+
}, CANDY_CRUSH_GAME_CONFIG.SWAP_DURATION);
|
|
166
|
+
} else {
|
|
167
|
+
// Invalid move - swap back
|
|
168
|
+
gameService.swapCandies(draft.grid, candy1, candy2);
|
|
169
|
+
draft.selectedCandy = null;
|
|
170
|
+
|
|
171
|
+
// Only update affected rows to minimize re-renders
|
|
172
|
+
const affectedRows = new Set([candy1.row, candy2.row]);
|
|
173
|
+
affectedRows.forEach(rowIndex => {
|
|
174
|
+
if (draft.grid[rowIndex]) {
|
|
175
|
+
draft.grid[rowIndex] = [...draft.grid[rowIndex]];
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
playSound(CANDY_CRUSH_SOUNDS.SWAP, draft.enableSounds);
|
|
179
|
+
playHaptic(HapticType.LIGHT, draft.enableHaptics);
|
|
180
|
+
}
|
|
181
|
+
} else {
|
|
182
|
+
// Not adjacent - select new candy
|
|
183
|
+
draft.selectedCandy = candy;
|
|
184
|
+
playSound(CANDY_CRUSH_SOUNDS.SWAP, draft.enableSounds);
|
|
185
|
+
playHaptic(HapticType.LIGHT, draft.enableHaptics);
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
},
|
|
189
|
+
processMatches: async () => {
|
|
190
|
+
let hasMatches = true;
|
|
191
|
+
let comboCount = 0;
|
|
192
|
+
while (hasMatches) {
|
|
193
|
+
// Get fresh state at the start of each iteration
|
|
194
|
+
const state = get();
|
|
195
|
+
|
|
196
|
+
// Find matches
|
|
197
|
+
const matchResult = gameService.findMatches(state.grid);
|
|
198
|
+
if (!matchResult.hasMatches) {
|
|
199
|
+
hasMatches = false;
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
comboCount++;
|
|
203
|
+
|
|
204
|
+
// Calculate score with combo multiplier
|
|
205
|
+
const baseScore = matchResult.score;
|
|
206
|
+
const comboMultiplier = comboCount > 1 ? Math.pow(CANDY_CRUSH_GAME_CONFIG.COMBO_MULTIPLIER, comboCount - 1) : 1;
|
|
207
|
+
const finalScore = Math.floor(baseScore * comboMultiplier);
|
|
208
|
+
|
|
209
|
+
// Update score
|
|
210
|
+
set(draft => {
|
|
211
|
+
draft.score += finalScore;
|
|
212
|
+
draft.comboCount = comboCount;
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
// Play sound
|
|
216
|
+
if (comboCount > 1) {
|
|
217
|
+
playSound(CANDY_CRUSH_SOUNDS.COMBO, state.enableSounds);
|
|
218
|
+
playHaptic(HapticType.HEAVY, state.enableHaptics);
|
|
219
|
+
} else {
|
|
220
|
+
playSound(CANDY_CRUSH_SOUNDS.MATCH, state.enableSounds);
|
|
221
|
+
playHaptic(HapticType.MEDIUM, state.enableHaptics);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// Mark candies as matched for animation using Set (no grid mutation needed)
|
|
225
|
+
set(draft => {
|
|
226
|
+
draft.matchedCandyIds = new Set(matchResult.matches.map(c => c.id));
|
|
227
|
+
// No grid update needed - animation state is separate
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
// Wait for animation
|
|
231
|
+
await new Promise(resolve => setTimeout(resolve, CANDY_CRUSH_GAME_CONFIG.ANIMATION_DURATION));
|
|
232
|
+
|
|
233
|
+
// Remove matches, apply gravity, and fill empty spaces (all in one set call)
|
|
234
|
+
set(draft => {
|
|
235
|
+
// Clear matched IDs
|
|
236
|
+
draft.matchedCandyIds = new Set();
|
|
237
|
+
|
|
238
|
+
// Track which rows will be affected by matches
|
|
239
|
+
const affectedRows = new Set();
|
|
240
|
+
matchResult.matches.forEach(candy => affectedRows.add(candy.row));
|
|
241
|
+
|
|
242
|
+
// Store original candy IDs per row to detect changes
|
|
243
|
+
const originalRowIds = draft.grid.map(row => row.map(c => c?.id).join(','));
|
|
244
|
+
|
|
245
|
+
// Remove matches
|
|
246
|
+
gameService.removeMatches(draft.grid, matchResult.matches);
|
|
247
|
+
|
|
248
|
+
// Apply gravity (affects all rows below matches)
|
|
249
|
+
gameService.applyGravity(draft.grid);
|
|
250
|
+
|
|
251
|
+
// Fill empty spaces (affects top rows)
|
|
252
|
+
gameService.fillEmptySpaces(draft.grid, state.candyTypes);
|
|
253
|
+
|
|
254
|
+
// Mark falling candies
|
|
255
|
+
const fallingIds = new Set();
|
|
256
|
+
draft.grid.forEach(row => {
|
|
257
|
+
row.forEach(candy => {
|
|
258
|
+
if (candy && candy.isFalling) {
|
|
259
|
+
fallingIds.add(candy.id);
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
});
|
|
263
|
+
draft.fallingCandyIds = fallingIds;
|
|
264
|
+
|
|
265
|
+
// Only update rows that actually changed
|
|
266
|
+
draft.grid.forEach((row, rowIndex) => {
|
|
267
|
+
const newRowIds = row.map(c => c?.id).join(',');
|
|
268
|
+
if (originalRowIds[rowIndex] !== newRowIds) {
|
|
269
|
+
draft.grid[rowIndex] = [...row];
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
// Wait for fall animation
|
|
275
|
+
await new Promise(resolve => setTimeout(resolve, CANDY_CRUSH_GAME_CONFIG.FALL_DURATION));
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// Reset processing state and clear animation states
|
|
279
|
+
set(draft => {
|
|
280
|
+
draft.isProcessing = false;
|
|
281
|
+
draft.comboCount = 0;
|
|
282
|
+
draft.matchedCandyIds = new Set();
|
|
283
|
+
draft.fallingCandyIds = new Set();
|
|
284
|
+
});
|
|
285
|
+
},
|
|
286
|
+
updateSettings: (enableSounds, enableHaptics) => {
|
|
287
|
+
set(state => {
|
|
288
|
+
state.enableSounds = enableSounds;
|
|
289
|
+
state.enableHaptics = enableHaptics;
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
}))));
|
|
293
|
+
|
|
294
|
+
// Selector hooks for optimal re-renders
|
|
295
|
+
export const useGrid = () => useCandyCrushStore(state => state.grid);
|
|
296
|
+
export const useScore = () => useCandyCrushStore(state => state.score);
|
|
297
|
+
export const useTimeRemaining = () => useCandyCrushStore(state => state.timeRemaining);
|
|
298
|
+
export const useGameDuration = () => useCandyCrushStore(state => state.gameDuration);
|
|
299
|
+
export const useIsPlaying = () => useCandyCrushStore(state => state.isPlaying);
|
|
300
|
+
export const useIsGameOver = () => useCandyCrushStore(state => state.isGameOver);
|
|
301
|
+
export const useSelectedCandy = () => useCandyCrushStore(state => state.selectedCandy);
|
|
302
|
+
export const useComboCount = () => useCandyCrushStore(state => state.comboCount);
|
|
303
|
+
export const useMatchedCandyIds = () => useCandyCrushStore(state => state.matchedCandyIds);
|
|
304
|
+
export const useFallingCandyIds = () => useCandyCrushStore(state => state.fallingCandyIds);
|
|
305
|
+
//# sourceMappingURL=CandyCrushStore.js.map
|