HoldAndWinBoard\<TData = `unknown`\>
pixi-reels / index / HoldAndWinBoard
Class: HoldAndWinBoard<TData = unknown>
Defined in: board/HoldAndWinBoard.ts:104
A Hold & Win board: a grid of independently spinning cells plus the round choreography every H&W game repeats - spin the free cells, lock the hits, reset-or-decrement the respin counter, detect the full board.
It composes two collaborators: a BoardGrid (the generic “board of reels”
mechanism - geometry, instances, spinning) and a HoldAndWinState (the pure
single-source reducer - ledger, counter, phase). The board is the
mediator: it drives the reels, reports each landing to the reducer, and
replays the reducer’s decided effects onto events.
It deliberately owns nothing about value. Coins are opaque { cell, id, data }
idpicks the registered art,datais the game layer’s to read and mutate. Adders, doublers, collectors and flights are game design, expressed through three openings rather than board features: events, symbolAt (the liveReelSymbolinstance) and cellBounds/cellCenter (pixel geometry for flights).
const board = new HoldAndWinBuilder<{ value: number }>()
.grid(5, 3).cellSize({ width: 101, height: 85 }, { columnGap: 4, rowGap: 0 })
.symbols((r) => r.register('coin', CoinSymbol, COIN_TRIGGER))
.weights({ coin: 1, empty: 3 }).respins(3).ticker(app.ticker)
.build();
board.events.on('coin:locked', ({ coin }) => hud.add(coin.data.value));
board.enter(triggerCoins);
while (true) {
const round = await server.respin(board.lockedCoins);
const result = await board.respin(round.hits);
if (result.done) break; // game animates between rounds
}
Type Parameters#
| Type Parameter | Default type |
|---|---|
TData | unknown |
Implements#
Constructors#
Constructor#
new HoldAndWinBoard<TData = unknown>(cfg: HoldAndWinBoardConfig<TData>): HoldAndWinBoard<TData>;
Defined in: board/HoldAndWinBoard.ts:122
Parameters#
| Parameter | Type |
|---|---|
cfg | HoldAndWinBoardConfig<TData> |
Returns#
HoldAndWinBoard<TData>
Properties#
| Property | Modifier | Type | Defined in |
|---|---|---|---|
cols | readonly | number | board/HoldAndWinBoard.ts:106 |
events | readonly | EventEmitter<HoldAndWinBoardEvents<TData>> | board/HoldAndWinBoard.ts:105 |
rows | readonly | number | board/HoldAndWinBoard.ts:107 |
Accessors#
capacity#
Get Signature#
get capacity(): number;
Defined in: board/HoldAndWinBoard.ts:238
Number of active cells - what isFull is measured against.
Returns
number
container#
Get Signature#
get container(): Container;
Defined in: board/HoldAndWinBoard.ts:180
Returns
Container
dimmedCells#
Get Signature#
get dimmedCells(): HwCell[];
Defined in: board/HoldAndWinBoard.ts:212
Cells a dim currently covers. See BoardGrid.dimmedCells.
Returns
HwCell[]
dimmedSymbolCells#
Get Signature#
get dimmedSymbolCells(): HwCell[];
Defined in: board/HoldAndWinBoard.ts:225
Cells whose symbol a dimSymbols currently tints.
Returns
HwCell[]
freeCells#
Get Signature#
get freeCells(): HwCell[];
Defined in: board/HoldAndWinBoard.ts:251
Active cells holding no coin.
Returns
HwCell[]
inactiveCells#
Get Signature#
get inactiveCells(): HwCell[];
Defined in: board/HoldAndWinBoard.ts:255
Dormant cells - built, drawn, but not part of the feature yet.
Returns
HwCell[]
isDestroyed#
Get Signature#
get isDestroyed(): boolean;
Defined in: board/HoldAndWinBoard.ts:474
Returns
boolean
Implementation of#
isFull#
Get Signature#
get isFull(): boolean;
Defined in: board/HoldAndWinBoard.ts:247
Returns
boolean
liftedCells#
Get Signature#
get liftedCells(): HwCell[];
Defined in: board/HoldAndWinBoard.ts:199
Currently lifted cells, in lift order. See BoardGrid.liftedCells.
Returns
HwCell[]
liftedLayer#
Get Signature#
get liftedLayer(): RenderLayer;
Defined in: board/HoldAndWinBoard.ts:185
The layer the cells’ lifted art renders in. See BoardGrid.liftedLayer.
Returns
RenderLayer
lockedCoins#
Get Signature#
get lockedCoins(): HwCoin<TData>[];
Defined in: board/HoldAndWinBoard.ts:244
Returns
HwCoin<TData>[]
phase#
Get Signature#
get phase(): HwPhase;
Defined in: board/HoldAndWinBoard.ts:259
Where the feature is right now: idle (no feature), active, or spinning.
Returns
respinsLeft#
Get Signature#
get respinsLeft(): number;
Defined in: board/HoldAndWinBoard.ts:241
Returns
number
speed#
Get Signature#
get speed(): string;
Defined in: board/HoldAndWinBoard.ts:263
Name of the speed profile every cell is set to.
Returns
string
speedNames#
Get Signature#
get speedNames(): string[];
Defined in: board/HoldAndWinBoard.ts:267
Every registered speed name, initial first.
Returns
string[]
Methods#
activate()#
activate(cells: HwCell[]): void;
Defined in: board/HoldAndWinBoard.ts:413
Wake dormant cells (see HoldAndWinBuilder.inactive): they show the empty
symbol, join the next respin and count toward the full board from now on.
Fires cells:activated. Not allowed while a wave is in flight.
Parameters#
| Parameter | Type |
|---|---|
cells | HwCell[] |
Returns#
void
addSpeed()#
addSpeed(name: string, profile: SpeedProfile): void;
Defined in: board/HoldAndWinBoard.ts:387
Register one more named profile into every cell’s SpeedManager after
build - reelSet.speed.addProfile() for the whole board. Its tension
variant is derived the same way as for the built-in ones. Select it with
setSpeed.
Parameters#
| Parameter | Type |
|---|---|
name | string |
profile | SpeedProfile |
Returns#
void
cellBounds()#
cellBounds(cell: HwCell): {
height: number;
width: number;
x: number;
y: number;
};
Defined in: board/HoldAndWinBoard.ts:273
Parameters#
| Parameter | Type |
|---|---|
cell | HwCell |
Returns#
{
height: number;
width: number;
x: number;
y: number;
}
| Name | Type | Defined in |
|---|---|---|
height | number | board/HoldAndWinBoard.ts:273 |
width | number | board/HoldAndWinBoard.ts:273 |
x | number | board/HoldAndWinBoard.ts:273 |
y | number | board/HoldAndWinBoard.ts:273 |
cellCenter()#
cellCenter(cell: HwCell): {
x: number;
y: number;
};
Defined in: board/HoldAndWinBoard.ts:276
Parameters#
| Parameter | Type |
|---|---|
cell | HwCell |
Returns#
{
x: number;
y: number;
}
| Name | Type | Defined in |
|---|---|---|
x | number | board/HoldAndWinBoard.ts:276 |
y | number | board/HoldAndWinBoard.ts:276 |
destroy()#
destroy(): void;
Defined in: board/HoldAndWinBoard.ts:478
Returns#
void
Implementation of#
dim()#
dim(opts?: {
amount?: number;
except?: HwCell[];
fade?: number;
}): () => void;
Defined in: board/HoldAndWinBoard.ts:208
Push every cell except these into the background until the returned
release is called - the partner of lift. Fades in and out over
fade ms; see BoardGrid.dim. Released by reset and
destroy.
Parameters#
| Parameter | Type |
|---|---|
opts | { amount?: number; except?: HwCell[]; fade?: number; } |
opts.amount? | number |
opts.except? | HwCell[] |
opts.fade? | number |
Returns#
() => void
dimSymbols()#
dimSymbols(opts?: {
amount?: number;
except?: HwCell[];
fade?: number;
}): () => void;
Defined in: board/HoldAndWinBoard.ts:221
Push every cell’s SYMBOL except these into the background - the same
shape as dim on a different channel, darkening the art and
leaving the cell’s own background alone. See BoardGrid.dimSymbols.
Released by reset and destroy.
Parameters#
| Parameter | Type |
|---|---|
opts | { amount?: number; except?: HwCell[]; fade?: number; } |
opts.amount? | number |
opts.except? | HwCell[] |
opts.fade? | number |
Returns#
() => void
enter()#
enter(seed: HwCoin<TData>[]): void;
Defined in: board/HoldAndWinBoard.ts:307
Activate the feature with the trigger coins. Seeds land locked, instantly.
Parameters#
| Parameter | Type |
|---|---|
seed | HwCoin<TData>[] |
Returns#
void
lift()#
lift(cell: HwCell): () => void;
Defined in: board/HoldAndWinBoard.ts:195
Draw one cell’s lifted art in front of every other cell’s until the
returned release is called - a coin upgrading in place, a collect
sweeping the board. See BoardGrid.lift. Released by reset and
destroy; NOT by respin, so a presentation may legitimately
span a respin.
Parameters#
| Parameter | Type |
|---|---|
cell | HwCell |
Returns#
() => void
playWin()#
playWin(cells?: HwCell[]): Promise<void>;
Defined in: board/HoldAndWinBoard.ts:403
Play the win animation on locked coins - by default every one of them, or
just cells. Resolves when the last one finishes. This is the explicit
celebration for a board built with lockAnimation('landing' | 'none'),
typically fired on board:full or feature:end; on the default 'win'
board it simply replays what each lock already played.
Parameters#
| Parameter | Type |
|---|---|
cells? | HwCell[] |
Returns#
Promise<void>
reelAt()#
reelAt(cell: HwCell): ReelSet;
Defined in: board/HoldAndWinBoard.ts:284
The cell’s underlying 1×1 ReelSet, for driving one cell directly.
Parameters#
| Parameter | Type |
|---|---|
cell | HwCell |
Returns#
refreshCellZIndex()#
refreshCellZIndex(): void;
Defined in: board/HoldAndWinBoard.ts:234
Re-ask the cellZIndex resolver for every cell. See
BoardGrid.refreshCellZIndex. The board already calls it on every place
and every landing; call it yourself when the resolver depends on state
the board does not watch - a HUD multiplier, a collected total.
Returns#
void
release()#
release(cells: HwCell[]): HwCoin<TData>[];
Defined in: board/HoldAndWinBoard.ts:424
Remove locked coins - the collect moment. Clears the cells (they become
free again) and returns the released coins; the flight itself is game-layer
animation, started from cellCenter() or the coin:released event.
Parameters#
| Parameter | Type |
|---|---|
cells | HwCell[] |
Returns#
HwCoin<TData>[]
reset()#
reset(): void;
Defined in: board/HoldAndWinBoard.ts:462
Clear the board back to idle. Fires feature:reset (not coin:released).
Cells activated during the feature go dormant again.
Returns#
void
respin()#
respin(hits: HwCoin<TData>[]): Promise<HwRespinResult<TData>>;
Defined in: board/HoldAndWinBoard.ts:318
Spin every free cell; hits land (and lock) their coins, all other spinning
cells land empty. Resolves once the wave has landed and the counter is
resolved. The game layer drives pacing between rounds.
Parameters#
| Parameter | Type |
|---|---|
hits | HwCoin<TData>[] |
Returns#
Promise<HwRespinResult<TData>>
setSpeed()#
setSpeed(name: string): void;
Defined in: board/HoldAndWinBoard.ts:368
Switch every cell to a registered speed profile at once - the board’s
reelSet.setSpeed(). Takes hold immediately on every cell’s SpeedManager;
as on a reel set, a cell already in flight finishes on the profile it
started with, so a wave in progress shows the change from its next wave -
or right away after skip(), the turbo-button semantic. Fires
speed:changed.
Parameters#
| Parameter | Type |
|---|---|
name | string |
Returns#
void
setSymbolAt()#
setSymbolAt(
cell: HwCell,
id: string,
data?: TData
): ReelSymbol;
Defined in: board/HoldAndWinBoard.ts:298
Rewrite a locked cell’s coin in place - coin → jackpot, mini → major,
raise a tier - without disturbing any other cell. The ledger entry is
rewritten so lockedCoins and totals stay correct. Throws on a free cell.
Returns the new live symbol instance.
Throws if called while a wave is in flight - await respin() first. To
upgrade a coin in reaction to its own coin:locked, defer the swap until
the awaited respin() resolves rather than swapping inside the listener.
Parameters#
| Parameter | Type |
|---|---|
cell | HwCell |
id | string |
data? | TData |
Returns#
skip()#
skip(options?: SkipOptions): number;
Defined in: board/HoldAndWinBoard.ts:443
Press skip on whatever is spinning. Under 'slam' (the default unless the
builder’s skipMode() says otherwise) every in-flight cell is placed on
its landed position; under 'quicken' every in-flight cell drops its
spin floor (the board’s stagger lives there, so the whole wave lands
together), spins its symbol in and bounces, on options.speed if named.
Then feature:skip fires with the count, the mode and the press’s own
speed / payload, so the game layer can cut its own flights short
after a slam and know which press it was. The normal landing ->
coin:locked -> feature:end flow still resolves either way; this only
removes the waiting. Returns the number of cells that were in flight.
Parameters#
| Parameter | Type |
|---|---|
options | SkipOptions |
Returns#
number
symbolAt()#
symbolAt(cell: HwCell): ReelSymbol;
Defined in: board/HoldAndWinBoard.ts:280
Live symbol instance currently shown in a cell.
Parameters#
| Parameter | Type |
|---|---|
cell | HwCell |