@nayan-ui/games 1.20.0 → 1.21.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/lib/module/games/arrows/Arrows.js +1 -1
- package/lib/module/games/arrows/ArrowsScene.js +1 -1
- package/lib/module/games/balloon-blaster/BalloonBlaster.js +1 -1
- package/lib/module/games/balloon-blaster/BalloonBlasterScene.js +1 -1
- package/lib/module/games/bike-racing/BikeMeshes.js +1 -1
- package/lib/module/games/bike-racing/BikeRacing.js +1 -1
- package/lib/module/games/bike-racing/BikeRacingConstants.js +1 -1
- package/lib/module/games/bike-racing/BikeRacingScene.js +1 -1
- package/lib/module/games/block-blast/BlockBlast.js +1 -1
- package/lib/module/games/block-blast/BlockBlastScene.js +1 -1
- package/lib/module/games/block-breaker/BlockBreaker.js +1 -1
- package/lib/module/games/block-breaker/BlockBreakerScene.js +1 -1
- package/lib/module/games/bluk/Bluk.js +1 -1
- package/lib/module/games/bluk/BlukScene.js +1 -1
- package/lib/module/games/bubble-shooter/BubbleShooter.js +1 -1
- package/lib/module/games/bubble-shooter/BubbleShooterScene.js +1 -1
- package/lib/module/games/candy-crush/CandyCrush.js +1 -1
- package/lib/module/games/candy-crush/CandyCrushScene.js +1 -1
- package/lib/module/games/car-racing/CarMeshes.js +1 -1
- package/lib/module/games/car-racing/CarRacing.js +1 -1
- package/lib/module/games/car-racing/CarRacingScene.js +1 -1
- package/lib/module/games/chameleon-run/ChameleonRun.js +1 -1
- package/lib/module/games/chameleon-run/ChameleonRunBackdrop.js +1 -1
- package/lib/module/games/chameleon-run/ChameleonRunMeshes.js +1 -1
- package/lib/module/games/checkers/Checkers.js +1 -1
- package/lib/module/games/checkers/CheckersScene.js +1 -1
- package/lib/module/games/color-switch/ColorSwitch.js +1 -1
- package/lib/module/games/color-switch/ColorSwitchScene.js +1 -1
- package/lib/module/games/colors-sort/ColorsSort.js +1 -1
- package/lib/module/games/colors-sort/ColorsSortScene.js +1 -1
- package/lib/module/games/connect-em-all/ConnectEmAll.js +1 -1
- package/lib/module/games/connect-em-all/ConnectEmAllScene.js +1 -1
- package/lib/module/games/crossy-road/CrossyRoad.js +1 -1
- package/lib/module/games/crossy-road/CrossyRoadMeshes.js +1 -1
- package/lib/module/games/crossy-road/CrossyRoadPerson.js +1 -1
- package/lib/module/games/dino-jump/DinoJump.js +1 -1
- package/lib/module/games/dino-jump/DinoJumpScene.js +1 -1
- package/lib/module/games/dots-and-boxes/DotsAndBoxes.js +1 -1
- package/lib/module/games/dots-and-boxes/DotsAndBoxesScene.js +1 -1
- package/lib/module/games/falling-sticks/FallingSticks.js +1 -1
- package/lib/module/games/falling-sticks/FallingSticksScene.js +1 -1
- package/lib/module/games/find-different-number/FindDifferentNumber.js +1 -1
- package/lib/module/games/find-different-number/FindDifferentNumberScene.js +1 -1
- package/lib/module/games/flappy-bird/FlappyBird.js +1 -1
- package/lib/module/games/flappy-bird/FlappyBirdScene.js +1 -1
- package/lib/module/games/fruit-merger/FruitMerger.js +1 -1
- package/lib/module/games/fruit-merger/FruitMergerScene.js +1 -1
- package/lib/module/games/fruit-ninja/FruitNinja.js +1 -1
- package/lib/module/games/fruit-ninja/FruitNinjaScene.js +1 -1
- package/lib/module/games/fruit-ninja/FruitNinjaWorld.js +1 -1
- package/lib/module/games/game-2048/Game2048.js +1 -1
- package/lib/module/games/game-2048/Game2048Scene.js +1 -1
- package/lib/module/games/knife-hit/KnifeHit.js +1 -1
- package/lib/module/games/knife-hit/KnifeHitScene.js +1 -1
- package/lib/module/games/ludo-king/LudoKing.js +1 -1
- package/lib/module/games/ludo-king/LudoKingScene.js +1 -1
- package/lib/module/games/maze-runner/MazeRunner.js +1 -1
- package/lib/module/games/maze-runner/MazeRunnerScene.js +1 -1
- package/lib/module/games/memory-match/MemoryMatch.js +1 -1
- package/lib/module/games/memory-match/MemoryMatchScene.js +1 -1
- package/lib/module/games/mine-sweeper/MineSweeper.js +1 -1
- package/lib/module/games/mine-sweeper/MineSweeperScene.js +1 -1
- package/lib/module/games/mob-control/MobControl.js +1 -1
- package/lib/module/games/mob-control/MobControlGame.js +1 -1
- package/lib/module/games/mob-control/MobControlMeshes.js +1 -1
- package/lib/module/games/mob-control/MobControlRenderer.js +1 -1
- package/lib/module/games/mob-control/MobControlRules.js +1 -1
- package/lib/module/games/mob-control/MobControlScene.js +1 -1
- package/lib/module/games/nuts-and-bolts/NutsAndBolts.js +1 -1
- package/lib/module/games/nuts-and-bolts/NutsAndBoltsScene.js +1 -1
- package/lib/module/games/pac-man/PacMan.js +1 -1
- package/lib/module/games/pac-man/PacManGame.js +1 -1
- package/lib/module/games/pac-man/PacManScene.js +1 -1
- package/lib/module/games/paper-io/PaperIo.js +1 -1
- package/lib/module/games/paper-io/PaperIoMeshes.js +1 -1
- package/lib/module/games/paper-io/PaperIoScene.js +1 -1
- package/lib/module/games/penguin-run/PenguinMeshes.js +1 -1
- package/lib/module/games/penguin-run/PenguinRun.js +1 -1
- package/lib/module/games/penguin-run/PenguinRunScene.js +1 -1
- package/lib/module/games/perfect-circle/PerfectCircle.js +1 -1
- package/lib/module/games/perfect-circle/PerfectCircleScene.js +1 -1
- package/lib/module/games/pipe-connect/PipeConnect.js +1 -1
- package/lib/module/games/pipe-connect/PipeConnectScene.js +1 -1
- package/lib/module/games/play-with-tua/PlayWithTua.js +1 -1
- package/lib/module/games/popit-fidget/PopitFidget.js +1 -1
- package/lib/module/games/popit-fidget/PopitFidgetScene.js +1 -1
- package/lib/module/games/reversi/Reversi.js +1 -1
- package/lib/module/games/reversi/ReversiScene.js +1 -1
- package/lib/module/games/search-grid/SearchGrid.js +1 -1
- package/lib/module/games/search-grid/SearchGridScene.js +1 -1
- package/lib/module/games/shared/BackdropCard.js +1 -1
- package/lib/module/games/shared/EngineBackdrop.js +1 -1
- package/lib/module/games/shared/EngineBlasts.js +1 -1
- package/lib/module/games/shared/EngineBlocks.js +1 -1
- package/lib/module/games/shared/EngineDice.js +1 -1
- package/lib/module/games/shared/EngineFruits.js +1 -1
- package/lib/module/games/shared/EngineGameLoader.js +1 -1
- package/lib/module/games/shared/EngineGameScreen.js +1 -1
- package/lib/module/games/shared/EngineGlyphs.js +1 -1
- package/lib/module/games/shared/EngineHud.js +1 -1
- package/lib/module/games/shared/EngineMeadow.js +1 -1
- package/lib/module/games/shared/EngineTouchSurface.js +1 -1
- package/lib/module/games/shared/GameActivity.js +1 -1
- package/lib/module/games/shared/GameLoading.js +1 -1
- package/lib/module/games/shared/GameLoadingTransition.js +1 -1
- package/lib/module/games/sliding-numbers/SlidingNumbers.js +1 -1
- package/lib/module/games/sliding-numbers/SlidingNumbersScene.js +1 -1
- package/lib/module/games/snake-3d/Snake3D.js +1 -1
- package/lib/module/games/snake-3d/Snake3DScene.js +1 -1
- package/lib/module/games/snakes-and-ladders/SnakesAndLadders.js +1 -1
- package/lib/module/games/snakes-and-ladders/SnakesAndLaddersScene.js +1 -1
- package/lib/module/games/space-fighter/SpaceFighter.js +1 -1
- package/lib/module/games/space-fighter/SpaceFighterScene.js +1 -1
- package/lib/module/games/spider-solitaire/SpiderSolitaire.js +1 -1
- package/lib/module/games/spider-solitaire/SpiderSolitaireScene.js +1 -1
- package/lib/module/games/stack-tower/StackTower.js +1 -1
- package/lib/module/games/stack-tower/StackTowerScene.js +1 -1
- package/lib/module/games/sudoku/Sudoku.js +1 -1
- package/lib/module/games/sudoku/SudokuScene.js +1 -1
- package/lib/module/games/tangram/Tangram.js +1 -1
- package/lib/module/games/tangram/TangramScene.js +1 -1
- package/lib/module/games/tank-1990/Tank1990.js +1 -1
- package/lib/module/games/tank-1990/Tank1990Scene.js +1 -1
- package/lib/module/games/tic-tac-toe/TicTacToe.js +1 -1
- package/lib/module/games/tic-tac-toe/TicTacToeScene.js +1 -1
- package/lib/module/games/tile-home/TileHome.js +1 -1
- package/lib/module/games/tile-home/TileHomeScene.js +1 -1
- package/lib/module/games/treasure-hunt/TreasureHunt.js +1 -1
- package/lib/module/games/treasure-hunt/TreasureHuntConstants.js +1 -1
- package/lib/module/games/treasure-hunt/TreasureHuntModel.js +1 -1
- package/lib/module/games/treasure-hunt/TreasureHuntScene.js +1 -1
- package/lib/module/games/whack-a-mole/WhackAMole.js +1 -1
- package/lib/module/games/whack-a-mole/WhackAMoleScene.js +1 -1
- package/lib/module/helpers/GameSettingsModal.js +1 -1
- package/lib/module/helpers/GameTheme.js +1 -1
- package/package.json +1 -2
- package/src/assets/fonts/Inter-SemiBold.ttf +0 -0
- package/src/assets/models/explorer/explorer.glb +0 -0
- package/src/assets/models/explorer/params.json +0 -51
- package/src/assets/models/explorer/source.json +0 -222
- package/src/assets/models/play-with-tua/play-with-tua.glb +0 -0
- package/src/assets/models/play-with-tua/sources.json +0 -141
- package/src/assets/sfx/balloon_pop.wav +0 -0
- package/src/assets/sfx/blocked.wav +0 -0
- package/src/assets/sfx/boing.wav +0 -0
- package/src/assets/sfx/bonus.wav +0 -0
- package/src/assets/sfx/boom.wav +0 -0
- package/src/assets/sfx/bump.wav +0 -0
- package/src/assets/sfx/cannon.wav +0 -0
- package/src/assets/sfx/capture.wav +0 -0
- package/src/assets/sfx/card_flip.wav +0 -0
- package/src/assets/sfx/card_place.wav +0 -0
- package/src/assets/sfx/catch.wav +0 -0
- package/src/assets/sfx/chime.wav +0 -0
- package/src/assets/sfx/chomp.wav +0 -0
- package/src/assets/sfx/chomp_alt.wav +0 -0
- package/src/assets/sfx/clack.wav +0 -0
- package/src/assets/sfx/clang.wav +0 -0
- package/src/assets/sfx/clash.wav +0 -0
- package/src/assets/sfx/click.wav +0 -0
- package/src/assets/sfx/coin.wav +0 -0
- package/src/assets/sfx/combo.wav +0 -0
- package/src/assets/sfx/crash.wav +0 -0
- package/src/assets/sfx/crunch.wav +0 -0
- package/src/assets/sfx/dance.wav +0 -0
- package/src/assets/sfx/deselect.wav +0 -0
- package/src/assets/sfx/dice_roll.wav +0 -0
- package/src/assets/sfx/die.wav +0 -0
- package/src/assets/sfx/draw.wav +0 -0
- package/src/assets/sfx/drop.wav +0 -0
- package/src/assets/sfx/eat.wav +0 -0
- package/src/assets/sfx/engine.wav +0 -0
- package/src/assets/sfx/error.wav +0 -0
- package/src/assets/sfx/flag.wav +0 -0
- package/src/assets/sfx/flap.wav +0 -0
- package/src/assets/sfx/flip_disc.wav +0 -0
- package/src/assets/sfx/footstep_run.wav +0 -0
- package/src/assets/sfx/footstep_walk.wav +0 -0
- package/src/assets/sfx/game_over.wav +0 -0
- package/src/assets/sfx/gate.wav +0 -0
- package/src/assets/sfx/hit.wav +0 -0
- package/src/assets/sfx/hop.wav +0 -0
- package/src/assets/sfx/hurt.wav +0 -0
- package/src/assets/sfx/invalid.wav +0 -0
- package/src/assets/sfx/jump.wav +0 -0
- package/src/assets/sfx/ladder.wav +0 -0
- package/src/assets/sfx/land.wav +0 -0
- package/src/assets/sfx/laugh.wav +0 -0
- package/src/assets/sfx/lose.wav +0 -0
- package/src/assets/sfx/merge.wav +0 -0
- package/src/assets/sfx/miss.wav +0 -0
- package/src/assets/sfx/nitro.wav +0 -0
- package/src/assets/sfx/pew.wav +0 -0
- package/src/assets/sfx/place.wav +0 -0
- package/src/assets/sfx/pling.wav +0 -0
- package/src/assets/sfx/point.wav +0 -0
- package/src/assets/sfx/pop.wav +0 -0
- package/src/assets/sfx/pop_soft.wav +0 -0
- package/src/assets/sfx/power_up.wav +0 -0
- package/src/assets/sfx/reveal.wav +0 -0
- package/src/assets/sfx/robot.wav +0 -0
- package/src/assets/sfx/rotate.wav +0 -0
- package/src/assets/sfx/run_steps.wav +0 -0
- package/src/assets/sfx/select.wav +0 -0
- package/src/assets/sfx/shuffle.wav +0 -0
- package/src/assets/sfx/six.wav +0 -0
- package/src/assets/sfx/slice.wav +0 -0
- package/src/assets/sfx/slide.wav +0 -0
- package/src/assets/sfx/snake.wav +0 -0
- package/src/assets/sfx/snap.wav +0 -0
- package/src/assets/sfx/splash.wav +0 -0
- package/src/assets/sfx/star.wav +0 -0
- package/src/assets/sfx/start.wav +0 -0
- package/src/assets/sfx/swoosh.wav +0 -0
- package/src/assets/sfx/tap.wav +0 -0
- package/src/assets/sfx/thud.wav +0 -0
- package/src/assets/sfx/thunk.wav +0 -0
- package/src/assets/sfx/tick.wav +0 -0
- package/src/assets/sfx/time_up.wav +0 -0
- package/src/assets/sfx/tock.wav +0 -0
- package/src/assets/sfx/walk_steps.wav +0 -0
- package/src/assets/sfx/warning.wav +0 -0
- package/src/assets/sfx/whack.wav +0 -0
- package/src/assets/sfx/whoosh.wav +0 -0
- package/src/assets/sfx/win.wav +0 -0
- package/src/assets/sfx/zap.wav +0 -0
- package/src/assets/textures/ad_bolt.png +0 -0
- package/src/assets/textures/ad_bubbles.png +0 -0
- package/src/assets/textures/ad_chevrons.png +0 -0
- package/src/assets/textures/asphalt.png +0 -0
- package/src/assets/textures/bark.jpg +0 -0
- package/src/assets/textures/explorer-atlas.png +0 -0
- package/src/assets/textures/facade.png +0 -0
- package/src/assets/textures/grass.png +0 -0
- package/src/assets/textures/leaves.png +0 -0
- package/src/assets/textures/limestone.jpg +0 -0
- package/src/assets/textures/meadow.jpg +0 -0
- package/src/assets/textures/nature-sources.json +0 -87
- package/src/assets/textures/pine.png +0 -0
- package/src/assets/textures/river.jpg +0 -0
- package/src/assets/textures/soft_glow.png +0 -0
- package/src/games/arrows/Arrows.tsx +0 -69
- package/src/games/arrows/ArrowsConstants.ts +0 -107
- package/src/games/arrows/ArrowsGame.ts +0 -735
- package/src/games/arrows/ArrowsScene.ts +0 -395
- package/src/games/balloon-blaster/BalloonBlaster.tsx +0 -75
- package/src/games/balloon-blaster/BalloonBlasterConstants.ts +0 -79
- package/src/games/balloon-blaster/BalloonBlasterGame.ts +0 -287
- package/src/games/balloon-blaster/BalloonBlasterPhysics.ts +0 -95
- package/src/games/balloon-blaster/BalloonBlasterScene.ts +0 -225
- package/src/games/bike-racing/BikeMeshes.ts +0 -273
- package/src/games/bike-racing/BikeRacing.tsx +0 -211
- package/src/games/bike-racing/BikeRacingConstants.ts +0 -103
- package/src/games/bike-racing/BikeRacingGame.ts +0 -557
- package/src/games/bike-racing/BikeRacingScene.ts +0 -119
- package/src/games/block-blast/BlockBlast.tsx +0 -73
- package/src/games/block-blast/BlockBlastConstants.ts +0 -179
- package/src/games/block-blast/BlockBlastGame.ts +0 -471
- package/src/games/block-blast/BlockBlastScene.ts +0 -156
- package/src/games/block-breaker/BlockBreaker.tsx +0 -79
- package/src/games/block-breaker/BlockBreakerConstants.ts +0 -139
- package/src/games/block-breaker/BlockBreakerGame.ts +0 -459
- package/src/games/block-breaker/BlockBreakerScene.ts +0 -257
- package/src/games/bluk/Bluk.tsx +0 -82
- package/src/games/bluk/BlukConstants.ts +0 -121
- package/src/games/bluk/BlukGame.ts +0 -323
- package/src/games/bluk/BlukRules.ts +0 -154
- package/src/games/bluk/BlukScene.ts +0 -514
- package/src/games/bubble-shooter/BubbleShooter.tsx +0 -76
- package/src/games/bubble-shooter/BubbleShooterConstants.ts +0 -103
- package/src/games/bubble-shooter/BubbleShooterGame.ts +0 -459
- package/src/games/bubble-shooter/BubbleShooterScene.ts +0 -158
- package/src/games/candy-crush/CandyCrush.tsx +0 -77
- package/src/games/candy-crush/CandyCrushConstants.ts +0 -94
- package/src/games/candy-crush/CandyCrushGame.ts +0 -477
- package/src/games/candy-crush/CandyCrushScene.ts +0 -209
- package/src/games/car-racing/CarMeshes.ts +0 -440
- package/src/games/car-racing/CarRacing.tsx +0 -211
- package/src/games/car-racing/CarRacingConstants.ts +0 -167
- package/src/games/car-racing/CarRacingFacade.ts +0 -40
- package/src/games/car-racing/CarRacingGame.ts +0 -539
- package/src/games/car-racing/CarRacingScene.ts +0 -1026
- package/src/games/car-racing/CarRacingScenery.ts +0 -265
- package/src/games/chameleon-run/ChameleonRun.tsx +0 -96
- package/src/games/chameleon-run/ChameleonRunBackdrop.ts +0 -186
- package/src/games/chameleon-run/ChameleonRunConstants.ts +0 -47
- package/src/games/chameleon-run/ChameleonRunGame.ts +0 -309
- package/src/games/chameleon-run/ChameleonRunMeshes.ts +0 -305
- package/src/games/chameleon-run/ChameleonRunRules.ts +0 -252
- package/src/games/chameleon-run/ChameleonRunScene.ts +0 -310
- package/src/games/checkers/Checkers.tsx +0 -83
- package/src/games/checkers/CheckersAI.ts +0 -255
- package/src/games/checkers/CheckersConstants.ts +0 -68
- package/src/games/checkers/CheckersGame.ts +0 -322
- package/src/games/checkers/CheckersRules.ts +0 -167
- package/src/games/checkers/CheckersScene.ts +0 -308
- package/src/games/color-switch/ColorSwitch.tsx +0 -75
- package/src/games/color-switch/ColorSwitchConstants.ts +0 -61
- package/src/games/color-switch/ColorSwitchGame.ts +0 -329
- package/src/games/color-switch/ColorSwitchScene.ts +0 -220
- package/src/games/colors-sort/ColorsSort.tsx +0 -82
- package/src/games/colors-sort/ColorsSortConstants.ts +0 -119
- package/src/games/colors-sort/ColorsSortGame.ts +0 -246
- package/src/games/colors-sort/ColorsSortScene.ts +0 -315
- package/src/games/connect-em-all/ConnectEmAll.tsx +0 -70
- package/src/games/connect-em-all/ConnectEmAllConstants.ts +0 -77
- package/src/games/connect-em-all/ConnectEmAllGame.ts +0 -401
- package/src/games/connect-em-all/ConnectEmAllScene.ts +0 -235
- package/src/games/crossy-road/CrossyRoad.tsx +0 -74
- package/src/games/crossy-road/CrossyRoadCamera.ts +0 -59
- package/src/games/crossy-road/CrossyRoadConstants.ts +0 -132
- package/src/games/crossy-road/CrossyRoadGame.ts +0 -293
- package/src/games/crossy-road/CrossyRoadMeshes.ts +0 -195
- package/src/games/crossy-road/CrossyRoadPerson.ts +0 -198
- package/src/games/crossy-road/CrossyRoadRules.ts +0 -99
- package/src/games/crossy-road/CrossyRoadScene.ts +0 -355
- package/src/games/dino-jump/DinoJump.tsx +0 -77
- package/src/games/dino-jump/DinoJumpConstants.ts +0 -80
- package/src/games/dino-jump/DinoJumpGame.ts +0 -344
- package/src/games/dino-jump/DinoJumpScene.ts +0 -686
- package/src/games/dots-and-boxes/DotsAndBoxes.tsx +0 -83
- package/src/games/dots-and-boxes/DotsAndBoxesConstants.ts +0 -77
- package/src/games/dots-and-boxes/DotsAndBoxesGame.ts +0 -271
- package/src/games/dots-and-boxes/DotsAndBoxesScene.ts +0 -249
- package/src/games/falling-sticks/FallingSticks.tsx +0 -72
- package/src/games/falling-sticks/FallingSticksConstants.ts +0 -62
- package/src/games/falling-sticks/FallingSticksGame.ts +0 -220
- package/src/games/falling-sticks/FallingSticksRules.ts +0 -145
- package/src/games/falling-sticks/FallingSticksScene.ts +0 -245
- package/src/games/find-different-number/FindDifferentNumber.tsx +0 -74
- package/src/games/find-different-number/FindDifferentNumberConstants.ts +0 -74
- package/src/games/find-different-number/FindDifferentNumberGame.ts +0 -174
- package/src/games/find-different-number/FindDifferentNumberRules.ts +0 -43
- package/src/games/find-different-number/FindDifferentNumberScene.ts +0 -193
- package/src/games/flappy-bird/FlappyBird.tsx +0 -73
- package/src/games/flappy-bird/FlappyBirdConstants.ts +0 -95
- package/src/games/flappy-bird/FlappyBirdGame.ts +0 -375
- package/src/games/flappy-bird/FlappyBirdScene.ts +0 -630
- package/src/games/fruit-merger/FruitMerger.tsx +0 -73
- package/src/games/fruit-merger/FruitMergerConstants.ts +0 -102
- package/src/games/fruit-merger/FruitMergerGame.ts +0 -285
- package/src/games/fruit-merger/FruitMergerRules.ts +0 -286
- package/src/games/fruit-merger/FruitMergerScene.ts +0 -498
- package/src/games/fruit-ninja/FruitNinja.tsx +0 -129
- package/src/games/fruit-ninja/FruitNinjaConstants.ts +0 -107
- package/src/games/fruit-ninja/FruitNinjaGame.ts +0 -391
- package/src/games/fruit-ninja/FruitNinjaScene.ts +0 -319
- package/src/games/fruit-ninja/FruitNinjaWorld.ts +0 -17
- package/src/games/game-2048/Game2048.tsx +0 -84
- package/src/games/game-2048/Game2048Constants.ts +0 -68
- package/src/games/game-2048/Game2048Game.ts +0 -181
- package/src/games/game-2048/Game2048Rules.ts +0 -101
- package/src/games/game-2048/Game2048Scene.ts +0 -206
- package/src/games/knife-hit/KnifeHit.tsx +0 -78
- package/src/games/knife-hit/KnifeHitConstants.ts +0 -89
- package/src/games/knife-hit/KnifeHitGame.ts +0 -264
- package/src/games/knife-hit/KnifeHitScene.ts +0 -360
- package/src/games/ludo-king/LudoKing.tsx +0 -86
- package/src/games/ludo-king/LudoKingConstants.ts +0 -212
- package/src/games/ludo-king/LudoKingGame.ts +0 -326
- package/src/games/ludo-king/LudoKingRules.ts +0 -143
- package/src/games/ludo-king/LudoKingScene.ts +0 -397
- package/src/games/maze-runner/MazeRunner.tsx +0 -88
- package/src/games/maze-runner/MazeRunnerConstants.ts +0 -65
- package/src/games/maze-runner/MazeRunnerGame.ts +0 -176
- package/src/games/maze-runner/MazeRunnerRules.ts +0 -161
- package/src/games/maze-runner/MazeRunnerScene.ts +0 -245
- package/src/games/memory-match/MemoryMatch.tsx +0 -77
- package/src/games/memory-match/MemoryMatchConstants.ts +0 -105
- package/src/games/memory-match/MemoryMatchGame.ts +0 -222
- package/src/games/memory-match/MemoryMatchRules.ts +0 -38
- package/src/games/memory-match/MemoryMatchScene.ts +0 -268
- package/src/games/mine-sweeper/MineSweeper.tsx +0 -77
- package/src/games/mine-sweeper/MineSweeperConstants.ts +0 -94
- package/src/games/mine-sweeper/MineSweeperGame.ts +0 -234
- package/src/games/mine-sweeper/MineSweeperRules.ts +0 -67
- package/src/games/mine-sweeper/MineSweeperScene.ts +0 -262
- package/src/games/mob-control/MobControl.tsx +0 -73
- package/src/games/mob-control/MobControlConstants.ts +0 -106
- package/src/games/mob-control/MobControlGame.ts +0 -176
- package/src/games/mob-control/MobControlMeshes.ts +0 -85
- package/src/games/mob-control/MobControlRenderer.ts +0 -108
- package/src/games/mob-control/MobControlRules.ts +0 -522
- package/src/games/mob-control/MobControlScene.ts +0 -399
- package/src/games/number-search/NumberSearch.tsx +0 -18
- package/src/games/number-search/NumberSearchNumbers.ts +0 -623
- package/src/games/nuts-and-bolts/NutsAndBolts.tsx +0 -85
- package/src/games/nuts-and-bolts/NutsAndBoltsConstants.ts +0 -75
- package/src/games/nuts-and-bolts/NutsAndBoltsGame.ts +0 -298
- package/src/games/nuts-and-bolts/NutsAndBoltsRules.ts +0 -474
- package/src/games/nuts-and-bolts/NutsAndBoltsScene.ts +0 -498
- package/src/games/pac-man/PacMan.tsx +0 -86
- package/src/games/pac-man/PacManConstants.ts +0 -169
- package/src/games/pac-man/PacManGame.ts +0 -406
- package/src/games/pac-man/PacManRules.ts +0 -255
- package/src/games/pac-man/PacManScene.ts +0 -387
- package/src/games/paper-io/PaperIo.tsx +0 -91
- package/src/games/paper-io/PaperIoConstants.ts +0 -86
- package/src/games/paper-io/PaperIoGame.ts +0 -193
- package/src/games/paper-io/PaperIoMeshes.ts +0 -233
- package/src/games/paper-io/PaperIoRules.ts +0 -315
- package/src/games/paper-io/PaperIoScene.ts +0 -310
- package/src/games/penguin-run/PenguinMeshes.ts +0 -269
- package/src/games/penguin-run/PenguinModel.ts +0 -712
- package/src/games/penguin-run/PenguinRun.tsx +0 -77
- package/src/games/penguin-run/PenguinRunConstants.ts +0 -69
- package/src/games/penguin-run/PenguinRunGame.ts +0 -406
- package/src/games/penguin-run/PenguinRunScene.ts +0 -949
- package/src/games/perfect-circle/PerfectCircle.tsx +0 -74
- package/src/games/perfect-circle/PerfectCircleConstants.ts +0 -52
- package/src/games/perfect-circle/PerfectCircleGame.ts +0 -153
- package/src/games/perfect-circle/PerfectCircleRules.ts +0 -111
- package/src/games/perfect-circle/PerfectCircleScene.ts +0 -176
- package/src/games/pipe-connect/PipeConnect.tsx +0 -69
- package/src/games/pipe-connect/PipeConnectConstants.ts +0 -101
- package/src/games/pipe-connect/PipeConnectGame.ts +0 -179
- package/src/games/pipe-connect/PipeConnectRules.ts +0 -326
- package/src/games/pipe-connect/PipeConnectScene.ts +0 -271
- package/src/games/play-with-tua/PlayWithTua.tsx +0 -123
- package/src/games/play-with-tua/PlayWithTuaConstants.ts +0 -70
- package/src/games/play-with-tua/PlayWithTuaGame.ts +0 -167
- package/src/games/play-with-tua/PlayWithTuaModel.ts +0 -42
- package/src/games/play-with-tua/PlayWithTuaScene.ts +0 -36
- package/src/games/popit-fidget/PopitFidget.tsx +0 -72
- package/src/games/popit-fidget/PopitFidgetConstants.ts +0 -71
- package/src/games/popit-fidget/PopitFidgetGame.ts +0 -148
- package/src/games/popit-fidget/PopitFidgetScene.ts +0 -242
- package/src/games/reversi/Reversi.tsx +0 -94
- package/src/games/reversi/ReversiConstants.ts +0 -67
- package/src/games/reversi/ReversiGame.ts +0 -266
- package/src/games/reversi/ReversiRules.ts +0 -176
- package/src/games/reversi/ReversiScene.ts +0 -240
- package/src/games/search-grid/SearchGrid.tsx +0 -92
- package/src/games/search-grid/SearchGridConstants.ts +0 -178
- package/src/games/search-grid/SearchGridGame.ts +0 -209
- package/src/games/search-grid/SearchGridScene.ts +0 -301
- package/src/games/shared/BackdropCard.tsx +0 -54
- package/src/games/shared/EngineBackdrop.ts +0 -300
- package/src/games/shared/EngineBlasts.ts +0 -136
- package/src/games/shared/EngineBlocks.ts +0 -91
- package/src/games/shared/EngineControlText.ts +0 -17
- package/src/games/shared/EngineDice.ts +0 -250
- package/src/games/shared/EngineFootprint.ts +0 -35
- package/src/games/shared/EngineFruits.ts +0 -1435
- package/src/games/shared/EngineGameLoader.tsx +0 -88
- package/src/games/shared/EngineGameScreen.tsx +0 -325
- package/src/games/shared/EngineGameWidth.ts +0 -3
- package/src/games/shared/EngineGameWidth.web.ts +0 -3
- package/src/games/shared/EngineGlyphs.ts +0 -178
- package/src/games/shared/EngineHud.ts +0 -815
- package/src/games/shared/EngineLoading.ts +0 -477
- package/src/games/shared/EngineMeadow.ts +0 -725
- package/src/games/shared/EngineMeshCache.ts +0 -15
- package/src/games/shared/EngineMeshes.ts +0 -10
- package/src/games/shared/EngineRacingChase.ts +0 -21
- package/src/games/shared/EngineRacingHandling.ts +0 -48
- package/src/games/shared/EngineReadyContext.ts +0 -4
- package/src/games/shared/EngineTilt.ts +0 -44
- package/src/games/shared/EngineTouchSurface.tsx +0 -103
- package/src/games/shared/EngineUtils.ts +0 -52
- package/src/games/shared/GameActivity.ts +0 -13
- package/src/games/shared/GameLoading.tsx +0 -202
- package/src/games/shared/GameLoadingTransition.tsx +0 -61
- package/src/games/shared/ProceduralCacheVersion.ts +0 -2
- package/src/games/shared/useEngineGame.ts +0 -240
- package/src/games/shared/useGameResource.ts +0 -21
- package/src/games/shared/useLiveState.ts +0 -58
- package/src/games/sliding-numbers/SlidingNumbers.tsx +0 -71
- package/src/games/sliding-numbers/SlidingNumbersConstants.ts +0 -65
- package/src/games/sliding-numbers/SlidingNumbersGame.ts +0 -192
- package/src/games/sliding-numbers/SlidingNumbersRules.ts +0 -79
- package/src/games/sliding-numbers/SlidingNumbersScene.ts +0 -193
- package/src/games/snake-3d/Snake3D.tsx +0 -76
- package/src/games/snake-3d/Snake3DConstants.ts +0 -61
- package/src/games/snake-3d/Snake3DGame.ts +0 -192
- package/src/games/snake-3d/Snake3DMotion.ts +0 -22
- package/src/games/snake-3d/Snake3DRules.ts +0 -116
- package/src/games/snake-3d/Snake3DScene.ts +0 -322
- package/src/games/snakes-and-ladders/SnakesAndLadders.tsx +0 -87
- package/src/games/snakes-and-ladders/SnakesAndLaddersConstants.ts +0 -136
- package/src/games/snakes-and-ladders/SnakesAndLaddersGame.ts +0 -310
- package/src/games/snakes-and-ladders/SnakesAndLaddersScene.ts +0 -515
- package/src/games/space-fighter/SpaceFighter.tsx +0 -74
- package/src/games/space-fighter/SpaceFighterConstants.ts +0 -86
- package/src/games/space-fighter/SpaceFighterGame.ts +0 -292
- package/src/games/space-fighter/SpaceFighterScene.ts +0 -550
- package/src/games/spider-solitaire/SpiderSolitaire.tsx +0 -80
- package/src/games/spider-solitaire/SpiderSolitaireConstants.ts +0 -107
- package/src/games/spider-solitaire/SpiderSolitaireGame.ts +0 -387
- package/src/games/spider-solitaire/SpiderSolitaireRules.ts +0 -123
- package/src/games/spider-solitaire/SpiderSolitaireScene.ts +0 -352
- package/src/games/stack-tower/StackTower.tsx +0 -76
- package/src/games/stack-tower/StackTowerConstants.ts +0 -74
- package/src/games/stack-tower/StackTowerGame.ts +0 -236
- package/src/games/stack-tower/StackTowerScene.ts +0 -186
- package/src/games/sudoku/Sudoku.tsx +0 -73
- package/src/games/sudoku/SudokuConstants.ts +0 -127
- package/src/games/sudoku/SudokuGame.ts +0 -250
- package/src/games/sudoku/SudokuRules.ts +0 -125
- package/src/games/sudoku/SudokuScene.ts +0 -304
- package/src/games/tangram/Tangram.tsx +0 -79
- package/src/games/tangram/TangramConstants.ts +0 -64
- package/src/games/tangram/TangramGame.ts +0 -356
- package/src/games/tangram/TangramRules.ts +0 -409
- package/src/games/tangram/TangramScene.ts +0 -203
- package/src/games/tank-1990/Tank1990.tsx +0 -78
- package/src/games/tank-1990/Tank1990Constants.ts +0 -81
- package/src/games/tank-1990/Tank1990Game.ts +0 -331
- package/src/games/tank-1990/Tank1990Rules.ts +0 -390
- package/src/games/tank-1990/Tank1990Scene.ts +0 -434
- package/src/games/tic-tac-toe/TicTacToe.tsx +0 -98
- package/src/games/tic-tac-toe/TicTacToeConstants.ts +0 -69
- package/src/games/tic-tac-toe/TicTacToeGame.ts +0 -200
- package/src/games/tic-tac-toe/TicTacToeRules.ts +0 -103
- package/src/games/tic-tac-toe/TicTacToeScene.ts +0 -245
- package/src/games/tile-home/TileHome.tsx +0 -92
- package/src/games/tile-home/TileHomeConstants.ts +0 -139
- package/src/games/tile-home/TileHomeGame.ts +0 -435
- package/src/games/tile-home/TileHomeScene.ts +0 -154
- package/src/games/treasure-hunt/TreasureHunt.tsx +0 -206
- package/src/games/treasure-hunt/TreasureHuntConstants.ts +0 -266
- package/src/games/treasure-hunt/TreasureHuntControls.ts +0 -280
- package/src/games/treasure-hunt/TreasureHuntGame.ts +0 -402
- package/src/games/treasure-hunt/TreasureHuntMeshes.ts +0 -422
- package/src/games/treasure-hunt/TreasureHuntModel.ts +0 -506
- package/src/games/treasure-hunt/TreasureHuntRules.ts +0 -1210
- package/src/games/treasure-hunt/TreasureHuntScene.ts +0 -586
- package/src/games/whack-a-mole/WhackAMole.tsx +0 -79
- package/src/games/whack-a-mole/WhackAMoleConstants.ts +0 -94
- package/src/games/whack-a-mole/WhackAMoleGame.ts +0 -233
- package/src/games/whack-a-mole/WhackAMoleScene.ts +0 -349
- package/src/games/word-search/WordSearch.tsx +0 -18
- package/src/games/word-search/WordSearchWords.ts +0 -1642
- package/src/helpers/GamePatternData.ts +0 -120
- package/src/helpers/GameSettingsModal.tsx +0 -384
- package/src/helpers/GameTheme.tsx +0 -37
- package/src/helpers/IconPaths.ts +0 -6
- package/src/helpers/index.ts +0 -2
- package/src/index.tsx +0 -60
- package/src/services/GameAssetLoader.ts +0 -111
- package/src/services/GameAssets.ts +0 -149
- package/src/services/GameLoaders.ts +0 -93
- package/src/services/GamesConstants.ts +0 -193
- package/src/services/GamesMetadata.ts +0 -711
- package/src/services/GamesService.ts +0 -116
- package/src/services/HapticsService.ts +0 -48
- package/src/services/ScoringService.ts +0 -19
- package/src/services/SfxSources.ts +0 -81
- package/src/services/SoundsService.ts +0 -582
- package/src/services/ThemeService.ts +0 -281
- package/src/services/UtilsService.ts +0 -134
- package/src/services/index.ts +0 -6
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
// Spider Solitaire's timings, colors and layout. The rules (in SpiderSolitaireRules.ts) and the score
|
|
2
|
-
// reported on a win match the original version (games/spider-solitaire), so scores carry over.
|
|
3
|
-
import { getScoreBoardTop } from '../shared/EngineHud';
|
|
4
|
-
import { project, type TiltView } from '../shared/EngineTilt';
|
|
5
|
-
import { frontLight, gameWidthFor } from '../shared/EngineUtils';
|
|
6
|
-
import type { Suit } from './SpiderSolitaireRules';
|
|
7
|
-
|
|
8
|
-
// ── Rules and scoring ─────────────────────────────────────────────────
|
|
9
|
-
|
|
10
|
-
/** A win scores by its time against ten minutes, as the original game did. */
|
|
11
|
-
export const EXPECTED_TIME = 600;
|
|
12
|
-
export const BASE_SCORE = 100;
|
|
13
|
-
|
|
14
|
-
// ── Touch and feel ────────────────────────────────────────────────────
|
|
15
|
-
|
|
16
|
-
export const TAP_SLOP = 10; // points a finger may wander and still tap
|
|
17
|
-
export const MOVE_TIME = 0.24; // a card gliding to its place
|
|
18
|
-
export const DEAL_STAGGER = 0.05; // between the cards of a dealt row
|
|
19
|
-
export const RUN_STAGGER = 0.045; // between the cards of a finished run flying off
|
|
20
|
-
export const WIN_DELAY = 1.1; // the last run flies home before the win card shows
|
|
21
|
-
|
|
22
|
-
// ── Colors ────────────────────────────────────────────────────────────
|
|
23
|
-
|
|
24
|
-
export const COLORS = {
|
|
25
|
-
FACE: '#FFFFFF',
|
|
26
|
-
BACK: '#1565C0',
|
|
27
|
-
BACK_LIGHT: '#3B82D6',
|
|
28
|
-
BACK_FRAME: '#E3F2FD',
|
|
29
|
-
RED: '#DC2626',
|
|
30
|
-
BLACK: '#1F2937',
|
|
31
|
-
SELECTED: '#FFE082',
|
|
32
|
-
CLASSIC_SLOT: 'rgba(255, 255, 255, 0.35)'
|
|
33
|
-
} as const;
|
|
34
|
-
export const SUIT_COLORS: Record<Suit, string> = { hearts: COLORS.RED, diamonds: COLORS.RED, clubs: COLORS.BLACK, spades: COLORS.BLACK };
|
|
35
|
-
|
|
36
|
-
// ── The scene ─────────────────────────────────────────────────────────
|
|
37
|
-
|
|
38
|
-
/** The camera leans back a little from straight down, so the cards' thickness and the stacks read as 3D. */
|
|
39
|
-
export const TILT = 0.2;
|
|
40
|
-
/** Lit from the upper left; surfaces facing up off the table (+z) keep their exact color. */
|
|
41
|
-
export const LIGHT = frontLight([-0.35, 0.5, 1], 0.5);
|
|
42
|
-
|
|
43
|
-
/** A card is 1.4 times as tall as it is wide, and this thin (of its width). */
|
|
44
|
-
export const CARD_RATIO = 1.4;
|
|
45
|
-
export const THICKNESS = 0.024;
|
|
46
|
-
/** How far down a pile each card shows below the one under it (of a card's height), as the original piles. */
|
|
47
|
-
export const FACE_DOWN_STEP = 0.15;
|
|
48
|
-
export const FACE_UP_STEP = 0.25;
|
|
49
|
-
/** The deck and the finished runs along the bottom are drawn at this size. */
|
|
50
|
-
export const SMALL = 0.74;
|
|
51
|
-
|
|
52
|
-
// ── Layout (view points; the world is one unit per point) ─────────────
|
|
53
|
-
|
|
54
|
-
const SCOREBOARD_HEIGHT = 82;
|
|
55
|
-
const CONTROLS_HEIGHT = 110;
|
|
56
|
-
|
|
57
|
-
export type Layout = TiltView & {
|
|
58
|
-
/** A tableau card's width and height. */
|
|
59
|
-
card: number;
|
|
60
|
-
cardH: number;
|
|
61
|
-
/** Each pile's centre (world x). */
|
|
62
|
-
columns: number[];
|
|
63
|
-
pitch: number;
|
|
64
|
-
/** The top edge of a pile's first card, and the lowest a pile may reach (world y). */
|
|
65
|
-
pileTop: number;
|
|
66
|
-
pileBottom: number;
|
|
67
|
-
/** The bottom row: its centre (world y), the deck's right edge and the first finished run's centre (world x). */
|
|
68
|
-
rowY: number;
|
|
69
|
-
stockRight: number;
|
|
70
|
-
foundationX: number;
|
|
71
|
-
/** Heights between stacked cards (world z). */
|
|
72
|
-
dz: number;
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
/** The world y under a view y on the table. */
|
|
76
|
-
const tableY = (v: TiltView, sy: number) => (v.centerY - sy) / Math.cos(v.tilt);
|
|
77
|
-
|
|
78
|
-
/** All ten piles side by side across the game area (the original piles scrolled sideways), the deck and runs below. */
|
|
79
|
-
export function getLayout(width: number, height: number, offset: number, tablet: boolean): Layout {
|
|
80
|
-
const gameWidth = gameWidthFor(width);
|
|
81
|
-
const gap = Math.max(3, Math.min(8, Math.round(width * 0.012)));
|
|
82
|
-
const card = Math.max(20, Math.min(tablet ? 96 : 64, Math.floor((gameWidth - gap * 9) / 10)));
|
|
83
|
-
const cardH = card * CARD_RATIO;
|
|
84
|
-
const pitch = card + gap;
|
|
85
|
-
const v: TiltView = { width, height, centerY: height / 2, tilt: TILT };
|
|
86
|
-
const top = getScoreBoardTop(offset) + SCOREBOARD_HEIGHT;
|
|
87
|
-
const bottom = height - CONTROLS_HEIGHT;
|
|
88
|
-
const smallH = cardH * SMALL;
|
|
89
|
-
const rowSy = bottom - smallH / 2 - 4;
|
|
90
|
-
const left = -((pitch * 10 - gap) / 2);
|
|
91
|
-
return {
|
|
92
|
-
...v,
|
|
93
|
-
card,
|
|
94
|
-
cardH,
|
|
95
|
-
columns: Array.from({ length: 10 }, (_, i) => left + card / 2 + i * pitch),
|
|
96
|
-
pitch,
|
|
97
|
-
pileTop: tableY(v, top + 6),
|
|
98
|
-
pileBottom: tableY(v, rowSy - smallH / 2 - 10),
|
|
99
|
-
rowY: tableY(v, rowSy),
|
|
100
|
-
stockRight: -left,
|
|
101
|
-
foundationX: left + (card * SMALL) / 2,
|
|
102
|
-
dz: card * THICKNESS + 0.35
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/** Where a table point at height z shows in the view. */
|
|
107
|
-
export const onScreen = (l: Layout, x: number, y: number, z: number) => project(l, x, y, z);
|
|
@@ -1,387 +0,0 @@
|
|
|
1
|
-
// Spider Solitaire's play, with no React: build a game with `createGame`, give it a layout, `start` it
|
|
2
|
-
// and `tick` it every frame. Tap a face-up card to pick up the run from it down (it must descend by
|
|
3
|
-
// one), then tap another pile to put it there: on a card one rank higher, or an empty pile. Or drag the
|
|
4
|
-
// run straight there. Tap the deck to deal a card onto every pile. A King-to-Ace run of one suit lifts
|
|
5
|
-
// off by itself; all eight home wins. The clock counts up; the win scores by the time it took.
|
|
6
|
-
//
|
|
7
|
-
// The rules are the original store's (SpiderSolitaireRules.ts); every tap does what it did there.
|
|
8
|
-
import { type Camera, type DragEvent, World } from '@nayan-ui/engine';
|
|
9
|
-
import { calculateTimeBasedScore } from '../../services/ScoringService';
|
|
10
|
-
import type { GameTheme } from '../../services/ThemeService';
|
|
11
|
-
import { aimTilted, project, unproject } from '../shared/EngineTilt';
|
|
12
|
-
import { BASE_SCORE, DEAL_STAGGER, EXPECTED_TIME, type Layout, MOVE_TIME, RUN_STAGGER, SMALL, TAP_SLOP, WIN_DELAY } from './SpiderSolitaireConstants';
|
|
13
|
-
import {
|
|
14
|
-
type Board,
|
|
15
|
-
canMove,
|
|
16
|
-
type Card,
|
|
17
|
-
dealBlocked,
|
|
18
|
-
dealRow,
|
|
19
|
-
dealsLeft,
|
|
20
|
-
moveRun,
|
|
21
|
-
newBoard,
|
|
22
|
-
pickable,
|
|
23
|
-
PILES,
|
|
24
|
-
RUNS_TO_WIN,
|
|
25
|
-
takeCompletedRun
|
|
26
|
-
} from './SpiderSolitaireRules';
|
|
27
|
-
import {
|
|
28
|
-
buildScene,
|
|
29
|
-
celebrate,
|
|
30
|
-
type Held,
|
|
31
|
-
layoutCards,
|
|
32
|
-
pileOffsets,
|
|
33
|
-
pileSpot,
|
|
34
|
-
placeCards,
|
|
35
|
-
removeScene,
|
|
36
|
-
type Scene,
|
|
37
|
-
setSceneTheme,
|
|
38
|
-
shakeCards,
|
|
39
|
-
sparkle
|
|
40
|
-
} from './SpiderSolitaireScene';
|
|
41
|
-
|
|
42
|
-
export type Phase = 'ready' | 'playing' | 'over';
|
|
43
|
-
/** select / deselect: a run picked up or put back; invalid: a move or deal not allowed; place: a run moved; deal: a row dealt; complete: a run lifted off; win: the eighth. */
|
|
44
|
-
export type GameEvent = 'select' | 'deselect' | 'invalid' | 'place' | 'deal' | 'complete' | 'win';
|
|
45
|
-
|
|
46
|
-
const WORLD_CAPACITY = 900; // 104 cards with their pips, the empty places, and the bursts
|
|
47
|
-
|
|
48
|
-
/** What a finger is on: a pile's card, a pile (its empty place or below its cards), or the deck. */
|
|
49
|
-
type Hit = { kind: 'card'; pile: number; index: number } | { kind: 'pile'; pile: number } | { kind: 'stock' } | null;
|
|
50
|
-
|
|
51
|
-
export function createGame(theme: GameTheme) {
|
|
52
|
-
const world = new World(WORLD_CAPACITY);
|
|
53
|
-
const camera: Camera = { eye: [0, 0, 240], target: [0, 0, 0], fov: 1, ortho: 1 };
|
|
54
|
-
const g = {
|
|
55
|
-
world,
|
|
56
|
-
camera,
|
|
57
|
-
theme,
|
|
58
|
-
layout: null as Layout | null,
|
|
59
|
-
scene: null as Scene | null,
|
|
60
|
-
phase: 'ready' as Phase,
|
|
61
|
-
board: newBoard(),
|
|
62
|
-
/** The run picked up (tapped), or being dragged. */
|
|
63
|
-
held: null as Held,
|
|
64
|
-
/** A finger down: where, on what, and (once it's moved off) where it grabbed the dragged run. */
|
|
65
|
-
press: null as { x: number; y: number; hit: Hit; grab: [number, number] | null; dragging: boolean } | null,
|
|
66
|
-
/** Seconds since the start (the original game's elapsed clock), and the score a win reports: both in the engine (Rust). */
|
|
67
|
-
get time() {
|
|
68
|
-
return world.scoreboard.shownSeconds;
|
|
69
|
-
},
|
|
70
|
-
get score() {
|
|
71
|
-
return world.scoreboard.score;
|
|
72
|
-
},
|
|
73
|
-
won: false,
|
|
74
|
-
// UI hooks, set by the screen.
|
|
75
|
-
onPhase: (_p: Phase) => {},
|
|
76
|
-
onDeals: (_n: number) => {},
|
|
77
|
-
onCompleted: (_n: number) => {},
|
|
78
|
-
onEvent: (_e: GameEvent) => {}
|
|
79
|
-
};
|
|
80
|
-
world.scoreboard.reset();
|
|
81
|
-
return g;
|
|
82
|
-
}
|
|
83
|
-
export type Game = ReturnType<typeof createGame>;
|
|
84
|
-
|
|
85
|
-
const allCards = (b: Board): Card[] => [...b.tableau.flat(), ...b.stock, ...b.completed.flat()];
|
|
86
|
-
|
|
87
|
-
// ── Scene ─────────────────────────────────────────────────────────────
|
|
88
|
-
|
|
89
|
-
/** Lays the table out for the view (first layout, header height, rotation); the first deal glides out of the deck. */
|
|
90
|
-
export function setLayout(g: Game, l: Layout) {
|
|
91
|
-
const first = !g.scene;
|
|
92
|
-
if (g.scene) removeScene(g.world, g.scene);
|
|
93
|
-
g.layout = l;
|
|
94
|
-
aimTilted(g.camera, l);
|
|
95
|
-
g.scene = buildScene(g.world, l, g.theme, allCards(g.board));
|
|
96
|
-
if (first) draw(g, dealOrder(g.board));
|
|
97
|
-
else draw(g, () => 0, true);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export function setTheme(g: Game, theme: GameTheme) {
|
|
101
|
-
g.theme = theme;
|
|
102
|
-
if (g.scene) setSceneTheme(g.world, g.scene, theme);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function draw(g: Game, delay?: (id: string) => number, instant = false, onlyHeld = false) {
|
|
106
|
-
const { layout: l, scene: s } = g;
|
|
107
|
-
if (l && s) placeCards(g.world, l, s, layoutCards(l, g.board, g.held, onlyHeld), delay, instant);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/** A fresh deal's cards leave the deck one after another, round the piles as a dealer would. */
|
|
111
|
-
function dealOrder(b: Board) {
|
|
112
|
-
const order = new Map<string, number>();
|
|
113
|
-
b.tableau.forEach((pile, col) => pile.forEach((c, i) => order.set(c.id, (i * PILES + col) * 0.018)));
|
|
114
|
-
return (id: string) => order.get(id) ?? 0;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function report(g: Game) {
|
|
118
|
-
g.onDeals(dealsLeft(g.board));
|
|
119
|
-
g.onCompleted(g.board.completed.length);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// ── Run ───────────────────────────────────────────────────────────────
|
|
123
|
-
|
|
124
|
-
/** Starts play on the deal already on the table. */
|
|
125
|
-
export function start(g: Game) {
|
|
126
|
-
if (g.phase !== 'ready') return;
|
|
127
|
-
g.phase = 'playing';
|
|
128
|
-
g.world.scoreboard.reset();
|
|
129
|
-
g.world.scoreboard.startClock();
|
|
130
|
-
g.won = false;
|
|
131
|
-
g.onPhase('playing');
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/** A fresh shuffle dealt out, not started (Stop, Play Again). The world, and the GPU view drawing it, are kept. */
|
|
135
|
-
export function reset(g: Game) {
|
|
136
|
-
g.world.cancelTimers();
|
|
137
|
-
g.board = newBoard();
|
|
138
|
-
g.held = null;
|
|
139
|
-
g.press = null;
|
|
140
|
-
g.world.scoreboard.reset();
|
|
141
|
-
g.won = false;
|
|
142
|
-
g.phase = 'ready';
|
|
143
|
-
draw(g, dealOrder(g.board));
|
|
144
|
-
report(g);
|
|
145
|
-
g.onPhase('ready');
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
export function dispose(g: Game) {
|
|
149
|
-
g.world.dispose();
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
export function tick(g: Game, dt: number) {
|
|
153
|
-
if (g.world.isDisposed) return;
|
|
154
|
-
g.world.update(dt);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
const canPlay = (g: Game) => g.phase === 'playing' && !g.won;
|
|
158
|
-
|
|
159
|
-
// ── The finger ────────────────────────────────────────────────────────
|
|
160
|
-
|
|
161
|
-
/** What's under a view point: the top-most card there, a pile's column, or the deck. */
|
|
162
|
-
export function hitAt(g: Game, sx: number, sy: number): Hit {
|
|
163
|
-
const l = g.layout;
|
|
164
|
-
if (!l) return null;
|
|
165
|
-
const b = g.board;
|
|
166
|
-
// The deck (or its empty place)
|
|
167
|
-
const small = l.card * SMALL;
|
|
168
|
-
const fan = Math.max(0, dealsLeft(b) - 1) * small * 0.22;
|
|
169
|
-
const [, deckTop] = project(l, 0, l.rowY + (l.cardH * SMALL) / 2, 2);
|
|
170
|
-
const [, deckBottom] = project(l, 0, l.rowY - (l.cardH * SMALL) / 2, 2);
|
|
171
|
-
const [deckLeft] = project(l, l.stockRight - small - fan, 0);
|
|
172
|
-
const [deckRight] = project(l, l.stockRight, 0);
|
|
173
|
-
if (sx >= deckLeft - 4 && sx <= deckRight + 4 && sy >= deckTop - 4 && sy <= deckBottom + 4) return { kind: 'stock' };
|
|
174
|
-
// A pile: the column under the finger, then the top-most of its cards there
|
|
175
|
-
const [wx] = unproject(l, sx, sy);
|
|
176
|
-
const col = l.columns.findIndex((x) => Math.abs(wx - x) <= l.pitch / 2);
|
|
177
|
-
if (col < 0) return null;
|
|
178
|
-
const pile = b.tableau[col]!;
|
|
179
|
-
const offsets = pileOffsets(l, pile);
|
|
180
|
-
for (let i = pile.length - 1; i >= 0; i--) {
|
|
181
|
-
const [, y, z] = pileSpot(l, col, offsets[i]!, i);
|
|
182
|
-
const [, top] = project(l, 0, y + l.cardH / 2, z);
|
|
183
|
-
const [, bottom] = project(l, 0, y - l.cardH / 2, z);
|
|
184
|
-
if (sy >= top && sy <= bottom) return { kind: 'card', pile: col, index: i };
|
|
185
|
-
}
|
|
186
|
-
const [, pileTop] = project(l, 0, l.pileTop, 0);
|
|
187
|
-
const [, pileBottom] = project(l, 0, l.pileBottom, 0);
|
|
188
|
-
return sy >= pileTop && sy <= pileBottom ? { kind: 'pile', pile: col } : null;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
/** A quick tap does what it did in the original game; a finger that moves off a face-up run drags it. */
|
|
192
|
-
export function drag(g: Game, e: DragEvent) {
|
|
193
|
-
const l = g.layout;
|
|
194
|
-
if (!l) return;
|
|
195
|
-
if (e.phase === 'start') {
|
|
196
|
-
g.press = { x: e.x, y: e.y, hit: canPlay(g) ? hitAt(g, e.x, e.y) : null, grab: null, dragging: false };
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
199
|
-
const p = g.press;
|
|
200
|
-
if (!p) return;
|
|
201
|
-
if (!p.dragging && Math.hypot(e.x - p.x, e.y - p.y) > TAP_SLOP) {
|
|
202
|
-
if (!beginDrag(g, p)) {
|
|
203
|
-
g.press = null;
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
if (p.dragging) {
|
|
208
|
-
const held = g.held;
|
|
209
|
-
if (!held || !canPlay(g)) {
|
|
210
|
-
g.press = null;
|
|
211
|
-
return;
|
|
212
|
-
}
|
|
213
|
-
const [wx, wy] = unproject(l, e.x, e.y, 40);
|
|
214
|
-
held.drag = { x: wx + p.grab![0], y: wy + p.grab![1] };
|
|
215
|
-
if (e.phase !== 'end') {
|
|
216
|
-
draw(g, undefined, true, true);
|
|
217
|
-
return;
|
|
218
|
-
}
|
|
219
|
-
g.press = null;
|
|
220
|
-
held.drag = null;
|
|
221
|
-
if (e.cancelled) return putBack(g);
|
|
222
|
-
// Dropped on the pile nearest the run's top card
|
|
223
|
-
const x = wx + p.grab![0];
|
|
224
|
-
let to = 0;
|
|
225
|
-
for (let i = 1; i < l.columns.length; i++) if (Math.abs(l.columns[i]! - x) < Math.abs(l.columns[to]! - x)) to = i;
|
|
226
|
-
if (to === held.pile || Math.abs(l.columns[to]! - x) > l.pitch) return putBack(g);
|
|
227
|
-
moveTo(g, to);
|
|
228
|
-
return;
|
|
229
|
-
}
|
|
230
|
-
if (e.phase !== 'end') return;
|
|
231
|
-
g.press = null;
|
|
232
|
-
tap(g, p.hit);
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
/** Picks up the run under a finger that's moved off it, if it can be picked up. */
|
|
236
|
-
function beginDrag(g: Game, p: NonNullable<Game['press']>): boolean {
|
|
237
|
-
const l = g.layout!;
|
|
238
|
-
const hit = p.hit;
|
|
239
|
-
if (!canPlay(g) || !hit || hit.kind !== 'card') return false;
|
|
240
|
-
const run = pickable(g.board, hit.pile, hit.index);
|
|
241
|
-
if (!run) {
|
|
242
|
-
// A face-up card that doesn't head a run: as the original tap, "not allowed"
|
|
243
|
-
if (g.board.tableau[hit.pile]![hit.index]!.faceUp) {
|
|
244
|
-
if (g.scene)
|
|
245
|
-
shakeCards(
|
|
246
|
-
g.world,
|
|
247
|
-
g.scene,
|
|
248
|
-
g.board.tableau[hit.pile]!.slice(hit.index).map((c) => c.id)
|
|
249
|
-
);
|
|
250
|
-
g.onEvent('invalid');
|
|
251
|
-
}
|
|
252
|
-
return false;
|
|
253
|
-
}
|
|
254
|
-
const offsets = pileOffsets(l, g.board.tableau[hit.pile]!);
|
|
255
|
-
const [x, y] = pileSpot(l, hit.pile, offsets[hit.index]!, hit.index);
|
|
256
|
-
const [wx, wy] = unproject(l, p.x, p.y, 40);
|
|
257
|
-
p.grab = [x - wx, y - wy];
|
|
258
|
-
p.dragging = true;
|
|
259
|
-
const had = g.held;
|
|
260
|
-
g.held = { pile: hit.pile, index: hit.index, drag: { x, y } };
|
|
261
|
-
if (!had || had.pile !== hit.pile || had.index !== hit.index) g.onEvent('select');
|
|
262
|
-
// Clear any previously selected run once; subsequent moves lay out only the held cards.
|
|
263
|
-
draw(g, undefined, true);
|
|
264
|
-
return true;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
/** A dragged run let go off any pile (or back on its own) settles back where it was. */
|
|
268
|
-
function putBack(g: Game) {
|
|
269
|
-
g.held = null;
|
|
270
|
-
draw(g);
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
function tap(g: Game, hit: Hit) {
|
|
274
|
-
if (!canPlay(g) || !hit) return;
|
|
275
|
-
if (hit.kind === 'stock') return deal(g);
|
|
276
|
-
if (hit.kind === 'card') return select(g, hit.pile, hit.index);
|
|
277
|
-
// An empty pile (or the space below a pile's cards) takes the picked-up run
|
|
278
|
-
const held = g.held;
|
|
279
|
-
if (held && held.pile !== hit.pile) moveTo(g, hit.pile);
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
// ── Moves (the original store's, step for step) ───────────────────────────
|
|
283
|
-
|
|
284
|
-
/** A card tapped: put back the run if it's the one picked up, move the picked-up run here, or pick up from here. */
|
|
285
|
-
export function select(g: Game, pile: number, index: number) {
|
|
286
|
-
if (!canPlay(g)) return;
|
|
287
|
-
const held = g.held;
|
|
288
|
-
if (held && held.pile === pile && held.index === index) {
|
|
289
|
-
g.held = null;
|
|
290
|
-
draw(g);
|
|
291
|
-
g.onEvent('deselect');
|
|
292
|
-
return;
|
|
293
|
-
}
|
|
294
|
-
if (held && held.pile !== pile) return moveTo(g, pile);
|
|
295
|
-
if (held) g.held = null;
|
|
296
|
-
const card = g.board.tableau[pile]?.[index];
|
|
297
|
-
if (!card || !card.faceUp) return draw(g);
|
|
298
|
-
if (!pickable(g.board, pile, index)) {
|
|
299
|
-
draw(g);
|
|
300
|
-
if (g.scene)
|
|
301
|
-
shakeCards(
|
|
302
|
-
g.world,
|
|
303
|
-
g.scene,
|
|
304
|
-
g.board.tableau[pile]!.slice(index).map((c) => c.id)
|
|
305
|
-
);
|
|
306
|
-
g.onEvent('invalid');
|
|
307
|
-
return;
|
|
308
|
-
}
|
|
309
|
-
g.held = { pile, index, drag: null };
|
|
310
|
-
draw(g);
|
|
311
|
-
g.onEvent('select');
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
/** Puts the picked-up run on a pile, if it may go there. */
|
|
315
|
-
export function moveTo(g: Game, to: number) {
|
|
316
|
-
const held = g.held;
|
|
317
|
-
if (!held) return;
|
|
318
|
-
g.held = null;
|
|
319
|
-
if (held.pile === to) return draw(g);
|
|
320
|
-
const run = g.board.tableau[held.pile]!.slice(held.index);
|
|
321
|
-
if (!canMove(g.board, run, to)) {
|
|
322
|
-
draw(g);
|
|
323
|
-
if (g.scene)
|
|
324
|
-
shakeCards(
|
|
325
|
-
g.world,
|
|
326
|
-
g.scene,
|
|
327
|
-
run.map((c) => c.id)
|
|
328
|
-
);
|
|
329
|
-
g.onEvent('invalid');
|
|
330
|
-
return;
|
|
331
|
-
}
|
|
332
|
-
moveRun(g.board, held.pile, held.index, to);
|
|
333
|
-
const done = checkRun(g, to, MOVE_TIME);
|
|
334
|
-
draw(g, done);
|
|
335
|
-
report(g);
|
|
336
|
-
g.onEvent('place');
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
/** One card onto every pile from the deck (not while a pile is empty). */
|
|
340
|
-
export function deal(g: Game) {
|
|
341
|
-
if (!canPlay(g)) return;
|
|
342
|
-
if (dealBlocked(g.board)) {
|
|
343
|
-
g.onEvent('invalid');
|
|
344
|
-
return;
|
|
345
|
-
}
|
|
346
|
-
const dealt = g.board.stock.slice(-PILES).reverse();
|
|
347
|
-
dealRow(g.board);
|
|
348
|
-
g.held = null;
|
|
349
|
-
const delays = new Map<string, number>(dealt.map((c, i) => [c.id, i * DEAL_STAGGER]));
|
|
350
|
-
const runs: ((id: string) => number)[] = [];
|
|
351
|
-
for (let i = 0; i < PILES; i++) runs.push(checkRun(g, i, MOVE_TIME + PILES * DEAL_STAGGER));
|
|
352
|
-
draw(g, (id) => delays.get(id) ?? Math.max(0, ...runs.map((r) => r(id))));
|
|
353
|
-
report(g);
|
|
354
|
-
g.onEvent('deal');
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
/**
|
|
358
|
-
* Lifts a finished run off a pile, if there is one: it flies home Ace first, after `after` seconds (the
|
|
359
|
-
* move that made it lands first). Returns each of its cards' delay; the eighth wins.
|
|
360
|
-
*/
|
|
361
|
-
function checkRun(g: Game, pile: number, after: number): (id: string) => number {
|
|
362
|
-
const offsets = g.layout ? pileOffsets(g.layout, g.board.tableau[pile]!) : [];
|
|
363
|
-
const run = takeCompletedRun(g.board, pile);
|
|
364
|
-
if (!run) return () => 0;
|
|
365
|
-
const l = g.layout;
|
|
366
|
-
if (l) {
|
|
367
|
-
const i = g.board.tableau[pile]!.length;
|
|
368
|
-
const [x, y] = pileSpot(l, pile, offsets[Math.min(i, offsets.length - 1)] ?? 0, i);
|
|
369
|
-
g.world.after(after, () => sparkle(g.world, l, x, y - l.cardH * 0.5));
|
|
370
|
-
}
|
|
371
|
-
g.onEvent('complete');
|
|
372
|
-
if (g.board.completed.length >= RUNS_TO_WIN) win(g);
|
|
373
|
-
const delays = new Map<string, number>(run.map((c, j) => [c.id, after + (12 - j) * RUN_STAGGER]));
|
|
374
|
-
return (id) => delays.get(id) ?? 0;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
function win(g: Game) {
|
|
378
|
-
g.won = true;
|
|
379
|
-
g.world.scoreboard.stop();
|
|
380
|
-
g.world.scoreboard.set(calculateTimeBasedScore(g.time, EXPECTED_TIME, BASE_SCORE));
|
|
381
|
-
g.onEvent('win');
|
|
382
|
-
g.world.after(WIN_DELAY, () => {
|
|
383
|
-
if (g.layout) celebrate(g.world, g.layout);
|
|
384
|
-
g.phase = 'over';
|
|
385
|
-
g.onPhase('over');
|
|
386
|
-
});
|
|
387
|
-
}
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
// Spider Solitaire's rules, with no React or engine: the deal, which runs may be picked up, where they
|
|
2
|
-
// may go, dealing a row from the stock and lifting out a finished King-to-Ace run. Ported from the
|
|
3
|
-
// original store (games/spider-solitaire), so a deal and every move play out as they did.
|
|
4
|
-
|
|
5
|
-
export const SUITS = ['hearts', 'diamonds', 'clubs', 'spades'] as const;
|
|
6
|
-
export const VALUES = ['A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K'] as const;
|
|
7
|
-
export type Suit = (typeof SUITS)[number];
|
|
8
|
-
export type Value = (typeof VALUES)[number];
|
|
9
|
-
|
|
10
|
-
export type Card = { id: string; suit: Suit; value: Value; faceUp: boolean };
|
|
11
|
-
/** The 10 piles, the stock (dealt from its end) and the runs lifted out so far (each K first). */
|
|
12
|
-
export type Board = { tableau: Card[][]; stock: Card[]; completed: Card[][] };
|
|
13
|
-
|
|
14
|
-
export const PILES = 10;
|
|
15
|
-
export const RUNS_TO_WIN = 8;
|
|
16
|
-
/** As the original game: always two suits. */
|
|
17
|
-
export const SUIT_COUNT = 2;
|
|
18
|
-
|
|
19
|
-
const RANK: Record<Value, number> = { 'A': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, '10': 10, 'J': 11, 'Q': 12, 'K': 13 };
|
|
20
|
-
export const rank = (v: Value) => RANK[v];
|
|
21
|
-
|
|
22
|
-
/** Two decks' worth: enough of each suit in play to make eight runs. */
|
|
23
|
-
function createDeck(suitCount: number): Card[] {
|
|
24
|
-
const deck: Card[] = [];
|
|
25
|
-
const suits = SUITS.slice(0, suitCount);
|
|
26
|
-
let id = 0;
|
|
27
|
-
for (let d = 0; d < Math.ceil(8 / suitCount); d++)
|
|
28
|
-
for (const suit of suits) for (const value of VALUES) deck.push({ id: `${suit}-${value}-${id++}`, suit, value, faceUp: false });
|
|
29
|
-
return deck.slice(0, 104);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function shuffle(deck: Card[]): Card[] {
|
|
33
|
-
const out = [...deck];
|
|
34
|
-
for (let i = out.length - 1; i > 0; i--) {
|
|
35
|
-
const j = Math.floor(Math.random() * (i + 1));
|
|
36
|
-
[out[i], out[j]] = [out[j]!, out[i]!];
|
|
37
|
-
}
|
|
38
|
-
return out;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/** A fresh deal: six cards in each of the first four piles, five in the rest, only the top ones face up; 50 left to deal. */
|
|
42
|
-
export function newBoard(): Board {
|
|
43
|
-
const deck = shuffle(createDeck(SUIT_COUNT));
|
|
44
|
-
const tableau: Card[][] = [];
|
|
45
|
-
let k = 0;
|
|
46
|
-
for (let i = 0; i < PILES; i++) {
|
|
47
|
-
const n = i < 4 ? 6 : 5;
|
|
48
|
-
const pile: Card[] = [];
|
|
49
|
-
for (let j = 0; j < n; j++) pile.push({ ...deck[k++]!, faceUp: j === n - 1 });
|
|
50
|
-
tableau.push(pile);
|
|
51
|
-
}
|
|
52
|
-
return { tableau, stock: deck.slice(k).map((c) => ({ ...c, faceUp: false })), completed: [] };
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/** Descending by one all the way down (any suit), so it can be picked up together. */
|
|
56
|
-
export function isValidSequence(cards: Card[]): boolean {
|
|
57
|
-
if (!cards.length) return false;
|
|
58
|
-
for (let i = 0; i < cards.length - 1; i++) if (rank(cards[i]!.value) !== rank(cards[i + 1]!.value) + 1) return false;
|
|
59
|
-
return true;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/** Whether a run can go on a pile: anything on an empty one, else one rank below its face-up top card. */
|
|
63
|
-
export function canMove(b: Board, cards: Card[], to: number): boolean {
|
|
64
|
-
const pile = b.tableau[to];
|
|
65
|
-
const first = cards[0];
|
|
66
|
-
if (!pile || !first) return false;
|
|
67
|
-
const top = pile[pile.length - 1];
|
|
68
|
-
if (!top) return true;
|
|
69
|
-
return top.faceUp && rank(first.value) === rank(top.value) - 1;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/** The run from `index` down, if it may be picked up (a single face-up card always may). */
|
|
73
|
-
export function pickable(b: Board, pile: number, index: number): Card[] | null {
|
|
74
|
-
const p = b.tableau[pile];
|
|
75
|
-
const card = p?.[index];
|
|
76
|
-
if (!p || !card || !card.faceUp) return null;
|
|
77
|
-
const run = p.slice(index);
|
|
78
|
-
return run.length === 1 || isValidSequence(run) ? run : null;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const flipTop = (pile: Card[]) => {
|
|
82
|
-
const top = pile[pile.length - 1];
|
|
83
|
-
if (top && !top.faceUp) top.faceUp = true;
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
/** Moves the run from `from` at `index` onto `to` (already checked), turning up the card it uncovers. */
|
|
87
|
-
export function moveRun(b: Board, from: number, index: number, to: number) {
|
|
88
|
-
const src = b.tableau[from]!;
|
|
89
|
-
const run = src.splice(index);
|
|
90
|
-
flipTop(src);
|
|
91
|
-
b.tableau[to]!.push(...run.map((c) => ({ ...c, faceUp: true })));
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/** Why a row can't be dealt (an empty pile, or nothing left), or null if it can. */
|
|
95
|
-
export const dealBlocked = (b: Board): 'empty-pile' | 'no-stock' | null =>
|
|
96
|
-
b.tableau.some((p) => p.length === 0) ? 'empty-pile' : b.stock.length === 0 ? 'no-stock' : null;
|
|
97
|
-
|
|
98
|
-
/** One card face up onto every pile, from the stock's end. */
|
|
99
|
-
export function dealRow(b: Board) {
|
|
100
|
-
for (let i = 0; i < PILES && b.stock.length > 0; i++) {
|
|
101
|
-
const card = b.stock.pop()!;
|
|
102
|
-
card.faceUp = true;
|
|
103
|
-
b.tableau[i]!.push(card);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const RUN: Value[] = ['K', 'Q', 'J', '10', '9', '8', '7', '6', '5', '4', '3', '2', 'A'];
|
|
108
|
-
|
|
109
|
-
/** Lifts a finished King-to-Ace run of one suit off the end of a pile, if there is one; returns it. */
|
|
110
|
-
export function takeCompletedRun(b: Board, pile: number): Card[] | null {
|
|
111
|
-
const p = b.tableau[pile];
|
|
112
|
-
if (!p || p.length < 13) return null;
|
|
113
|
-
const last = p.slice(-13);
|
|
114
|
-
const suit = last[0]!.suit;
|
|
115
|
-
if (!last.every((c, i) => c.suit === suit && c.value === RUN[i])) return null;
|
|
116
|
-
p.splice(-13);
|
|
117
|
-
flipTop(p);
|
|
118
|
-
b.completed.push(last);
|
|
119
|
-
return last;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/** Deals left (each a row of 10). */
|
|
123
|
-
export const dealsLeft = (b: Board) => Math.ceil(b.stock.length / PILES);
|