pixi-reels 4.4.1 → 5.0.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/CHANGELOG.md +93 -0
- package/README.md +4 -4
- package/dist/ObjectPool-BW9bKrDL.js +63 -0
- package/dist/ObjectPool-BW9bKrDL.js.map +1 -0
- package/dist/ObjectPool-DB4X2RtM.cjs +2 -0
- package/dist/ObjectPool-DB4X2RtM.cjs.map +1 -0
- package/dist/{PhaseCardSymbol-Ct9bCE4I.cjs → PhaseCardSymbol-7lDe3r-J.cjs} +2 -2
- package/dist/{PhaseCardSymbol-Ct9bCE4I.cjs.map → PhaseCardSymbol-7lDe3r-J.cjs.map} +1 -1
- package/dist/{PhaseCardSymbol-bVa7GpDn.js → PhaseCardSymbol-GpZ1FPA1.js} +2 -2
- package/dist/{PhaseCardSymbol-bVa7GpDn.js.map → PhaseCardSymbol-GpZ1FPA1.js.map} +1 -1
- package/dist/{ReelSymbol-C7Pd7BeO.js → ReelSymbol-C2Du9CWR.js} +42 -28
- package/dist/ReelSymbol-C2Du9CWR.js.map +1 -0
- package/dist/ReelSymbol-CB5GkYP3.cjs +2 -0
- package/dist/ReelSymbol-CB5GkYP3.cjs.map +1 -0
- package/dist/board/HoldAndWinState.d.ts.map +1 -1
- package/dist/cascade/tumbleAlgorithm.d.ts +2 -1
- package/dist/cascade/tumbleAlgorithm.d.ts.map +1 -1
- package/dist/config/SpeedPresets.d.ts +5 -0
- package/dist/config/SpeedPresets.d.ts.map +1 -1
- package/dist/config/types.d.ts +13 -12
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/v1Renames.d.ts +6 -1
- package/dist/config/v1Renames.d.ts.map +1 -1
- package/dist/core/Reel.d.ts +8 -0
- package/dist/core/Reel.d.ts.map +1 -1
- package/dist/core/ReelSet.d.ts +5 -0
- package/dist/core/ReelSet.d.ts.map +1 -1
- package/dist/core/ReelSetBuilder.d.ts +13 -15
- package/dist/core/ReelSetBuilder.d.ts.map +1 -1
- package/dist/core/ReelViewport.d.ts +21 -18
- package/dist/core/ReelViewport.d.ts.map +1 -1
- package/dist/core/maskStrategies.d.ts +14 -11
- package/dist/core/maskStrategies.d.ts.map +1 -1
- package/dist/debug/debugOverlay.d.ts.map +1 -1
- package/dist/debug/roundRectPath.d.ts +1 -1
- package/dist/{debug-DafouaZ6.js → debug-CYw6yqjb.js} +602 -540
- package/dist/debug-CYw6yqjb.js.map +1 -0
- package/dist/debug-Dmjj8dAd.cjs +4 -0
- package/dist/debug-Dmjj8dAd.cjs.map +1 -0
- package/dist/debug.cjs +2 -2
- package/dist/debug.cjs.map +1 -1
- package/dist/debug.js +85 -73
- package/dist/debug.js.map +1 -1
- package/dist/events/EventEmitter.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +140 -120
- package/dist/index.js.map +1 -1
- package/dist/snapshot/StaticSpinSymbol.d.ts.map +1 -1
- package/dist/speed/SpeedManager.d.ts +6 -1
- package/dist/speed/SpeedManager.d.ts.map +1 -1
- package/dist/spin/SpinController.d.ts +28 -0
- package/dist/spin/SpinController.d.ts.map +1 -1
- package/dist/spin/modes/CascadeMode.d.ts +5 -0
- package/dist/spin/modes/CascadeMode.d.ts.map +1 -1
- package/dist/spin/modes/SpinningMode.d.ts +1 -1
- package/dist/spin/modes/StandardMode.d.ts +10 -0
- package/dist/spin/modes/StandardMode.d.ts.map +1 -1
- package/dist/spin/phases/AdjustPhase.d.ts.map +1 -1
- package/dist/spin/phases/ReelPhase.d.ts +2 -0
- package/dist/spin/phases/ReelPhase.d.ts.map +1 -1
- package/dist/spin/phases/steps.d.ts.map +1 -1
- package/dist/spine/SpinePool.d.ts +139 -0
- package/dist/spine/SpinePool.d.ts.map +1 -0
- package/dist/spine/SpineReelSymbol.d.ts +86 -30
- package/dist/spine/SpineReelSymbol.d.ts.map +1 -1
- package/dist/spine/index.d.ts +2 -0
- package/dist/spine/index.d.ts.map +1 -1
- package/dist/spine.cjs +1 -1
- package/dist/spine.cjs.map +1 -1
- package/dist/spine.js +243 -61
- package/dist/spine.js.map +1 -1
- package/dist/symbols/AnimatedSpriteSymbol.d.ts.map +1 -1
- package/dist/symbols/ReelSymbol.d.ts +18 -0
- package/dist/symbols/ReelSymbol.d.ts.map +1 -1
- package/dist/symbols/SpineSymbol.d.ts +35 -18
- package/dist/symbols/SpineSymbol.d.ts.map +1 -1
- package/dist/symbols/SpriteSymbol.d.ts +5 -0
- package/dist/symbols/SpriteSymbol.d.ts.map +1 -1
- package/dist/testing.cjs +1 -1
- package/dist/testing.js +2 -2
- package/dist/wins/WinPresenter.d.ts +7 -2
- package/dist/wins/WinPresenter.d.ts.map +1 -1
- package/package.json +10 -10
- package/dist/ReelSymbol-B5QBhkmw.cjs +0 -2
- package/dist/ReelSymbol-B5QBhkmw.cjs.map +0 -1
- package/dist/ReelSymbol-C7Pd7BeO.js.map +0 -1
- package/dist/SpineSymbol-C6V1wpFV.cjs +0 -2
- package/dist/SpineSymbol-C6V1wpFV.cjs.map +0 -1
- package/dist/SpineSymbol-W5z5WZ2r.js +0 -76
- package/dist/SpineSymbol-W5z5WZ2r.js.map +0 -1
- package/dist/debug-DafouaZ6.js.map +0 -1
- package/dist/debug-Dq7W3pAD.cjs +0 -4
- package/dist/debug-Dq7W3pAD.cjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,98 @@
|
|
|
1
1
|
# pixi-reels
|
|
2
2
|
|
|
3
|
+
## 5.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#304](https://github.com/schmooky/pixi-reels/pull/304) [`c5b957f`](https://github.com/schmooky/pixi-reels/commit/c5b957f611a6626c0703ac99cd76dc30ce447b9d) Thanks [@igaming-bulochka](https://github.com/igaming-bulochka)! - Change: `ReelSetBuilder.build()` throws, naming the input, where it used to build something broken: a `symbolSize()` that is zero, negative or not a number; a weight in `weights()`, `randomSymbols()` or `symbolData()` that is negative, infinite or not a number; a `size` that is not a whole number of cells of at least 1 (a 0-cell size hung `splitSymbol()`); and `symbolData()` for an id that is not registered. A game that shares one `symbolData` table between sets that register different symbols must pass each set only its own ids.
|
|
8
|
+
|
|
9
|
+
- [#304](https://github.com/schmooky/pixi-reels/pull/304) [`c5b957f`](https://github.com/schmooky/pixi-reels/commit/c5b957f611a6626c0703ac99cd76dc30ce447b9d) Thanks [@igaming-bulochka](https://github.com/igaming-bulochka)! - Change: `destroy()` in the middle of a round rejects the round's promise with an `AbortError`, as `nudge()` already did: `spin()`, `refill()`, and the `runCascade()`, `expand()` and Hold & Win `respin()` calls that wait on them. The promise used to stay pending for good, so the code after its `await` never ran. A game that tears a set down mid-round and awaits the round should catch it: `.catch((e) => { if (e.name !== 'AbortError') throw e; })`.
|
|
10
|
+
|
|
11
|
+
- [#304](https://github.com/schmooky/pixi-reels/pull/304) [`c5b957f`](https://github.com/schmooky/pixi-reels/commit/c5b957f611a6626c0703ac99cd76dc30ce447b9d) Thanks [@igaming-bulochka](https://github.com/igaming-bulochka)! - Change: the viewport dim draws as dark as asked. `spotlight.show({ dimAmount })`, `viewport.showDim(alpha)` and `destroySymbols({ dim })` drew half their value: the default `dimAmount: 0.5` drew 25 percent black. To keep the 4.x look, pass half the value you passed before, and `dimAmount: 0.25` where you relied on the default.
|
|
12
|
+
|
|
13
|
+
- [#304](https://github.com/schmooky/pixi-reels/pull/304) [`c5b957f`](https://github.com/schmooky/pixi-reels/commit/c5b957f611a6626c0703ac99cd76dc30ce447b9d) Thanks [@igaming-bulochka](https://github.com/igaming-bulochka)! - Change: the default mask no longer cuts a strip out of the art at the gap between two reels. `RectMaskStrategy` still draws one rect per reel and still clips each reel at its own two ends, so a pyramid keeps its steps and hides its buffer cells, but every rect now reaches the middle of the gap to its neighbour: a glow, a wing or a block two reels wide that crosses a gap draws whole. `RoundedRectMaskStrategy` with `scope: 'outer'` does the same, and `SilhouetteMaskStrategy` draws one outline across a cross gap instead of falling back to a rounded rect per reel.
|
|
14
|
+
|
|
15
|
+
Curve bleed and `inset()` move only the two outer edges of these masks, so an inset of the default mask no longer opens a slit between every two reels.
|
|
16
|
+
|
|
17
|
+
The builder no longer switches to `SharedRectMaskStrategy` for blocks wider than one reel or for `unmask: true` symbols: the default covers the gaps they cross, and on a board whose reels change height it keeps hiding the buffer cells the shared box showed. It still switches for a `curveFocus` that leans cells out of their column.
|
|
18
|
+
|
|
19
|
+
To clip every reel to its own column as 4.x did, pass `.maskStrategy(new RoundedRectMaskStrategy({ radius: 0, scope: 'reel' }))`.
|
|
20
|
+
|
|
21
|
+
- [#304](https://github.com/schmooky/pixi-reels/pull/304) [`c5b957f`](https://github.com/schmooky/pixi-reels/commit/c5b957f611a6626c0703ac99cd76dc30ce447b9d) Thanks [@igaming-bulochka](https://github.com/igaming-bulochka)! - Change: a cascade's refills are part of the round its spin started, so they spend no pin turns. `refill()` fires `spin:start` and `spin:allLanded` like a spin, and each refill took a turn from every numeric pin and cleared every `'eval'` pin: a sticky wild "for 3 spins" could run out inside one cascade round, and an expanding wild held for the round vanished at the first refill. Turns now count spins, as `expand()` steps already did.
|
|
22
|
+
|
|
23
|
+
- [#304](https://github.com/schmooky/pixi-reels/pull/304) [`c5b957f`](https://github.com/schmooky/pixi-reels/commit/c5b957f611a6626c0703ac99cd76dc30ce447b9d) Thanks [@igaming-bulochka](https://github.com/igaming-bulochka)! - Change: a reel spins at the same speed on every display. `StandardMode` capped each frame's step at half a slot, so the speed depended on the refresh rate: at 60 Hz every profile above 30 slots a second (Turbo's 50, SuperTurbo's 80) spun at exactly 30, no faster than Normal; at 120 Hz they reached 50 and 60; below 60 fps Normal slowed down. The cap is per second now, at what 60 Hz allowed: `MAX_SPIN_SPEED`, 30 slots a second, newly exported. At 60 Hz nothing changes; on a faster display a profile above 30 spins at 30, and below 60 fps a reel keeps its speed. `CascadeMode` gets the same treatment at `MAX_CASCADE_SPEED`, 60 slots a second (a slot a frame at 60 Hz). However long a frame is, the strip moves in steps of at most half a slot, so a stopping reel still lands exactly on its target frame.
|
|
24
|
+
|
|
25
|
+
- [#304](https://github.com/schmooky/pixi-reels/pull/304) [`c5b957f`](https://github.com/schmooky/pixi-reels/commit/c5b957f611a6626c0703ac99cd76dc30ce447b9d) Thanks [@igaming-bulochka](https://github.com/igaming-bulochka)! - Change: Spine symbols are drawn by [pixi-marrow](https://pixi-marrow.schmooky.dev). `pixi-reels/spine` no longer works with `@esotericsoftware/spine-pixi-v8`: install `pixi-marrow`, which needs pixi.js 8.23 or later, and call its `registerMarrowAssets()` before the first Spine file loads through Pixi `Assets`. The skeleton and atlas files of a game stay as they are. [Migrating to 5.0.0](https://pixi-reels.schmooky.dev/reference/migrating-to-5-0/) maps every call that changes.
|
|
26
|
+
|
|
27
|
+
**Peer versions.** Change: `pixi.js` is `^8.23.0` (was `^8.18.1`), the version pixi-marrow needs, so the engine has one floor whether or not a game draws Spine. Change: `pixi-silk`, the optional peer of `pixi-reels/debug`, is `^1.0.1` (was `^0.1.0`). pixi-silk 1.0 strokes with mitered joins by default, so the overlay asks for round ones where it drew them before; nothing in the `pixi-reels/debug` API changed.
|
|
28
|
+
|
|
29
|
+
**`SpineReelSymbol`.** `symbol.spine` is a pixi-marrow `MarrowSpine`: play with `spine.play(name, { track, loop })`, not `spine.state.setAnimation()`. `playOnTrack()` returns a pixi-marrow `Track` instead of a spine-core `TrackEntry`: set `track.speed` where code set `entry.timeScale`, and `await track.finished` where it set `entry.listener`.
|
|
30
|
+
|
|
31
|
+
- Add: `trackOn(track)` returns what the symbol plays on a track. pixi-marrow has no `getCurrent()`.
|
|
32
|
+
- Add: a `spineMap` entry can be `{ asset }`, a `MarrowAsset` from `MarrowAsset.load()`, in place of the two aliases of files Pixi `Assets` loaded.
|
|
33
|
+
- Add: the `spine` option hands `ticker`, `renderMode`, `perf` and the other `MarrowSpine` options to every skeleton a symbol creates. Pass `spine: { ticker: app.ticker }` so that the ticker's `speed` and `stop()` reach the skeletons.
|
|
34
|
+
|
|
35
|
+
**A shared pool of instances.** Add: `SpinePool`, and a `pool` option on `SpineReelSymbol`. Symbols that are given one pool take a skeleton instance from it when they enter a cell and give it back when they leave, as the pixi-marrow guide does in [Keep instances in a pool](https://pixi-marrow.schmooky.dev/guide/assets/). It is opt-in: without `pool` a symbol keeps the instances it made, as before. It pays when several symbol ids share a skeleton, when a reel set is built again, and when several sets or the game itself use the same skeletons; one set whose ids each have their own skeleton makes as many instances either way.
|
|
36
|
+
|
|
37
|
+
Every pixi-marrow setting stays yours. `new SpinePool({ spine })` takes any `MarrowSpine` option, or a function that picks them per source; a subclass overrides `create()` and `reset()`; and a symbol takes any `SpineInstancePool`, an object with `take(source)` and `give(source, instance)`, so a game can write its own. `createSpine(source, options)` makes one instance the way the library does.
|
|
38
|
+
|
|
39
|
+
**`SpineSymbol`.**
|
|
40
|
+
|
|
41
|
+
- Remove: `SpineSymbol`, `SpineSymbolOptions` and `whenSpineReady` from the main entry. Import `SpineSymbol` from `pixi-reels/spine`. The runtime loads with that subpath, so there is nothing to wait for before the first symbol is made. The main entry no longer imports any Spine code.
|
|
42
|
+
- Change: `SpineSymbol` takes `assets`, a `MarrowAsset` per symbol id, in place of `skeletonDataMap`. Passing `skeletonDataMap` throws an error that names the new option.
|
|
43
|
+
- Add: `SpineSymbol.spine`, the skeleton on screen.
|
|
44
|
+
- Fix: `SpineSymbol` fits its skeleton to the cell from the bounds of its setup pose, and moves it into the cell. It measured its own scaled bounds on every symbol swap, so the size flipped between two values, and the skeleton stayed centred on the cell's top-left corner.
|
|
45
|
+
|
|
46
|
+
**`@pixi-reels/kit`.** Add: the `bzzz` Spine set, `createAssets().spineSet('bzzz')`: nine symbols, each its own skeleton, with a `symbolScale` that fits the two tall ones into a cell. A loaded set now carries `symbolScale` (empty for a set whose art fits as authored). The rigs are used with the leave of the owner of the game and are not under the MIT licence.
|
|
47
|
+
|
|
48
|
+
**`@pixi-reels/kit/spine`.** `freezeAtEnd()` and `settleMoneyFace()` take a `MarrowSpine` and return a `Track`. `GoldCoinSymbol.playWin()` resolves when the coin is recycled mid-flourish instead of never.
|
|
49
|
+
|
|
50
|
+
**Cascades.** Fix: `runCascade()` stops when the reel set is destroyed in the middle of a round. A symbol's exit settles when the symbol is destroyed, and the chain went on to refill reels that no longer existed, which threw from the phase chain on every reel.
|
|
51
|
+
|
|
52
|
+
### Patch Changes
|
|
53
|
+
|
|
54
|
+
- [#304](https://github.com/schmooky/pixi-reels/pull/304) [`c5b957f`](https://github.com/schmooky/pixi-reels/commit/c5b957f611a6626c0703ac99cd76dc30ce447b9d) Thanks [@igaming-bulochka](https://github.com/igaming-bulochka)! - Fix: a skip press (`skipSpin()`, `slamStop()`, `requestSkip()`) while a MultiWays reshape is migrating a pin no longer throws a `TypeError`; the round lands as it should.
|
|
55
|
+
|
|
56
|
+
- [#304](https://github.com/schmooky/pixi-reels/pull/304) [`c5b957f`](https://github.com/schmooky/pixi-reels/commit/c5b957f611a6626c0703ac99cd76dc30ce447b9d) Thanks [@igaming-bulochka](https://github.com/igaming-bulochka)! - Fix: a second `AnimatedSpriteSymbol.playWin()` settles the first call's promise, so a win that lists two cells of one tall symbol no longer hangs `WinPresenter.show()`.
|
|
57
|
+
|
|
58
|
+
- [#304](https://github.com/schmooky/pixi-reels/pull/304) [`c5b957f`](https://github.com/schmooky/pixi-reels/commit/c5b957f611a6626c0703ac99cd76dc30ce447b9d) Thanks [@igaming-bulochka](https://github.com/igaming-bulochka)! - Fix: an error for a renamed v1 name no longer tells you to run `npx pixi-reels-codemod v1-to-v2`. That package is not on npm, so the command fetched whatever anyone published under the name; the error now points at the codemod in the 2.0 migration guide, which runs it from a clone of the repository.
|
|
59
|
+
|
|
60
|
+
- [#304](https://github.com/schmooky/pixi-reels/pull/304) [`c5b957f`](https://github.com/schmooky/pixi-reels/commit/c5b957f611a6626c0703ac99cd76dc30ce447b9d) Thanks [@igaming-bulochka](https://github.com/igaming-bulochka)! - Fix: Hold & Win `enter(seed)` and `activate(cells)` that throw on a bad entry now change nothing. `enter()` locked the coins listed before the bad one, so a retry carried them into the feature and its `feature:end`; `activate()` woke the cells listed before the bad one without reporting them, so a retry skipped them as already active and their `cells:activated` never fired.
|
|
61
|
+
|
|
62
|
+
- [#304](https://github.com/schmooky/pixi-reels/pull/304) [`c5b957f`](https://github.com/schmooky/pixi-reels/commit/c5b957f611a6626c0703ac99cd76dc30ce447b9d) Thanks [@igaming-bulochka](https://github.com/igaming-bulochka)! - Fix: `slamStop()` called from a `spin:reelLanded` listener finishes the round once. The landing that ran the listener finished it again, so `spin:allLanded` and `spin:complete` fired several times and every pin counted several turns for one spin.
|
|
63
|
+
|
|
64
|
+
- [#304](https://github.com/schmooky/pixi-reels/pull/304) [`c5b957f`](https://github.com/schmooky/pixi-reels/commit/c5b957f611a6626c0703ac99cd76dc30ce447b9d) Thanks [@igaming-bulochka](https://github.com/igaming-bulochka)! - Fix: a symbol whose `onReelLanded()` throws (a missing landing animation, say) no longer leaves `spin()` pending for good. The throw is reported on the notice channel as `symbol-hook-threw` and the reel lands anyway; it used to escape the landing, and the recovery slam called the same hook again.
|
|
65
|
+
|
|
66
|
+
- [#304](https://github.com/schmooky/pixi-reels/pull/304) [`c5b957f`](https://github.com/schmooky/pixi-reels/commit/c5b957f611a6626c0703ac99cd76dc30ce447b9d) Thanks [@igaming-bulochka](https://github.com/igaming-bulochka)! - Fix: a phase step that throws after an asynchronous step no longer leaves its reel halted and `spin()` pending for ever; like a throw from the first step, it logs `phase-chain-threw` and the spin resolves with `wasSkipped: true`.
|
|
67
|
+
|
|
68
|
+
- [#304](https://github.com/schmooky/pixi-reels/pull/304) [`c5b957f`](https://github.com/schmooky/pixi-reels/commit/c5b957f611a6626c0703ac99cd76dc30ce447b9d) Thanks [@igaming-bulochka](https://github.com/igaming-bulochka)! - Fix: a `once()` listener runs at most once, even when a listener before it re-emits the same event during dispatch.
|
|
69
|
+
|
|
70
|
+
- [#304](https://github.com/schmooky/pixi-reels/pull/304) [`c5b957f`](https://github.com/schmooky/pixi-reels/commit/c5b957f611a6626c0703ac99cd76dc30ce447b9d) Thanks [@igaming-bulochka](https://github.com/igaming-bulochka)! - Fix: overlapping `playDestroy()`, `playIn()` or `playOut()` calls on one symbol, such as a cascade destroying every cell of a tall symbol, restore its original pivot and position, so it is no longer drawn half a block off in the cells that reuse it.
|
|
71
|
+
|
|
72
|
+
- [#304](https://github.com/schmooky/pixi-reels/pull/304) [`c5b957f`](https://github.com/schmooky/pixi-reels/commit/c5b957f611a6626c0703ac99cd76dc30ce447b9d) Thanks [@igaming-bulochka](https://github.com/igaming-bulochka)! - Fix: `reelSet.speed.addProfile(name, profile)` under the active profile's name now makes the new profile the active one at once (a spin already running finishes on the old one) instead of keeping the old one until the next `setSpeed()`; it fires no `speed:changed`.
|
|
73
|
+
|
|
74
|
+
- [#304](https://github.com/schmooky/pixi-reels/pull/304) [`c5b957f`](https://github.com/schmooky/pixi-reels/commit/c5b957f611a6626c0703ac99cd76dc30ce447b9d) Thanks [@igaming-bulochka](https://github.com/igaming-bulochka)! - Fix: a skip press during a cascade's opening spin fast-forwards the whole `runCascade()` chain, every refill landing at once, as the skip docs describe. The first auto-slammed refill counted as a fresh press and ended the chain after one stage with `wasSkipped: true`. A press during the chain still ends it.
|
|
75
|
+
|
|
76
|
+
- [#304](https://github.com/schmooky/pixi-reels/pull/304) [`c5b957f`](https://github.com/schmooky/pixi-reels/commit/c5b957f611a6626c0703ac99cd76dc30ce447b9d) Thanks [@igaming-bulochka](https://github.com/igaming-bulochka)! - Fix: a `spin()` promise always settles, and a reel set is never left "spinning" with nothing in flight. Five ways it could hang are gone.
|
|
77
|
+
|
|
78
|
+
- **Autoplay.** `spin()` called from a `spin:complete` (or `spin:allLanded`) listener is a round of its own. The round that had just landed never resolved, and the new one resolved at once with the old round's grid, before its reels moved.
|
|
79
|
+
- **A listener that throws.** On `spin:start`, `spin()` and `refill()` reject with the listener's error and the set is at rest; it stayed spinning for good, and every later `spin()` threw "Cannot start a new spin while one is in progress". On `spin:complete` or `spin:allLanded`, the promise still resolves and the error reaches whoever landed the round.
|
|
80
|
+
- **A symbol nobody registered.** `setResult()` throws, and `refill()` and `runCascade()` reject, for a target cell that names an unregistered symbol: `setResult() column 0: symbol 'typo' is not registered`. The id was accepted and failed later inside the reel, where the round could no longer end. A cell a big symbol covers still takes any placeholder, and the column of a held reel is not read.
|
|
81
|
+
- **A skip with every reel held.** `skipSpin()`, `slamStop()` or an aborted `signal` in the same tick as `spin({ holdReels })` with every reel held ends the round. The same path ends a round whose last reel threw from a `spin:reelLanded` listener.
|
|
82
|
+
- **A block that does not fit in `refill()`.** A big symbol whose block runs off the board rejects before the round starts, as the JSDoc said. It rejected after, and left the set spinning.
|
|
83
|
+
|
|
84
|
+
- [#304](https://github.com/schmooky/pixi-reels/pull/304) [`c5b957f`](https://github.com/schmooky/pixi-reels/commit/c5b957f611a6626c0703ac99cd76dc30ce447b9d) Thanks [@igaming-bulochka](https://github.com/igaming-bulochka)! - Fix: `SpriteSymbol` art no longer jumps to its native texture size after a win; the pulse swells from the size `resize()` fitted it to, and `stopAnimation()` returns to that size.
|
|
85
|
+
|
|
86
|
+
- [#304](https://github.com/schmooky/pixi-reels/pull/304) [`c5b957f`](https://github.com/schmooky/pixi-reels/commit/c5b957f611a6626c0703ac99cd76dc30ce447b9d) Thanks [@igaming-bulochka](https://github.com/igaming-bulochka)! - Fix: a `StaticSpinSymbol` destroyed at rest and then refilled with the same id shows its art again, instead of staying blank until the next spin.
|
|
87
|
+
|
|
88
|
+
- [#304](https://github.com/schmooky/pixi-reels/pull/304) [`c5b957f`](https://github.com/schmooky/pixi-reels/commit/c5b957f611a6626c0703ac99cd76dc30ce447b9d) Thanks [@igaming-bulochka](https://github.com/igaming-bulochka)! - Fix: a phase step whose promise rejects is reported on the notice channel as `phase-step-rejected`. It was swallowed without a trace and the round went on as if the step had worked; the round still goes on. A step cancelled through `ctx.signal` stays quiet.
|
|
89
|
+
|
|
90
|
+
- [#304](https://github.com/schmooky/pixi-reels/pull/304) [`c5b957f`](https://github.com/schmooky/pixi-reels/commit/c5b957f611a6626c0703ac99cd76dc30ce447b9d) Thanks [@igaming-bulochka](https://github.com/igaming-bulochka)! - Fix: a winner cell listed twice in `refill()` or `runCascade()` (two overlapping wins on one cell) is refilled once, so untouched survivors no longer jump up the reel and slide back; `computeDropOffsets` counts distinct cells.
|
|
91
|
+
|
|
92
|
+
- [#304](https://github.com/schmooky/pixi-reels/pull/304) [`c5b957f`](https://github.com/schmooky/pixi-reels/commit/c5b957f611a6626c0703ac99cd76dc30ce447b9d) Thanks [@igaming-bulochka](https://github.com/igaming-bulochka)! - Fix: the `timeoutMs` watchdog of `spin()` is off once `setResult()` is called. A result that arrived just inside the timeout was rejected with "setResult() was never called" while its reels were still landing.
|
|
93
|
+
|
|
94
|
+
- [#304](https://github.com/schmooky/pixi-reels/pull/304) [`c5b957f`](https://github.com/schmooky/pixi-reels/commit/c5b957f611a6626c0703ac99cd76dc30ce447b9d) Thanks [@igaming-bulochka](https://github.com/igaming-bulochka)! - Fix: a `WinPresenter.show()` that starts while another is running now replaces it cleanly: the old one's `win:end('aborted')` fires before the new `win:start` and the new win keeps its dim, because `abort()` now ends a presentation at once instead of when its in-flight animations settle.
|
|
95
|
+
|
|
3
96
|
## 4.4.1
|
|
4
97
|
|
|
5
98
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -118,7 +118,7 @@ r.register('wild', SpineReelSymbol, {
|
|
|
118
118
|
});
|
|
119
119
|
```
|
|
120
120
|
|
|
121
|
-
Install the peer
|
|
121
|
+
Spine is drawn by [pixi-marrow](https://pixi-marrow.schmooky.dev). Install the peer, `pnpm add pixi-marrow`, and call its `registerMarrowAssets()` before the first Spine file loads through Pixi `Assets`.
|
|
122
122
|
|
|
123
123
|
## Debug mode
|
|
124
124
|
|
|
@@ -156,10 +156,10 @@ The standalone `examples/` apps moved to their own repo in 2.0. Keeping two para
|
|
|
156
156
|
|
|
157
157
|
## Peer dependencies
|
|
158
158
|
|
|
159
|
-
- `pixi.js` ^8.
|
|
159
|
+
- `pixi.js` ^8.23.0
|
|
160
160
|
- `gsap` ^3.15.0
|
|
161
|
-
-
|
|
162
|
-
- `pixi-silk` ^0.1
|
|
161
|
+
- `pixi-marrow` ^0.3.1 (optional, only where you import `pixi-reels/spine`)
|
|
162
|
+
- `pixi-silk` ^1.0.1 (optional, only where you import `pixi-reels/debug`)
|
|
163
163
|
|
|
164
164
|
## Contributing
|
|
165
165
|
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
//#region src/pool/ObjectPool.ts
|
|
2
|
+
var e = class {
|
|
3
|
+
_factory;
|
|
4
|
+
_reset;
|
|
5
|
+
_dispose;
|
|
6
|
+
_maxPerKey;
|
|
7
|
+
_pools = /* @__PURE__ */ new Map();
|
|
8
|
+
_pooled = /* @__PURE__ */ new Set();
|
|
9
|
+
_isDestroyed = !1;
|
|
10
|
+
constructor(e, t, n, r = 20) {
|
|
11
|
+
this._factory = e, this._reset = t, this._dispose = n, this._maxPerKey = r;
|
|
12
|
+
}
|
|
13
|
+
get isDestroyed() {
|
|
14
|
+
return this._isDestroyed;
|
|
15
|
+
}
|
|
16
|
+
acquire(e) {
|
|
17
|
+
if (this._isDestroyed) throw Error(`ObjectPool.acquire('${e}') called after destroy(). A ticker or promise callback is still running past teardown; cancel it before destroying the pool.`);
|
|
18
|
+
let t = this._pools.get(e);
|
|
19
|
+
if (t && t.length > 0) {
|
|
20
|
+
let e = t.pop();
|
|
21
|
+
return this._pooled.delete(e), this._reset?.(e), e;
|
|
22
|
+
}
|
|
23
|
+
return this._factory(e);
|
|
24
|
+
}
|
|
25
|
+
release(e, t) {
|
|
26
|
+
if (this._isDestroyed || this._pooled.has(t)) return;
|
|
27
|
+
let n = this._pools.get(e);
|
|
28
|
+
if (n || (n = [], this._pools.set(e, n)), n.length >= this._maxPerKey) {
|
|
29
|
+
this._dispose?.(t);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
n.push(t), this._pooled.add(t);
|
|
33
|
+
}
|
|
34
|
+
get maxPerKey() {
|
|
35
|
+
return this._maxPerKey;
|
|
36
|
+
}
|
|
37
|
+
setMaxPerKey(e) {
|
|
38
|
+
this._maxPerKey = e;
|
|
39
|
+
for (let t of this._pools.values()) for (; t.length > e;) {
|
|
40
|
+
let e = t.pop();
|
|
41
|
+
this._pooled.delete(e), this._dispose?.(e);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
size(e) {
|
|
45
|
+
return this._pools.get(e)?.length ?? 0;
|
|
46
|
+
}
|
|
47
|
+
get totalSize() {
|
|
48
|
+
let e = 0;
|
|
49
|
+
for (let t of this._pools.values()) e += t.length;
|
|
50
|
+
return e;
|
|
51
|
+
}
|
|
52
|
+
clear() {
|
|
53
|
+
if (this._dispose) for (let e of this._pools.values()) for (let t of e) this._dispose(t);
|
|
54
|
+
this._pools.clear(), this._pooled.clear();
|
|
55
|
+
}
|
|
56
|
+
destroy() {
|
|
57
|
+
this._isDestroyed ||= (this.clear(), !0);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
//#endregion
|
|
61
|
+
export { e as t };
|
|
62
|
+
|
|
63
|
+
//# sourceMappingURL=ObjectPool-BW9bKrDL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ObjectPool-BW9bKrDL.js","names":[],"sources":["../src/pool/ObjectPool.ts"],"sourcesContent":["import type { Disposable } from '../utils/Disposable.js';\n\n/**\n * Generic object pool for reusing expensive-to-create objects.\n *\n * Reduces GC pressure by recycling objects instead of creating/destroying them each frame.\n * Used internally for ReelSymbol instances and available to game code for trails, particles, etc.\n *\n * @typeParam T - The type of object to pool.\n */\nexport class ObjectPool<T> implements Disposable {\n private _pools = new Map<string, T[]>();\n /** Mirror of every item currently held in a pool, for O(1) double-release detection. */\n private _pooled = new Set<T>();\n private _isDestroyed = false;\n\n constructor(\n private _factory: (key: string) => T,\n private _reset?: (item: T) => void,\n private _dispose?: (item: T) => void,\n private _maxPerKey: number = 20,\n ) {}\n\n get isDestroyed(): boolean {\n return this._isDestroyed;\n }\n\n /**\n * Get an object from the pool, or create a new one if the pool is empty.\n */\n acquire(key: string): T {\n if (this._isDestroyed) {\n throw new Error(\n `ObjectPool.acquire('${key}') called after destroy(). A ticker or promise ` +\n `callback is still running past teardown; cancel it before destroying the pool.`,\n );\n }\n const pool = this._pools.get(key);\n if (pool && pool.length > 0) {\n const item = pool.pop()!;\n this._pooled.delete(item);\n this._reset?.(item);\n return item;\n }\n return this._factory(key);\n }\n\n /**\n * Return an object to the pool for reuse.\n * If the pool is at capacity, the object is disposed instead.\n */\n release(key: string, item: T): void {\n // Dropping a release after destroy() avoids resurrecting (and leaking) the pool.\n if (this._isDestroyed) return;\n // Guard against double-release: pooling the same instance twice would hand it\n // to two different cells on the next two acquire() calls (silent aliasing).\n if (this._pooled.has(item)) return;\n\n let pool = this._pools.get(key);\n if (!pool) {\n pool = [];\n this._pools.set(key, pool);\n }\n if (pool.length >= this._maxPerKey) {\n this._dispose?.(item);\n return;\n }\n pool.push(item);\n this._pooled.add(item);\n }\n\n /** Max items kept per key; releases past it are disposed. */\n get maxPerKey(): number {\n return this._maxPerKey;\n }\n\n /**\n * Change the per-key cap. Lowering it disposes whatever each key holds past\n * the new cap, so a pool sized for a large board gives the memory back when\n * the board shrinks.\n */\n setMaxPerKey(max: number): void {\n this._maxPerKey = max;\n for (const pool of this._pools.values()) {\n while (pool.length > max) {\n const item = pool.pop()!;\n this._pooled.delete(item);\n this._dispose?.(item);\n }\n }\n }\n\n /** Get the number of pooled items for a key. */\n size(key: string): number {\n return this._pools.get(key)?.length ?? 0;\n }\n\n /** Get total pooled items across all keys. */\n get totalSize(): number {\n let total = 0;\n for (const pool of this._pools.values()) {\n total += pool.length;\n }\n return total;\n }\n\n /** Clear all pooled items, calling dispose on each. */\n clear(): void {\n if (this._dispose) {\n for (const pool of this._pools.values()) {\n for (const item of pool) {\n this._dispose(item);\n }\n }\n }\n this._pools.clear();\n this._pooled.clear();\n }\n\n destroy(): void {\n if (this._isDestroyed) return;\n this.clear();\n this._isDestroyed = true;\n }\n}\n"],"mappings":";AAUA,IAAa,IAAb,MAAiD;CAOrC;CACA;CACA;CACA;CATV,yBAAiB,IAAI,IAAiB;CAEtC,0BAAkB,IAAI,IAAO;CAC7B,eAAuB;CAEvB,YACE,GACA,GACA,GACA,IAA6B,IAC7B;EADQ,AAHA,KAAA,WAAA,GACA,KAAA,SAAA,GACA,KAAA,WAAA,GACA,KAAA,aAAA;CACP;CAEH,IAAI,cAAuB;EACzB,OAAO,KAAK;CACd;CAKA,QAAQ,GAAgB;EACtB,IAAI,KAAK,cACP,MAAU,MACR,uBAAuB,EAAI,8HAE7B;EAEF,IAAM,IAAO,KAAK,OAAO,IAAI,CAAG;EAChC,IAAI,KAAQ,EAAK,SAAS,GAAG;GAC3B,IAAM,IAAO,EAAK,IAAI;GAGtB,OAFA,KAAK,QAAQ,OAAO,CAAI,GACxB,KAAK,SAAS,CAAI,GACX;EACT;EACA,OAAO,KAAK,SAAS,CAAG;CAC1B;CAMA,QAAQ,GAAa,GAAe;EAKlC,IAHI,KAAK,gBAGL,KAAK,QAAQ,IAAI,CAAI,GAAG;EAE5B,IAAI,IAAO,KAAK,OAAO,IAAI,CAAG;EAK9B,IAJK,MACH,IAAO,CAAC,GACR,KAAK,OAAO,IAAI,GAAK,CAAI,IAEvB,EAAK,UAAU,KAAK,YAAY;GAClC,KAAK,WAAW,CAAI;GACpB;EACF;EAEA,AADA,EAAK,KAAK,CAAI,GACd,KAAK,QAAQ,IAAI,CAAI;CACvB;CAGA,IAAI,YAAoB;EACtB,OAAO,KAAK;CACd;CAOA,aAAa,GAAmB;EAC9B,KAAK,aAAa;EAClB,KAAK,IAAM,KAAQ,KAAK,OAAO,OAAO,GACpC,OAAO,EAAK,SAAS,IAAK;GACxB,IAAM,IAAO,EAAK,IAAI;GAEtB,AADA,KAAK,QAAQ,OAAO,CAAI,GACxB,KAAK,WAAW,CAAI;EACtB;CAEJ;CAGA,KAAK,GAAqB;EACxB,OAAO,KAAK,OAAO,IAAI,CAAG,CAAC,EAAE,UAAU;CACzC;CAGA,IAAI,YAAoB;EACtB,IAAI,IAAQ;EACZ,KAAK,IAAM,KAAQ,KAAK,OAAO,OAAO,GACpC,KAAS,EAAK;EAEhB,OAAO;CACT;CAGA,QAAc;EACZ,IAAI,KAAK,UACP,KAAK,IAAM,KAAQ,KAAK,OAAO,OAAO,GACpC,KAAK,IAAM,KAAQ,GACjB,KAAK,SAAS,CAAI;EAKxB,AADA,KAAK,OAAO,MAAM,GAClB,KAAK,QAAQ,MAAM;CACrB;CAEA,UAAgB;EACV,AAEJ,KAAK,kBADL,KAAK,MAAM,GACS;CACtB;AACF"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var e=class{_factory;_reset;_dispose;_maxPerKey;_pools=new Map;_pooled=new Set;_isDestroyed=!1;constructor(e,t,n,r=20){this._factory=e,this._reset=t,this._dispose=n,this._maxPerKey=r}get isDestroyed(){return this._isDestroyed}acquire(e){if(this._isDestroyed)throw Error(`ObjectPool.acquire('${e}') called after destroy(). A ticker or promise callback is still running past teardown; cancel it before destroying the pool.`);let t=this._pools.get(e);if(t&&t.length>0){let e=t.pop();return this._pooled.delete(e),this._reset?.(e),e}return this._factory(e)}release(e,t){if(this._isDestroyed||this._pooled.has(t))return;let n=this._pools.get(e);if(n||(n=[],this._pools.set(e,n)),n.length>=this._maxPerKey){this._dispose?.(t);return}n.push(t),this._pooled.add(t)}get maxPerKey(){return this._maxPerKey}setMaxPerKey(e){this._maxPerKey=e;for(let t of this._pools.values())for(;t.length>e;){let e=t.pop();this._pooled.delete(e),this._dispose?.(e)}}size(e){return this._pools.get(e)?.length??0}get totalSize(){let e=0;for(let t of this._pools.values())e+=t.length;return e}clear(){if(this._dispose)for(let e of this._pools.values())for(let t of e)this._dispose(t);this._pools.clear(),this._pooled.clear()}destroy(){this._isDestroyed||=(this.clear(),!0)}};Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return e}});
|
|
2
|
+
//# sourceMappingURL=ObjectPool-DB4X2RtM.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ObjectPool-DB4X2RtM.cjs","names":[],"sources":["../src/pool/ObjectPool.ts"],"sourcesContent":["import type { Disposable } from '../utils/Disposable.js';\n\n/**\n * Generic object pool for reusing expensive-to-create objects.\n *\n * Reduces GC pressure by recycling objects instead of creating/destroying them each frame.\n * Used internally for ReelSymbol instances and available to game code for trails, particles, etc.\n *\n * @typeParam T - The type of object to pool.\n */\nexport class ObjectPool<T> implements Disposable {\n private _pools = new Map<string, T[]>();\n /** Mirror of every item currently held in a pool, for O(1) double-release detection. */\n private _pooled = new Set<T>();\n private _isDestroyed = false;\n\n constructor(\n private _factory: (key: string) => T,\n private _reset?: (item: T) => void,\n private _dispose?: (item: T) => void,\n private _maxPerKey: number = 20,\n ) {}\n\n get isDestroyed(): boolean {\n return this._isDestroyed;\n }\n\n /**\n * Get an object from the pool, or create a new one if the pool is empty.\n */\n acquire(key: string): T {\n if (this._isDestroyed) {\n throw new Error(\n `ObjectPool.acquire('${key}') called after destroy(). A ticker or promise ` +\n `callback is still running past teardown; cancel it before destroying the pool.`,\n );\n }\n const pool = this._pools.get(key);\n if (pool && pool.length > 0) {\n const item = pool.pop()!;\n this._pooled.delete(item);\n this._reset?.(item);\n return item;\n }\n return this._factory(key);\n }\n\n /**\n * Return an object to the pool for reuse.\n * If the pool is at capacity, the object is disposed instead.\n */\n release(key: string, item: T): void {\n // Dropping a release after destroy() avoids resurrecting (and leaking) the pool.\n if (this._isDestroyed) return;\n // Guard against double-release: pooling the same instance twice would hand it\n // to two different cells on the next two acquire() calls (silent aliasing).\n if (this._pooled.has(item)) return;\n\n let pool = this._pools.get(key);\n if (!pool) {\n pool = [];\n this._pools.set(key, pool);\n }\n if (pool.length >= this._maxPerKey) {\n this._dispose?.(item);\n return;\n }\n pool.push(item);\n this._pooled.add(item);\n }\n\n /** Max items kept per key; releases past it are disposed. */\n get maxPerKey(): number {\n return this._maxPerKey;\n }\n\n /**\n * Change the per-key cap. Lowering it disposes whatever each key holds past\n * the new cap, so a pool sized for a large board gives the memory back when\n * the board shrinks.\n */\n setMaxPerKey(max: number): void {\n this._maxPerKey = max;\n for (const pool of this._pools.values()) {\n while (pool.length > max) {\n const item = pool.pop()!;\n this._pooled.delete(item);\n this._dispose?.(item);\n }\n }\n }\n\n /** Get the number of pooled items for a key. */\n size(key: string): number {\n return this._pools.get(key)?.length ?? 0;\n }\n\n /** Get total pooled items across all keys. */\n get totalSize(): number {\n let total = 0;\n for (const pool of this._pools.values()) {\n total += pool.length;\n }\n return total;\n }\n\n /** Clear all pooled items, calling dispose on each. */\n clear(): void {\n if (this._dispose) {\n for (const pool of this._pools.values()) {\n for (const item of pool) {\n this._dispose(item);\n }\n }\n }\n this._pools.clear();\n this._pooled.clear();\n }\n\n destroy(): void {\n if (this._isDestroyed) return;\n this.clear();\n this._isDestroyed = true;\n }\n}\n"],"mappings":"AAUA,IAAa,EAAb,KAAiD,CAOrC,SACA,OACA,SACA,WATV,OAAiB,IAAI,IAErB,QAAkB,IAAI,IACtB,aAAuB,GAEvB,YACE,EACA,EACA,EACA,EAA6B,GAC7B,CAJQ,KAAA,SAAA,EACA,KAAA,OAAA,EACA,KAAA,SAAA,EACA,KAAA,WAAA,CACP,CAEH,IAAI,aAAuB,CACzB,OAAO,KAAK,YACd,CAKA,QAAQ,EAAgB,CACtB,GAAI,KAAK,aACP,MAAU,MACR,uBAAuB,EAAI,8HAE7B,EAEF,IAAM,EAAO,KAAK,OAAO,IAAI,CAAG,EAChC,GAAI,GAAQ,EAAK,OAAS,EAAG,CAC3B,IAAM,EAAO,EAAK,IAAI,EAGtB,OAFA,KAAK,QAAQ,OAAO,CAAI,EACxB,KAAK,SAAS,CAAI,EACX,CACT,CACA,OAAO,KAAK,SAAS,CAAG,CAC1B,CAMA,QAAQ,EAAa,EAAe,CAKlC,GAHI,KAAK,cAGL,KAAK,QAAQ,IAAI,CAAI,EAAG,OAE5B,IAAI,EAAO,KAAK,OAAO,IAAI,CAAG,EAK9B,GAJK,IACH,EAAO,CAAC,EACR,KAAK,OAAO,IAAI,EAAK,CAAI,GAEvB,EAAK,QAAU,KAAK,WAAY,CAClC,KAAK,WAAW,CAAI,EACpB,MACF,CACA,EAAK,KAAK,CAAI,EACd,KAAK,QAAQ,IAAI,CAAI,CACvB,CAGA,IAAI,WAAoB,CACtB,OAAO,KAAK,UACd,CAOA,aAAa,EAAmB,CAC9B,KAAK,WAAa,EAClB,IAAK,IAAM,KAAQ,KAAK,OAAO,OAAO,EACpC,KAAO,EAAK,OAAS,GAAK,CACxB,IAAM,EAAO,EAAK,IAAI,EACtB,KAAK,QAAQ,OAAO,CAAI,EACxB,KAAK,WAAW,CAAI,CACtB,CAEJ,CAGA,KAAK,EAAqB,CACxB,OAAO,KAAK,OAAO,IAAI,CAAG,CAAC,EAAE,QAAU,CACzC,CAGA,IAAI,WAAoB,CACtB,IAAI,EAAQ,EACZ,IAAK,IAAM,KAAQ,KAAK,OAAO,OAAO,EACpC,GAAS,EAAK,OAEhB,OAAO,CACT,CAGA,OAAc,CACZ,GAAI,KAAK,SACP,IAAK,IAAM,KAAQ,KAAK,OAAO,OAAO,EACpC,IAAK,IAAM,KAAQ,EACjB,KAAK,SAAS,CAAI,EAIxB,KAAK,OAAO,MAAM,EAClB,KAAK,QAAQ,MAAM,CACrB,CAEA,SAAgB,CACV,AAEJ,KAAK,gBADL,KAAK,MAAM,EACS,GACtB,CACF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./ReelSymbol-
|
|
2
|
-
//# sourceMappingURL=PhaseCardSymbol-
|
|
1
|
+
const e=require("./ReelSymbol-CB5GkYP3.cjs");let t=require("pixi.js");var n=class extends e.t{_color;_label;_textColor;_gfx;_text;_win=null;constructor(e){super(),this._color=e.color,this._label=e.label,this._textColor=e.textColor??16777215,this._gfx=new t.Graphics,this._text=new t.Text({text:this._label,style:{fontFamily:`"Roboto Condensed", "Arial Narrow", "Helvetica Neue Condensed", "Liberation Sans Narrow", system-ui, sans-serif`,fontSize:32,fontWeight:`700`,fill:this._textColor,align:`center`}}),this._text.anchor.set(.5),this.view.addChild(this._gfx),this.view.addChild(this._text)}onActivate(e){}onDeactivate(){}async playWin(){return this._endWin(),new Promise(e=>{this.gsap.killTweensOf(this._text),this.gsap.killTweensOf(this._text.scale);let t=this._textColor,n=this.gsap.timeline({onComplete:()=>{this._win=null,this._text.scale.set(1,1),this._text.rotation=0,this._text.style.fill=t,e()}});n.to(this._text.scale,{x:1.4,y:1.4,duration:.18,ease:`back.out(2)`},0).to(this._text,{rotation:-.12,duration:.09,ease:`sine.inOut`},0).to(this._text,{rotation:.12,duration:.18,ease:`sine.inOut`},.09).to(this._text,{rotation:0,duration:.09,ease:`sine.inOut`},.27).to(this._text.scale,{x:1,y:1,duration:.18,ease:`power2.out`},.32);let r=[this.gsap.delayedCall(.06,()=>this._text.style.fill=16769384),this.gsap.delayedCall(.42,()=>this._text.style.fill=t)];this._win={tl:n,calls:r,resolve:e}})}stopAnimation(){this._endWin(),this.gsap.killTweensOf(this._text),this.gsap.killTweensOf(this._text.scale),this._text.scale.set(1,1),this._text.rotation=0,this._text.style.fill=this._textColor,this._gfx.alpha=1}onDestroy(){this._endWin()}_endWin(){let e=this._win;if(e){this._win=null,e.tl.kill();for(let t of e.calls)t.kill();e.resolve()}}resize(e,t){this._gfx.clear(),this._gfx.rect(0,0,e,t).fill({color:this._color}),this._gfx.rect(1,1,e-2,t-2).stroke({color:0,width:2,alpha:.25}),this._text.x=e/2,this._text.y=t/2;let n=Math.max(1,this._label.length),r=t*.38,i=e*.7/(n*.45);this._text.style.fontSize=Math.max(7,Math.floor(Math.min(r,i)))}},r=[{id:`7`,color:12597547,label:`7`},{id:`8`,color:15105570,label:`8`},{id:`9`,color:15844367,label:`9`},{id:`10`,color:2600544,label:`10`},{id:`J`,color:1482885,label:`J`},{id:`Q`,color:2719929,label:`Q`},{id:`K`,color:9323693,label:`K`},{id:`A`,color:2899536,label:`A`}],i={id:`wild`,color:16774048,label:`WILD`,textColor:7033856},a={rest:4937059,start:3718648,spin:2450411,anticipation:16096779,stop:9133302,landed:2278750,adjust:15485081,"cascade:fall":959977,"cascade:place":1357990,"cascade:dropIn":440020,other:10265519},o=350,s=class e extends n{_colors;_landedMs;_phase=`rest`;_width=0;_height=0;_restCall=null;constructor(e){let t={...a};for(let[n,r]of Object.entries(e.colors??{}))r!==void 0&&(t[n]=r);super({color:t.rest,label:e.label,textColor:e.textColor}),this._colors=t,this._landedMs=e.landedMs??o}get phase(){return this._phase}setPhase(e){if(this._cancelRest(),this._phase=e,this._color=this._colors[e]??this._colors.other,this._width>0&&this.resize(this._width,this._height),e===`landed`){if(this._landedMs<=0){this.setPhase(`rest`);return}this._restCall=this.gsap.delayedCall(this._landedMs/1e3,()=>{this._restCall=null,this.setPhase(`rest`)})}}resize(e,t){this._width=e,this._height=t,super.resize(e,t)}static watch(t){let n=[];for(let r of t){let t=`rest`,i=(t,n)=>{t instanceof e&&t.setPhase(n)},a=e=>{for(let t of r.symbols)i(t,e)},o=e=>{t=e,a(e)},s=()=>{t=`rest`,a(`landed`)},c=(e,n)=>{let a=r.symbols[n];a&&i(a,t)};r.events.on(`phase:enter`,o),r.events.on(`landed`,s),r.events.on(`symbol:created`,c),n.push(()=>{r.events.off(`phase:enter`,o),r.events.off(`landed`,s),r.events.off(`symbol:created`,c)})}return()=>{for(let e of n)e();n.length=0}}onDeactivate(){this._cancelRest(),this._phase=`rest`,this._color=this._colors.rest,super.onDeactivate()}onDestroy(){this._cancelRest(),super.onDestroy()}_cancelRest(){this._restCall&&=(this._restCall.kill(),null)}};Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return a}});
|
|
2
|
+
//# sourceMappingURL=PhaseCardSymbol-7lDe3r-J.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PhaseCardSymbol-Ct9bCE4I.cjs","names":[],"sources":["../src/symbols/CardSymbol.ts","../src/symbols/PhaseCardSymbol.ts"],"sourcesContent":["import { Graphics, Text } from 'pixi.js';\nimport { ReelSymbol } from './ReelSymbol.js';\n\n/**\n * **Debug / prototyping symbol - NOT for production.**\n *\n * `CardSymbol` is a flat-rectangle-plus-centered-text `ReelSymbol` drawn\n * entirely with `PIXI.Graphics`. It exists to give recipes, demos, and\n * mechanic tests a no-asset, no-loader, infinitely-resizable visual that\n * always renders crisply at any cell size, showing how the engine treats\n * cell space across MultiWays reshapes, big-symbol blocks, and pyramid\n * layouts.\n *\n * In a real game, ship one of:\n *\n * - `SpriteSymbol` - pre-rendered art at one resolution. Cheapest.\n * - `AnimatedSpriteSymbol` - frame-by-frame win/idle animation.\n * - `SpineSymbol` (via `pixi-reels/spine`) - vector skeletal animation\n * that scales without quality loss. Best for MultiWays where cells\n * resize across spins.\n * - Or a custom `ReelSymbol` subclass for game-specific visuals.\n *\n * Ships from the package so a prototype runs with no art at all. It is\n * deliberately plain `Graphics`: swap it for real art before you ship.\n *\n * ```ts\n * import { CardSymbol, CARD_DECK } from 'pixi-reels';\n *\n * builder.symbols((registry) => {\n * for (const card of CARD_DECK) {\n * registry.register(card.id, CardSymbol, { color: card.color, label: card.label });\n * }\n * });\n * ```\n */\nexport interface CardSymbolOptions {\n /** Hex fill color (e.g. `0xc0392b`). */\n color: number;\n /** Centered label text (e.g. `'A'`, `'10'`, `'WILD'`). */\n label: string;\n /** Text fill color. Defaults to white. */\n textColor?: number;\n}\n\nexport class CardSymbol extends ReelSymbol {\n protected _color: number;\n private _label: string;\n private _textColor: number;\n private _gfx: Graphics;\n private _text: Text;\n /** The win in flight: its timeline, its two fill calls and the promise to settle. */\n private _win: { tl: gsap.core.Timeline; calls: gsap.core.Tween[]; resolve: () => void } | null = null;\n\n constructor(opts: CardSymbolOptions) {\n super();\n this._color = opts.color;\n this._label = opts.label;\n this._textColor = opts.textColor ?? 0xffffff;\n this._gfx = new Graphics();\n this._text = new Text({\n text: this._label,\n style: {\n // Roboto Condensed if installed (the site loads it via @fontsource);\n // falls through to a system condensed sans-serif on plain pages.\n fontFamily:\n '\"Roboto Condensed\", \"Arial Narrow\", \"Helvetica Neue Condensed\", \"Liberation Sans Narrow\", system-ui, sans-serif',\n fontSize: 32,\n fontWeight: '700',\n fill: this._textColor,\n align: 'center',\n },\n });\n this._text.anchor.set(0.5);\n this.view.addChild(this._gfx);\n this.view.addChild(this._text);\n }\n\n protected onActivate(_symbolId: string): void {\n // No-op - this symbol's visual identity is set at construction.\n }\n\n protected onDeactivate(): void {\n // No-op - leave _gfx/_text in their last state until next activate.\n }\n\n async playWin(): Promise<void> {\n // A win already playing ends here, its promise settled, before this one starts.\n this._endWin();\n return new Promise((resolve) => {\n // Animate only the glyph - the card body stays put. Useful for big\n // symbols (the rectangle is the cell footprint) and any setting\n // where movement of the cell border is distracting (cascade refills,\n // MultiWays adjust). The text is anchored at (0.5, 0.5) so its\n // scale tween pivots about the centre.\n this.gsap.killTweensOf(this._text);\n this.gsap.killTweensOf(this._text.scale);\n const originalFill = this._textColor;\n const tl = this.gsap.timeline({\n onComplete: () => {\n this._win = null;\n this._text.scale.set(1, 1);\n this._text.rotation = 0;\n this._text.style.fill = originalFill;\n resolve();\n },\n });\n tl.to(this._text.scale, { x: 1.4, y: 1.4, duration: 0.18, ease: 'back.out(2)' }, 0)\n .to(this._text, { rotation: -0.12, duration: 0.09, ease: 'sine.inOut' }, 0)\n .to(this._text, { rotation: 0.12, duration: 0.18, ease: 'sine.inOut' }, 0.09)\n .to(this._text, { rotation: 0, duration: 0.09, ease: 'sine.inOut' }, 0.27)\n .to(this._text.scale, { x: 1, y: 1, duration: 0.18, ease: 'power2.out' }, 0.32);\n // Glyph fill flashes warm gold mid-pulse - `Text.style.fill` isn't\n // a tweenable target on every Pixi version, so we set it discretely.\n const calls = [\n this.gsap.delayedCall(0.06, () => (this._text.style.fill = 0xffe168)),\n this.gsap.delayedCall(0.42, () => (this._text.style.fill = originalFill)),\n ];\n this._win = { tl, calls, resolve };\n });\n }\n\n stopAnimation(): void {\n this._endWin();\n this.gsap.killTweensOf(this._text);\n this.gsap.killTweensOf(this._text.scale);\n this._text.scale.set(1, 1);\n this._text.rotation = 0;\n this._text.style.fill = this._textColor;\n this._gfx.alpha = 1;\n }\n\n protected override onDestroy(): void {\n this._endWin();\n }\n\n /**\n * Kill the win in flight and settle its promise. Killing the glyph's tweens\n * alone would leave the timeline's `onComplete` and both fill calls armed,\n * and they would fire into a symbol that has since been recycled or\n * destroyed, with the `await playWin()` never settling.\n */\n private _endWin(): void {\n const win = this._win;\n if (!win) return;\n this._win = null;\n win.tl.kill();\n for (const call of win.calls) call.kill();\n win.resolve();\n }\n\n resize(width: number, height: number): void {\n this._gfx.clear();\n this._gfx.rect(0, 0, width, height).fill({ color: this._color });\n // Inner darker stroke so adjacent cells are visually separated even\n // when they share the same color.\n this._gfx.rect(1, 1, width - 2, height - 2).stroke({ color: 0x000000, width: 2, alpha: 0.25 });\n this._text.x = width / 2;\n this._text.y = height / 2;\n // Font size constrained by both height (~38%) and label width (so\n // multi-char labels like '10' or 'WILD' don't overflow narrow cells).\n // Smaller than half-cell to leave breathing room - looks less crowded.\n const labelLen = Math.max(1, this._label.length);\n const fitH = height * 0.38;\n // Roboto Condensed glyphs are narrower (~0.45 avg ratio) than serif fonts.\n const fitW = (width * 0.7) / (labelLen * 0.45);\n this._text.style.fontSize = Math.max(7, Math.floor(Math.min(fitH, fitW)));\n }\n}\n\n/**\n * Standard high-card deck for prototyping. Each card has its own color\n * so a full grid is visually unambiguous at a glance.\n */\nexport const CARD_DECK: ReadonlyArray<{ id: string; color: number; label: string; textColor?: number }> = [\n { id: '7', color: 0xc0392b, label: '7' }, // crimson\n { id: '8', color: 0xe67e22, label: '8' }, // orange\n { id: '9', color: 0xf1c40f, label: '9' }, // amber\n { id: '10', color: 0x27ae60, label: '10' }, // green\n { id: 'J', color: 0x16a085, label: 'J' }, // teal\n { id: 'Q', color: 0x2980b9, label: 'Q' }, // blue\n { id: 'K', color: 0x8e44ad, label: 'K' }, // purple\n { id: 'A', color: 0x2c3e50, label: 'A' }, // navy\n];\n\n/** A pale-yellow `WILD` card for sticky/expanding-wild prototypes. */\nexport const WILD_CARD = {\n id: 'wild',\n color: 0xfff3a0,\n label: 'WILD',\n textColor: 0x6b5400,\n} as const;\n","import type { gsap } from 'gsap';\nimport type { EventEmitter } from '../events/EventEmitter.js';\nimport type { ReelEvents } from '../events/ReelEvents.js';\nimport { CardSymbol } from './CardSymbol.js';\nimport type { ReelSymbol } from './ReelSymbol.js';\n\n/**\n * Fill per phase for {@link PhaseCardSymbol}. Keys are the names phases\n * register under (`'start'`, `'spin'`, `'anticipation'`, `'stop'`, the\n * cascade and MultiWays keys, and any custom key), plus `rest` (at rest,\n * the default) and `landed` (the beat between landing and rest). A phase\n * with no entry draws `other`.\n */\nexport const PHASE_CARD_COLORS: Readonly<Record<string, number>> = {\n rest: 0x4b5563,\n start: 0x38bdf8,\n spin: 0x2563eb,\n anticipation: 0xf59e0b,\n stop: 0x8b5cf6,\n landed: 0x22c55e,\n adjust: 0xec4899,\n 'cascade:fall': 0x0ea5e9,\n 'cascade:place': 0x14b8a6,\n 'cascade:dropIn': 0x06b6d4,\n other: 0x9ca3af,\n};\n\nexport interface PhaseCardSymbolOptions {\n /** Centered label text (e.g. `'A'`, `'10'`). */\n label: string;\n /** Text fill color. Defaults to white. */\n textColor?: number;\n /** Fills to override or add; unlisted phases keep {@link PHASE_CARD_COLORS}. */\n colors?: Partial<Record<string, number>>;\n /** How long the `landed` fill shows before the card rests, in ms. `0` rests at once. Default 350. */\n landedMs?: number;\n}\n\n/**\n * The slice of a `Reel` that {@link PhaseCardSymbol.watch} reads. Every\n * entry of `ReelSet.reels` satisfies it.\n */\nexport interface PhaseWatchedReel {\n readonly symbols: readonly ReelSymbol[];\n readonly events: EventEmitter<ReelEvents>;\n}\n\n/** The `landed` beat, in ms, when the options do not say. */\nconst DEFAULT_LANDED_MS = 350;\n\n/**\n * **Debug / prototyping symbol - NOT for production.**\n *\n * A {@link CardSymbol} that is grey at rest and takes the colour of whatever\n * phase its reel is running, so a spin can be read off the board: sky while\n * the reel accelerates, blue at full speed, amber through a tease, violet\n * while the stop spins the frame in, a green beat on landing, then grey\n * again. A slam shows as amber or blue going straight to green; a quicken\n * shows the violet in between.\n *\n * The card does not know its reel. Point a watcher at the reels once and it\n * paints every card on them from the reel's own `phase:enter`, `landed` and\n * `symbol:created` events, custom phases included:\n *\n * ```ts\n * import { PhaseCardSymbol } from 'pixi-reels';\n *\n * builder.symbols((r) => r.register('A', PhaseCardSymbol, { label: 'A' }));\n * const stop = PhaseCardSymbol.watch(reelSet.reels);\n * // ...later, before reelSet.destroy():\n * stop();\n * ```\n *\n * `setPhase()` is public, so anything else that knows the phase can drive a\n * card directly.\n */\nexport class PhaseCardSymbol extends CardSymbol {\n private readonly _colors: Record<string, number>;\n private readonly _landedMs: number;\n private _phase = 'rest';\n private _width = 0;\n private _height = 0;\n private _restCall: gsap.core.Tween | null = null;\n\n constructor(opts: PhaseCardSymbolOptions) {\n const colors: Record<string, number> = { ...PHASE_CARD_COLORS };\n for (const [phase, color] of Object.entries(opts.colors ?? {})) {\n if (color !== undefined) colors[phase] = color;\n }\n super({ color: colors.rest, label: opts.label, textColor: opts.textColor });\n this._colors = colors;\n this._landedMs = opts.landedMs ?? DEFAULT_LANDED_MS;\n }\n\n /** The phase the card currently shows: a phase name, `'landed'` or `'rest'`. */\n get phase(): string {\n return this._phase;\n }\n\n /**\n * Show `phase`. A phase with no colour of its own draws `other`. `'landed'`\n * shows its beat and then rests on its own; anything set in the meantime\n * cancels that.\n */\n setPhase(phase: string): void {\n this._cancelRest();\n this._phase = phase;\n this._color = this._colors[phase] ?? this._colors.other;\n if (this._width > 0) this.resize(this._width, this._height);\n if (phase === 'landed') {\n if (this._landedMs <= 0) {\n this.setPhase('rest');\n return;\n }\n this._restCall = this.gsap.delayedCall(this._landedMs / 1000, () => {\n this._restCall = null;\n this.setPhase('rest');\n });\n }\n }\n\n override resize(width: number, height: number): void {\n this._width = width;\n this._height = height;\n super.resize(width, height);\n }\n\n /**\n * Paint every {@link PhaseCardSymbol} on `reels` from the reels' own\n * events, for as long as the returned function has not been called. Other\n * symbol classes on the same reels are left alone. A card that arrives\n * mid-phase (a pool swap as the strip wraps) is painted on arrival.\n */\n static watch(reels: Iterable<PhaseWatchedReel>): () => void {\n const stops: Array<() => void> = [];\n for (const reel of reels) {\n // What a card created from now on should show. `rest` after a landing:\n // the landed beat is for the cards that landed, not for a swap-in.\n let current = 'rest';\n const paint = (symbol: ReelSymbol, phase: string): void => {\n if (symbol instanceof PhaseCardSymbol) symbol.setPhase(phase);\n };\n const paintAll = (phase: string): void => {\n for (const symbol of reel.symbols) paint(symbol, phase);\n };\n const onEnter = (name: string): void => {\n current = name;\n paintAll(name);\n };\n const onLanded = (): void => {\n current = 'rest';\n paintAll('landed');\n };\n const onCreated = (_id: string, stripIndex: number): void => {\n const symbol = reel.symbols[stripIndex];\n if (symbol) paint(symbol, current);\n };\n reel.events.on('phase:enter', onEnter);\n reel.events.on('landed', onLanded);\n reel.events.on('symbol:created', onCreated);\n stops.push(() => {\n reel.events.off('phase:enter', onEnter);\n reel.events.off('landed', onLanded);\n reel.events.off('symbol:created', onCreated);\n });\n }\n return () => {\n for (const stop of stops) stop();\n stops.length = 0;\n };\n }\n\n protected override onDeactivate(): void {\n // A pooled card must not carry a phase into whichever cell takes it next.\n this._cancelRest();\n this._phase = 'rest';\n this._color = this._colors.rest;\n super.onDeactivate();\n }\n\n protected override onDestroy(): void {\n this._cancelRest();\n super.onDestroy();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,EAAO,EAAK,EAC/B,EAAM,OAAS,CACjB,CACF,CAEA,cAAwC,CAEtC,KAAK,YAAY,EACjB,KAAK,OAAS,OACd,KAAK,OAAS,KAAK,QAAQ,KAC3B,MAAM,aAAa,CACrB,CAEA,WAAqC,CACnC,KAAK,YAAY,EACjB,MAAM,UAAU,CAClB,CAEA,aAA4B,CAC1B,AAEE,KAAK,aADL,KAAK,UAAU,KAAK,EACH,KAErB,CACF"}
|
|
1
|
+
{"version":3,"file":"PhaseCardSymbol-7lDe3r-J.cjs","names":[],"sources":["../src/symbols/CardSymbol.ts","../src/symbols/PhaseCardSymbol.ts"],"sourcesContent":["import { Graphics, Text } from 'pixi.js';\nimport { ReelSymbol } from './ReelSymbol.js';\n\n/**\n * **Debug / prototyping symbol - NOT for production.**\n *\n * `CardSymbol` is a flat-rectangle-plus-centered-text `ReelSymbol` drawn\n * entirely with `PIXI.Graphics`. It exists to give recipes, demos, and\n * mechanic tests a no-asset, no-loader, infinitely-resizable visual that\n * always renders crisply at any cell size, showing how the engine treats\n * cell space across MultiWays reshapes, big-symbol blocks, and pyramid\n * layouts.\n *\n * In a real game, ship one of:\n *\n * - `SpriteSymbol` - pre-rendered art at one resolution. Cheapest.\n * - `AnimatedSpriteSymbol` - frame-by-frame win/idle animation.\n * - `SpineSymbol` (via `pixi-reels/spine`) - vector skeletal animation\n * that scales without quality loss. Best for MultiWays where cells\n * resize across spins.\n * - Or a custom `ReelSymbol` subclass for game-specific visuals.\n *\n * Ships from the package so a prototype runs with no art at all. It is\n * deliberately plain `Graphics`: swap it for real art before you ship.\n *\n * ```ts\n * import { CardSymbol, CARD_DECK } from 'pixi-reels';\n *\n * builder.symbols((registry) => {\n * for (const card of CARD_DECK) {\n * registry.register(card.id, CardSymbol, { color: card.color, label: card.label });\n * }\n * });\n * ```\n */\nexport interface CardSymbolOptions {\n /** Hex fill color (e.g. `0xc0392b`). */\n color: number;\n /** Centered label text (e.g. `'A'`, `'10'`, `'WILD'`). */\n label: string;\n /** Text fill color. Defaults to white. */\n textColor?: number;\n}\n\nexport class CardSymbol extends ReelSymbol {\n protected _color: number;\n private _label: string;\n private _textColor: number;\n private _gfx: Graphics;\n private _text: Text;\n /** The win in flight: its timeline, its two fill calls and the promise to settle. */\n private _win: { tl: gsap.core.Timeline; calls: gsap.core.Tween[]; resolve: () => void } | null = null;\n\n constructor(opts: CardSymbolOptions) {\n super();\n this._color = opts.color;\n this._label = opts.label;\n this._textColor = opts.textColor ?? 0xffffff;\n this._gfx = new Graphics();\n this._text = new Text({\n text: this._label,\n style: {\n // Roboto Condensed if installed (the site loads it via @fontsource);\n // falls through to a system condensed sans-serif on plain pages.\n fontFamily:\n '\"Roboto Condensed\", \"Arial Narrow\", \"Helvetica Neue Condensed\", \"Liberation Sans Narrow\", system-ui, sans-serif',\n fontSize: 32,\n fontWeight: '700',\n fill: this._textColor,\n align: 'center',\n },\n });\n this._text.anchor.set(0.5);\n this.view.addChild(this._gfx);\n this.view.addChild(this._text);\n }\n\n protected onActivate(_symbolId: string): void {\n // No-op - this symbol's visual identity is set at construction.\n }\n\n protected onDeactivate(): void {\n // No-op - leave _gfx/_text in their last state until next activate.\n }\n\n async playWin(): Promise<void> {\n // A win already playing ends here, its promise settled, before this one starts.\n this._endWin();\n return new Promise((resolve) => {\n // Animate only the glyph - the card body stays put. Useful for big\n // symbols (the rectangle is the cell footprint) and any setting\n // where movement of the cell border is distracting (cascade refills,\n // MultiWays adjust). The text is anchored at (0.5, 0.5) so its\n // scale tween pivots about the centre.\n this.gsap.killTweensOf(this._text);\n this.gsap.killTweensOf(this._text.scale);\n const originalFill = this._textColor;\n const tl = this.gsap.timeline({\n onComplete: () => {\n this._win = null;\n this._text.scale.set(1, 1);\n this._text.rotation = 0;\n this._text.style.fill = originalFill;\n resolve();\n },\n });\n tl.to(this._text.scale, { x: 1.4, y: 1.4, duration: 0.18, ease: 'back.out(2)' }, 0)\n .to(this._text, { rotation: -0.12, duration: 0.09, ease: 'sine.inOut' }, 0)\n .to(this._text, { rotation: 0.12, duration: 0.18, ease: 'sine.inOut' }, 0.09)\n .to(this._text, { rotation: 0, duration: 0.09, ease: 'sine.inOut' }, 0.27)\n .to(this._text.scale, { x: 1, y: 1, duration: 0.18, ease: 'power2.out' }, 0.32);\n // Glyph fill flashes warm gold mid-pulse - `Text.style.fill` isn't\n // a tweenable target on every Pixi version, so we set it discretely.\n const calls = [\n this.gsap.delayedCall(0.06, () => (this._text.style.fill = 0xffe168)),\n this.gsap.delayedCall(0.42, () => (this._text.style.fill = originalFill)),\n ];\n this._win = { tl, calls, resolve };\n });\n }\n\n stopAnimation(): void {\n this._endWin();\n this.gsap.killTweensOf(this._text);\n this.gsap.killTweensOf(this._text.scale);\n this._text.scale.set(1, 1);\n this._text.rotation = 0;\n this._text.style.fill = this._textColor;\n this._gfx.alpha = 1;\n }\n\n protected override onDestroy(): void {\n this._endWin();\n }\n\n /**\n * Kill the win in flight and settle its promise. Killing the glyph's tweens\n * alone would leave the timeline's `onComplete` and both fill calls armed,\n * and they would fire into a symbol that has since been recycled or\n * destroyed, with the `await playWin()` never settling.\n */\n private _endWin(): void {\n const win = this._win;\n if (!win) return;\n this._win = null;\n win.tl.kill();\n for (const call of win.calls) call.kill();\n win.resolve();\n }\n\n resize(width: number, height: number): void {\n this._gfx.clear();\n this._gfx.rect(0, 0, width, height).fill({ color: this._color });\n // Inner darker stroke so adjacent cells are visually separated even\n // when they share the same color.\n this._gfx.rect(1, 1, width - 2, height - 2).stroke({ color: 0x000000, width: 2, alpha: 0.25 });\n this._text.x = width / 2;\n this._text.y = height / 2;\n // Font size constrained by both height (~38%) and label width (so\n // multi-char labels like '10' or 'WILD' don't overflow narrow cells).\n // Smaller than half-cell to leave breathing room - looks less crowded.\n const labelLen = Math.max(1, this._label.length);\n const fitH = height * 0.38;\n // Roboto Condensed glyphs are narrower (~0.45 avg ratio) than serif fonts.\n const fitW = (width * 0.7) / (labelLen * 0.45);\n this._text.style.fontSize = Math.max(7, Math.floor(Math.min(fitH, fitW)));\n }\n}\n\n/**\n * Standard high-card deck for prototyping. Each card has its own color\n * so a full grid is visually unambiguous at a glance.\n */\nexport const CARD_DECK: ReadonlyArray<{ id: string; color: number; label: string; textColor?: number }> = [\n { id: '7', color: 0xc0392b, label: '7' }, // crimson\n { id: '8', color: 0xe67e22, label: '8' }, // orange\n { id: '9', color: 0xf1c40f, label: '9' }, // amber\n { id: '10', color: 0x27ae60, label: '10' }, // green\n { id: 'J', color: 0x16a085, label: 'J' }, // teal\n { id: 'Q', color: 0x2980b9, label: 'Q' }, // blue\n { id: 'K', color: 0x8e44ad, label: 'K' }, // purple\n { id: 'A', color: 0x2c3e50, label: 'A' }, // navy\n];\n\n/** A pale-yellow `WILD` card for sticky/expanding-wild prototypes. */\nexport const WILD_CARD = {\n id: 'wild',\n color: 0xfff3a0,\n label: 'WILD',\n textColor: 0x6b5400,\n} as const;\n","import type { gsap } from 'gsap';\nimport type { EventEmitter } from '../events/EventEmitter.js';\nimport type { ReelEvents } from '../events/ReelEvents.js';\nimport { CardSymbol } from './CardSymbol.js';\nimport type { ReelSymbol } from './ReelSymbol.js';\n\n/**\n * Fill per phase for {@link PhaseCardSymbol}. Keys are the names phases\n * register under (`'start'`, `'spin'`, `'anticipation'`, `'stop'`, the\n * cascade and MultiWays keys, and any custom key), plus `rest` (at rest,\n * the default) and `landed` (the beat between landing and rest). A phase\n * with no entry draws `other`.\n */\nexport const PHASE_CARD_COLORS: Readonly<Record<string, number>> = {\n rest: 0x4b5563,\n start: 0x38bdf8,\n spin: 0x2563eb,\n anticipation: 0xf59e0b,\n stop: 0x8b5cf6,\n landed: 0x22c55e,\n adjust: 0xec4899,\n 'cascade:fall': 0x0ea5e9,\n 'cascade:place': 0x14b8a6,\n 'cascade:dropIn': 0x06b6d4,\n other: 0x9ca3af,\n};\n\nexport interface PhaseCardSymbolOptions {\n /** Centered label text (e.g. `'A'`, `'10'`). */\n label: string;\n /** Text fill color. Defaults to white. */\n textColor?: number;\n /** Fills to override or add; unlisted phases keep {@link PHASE_CARD_COLORS}. */\n colors?: Partial<Record<string, number>>;\n /** How long the `landed` fill shows before the card rests, in ms. `0` rests at once. Default 350. */\n landedMs?: number;\n}\n\n/**\n * The slice of a `Reel` that {@link PhaseCardSymbol.watch} reads. Every\n * entry of `ReelSet.reels` satisfies it.\n */\nexport interface PhaseWatchedReel {\n readonly symbols: readonly ReelSymbol[];\n readonly events: EventEmitter<ReelEvents>;\n}\n\n/** The `landed` beat, in ms, when the options do not say. */\nconst DEFAULT_LANDED_MS = 350;\n\n/**\n * **Debug / prototyping symbol - NOT for production.**\n *\n * A {@link CardSymbol} that is grey at rest and takes the colour of whatever\n * phase its reel is running, so a spin can be read off the board: sky while\n * the reel accelerates, blue at full speed, amber through a tease, violet\n * while the stop spins the frame in, a green beat on landing, then grey\n * again. A slam shows as amber or blue going straight to green; a quicken\n * shows the violet in between.\n *\n * The card does not know its reel. Point a watcher at the reels once and it\n * paints every card on them from the reel's own `phase:enter`, `landed` and\n * `symbol:created` events, custom phases included:\n *\n * ```ts\n * import { PhaseCardSymbol } from 'pixi-reels';\n *\n * builder.symbols((r) => r.register('A', PhaseCardSymbol, { label: 'A' }));\n * const stop = PhaseCardSymbol.watch(reelSet.reels);\n * // ...later, before reelSet.destroy():\n * stop();\n * ```\n *\n * `setPhase()` is public, so anything else that knows the phase can drive a\n * card directly.\n */\nexport class PhaseCardSymbol extends CardSymbol {\n private readonly _colors: Record<string, number>;\n private readonly _landedMs: number;\n private _phase = 'rest';\n private _width = 0;\n private _height = 0;\n private _restCall: gsap.core.Tween | null = null;\n\n constructor(opts: PhaseCardSymbolOptions) {\n const colors: Record<string, number> = { ...PHASE_CARD_COLORS };\n for (const [phase, color] of Object.entries(opts.colors ?? {})) {\n if (color !== undefined) colors[phase] = color;\n }\n super({ color: colors.rest, label: opts.label, textColor: opts.textColor });\n this._colors = colors;\n this._landedMs = opts.landedMs ?? DEFAULT_LANDED_MS;\n }\n\n /** The phase the card currently shows: a phase name, `'landed'` or `'rest'`. */\n get phase(): string {\n return this._phase;\n }\n\n /**\n * Show `phase`. A phase with no colour of its own draws `other`. `'landed'`\n * shows its beat and then rests on its own; anything set in the meantime\n * cancels that.\n */\n setPhase(phase: string): void {\n this._cancelRest();\n this._phase = phase;\n this._color = this._colors[phase] ?? this._colors.other;\n if (this._width > 0) this.resize(this._width, this._height);\n if (phase === 'landed') {\n if (this._landedMs <= 0) {\n this.setPhase('rest');\n return;\n }\n this._restCall = this.gsap.delayedCall(this._landedMs / 1000, () => {\n this._restCall = null;\n this.setPhase('rest');\n });\n }\n }\n\n override resize(width: number, height: number): void {\n this._width = width;\n this._height = height;\n super.resize(width, height);\n }\n\n /**\n * Paint every {@link PhaseCardSymbol} on `reels` from the reels' own\n * events, for as long as the returned function has not been called. Other\n * symbol classes on the same reels are left alone. A card that arrives\n * mid-phase (a pool swap as the strip wraps) is painted on arrival.\n */\n static watch(reels: Iterable<PhaseWatchedReel>): () => void {\n const stops: Array<() => void> = [];\n for (const reel of reels) {\n // What a card created from now on should show. `rest` after a landing:\n // the landed beat is for the cards that landed, not for a swap-in.\n let current = 'rest';\n const paint = (symbol: ReelSymbol, phase: string): void => {\n if (symbol instanceof PhaseCardSymbol) symbol.setPhase(phase);\n };\n const paintAll = (phase: string): void => {\n for (const symbol of reel.symbols) paint(symbol, phase);\n };\n const onEnter = (name: string): void => {\n current = name;\n paintAll(name);\n };\n const onLanded = (): void => {\n current = 'rest';\n paintAll('landed');\n };\n const onCreated = (_id: string, stripIndex: number): void => {\n const symbol = reel.symbols[stripIndex];\n if (symbol) paint(symbol, current);\n };\n reel.events.on('phase:enter', onEnter);\n reel.events.on('landed', onLanded);\n reel.events.on('symbol:created', onCreated);\n stops.push(() => {\n reel.events.off('phase:enter', onEnter);\n reel.events.off('landed', onLanded);\n reel.events.off('symbol:created', onCreated);\n });\n }\n return () => {\n for (const stop of stops) stop();\n stops.length = 0;\n };\n }\n\n protected override onDeactivate(): void {\n // A pooled card must not carry a phase into whichever cell takes it next.\n this._cancelRest();\n this._phase = 'rest';\n this._color = this._colors.rest;\n super.onDeactivate();\n }\n\n protected override onDestroy(): void {\n this._cancelRest();\n super.onDestroy();\n }\n\n private _cancelRest(): void {\n if (this._restCall) {\n this._restCall.kill();\n this._restCall = null;\n }\n }\n}\n"],"mappings":"sEA4CA,IAAa,EAAb,cAAgC,EAAA,CAAW,CACzC,OACA,OACA,WACA,KACA,MAEA,KAAiG,KAEjG,YAAY,EAAyB,CACnC,MAAM,EACN,KAAK,OAAS,EAAK,MACnB,KAAK,OAAS,EAAK,MACnB,KAAK,WAAa,EAAK,WAAa,SACpC,KAAK,KAAO,IAAI,EAAA,SAChB,KAAK,MAAQ,IAAI,EAAA,KAAK,CACpB,KAAM,KAAK,OACX,MAAO,CAGL,WACE,kHACF,SAAU,GACV,WAAY,MACZ,KAAM,KAAK,WACX,MAAO,QACT,CACF,CAAC,EACD,KAAK,MAAM,OAAO,IAAI,EAAG,EACzB,KAAK,KAAK,SAAS,KAAK,IAAI,EAC5B,KAAK,KAAK,SAAS,KAAK,KAAK,CAC/B,CAEA,WAAqB,EAAyB,CAE9C,CAEA,cAA+B,CAE/B,CAEA,MAAM,SAAyB,CAG7B,OADA,KAAK,QAAQ,EACN,IAAI,QAAS,GAAY,CAM9B,KAAK,KAAK,aAAa,KAAK,KAAK,EACjC,KAAK,KAAK,aAAa,KAAK,MAAM,KAAK,EACvC,IAAM,EAAe,KAAK,WACpB,EAAK,KAAK,KAAK,SAAS,CAC5B,eAAkB,CAChB,KAAK,KAAO,KACZ,KAAK,MAAM,MAAM,IAAI,EAAG,CAAC,EACzB,KAAK,MAAM,SAAW,EACtB,KAAK,MAAM,MAAM,KAAO,EACxB,EAAQ,CACV,CACF,CAAC,EACD,EAAG,GAAG,KAAK,MAAM,MAAO,CAAE,EAAG,IAAK,EAAG,IAAK,SAAU,IAAM,KAAM,aAAc,EAAG,CAAC,CAAC,CAChF,GAAG,KAAK,MAAO,CAAE,SAAU,KAAO,S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OAAO,IAAI,SAAU,CAAQ,EAClC,EAAK,OAAO,IAAI,iBAAkB,CAAS,CAC7C,CAAC,CACH,CACA,UAAa,CACX,IAAK,IAAM,KAAQ,EAAO,EAAK,EAC/B,EAAM,OAAS,CACjB,CACF,CAEA,cAAwC,CAEtC,KAAK,YAAY,EACjB,KAAK,OAAS,OACd,KAAK,OAAS,KAAK,QAAQ,KAC3B,MAAM,aAAa,CACrB,CAEA,WAAqC,CACnC,KAAK,YAAY,EACjB,MAAM,UAAU,CAClB,CAEA,aAA4B,CAC1B,AAEE,KAAK,aADL,KAAK,UAAU,KAAK,EACH,KAErB,CACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as e } from "./ReelSymbol-
|
|
1
|
+
import { t as e } from "./ReelSymbol-C2Du9CWR.js";
|
|
2
2
|
import { Graphics as t, Text as n } from "pixi.js";
|
|
3
3
|
//#region src/symbols/CardSymbol.ts
|
|
4
4
|
var r = class extends e {
|
|
@@ -210,4 +210,4 @@ var r = class extends e {
|
|
|
210
210
|
//#endregion
|
|
211
211
|
export { a, r as i, c as n, i as r, o as t };
|
|
212
212
|
|
|
213
|
-
//# sourceMappingURL=PhaseCardSymbol-
|
|
213
|
+
//# sourceMappingURL=PhaseCardSymbol-GpZ1FPA1.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PhaseCardSymbol-bVa7GpDn.js","names":[],"sources":["../src/symbols/CardSymbol.ts","../src/symbols/PhaseCardSymbol.ts"],"sourcesContent":["import { Graphics, Text } from 'pixi.js';\nimport { ReelSymbol } from './ReelSymbol.js';\n\n/**\n * **Debug / prototyping symbol - NOT for production.**\n *\n * `CardSymbol` is a flat-rectangle-plus-centered-text `ReelSymbol` drawn\n * entirely with `PIXI.Graphics`. It exists to give recipes, demos, and\n * mechanic tests a no-asset, no-loader, infinitely-resizable visual that\n * always renders crisply at any cell size, showing how the engine treats\n * cell space across MultiWays reshapes, big-symbol blocks, and pyramid\n * layouts.\n *\n * In a real game, ship one of:\n *\n * - `SpriteSymbol` - pre-rendered art at one resolution. Cheapest.\n * - `AnimatedSpriteSymbol` - frame-by-frame win/idle animation.\n * - `SpineSymbol` (via `pixi-reels/spine`) - vector skeletal animation\n * that scales without quality loss. Best for MultiWays where cells\n * resize across spins.\n * - Or a custom `ReelSymbol` subclass for game-specific visuals.\n *\n * Ships from the package so a prototype runs with no art at all. It is\n * deliberately plain `Graphics`: swap it for real art before you ship.\n *\n * ```ts\n * import { CardSymbol, CARD_DECK } from 'pixi-reels';\n *\n * builder.symbols((registry) => {\n * for (const card of CARD_DECK) {\n * registry.register(card.id, CardSymbol, { color: card.color, label: card.label });\n * }\n * });\n * ```\n */\nexport interface CardSymbolOptions {\n /** Hex fill color (e.g. `0xc0392b`). */\n color: number;\n /** Centered label text (e.g. `'A'`, `'10'`, `'WILD'`). */\n label: string;\n /** Text fill color. Defaults to white. */\n textColor?: number;\n}\n\nexport class CardSymbol extends ReelSymbol {\n protected _color: number;\n private _label: string;\n private _textColor: number;\n private _gfx: Graphics;\n private _text: Text;\n /** The win in flight: its timeline, its two fill calls and the promise to settle. */\n private _win: { tl: gsap.core.Timeline; calls: gsap.core.Tween[]; resolve: () => void } | null = null;\n\n constructor(opts: CardSymbolOptions) {\n super();\n this._color = opts.color;\n this._label = opts.label;\n this._textColor = opts.textColor ?? 0xffffff;\n this._gfx = new Graphics();\n this._text = new Text({\n text: this._label,\n style: {\n // Roboto Condensed if installed (the site loads it via @fontsource);\n // falls through to a system condensed sans-serif on plain pages.\n fontFamily:\n '\"Roboto Condensed\", \"Arial Narrow\", \"Helvetica Neue Condensed\", \"Liberation Sans Narrow\", system-ui, sans-serif',\n fontSize: 32,\n fontWeight: '700',\n fill: this._textColor,\n align: 'center',\n },\n });\n this._text.anchor.set(0.5);\n this.view.addChild(this._gfx);\n this.view.addChild(this._text);\n }\n\n protected onActivate(_symbolId: string): void {\n // No-op - this symbol's visual identity is set at construction.\n }\n\n protected onDeactivate(): void {\n // No-op - leave _gfx/_text in their last state until next activate.\n }\n\n async playWin(): Promise<void> {\n // A win already playing ends here, its promise settled, before this one starts.\n this._endWin();\n return new Promise((resolve) => {\n // Animate only the glyph - the card body stays put. Useful for big\n // symbols (the rectangle is the cell footprint) and any setting\n // where movement of the cell border is distracting (cascade refills,\n // MultiWays adjust). The text is anchored at (0.5, 0.5) so its\n // scale tween pivots about the centre.\n this.gsap.killTweensOf(this._text);\n this.gsap.killTweensOf(this._text.scale);\n const originalFill = this._textColor;\n const tl = this.gsap.timeline({\n onComplete: () => {\n this._win = null;\n this._text.scale.set(1, 1);\n this._text.rotation = 0;\n this._text.style.fill = originalFill;\n resolve();\n },\n });\n tl.to(this._text.scale, { x: 1.4, y: 1.4, duration: 0.18, ease: 'back.out(2)' }, 0)\n .to(this._text, { rotation: -0.12, duration: 0.09, ease: 'sine.inOut' }, 0)\n .to(this._text, { rotation: 0.12, duration: 0.18, ease: 'sine.inOut' }, 0.09)\n .to(this._text, { rotation: 0, duration: 0.09, ease: 'sine.inOut' }, 0.27)\n .to(this._text.scale, { x: 1, y: 1, duration: 0.18, ease: 'power2.out' }, 0.32);\n // Glyph fill flashes warm gold mid-pulse - `Text.style.fill` isn't\n // a tweenable target on every Pixi version, so we set it discretely.\n const calls = [\n this.gsap.delayedCall(0.06, () => (this._text.style.fill = 0xffe168)),\n this.gsap.delayedCall(0.42, () => (this._text.style.fill = originalFill)),\n ];\n this._win = { tl, calls, resolve };\n });\n }\n\n stopAnimation(): void {\n this._endWin();\n this.gsap.killTweensOf(this._text);\n this.gsap.killTweensOf(this._text.scale);\n this._text.scale.set(1, 1);\n this._text.rotation = 0;\n this._text.style.fill = this._textColor;\n this._gfx.alpha = 1;\n }\n\n protected override onDestroy(): void {\n this._endWin();\n }\n\n /**\n * Kill the win in flight and settle its promise. Killing the glyph's tweens\n * alone would leave the timeline's `onComplete` and both fill calls armed,\n * and they would fire into a symbol that has since been recycled or\n * destroyed, with the `await playWin()` never settling.\n */\n private _endWin(): void {\n const win = this._win;\n if (!win) return;\n this._win = null;\n win.tl.kill();\n for (const call of win.calls) call.kill();\n win.resolve();\n }\n\n resize(width: number, height: number): void {\n this._gfx.clear();\n this._gfx.rect(0, 0, width, height).fill({ color: this._color });\n // Inner darker stroke so adjacent cells are visually separated even\n // when they share the same color.\n this._gfx.rect(1, 1, width - 2, height - 2).stroke({ color: 0x000000, width: 2, alpha: 0.25 });\n this._text.x = width / 2;\n this._text.y = height / 2;\n // Font size constrained by both height (~38%) and label width (so\n // multi-char labels like '10' or 'WILD' don't overflow narrow cells).\n // Smaller than half-cell to leave breathing room - looks less crowded.\n const labelLen = Math.max(1, this._label.length);\n const fitH = height * 0.38;\n // Roboto Condensed glyphs are narrower (~0.45 avg ratio) than serif fonts.\n const fitW = (width * 0.7) / (labelLen * 0.45);\n this._text.style.fontSize = Math.max(7, Math.floor(Math.min(fitH, fitW)));\n }\n}\n\n/**\n * Standard high-card deck for prototyping. Each card has its own color\n * so a full grid is visually unambiguous at a glance.\n */\nexport const CARD_DECK: ReadonlyArray<{ id: string; color: number; label: string; textColor?: number }> = [\n { id: '7', color: 0xc0392b, label: '7' }, // crimson\n { id: '8', color: 0xe67e22, label: '8' }, // orange\n { id: '9', color: 0xf1c40f, label: '9' }, // amber\n { id: '10', color: 0x27ae60, label: '10' }, // green\n { id: 'J', color: 0x16a085, label: 'J' }, // teal\n { id: 'Q', color: 0x2980b9, label: 'Q' }, // blue\n { id: 'K', color: 0x8e44ad, label: 'K' }, // purple\n { id: 'A', color: 0x2c3e50, label: 'A' }, // navy\n];\n\n/** A pale-yellow `WILD` card for sticky/expanding-wild prototypes. */\nexport const WILD_CARD = {\n id: 'wild',\n color: 0xfff3a0,\n label: 'WILD',\n textColor: 0x6b5400,\n} as const;\n","import type { gsap } from 'gsap';\nimport type { EventEmitter } from '../events/EventEmitter.js';\nimport type { ReelEvents } from '../events/ReelEvents.js';\nimport { CardSymbol } from './CardSymbol.js';\nimport type { ReelSymbol } from './ReelSymbol.js';\n\n/**\n * Fill per phase for {@link PhaseCardSymbol}. Keys are the names phases\n * register under (`'start'`, `'spin'`, `'anticipation'`, `'stop'`, the\n * cascade and MultiWays keys, and any custom key), plus `rest` (at rest,\n * the default) and `landed` (the beat between landing and rest). A phase\n * with no entry draws `other`.\n */\nexport const PHASE_CARD_COLORS: Readonly<Record<string, number>> = {\n rest: 0x4b5563,\n start: 0x38bdf8,\n spin: 0x2563eb,\n anticipation: 0xf59e0b,\n stop: 0x8b5cf6,\n landed: 0x22c55e,\n adjust: 0xec4899,\n 'cascade:fall': 0x0ea5e9,\n 'cascade:place': 0x14b8a6,\n 'cascade:dropIn': 0x06b6d4,\n other: 0x9ca3af,\n};\n\nexport interface PhaseCardSymbolOptions {\n /** Centered label text (e.g. `'A'`, `'10'`). */\n label: string;\n /** Text fill color. Defaults to white. */\n textColor?: number;\n /** Fills to override or add; unlisted phases keep {@link PHASE_CARD_COLORS}. */\n colors?: Partial<Record<string, number>>;\n /** How long the `landed` fill shows before the card rests, in ms. `0` rests at once. Default 350. */\n landedMs?: number;\n}\n\n/**\n * The slice of a `Reel` that {@link PhaseCardSymbol.watch} reads. Every\n * entry of `ReelSet.reels` satisfies it.\n */\nexport interface PhaseWatchedReel {\n readonly symbols: readonly ReelSymbol[];\n readonly events: EventEmitter<ReelEvents>;\n}\n\n/** The `landed` beat, in ms, when the options do not say. */\nconst DEFAULT_LANDED_MS = 350;\n\n/**\n * **Debug / prototyping symbol - NOT for production.**\n *\n * A {@link CardSymbol} that is grey at rest and takes the colour of whatever\n * phase its reel is running, so a spin can be read off the board: sky while\n * the reel accelerates, blue at full speed, amber through a tease, violet\n * while the stop spins the frame in, a green beat on landing, then grey\n * again. A slam shows as amber or blue going straight to green; a quicken\n * shows the violet in between.\n *\n * The card does not know its reel. Point a watcher at the reels once and it\n * paints every card on them from the reel's own `phase:enter`, `landed` and\n * `symbol:created` events, custom phases included:\n *\n * ```ts\n * import { PhaseCardSymbol } from 'pixi-reels';\n *\n * builder.symbols((r) => r.register('A', PhaseCardSymbol, { label: 'A' }));\n * const stop = PhaseCardSymbol.watch(reelSet.reels);\n * // ...later, before reelSet.destroy():\n * stop();\n * ```\n *\n * `setPhase()` is public, so anything else that knows the phase can drive a\n * card directly.\n */\nexport class PhaseCardSymbol extends CardSymbol {\n private readonly _colors: Record<string, number>;\n private readonly _landedMs: number;\n private _phase = 'rest';\n private _width = 0;\n private _height = 0;\n private _restCall: gsap.core.Tween | null = null;\n\n constructor(opts: PhaseCardSymbolOptions) {\n const colors: Record<string, number> = { ...PHASE_CARD_COLORS };\n for (const [phase, color] of Object.entries(opts.colors ?? {})) {\n if (color !== undefined) colors[phase] = color;\n }\n super({ color: colors.rest, label: opts.label, textColor: opts.textColor });\n this._colors = colors;\n this._landedMs = opts.landedMs ?? DEFAULT_LANDED_MS;\n }\n\n /** The phase the card currently shows: a phase name, `'landed'` or `'rest'`. */\n get phase(): string {\n return this._phase;\n }\n\n /**\n * Show `phase`. A phase with no colour of its own draws `other`. `'landed'`\n * shows its beat and then rests on its own; anything set in the meantime\n * cancels that.\n */\n setPhase(phase: string): void {\n this._cancelRest();\n this._phase = phase;\n this._color = this._colors[phase] ?? this._colors.other;\n if (this._width > 0) this.resize(this._width, this._height);\n if (phase === 'landed') {\n if (this._landedMs <= 0) {\n this.setPhase('rest');\n return;\n }\n this._restCall = this.gsap.delayedCall(this._landedMs / 1000, () => {\n this._restCall = null;\n this.setPhase('rest');\n });\n }\n }\n\n override resize(width: number, height: number): void {\n this._width = width;\n this._height = height;\n super.resize(width, height);\n }\n\n /**\n * Paint every {@link PhaseCardSymbol} on `reels` from the reels' own\n * events, for as long as the returned function has not been called. Other\n * symbol classes on the same reels are left alone. A card that arrives\n * mid-phase (a pool swap as the strip wraps) is painted on arrival.\n */\n static watch(reels: Iterable<PhaseWatchedReel>): () => void {\n const stops: Array<() => void> = [];\n for (const reel of reels) {\n // What a card created from now on should show. `rest` after a landing:\n // the landed beat is for the cards that landed, not for a swap-in.\n let current = 'rest';\n const paint = (symbol: ReelSymbol, phase: string): void => {\n if (symbol instanceof PhaseCardSymbol) symbol.setPhase(phase);\n };\n const paintAll = (phase: string): void => {\n for (const symbol of reel.symbols) paint(symbol, phase);\n };\n const onEnter = (name: string): void => {\n current = name;\n paintAll(name);\n };\n const onLanded = (): void => {\n current = 'rest';\n paintAll('landed');\n };\n const onCreated = (_id: string, stripIndex: number): void => {\n const symbol = reel.symbols[stripIndex];\n if (symbol) paint(symbol, current);\n };\n reel.events.on('phase:enter', onEnter);\n reel.events.on('landed', onLanded);\n reel.events.on('symbol:created', onCreated);\n stops.push(() => {\n reel.events.off('phase:enter', onEnter);\n reel.events.off('landed', onLanded);\n reel.events.off('symbol:created', onCreated);\n });\n }\n return () => {\n for (const stop of stops) stop();\n stops.length = 0;\n };\n }\n\n protected override onDeactivate(): void {\n // A pooled card must not carry a phase into whichever cell takes it next.\n this._cancelRest();\n this._phase = 'rest';\n this._color = this._colors.rest;\n super.onDeactivate();\n }\n\n protected override onDestroy(): void {\n this._cancelRest();\n super.onDestroy();\n }\n\n private _cancelRest(): void {\n if (this._restCall) {\n this._restCall.kill();\n this._restCall = null;\n }\n }\n}\n"],"mappings":";;;AA4CA,IAAa,IAAb,cAAgC,EAAW;CACzC;CACA;CACA;CACA;CACA;CAEA,OAAiG;CAEjG,YAAY,GAAyB;EAqBnC,AApBA,MAAM,GACN,KAAK,SAAS,EAAK,OACnB,KAAK,SAAS,EAAK,OACnB,KAAK,aAAa,EAAK,aAAa,UACpC,KAAK,OAAO,IAAI,EAAS,GACzB,KAAK,QAAQ,IAAI,EAAK;GACpB,MAAM,KAAK;GACX,OAAO;IAGL,YACE;IACF,UAAU;IACV,YAAY;IACZ,MAAM,KAAK;IACX,OAAO;GACT;EACF,CAAC,GACD,KAAK,MAAM,OAAO,IAAI,EAAG,GACzB,KAAK,KAAK,SAAS,KAAK,IAAI,GAC5B,KAAK,KAAK,SAAS,KAAK,KAAK;CAC/B;CAEA,WAAqB,GAAyB,C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IAA2B,CAAC;EAClC,KAAK,IAAM,KAAQ,GAAO;GAGxB,IAAI,IAAU,QACR,KAAS,GAAoB,MAAwB;IACzD,AAAI,aAAkB,KAAiB,EAAO,SAAS,CAAK;GAC9D,GACM,KAAY,MAAwB;IACxC,KAAK,IAAM,KAAU,EAAK,SAAS,EAAM,GAAQ,CAAK;GACxD,GACM,KAAW,MAAuB;IAEtC,AADA,IAAU,GACV,EAAS,CAAI;GACf,GACM,UAAuB;IAE3B,AADA,IAAU,QACV,EAAS,QAAQ;GACnB,GACM,KAAa,GAAa,MAA6B;IAC3D,IAAM,IAAS,EAAK,QAAQ;IAC5B,AAAI,KAAQ,EAAM,GAAQ,CAAO;GACnC;GAIA,AAHA,EAAK,OAAO,GAAG,eAAe,CAAO,GACrC,EAAK,OAAO,GAAG,UAAU,CAAQ,GACjC,EAAK,OAAO,GAAG,kBAAkB,CAAS,GAC1C,EAAM,WAAW;IAGf,AAFA,EAAK,OAAO,IAAI,eAAe,CAAO,GACtC,EAAK,OAAO,IAAI,UAAU,CAAQ,GAClC,EAAK,OAAO,IAAI,kBAAkB,CAAS;GAC7C,CAAC;EACH;EACA,aAAa;GACX,KAAK,IAAM,KAAQ,GAAO,EAAK;GAC/B,EAAM,SAAS;EACjB;CACF;CAEA,eAAwC;EAKtC,AAHA,KAAK,YAAY,GACjB,KAAK,SAAS,QACd,KAAK,SAAS,KAAK,QAAQ,MAC3B,MAAM,aAAa;CACrB;CAEA,YAAqC;EAEnC,AADA,KAAK,YAAY,GACjB,MAAM,UAAU;CAClB;CAEA,cAA4B;EAC1B,AAEE,KAAK,eADL,KAAK,UAAU,KAAK,GACH;CAErB;AACF"}
|
|
1
|
+
{"version":3,"file":"PhaseCardSymbol-GpZ1FPA1.js","names":[],"sources":["../src/symbols/CardSymbol.ts","../src/symbols/PhaseCardSymbol.ts"],"sourcesContent":["import { Graphics, Text } from 'pixi.js';\nimport { ReelSymbol } from './ReelSymbol.js';\n\n/**\n * **Debug / prototyping symbol - NOT for production.**\n *\n * `CardSymbol` is a flat-rectangle-plus-centered-text `ReelSymbol` drawn\n * entirely with `PIXI.Graphics`. It exists to give recipes, demos, and\n * mechanic tests a no-asset, no-loader, infinitely-resizable visual that\n * always renders crisply at any cell size, showing how the engine treats\n * cell space across MultiWays reshapes, big-symbol blocks, and pyramid\n * layouts.\n *\n * In a real game, ship one of:\n *\n * - `SpriteSymbol` - pre-rendered art at one resolution. Cheapest.\n * - `AnimatedSpriteSymbol` - frame-by-frame win/idle animation.\n * - `SpineSymbol` (via `pixi-reels/spine`) - vector skeletal animation\n * that scales without quality loss. Best for MultiWays where cells\n * resize across spins.\n * - Or a custom `ReelSymbol` subclass for game-specific visuals.\n *\n * Ships from the package so a prototype runs with no art at all. It is\n * deliberately plain `Graphics`: swap it for real art before you ship.\n *\n * ```ts\n * import { CardSymbol, CARD_DECK } from 'pixi-reels';\n *\n * builder.symbols((registry) => {\n * for (const card of CARD_DECK) {\n * registry.register(card.id, CardSymbol, { color: card.color, label: card.label });\n * }\n * });\n * ```\n */\nexport interface CardSymbolOptions {\n /** Hex fill color (e.g. `0xc0392b`). */\n color: number;\n /** Centered label text (e.g. `'A'`, `'10'`, `'WILD'`). */\n label: string;\n /** Text fill color. Defaults to white. */\n textColor?: number;\n}\n\nexport class CardSymbol extends ReelSymbol {\n protected _color: number;\n private _label: string;\n private _textColor: number;\n private _gfx: Graphics;\n private _text: Text;\n /** The win in flight: its timeline, its two fill calls and the promise to settle. */\n private _win: { tl: gsap.core.Timeline; calls: gsap.core.Tween[]; resolve: () => void } | null = null;\n\n constructor(opts: CardSymbolOptions) {\n super();\n this._color = opts.color;\n this._label = opts.label;\n this._textColor = opts.textColor ?? 0xffffff;\n this._gfx = new Graphics();\n this._text = new Text({\n text: this._label,\n style: {\n // Roboto Condensed if installed (the site loads it via @fontsource);\n // falls through to a system condensed sans-serif on plain pages.\n fontFamily:\n '\"Roboto Condensed\", \"Arial Narrow\", \"Helvetica Neue Condensed\", \"Liberation Sans Narrow\", system-ui, sans-serif',\n fontSize: 32,\n fontWeight: '700',\n fill: this._textColor,\n align: 'center',\n },\n });\n this._text.anchor.set(0.5);\n this.view.addChild(this._gfx);\n this.view.addChild(this._text);\n }\n\n protected onActivate(_symbolId: string): void {\n // No-op - this symbol's visual identity is set at construction.\n }\n\n protected onDeactivate(): void {\n // No-op - leave _gfx/_text in their last state until next activate.\n }\n\n async playWin(): Promise<void> {\n // A win already playing ends here, its promise settled, before this one starts.\n this._endWin();\n return new Promise((resolve) => {\n // Animate only the glyph - the card body stays put. Useful for big\n // symbols (the rectangle is the cell footprint) and any setting\n // where movement of the cell border is distracting (cascade refills,\n // MultiWays adjust). The text is anchored at (0.5, 0.5) so its\n // scale tween pivots about the centre.\n this.gsap.killTweensOf(this._text);\n this.gsap.killTweensOf(this._text.scale);\n const originalFill = this._textColor;\n const tl = this.gsap.timeline({\n onComplete: () => {\n this._win = null;\n this._text.scale.set(1, 1);\n this._text.rotation = 0;\n this._text.style.fill = originalFill;\n resolve();\n },\n });\n tl.to(this._text.scale, { x: 1.4, y: 1.4, duration: 0.18, ease: 'back.out(2)' }, 0)\n .to(this._text, { rotation: -0.12, duration: 0.09, ease: 'sine.inOut' }, 0)\n .to(this._text, { rotation: 0.12, duration: 0.18, ease: 'sine.inOut' }, 0.09)\n .to(this._text, { rotation: 0, duration: 0.09, ease: 'sine.inOut' }, 0.27)\n .to(this._text.scale, { x: 1, y: 1, duration: 0.18, ease: 'power2.out' }, 0.32);\n // Glyph fill flashes warm gold mid-pulse - `Text.style.fill` isn't\n // a tweenable target on every Pixi version, so we set it discretely.\n const calls = [\n this.gsap.delayedCall(0.06, () => (this._text.style.fill = 0xffe168)),\n this.gsap.delayedCall(0.42, () => (this._text.style.fill = originalFill)),\n ];\n this._win = { tl, calls, resolve };\n });\n }\n\n stopAnimation(): void {\n this._endWin();\n this.gsap.killTweensOf(this._text);\n this.gsap.killTweensOf(this._text.scale);\n this._text.scale.set(1, 1);\n this._text.rotation = 0;\n this._text.style.fill = this._textColor;\n this._gfx.alpha = 1;\n }\n\n protected override onDestroy(): void {\n this._endWin();\n }\n\n /**\n * Kill the win in flight and settle its promise. Killing the glyph's tweens\n * alone would leave the timeline's `onComplete` and both fill calls armed,\n * and they would fire into a symbol that has since been recycled or\n * destroyed, with the `await playWin()` never settling.\n */\n private _endWin(): void {\n const win = this._win;\n if (!win) return;\n this._win = null;\n win.tl.kill();\n for (const call of win.calls) call.kill();\n win.resolve();\n }\n\n resize(width: number, height: number): void {\n this._gfx.clear();\n this._gfx.rect(0, 0, width, height).fill({ color: this._color });\n // Inner darker stroke so adjacent cells are visually separated even\n // when they share the same color.\n this._gfx.rect(1, 1, width - 2, height - 2).stroke({ color: 0x000000, width: 2, alpha: 0.25 });\n this._text.x = width / 2;\n this._text.y = height / 2;\n // Font size constrained by both height (~38%) and label width (so\n // multi-char labels like '10' or 'WILD' don't overflow narrow cells).\n // Smaller than half-cell to leave breathing room - looks less crowded.\n const labelLen = Math.max(1, this._label.length);\n const fitH = height * 0.38;\n // Roboto Condensed glyphs are narrower (~0.45 avg ratio) than serif fonts.\n const fitW = (width * 0.7) / (labelLen * 0.45);\n this._text.style.fontSize = Math.max(7, Math.floor(Math.min(fitH, fitW)));\n }\n}\n\n/**\n * Standard high-card deck for prototyping. Each card has its own color\n * so a full grid is visually unambiguous at a glance.\n */\nexport const CARD_DECK: ReadonlyArray<{ id: string; color: number; label: string; textColor?: number }> = [\n { id: '7', color: 0xc0392b, label: '7' }, // crimson\n { id: '8', color: 0xe67e22, label: '8' }, // orange\n { id: '9', color: 0xf1c40f, label: '9' }, // amber\n { id: '10', color: 0x27ae60, label: '10' }, // green\n { id: 'J', color: 0x16a085, label: 'J' }, // teal\n { id: 'Q', color: 0x2980b9, label: 'Q' }, // blue\n { id: 'K', color: 0x8e44ad, label: 'K' }, // purple\n { id: 'A', color: 0x2c3e50, label: 'A' }, // navy\n];\n\n/** A pale-yellow `WILD` card for sticky/expanding-wild prototypes. */\nexport const WILD_CARD = {\n id: 'wild',\n color: 0xfff3a0,\n label: 'WILD',\n textColor: 0x6b5400,\n} as const;\n","import type { gsap } from 'gsap';\nimport type { EventEmitter } from '../events/EventEmitter.js';\nimport type { ReelEvents } from '../events/ReelEvents.js';\nimport { CardSymbol } from './CardSymbol.js';\nimport type { ReelSymbol } from './ReelSymbol.js';\n\n/**\n * Fill per phase for {@link PhaseCardSymbol}. Keys are the names phases\n * register under (`'start'`, `'spin'`, `'anticipation'`, `'stop'`, the\n * cascade and MultiWays keys, and any custom key), plus `rest` (at rest,\n * the default) and `landed` (the beat between landing and rest). A phase\n * with no entry draws `other`.\n */\nexport const PHASE_CARD_COLORS: Readonly<Record<string, number>> = {\n rest: 0x4b5563,\n start: 0x38bdf8,\n spin: 0x2563eb,\n anticipation: 0xf59e0b,\n stop: 0x8b5cf6,\n landed: 0x22c55e,\n adjust: 0xec4899,\n 'cascade:fall': 0x0ea5e9,\n 'cascade:place': 0x14b8a6,\n 'cascade:dropIn': 0x06b6d4,\n other: 0x9ca3af,\n};\n\nexport interface PhaseCardSymbolOptions {\n /** Centered label text (e.g. `'A'`, `'10'`). */\n label: string;\n /** Text fill color. Defaults to white. */\n textColor?: number;\n /** Fills to override or add; unlisted phases keep {@link PHASE_CARD_COLORS}. */\n colors?: Partial<Record<string, number>>;\n /** How long the `landed` fill shows before the card rests, in ms. `0` rests at once. Default 350. */\n landedMs?: number;\n}\n\n/**\n * The slice of a `Reel` that {@link PhaseCardSymbol.watch} reads. Every\n * entry of `ReelSet.reels` satisfies it.\n */\nexport interface PhaseWatchedReel {\n readonly symbols: readonly ReelSymbol[];\n readonly events: EventEmitter<ReelEvents>;\n}\n\n/** The `landed` beat, in ms, when the options do not say. */\nconst DEFAULT_LANDED_MS = 350;\n\n/**\n * **Debug / prototyping symbol - NOT for production.**\n *\n * A {@link CardSymbol} that is grey at rest and takes the colour of whatever\n * phase its reel is running, so a spin can be read off the board: sky while\n * the reel accelerates, blue at full speed, amber through a tease, violet\n * while the stop spins the frame in, a green beat on landing, then grey\n * again. A slam shows as amber or blue going straight to green; a quicken\n * shows the violet in between.\n *\n * The card does not know its reel. Point a watcher at the reels once and it\n * paints every card on them from the reel's own `phase:enter`, `landed` and\n * `symbol:created` events, custom phases included:\n *\n * ```ts\n * import { PhaseCardSymbol } from 'pixi-reels';\n *\n * builder.symbols((r) => r.register('A', PhaseCardSymbol, { label: 'A' }));\n * const stop = PhaseCardSymbol.watch(reelSet.reels);\n * // ...later, before reelSet.destroy():\n * stop();\n * ```\n *\n * `setPhase()` is public, so anything else that knows the phase can drive a\n * card directly.\n */\nexport class PhaseCardSymbol extends CardSymbol {\n private readonly _colors: Record<string, number>;\n private readonly _landedMs: number;\n private _phase = 'rest';\n private _width = 0;\n private _height = 0;\n private _restCall: gsap.core.Tween | null = null;\n\n constructor(opts: PhaseCardSymbolOptions) {\n const colors: Record<string, number> = { ...PHASE_CARD_COLORS };\n for (const [phase, color] of Object.entries(opts.colors ?? {})) {\n if (color !== undefined) colors[phase] = color;\n }\n super({ color: colors.rest, label: opts.label, textColor: opts.textColor });\n this._colors = colors;\n this._landedMs = opts.landedMs ?? DEFAULT_LANDED_MS;\n }\n\n /** The phase the card currently shows: a phase name, `'landed'` or `'rest'`. */\n get phase(): string {\n return this._phase;\n }\n\n /**\n * Show `phase`. A phase with no colour of its own draws `other`. `'landed'`\n * shows its beat and then rests on its own; anything set in the meantime\n * cancels that.\n */\n setPhase(phase: string): void {\n this._cancelRest();\n this._phase = phase;\n this._color = this._colors[phase] ?? this._colors.other;\n if (this._width > 0) this.resize(this._width, this._height);\n if (phase === 'landed') {\n if (this._landedMs <= 0) {\n this.setPhase('rest');\n return;\n }\n this._restCall = this.gsap.delayedCall(this._landedMs / 1000, () => {\n this._restCall = null;\n this.setPhase('rest');\n });\n }\n }\n\n override resize(width: number, height: number): void {\n this._width = width;\n this._height = height;\n super.resize(width, height);\n }\n\n /**\n * Paint every {@link PhaseCardSymbol} on `reels` from the reels' own\n * events, for as long as the returned function has not been called. Other\n * symbol classes on the same reels are left alone. A card that arrives\n * mid-phase (a pool swap as the strip wraps) is painted on arrival.\n */\n static watch(reels: Iterable<PhaseWatchedReel>): () => void {\n const stops: Array<() => void> = [];\n for (const reel of reels) {\n // What a card created from now on should show. `rest` after a landing:\n // the landed beat is for the cards that landed, not for a swap-in.\n let current = 'rest';\n const paint = (symbol: ReelSymbol, phase: string): void => {\n if (symbol instanceof PhaseCardSymbol) symbol.setPhase(phase);\n };\n const paintAll = (phase: string): void => {\n for (const symbol of reel.symbols) paint(symbol, phase);\n };\n const onEnter = (name: string): void => {\n current = name;\n paintAll(name);\n };\n const onLanded = (): void => {\n current = 'rest';\n paintAll('landed');\n };\n const onCreated = (_id: string, stripIndex: number): void => {\n const symbol = reel.symbols[stripIndex];\n if (symbol) paint(symbol, current);\n };\n reel.events.on('phase:enter', onEnter);\n reel.events.on('landed', onLanded);\n reel.events.on('symbol:created', onCreated);\n stops.push(() => {\n reel.events.off('phase:enter', onEnter);\n reel.events.off('landed', onLanded);\n reel.events.off('symbol:created', onCreated);\n });\n }\n return () => {\n for (const stop of stops) stop();\n stops.length = 0;\n };\n }\n\n protected override onDeactivate(): void {\n // A pooled card must not carry a phase into whichever cell takes it next.\n this._cancelRest();\n this._phase = 'rest';\n this._color = this._colors.rest;\n super.onDeactivate();\n }\n\n protected override onDestroy(): void {\n this._cancelRest();\n super.onDestroy();\n }\n\n private _cancelRest(): void {\n if (this._restCall) {\n this._restCall.kill();\n this._restCall = null;\n }\n }\n}\n"],"mappings":";;;AA4CA,IAAa,IAAb,cAAgC,EAAW;CACzC;CACA;CACA;CACA;CACA;CAEA,OAAiG;CAEjG,YAAY,GAAyB;EAqBnC,AApBA,MAAM,GACN,KAAK,SAAS,EAAK,OACnB,KAAK,SAAS,EAAK,OACnB,KAAK,aAAa,EAAK,aAAa,UACpC,KAAK,OAAO,IAAI,EAAS,GACzB,KAAK,QAAQ,IAAI,EAAK;GACpB,MAAM,KAAK;GACX,OAAO;IA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ErB;AACF"}
|
|
@@ -53,21 +53,19 @@ var n = t, r = class {
|
|
|
53
53
|
onDestroy() {}
|
|
54
54
|
async playLanding() {}
|
|
55
55
|
async playDestroy(e) {
|
|
56
|
-
let t = this.view, n =
|
|
57
|
-
t.pivot.set(s, c), t.x = i + (s - n) * t.scale.x, t.y = a + (c - r) * t.scale.y;
|
|
58
|
-
let l = e?.delay ?? 0, u = e?.signal, d = () => {
|
|
56
|
+
let t = this.view, n = this._pivotOnCentre(), r = e?.delay ?? 0, i = e?.signal, a = () => {
|
|
59
57
|
t.alpha = 0, t.scale.set(0, 0);
|
|
60
58
|
};
|
|
61
|
-
if (
|
|
62
|
-
|
|
59
|
+
if (i?.aborted) {
|
|
60
|
+
a(), n(), t.scale.set(1, 1), t.alpha = 0;
|
|
63
61
|
return;
|
|
64
62
|
}
|
|
65
63
|
await new Promise((e) => {
|
|
66
64
|
let n = this.gsap.timeline({
|
|
67
65
|
onComplete: () => {
|
|
68
|
-
|
|
66
|
+
i && i.removeEventListener("abort", o), e();
|
|
69
67
|
},
|
|
70
|
-
delay:
|
|
68
|
+
delay: r
|
|
71
69
|
}).to(t.scale, {
|
|
72
70
|
x: 1.1,
|
|
73
71
|
y: 1.1,
|
|
@@ -82,11 +80,11 @@ var n = t, r = class {
|
|
|
82
80
|
alpha: 0,
|
|
83
81
|
duration: .14,
|
|
84
82
|
ease: "power3.in"
|
|
85
|
-
}, "<"),
|
|
86
|
-
n.kill(),
|
|
83
|
+
}, "<"), o = () => {
|
|
84
|
+
n.kill(), a(), e();
|
|
87
85
|
};
|
|
88
|
-
|
|
89
|
-
}),
|
|
86
|
+
i && i.addEventListener("abort", o, { once: !0 });
|
|
87
|
+
}), n(), t.scale.set(1, 1);
|
|
90
88
|
}
|
|
91
89
|
async playOut(e) {
|
|
92
90
|
await this._tweenPresence("out", e);
|
|
@@ -95,27 +93,23 @@ var n = t, r = class {
|
|
|
95
93
|
await this._tweenPresence("in", e);
|
|
96
94
|
}
|
|
97
95
|
async _tweenPresence(e, t) {
|
|
98
|
-
let n = this.view, r =
|
|
99
|
-
n.pivot.set(c, l), n.x = a + (c - r) * n.scale.x, n.y = o + (l - i) * n.scale.y;
|
|
100
|
-
let u = () => {
|
|
101
|
-
n.pivot.set(r, i), n.x = a, n.y = o;
|
|
102
|
-
}, d = () => {
|
|
96
|
+
let n = this.view, r = this._pivotOnCentre(), i = () => {
|
|
103
97
|
e === "out" ? (n.alpha = 0, n.scale.set(1, 1)) : (n.visible = !0, n.alpha = 1, n.scale.set(1, 1));
|
|
104
|
-
},
|
|
105
|
-
if (e === "in" && (n.visible = !0, n.alpha = 0, n.scale.set(.72, .72)),
|
|
106
|
-
|
|
98
|
+
}, a = t?.delay ?? 0, o = t?.signal;
|
|
99
|
+
if (e === "in" && (n.visible = !0, n.alpha = 0, n.scale.set(.72, .72)), o?.aborted) {
|
|
100
|
+
i(), r();
|
|
107
101
|
return;
|
|
108
102
|
}
|
|
109
103
|
await new Promise((t) => {
|
|
110
104
|
let r = () => {
|
|
111
|
-
|
|
112
|
-
},
|
|
113
|
-
delay:
|
|
105
|
+
s.kill(), i(), t();
|
|
106
|
+
}, s = this.gsap.timeline({
|
|
107
|
+
delay: a,
|
|
114
108
|
onComplete: () => {
|
|
115
|
-
|
|
109
|
+
o && o.removeEventListener("abort", r), t();
|
|
116
110
|
}
|
|
117
111
|
});
|
|
118
|
-
e === "out" ?
|
|
112
|
+
e === "out" ? s.to(n.scale, {
|
|
119
113
|
x: .72,
|
|
120
114
|
y: .72,
|
|
121
115
|
duration: .18,
|
|
@@ -124,7 +118,7 @@ var n = t, r = class {
|
|
|
124
118
|
alpha: 0,
|
|
125
119
|
duration: .18,
|
|
126
120
|
ease: "power2.in"
|
|
127
|
-
}, "<") :
|
|
121
|
+
}, "<") : s.to(n.scale, {
|
|
128
122
|
x: 1,
|
|
129
123
|
y: 1,
|
|
130
124
|
duration: .2,
|
|
@@ -133,8 +127,28 @@ var n = t, r = class {
|
|
|
133
127
|
alpha: 1,
|
|
134
128
|
duration: .16,
|
|
135
129
|
ease: "power2.out"
|
|
136
|
-
}, "<"),
|
|
137
|
-
}), n.scale.set(1, 1),
|
|
130
|
+
}, "<"), o && o.addEventListener("abort", r, { once: !0 });
|
|
131
|
+
}), n.scale.set(1, 1), r();
|
|
132
|
+
}
|
|
133
|
+
_restPose = null;
|
|
134
|
+
_restPoseHolds = 0;
|
|
135
|
+
_pivotOnCentre() {
|
|
136
|
+
let e = this.view, t = this._restPose;
|
|
137
|
+
if (!t) {
|
|
138
|
+
t = {
|
|
139
|
+
pivotX: e.pivot.x,
|
|
140
|
+
pivotY: e.pivot.y,
|
|
141
|
+
x: e.x,
|
|
142
|
+
y: e.y
|
|
143
|
+
};
|
|
144
|
+
let n = e.getLocalBounds(), r = n.x + n.width / 2, i = n.y + n.height / 2;
|
|
145
|
+
e.pivot.set(r, i), e.x = t.x + (r - t.pivotX) * e.scale.x, e.y = t.y + (i - t.pivotY) * e.scale.y, this._restPose = t;
|
|
146
|
+
}
|
|
147
|
+
this._restPoseHolds++;
|
|
148
|
+
let n = t;
|
|
149
|
+
return () => {
|
|
150
|
+
this._restPoseHolds--, !(this._restPoseHolds > 0) && (this._restPose = null, e.pivot.set(n.pivotX, n.pivotY), e.x = n.x, e.y = n.y);
|
|
151
|
+
};
|
|
138
152
|
}
|
|
139
153
|
get cellInset() {
|
|
140
154
|
return null;
|
|
@@ -156,4 +170,4 @@ var n = t, r = class {
|
|
|
156
170
|
//#endregion
|
|
157
171
|
export { n, r as t };
|
|
158
172
|
|
|
159
|
-
//# sourceMappingURL=ReelSymbol-
|
|
173
|
+
//# sourceMappingURL=ReelSymbol-C2Du9CWR.js.map
|