pixi-reels

API reference

SpinMetrics

pixi-reels


pixi-reels / debug / SpinMetrics

Defined in: debug/SpinMetrics.ts:179

Records what each spin did, per reel, on a clock: when every phase started and ended, when the reel was asked to stop, landed and settled, the tease window, every skip press, and how many symbols were swapped into cells.

Event-driven: it listens on the set bus and on every reel’s bus, so it costs nothing between spins. Given a ticker, it also samples each reel’s normalized speed while a round runs, which is what lets a timeline show the shape of a tease instead of only its start and end.

Dev-only, like the rest of pixi-reels/debug: the record shape follows the engine’s events and is not semver-protected.

const metrics = new SpinMetrics(reelSet, { ticker: app.ticker });
await reelSet.spin();
metrics.current?.reels[4].tease; // { start: 912, end: 1840, order: 1, total: 2 }
metrics.destroy();

Implements#

Constructors#

Constructor#

new SpinMetrics(_reelSet: ReelSet, options?: SpinMetricsOptions): SpinMetrics;

Defined in: debug/SpinMetrics.ts:192

Parameters#

ParameterType
_reelSetReelSet
optionsSpinMetricsOptions

Returns#

SpinMetrics

Accessors#

current#

Get Signature#

get current(): DebugRound | null;

Defined in: debug/SpinMetrics.ts:217

The latest round, running or settled. null before anything happened.

Returns

DebugRound | null


isActive#

Get Signature#

get isActive(): boolean;

Defined in: debug/SpinMetrics.ts:231

Whether the current round is still moving: a reel is inside a phase, or a spin has not reached spin:complete yet. An aborted or timed-out spin never reaches it, so a spin round also ends when the set stops spinning.

Returns

boolean


isDestroyed#

Get Signature#

get isDestroyed(): boolean;

Defined in: debug/SpinMetrics.ts:212

Returns

boolean

Implementation of#

Disposable.isDestroyed


length#

Get Signature#

get length(): number;

Defined in: debug/SpinMetrics.ts:243

How long the current round has lasted, ms: the live clock while it is active, its last recorded activity once it has settled. 0 before any round. This is the length a timeline should span.

Returns

number


rounds#

Get Signature#

get rounds(): readonly DebugRound[];

Defined in: debug/SpinMetrics.ts:222

The kept rounds, oldest first. The last one is current.

Returns

readonly DebugRound[]


totals#

Get Signature#

get totals(): DebugMetricsTotals;

Defined in: debug/SpinMetrics.ts:249

Returns

DebugMetricsTotals

Methods#

clear()#

clear(): void;

Defined in: debug/SpinMetrics.ts:269

Forget every kept round. The round counter keeps counting.

Returns#

void


destroy()#

destroy(): void;

Defined in: debug/SpinMetrics.ts:273

Returns#

void

Implementation of#

Disposable.destroy


snapshot()#

snapshot(): SpinMetricsSnapshot;

Defined in: debug/SpinMetrics.ts:261

A deep, plain-JSON copy of every kept round plus the totals.

Returns#

SpinMetricsSnapshot