pixi-reels

HoldAndWinBoard\<TData\>

pixi-reels


pixi-reels / index / HoldAndWinBoard

Class: HoldAndWinBoard<TData>

Defined in: board/HoldAndWinBoard.ts:78

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 }id picks the registered art, data is 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 live ReelSymbol instance) and cellBounds/cellCenter (pixel geometry for flights).

const board = new HoldAndWinBuilder<{ value: number }>()
  .grid(5, 3).cellSize(72, { gap: 4 })
  .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 ParameterDefault type
TDataunknown

Implements

Constructors

Constructor

new HoldAndWinBoard<TData>(cfg: HoldAndWinBoardConfig<TData>): HoldAndWinBoard<TData>;

Defined in: board/HoldAndWinBoard.ts:88

Parameters

ParameterType
cfgHoldAndWinBoardConfig<TData>

Returns

HoldAndWinBoard<TData>

Properties

PropertyModifierTypeDefined in
colsreadonlynumberboard/HoldAndWinBoard.ts:80
eventsreadonlyEventEmitter<HoldAndWinBoardEvents<TData>>board/HoldAndWinBoard.ts:79
rowsreadonlynumberboard/HoldAndWinBoard.ts:81

Accessors

capacity

Get Signature

get capacity(): number;

Defined in: board/HoldAndWinBoard.ts:121

Returns

number


container

Get Signature

get container(): Container;

Defined in: board/HoldAndWinBoard.ts:118

Returns

Container


freeCells

Get Signature

get freeCells(): HwCell[];

Defined in: board/HoldAndWinBoard.ts:133

Returns

HwCell[]


isDestroyed

Get Signature

get isDestroyed(): boolean;

Defined in: board/HoldAndWinBoard.ts:260

Returns

boolean

Implementation of

Disposable.isDestroyed


isFull

Get Signature

get isFull(): boolean;

Defined in: board/HoldAndWinBoard.ts:130

Returns

boolean


lockedCoins

Get Signature

get lockedCoins(): HwCoin<TData>[];

Defined in: board/HoldAndWinBoard.ts:127

Returns

HwCoin<TData>[]


phase

Get Signature

get phase(): HwPhase;

Defined in: board/HoldAndWinBoard.ts:137

Where the feature is right now: idle (no feature), active, or spinning.

Returns

HwPhase


respinsLeft

Get Signature

get respinsLeft(): number;

Defined in: board/HoldAndWinBoard.ts:124

Returns

number

Methods

cellBounds()

cellBounds(cell: HwCell): {
  height: number;
  width: number;
  x: number;
  y: number;
};

Defined in: board/HoldAndWinBoard.ts:143

Parameters

ParameterType
cellHwCell

Returns

{
  height: number;
  width: number;
  x: number;
  y: number;
}
NameTypeDefined in
heightnumberboard/HoldAndWinBoard.ts:143
widthnumberboard/HoldAndWinBoard.ts:143
xnumberboard/HoldAndWinBoard.ts:143
ynumberboard/HoldAndWinBoard.ts:143

cellCenter()

cellCenter(cell: HwCell): {
  x: number;
  y: number;
};

Defined in: board/HoldAndWinBoard.ts:146

Parameters

ParameterType
cellHwCell

Returns

{
  x: number;
  y: number;
}
NameTypeDefined in
xnumberboard/HoldAndWinBoard.ts:146
ynumberboard/HoldAndWinBoard.ts:146

destroy()

destroy(): void;

Defined in: board/HoldAndWinBoard.ts:264

Returns

void

Implementation of

Disposable.destroy


enter()

enter(seed: HwCoin<TData>[]): void;

Defined in: board/HoldAndWinBoard.ts:177

Activate the feature with the trigger coins. Seeds land locked, instantly.

Parameters

ParameterType
seedHwCoin<TData>[]

Returns

void


reelAt()

reelAt(cell: HwCell): ReelSet;

Defined in: board/HoldAndWinBoard.ts:154

The cell’s underlying 1×1 ReelSet, for driving one cell directly.

Parameters

ParameterType
cellHwCell

Returns

ReelSet


release()

release(cells: HwCell[]): HwCoin<TData>[];

Defined in: board/HoldAndWinBoard.ts:233

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

ParameterType
cellsHwCell[]

Returns

HwCoin<TData>[]


reset()

reset(): void;

Defined in: board/HoldAndWinBoard.ts:254

Clear the board back to idle. Fires feature:reset (not coin:released).

Returns

void


respin()

respin(hits: HwCoin<TData>[]): Promise<HwRespinResult<TData>>;

Defined in: board/HoldAndWinBoard.ts:188

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

ParameterType
hitsHwCoin<TData>[]

Returns

Promise<HwRespinResult<TData>>


setSymbolAt()

setSymbolAt(
   cell: HwCell, 
   id: string, 
   data?: TData): ReelSymbol;

Defined in: board/HoldAndWinBoard.ts:168

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

ParameterType
cellHwCell
idstring
data?TData

Returns

ReelSymbol


skip()

skip(): number;

Defined in: board/HoldAndWinBoard.ts:247

Fast-forward whatever is spinning: every in-flight cell is slammed to its landed position, then feature:skip fires so the game layer can cut its own flights short. The normal landing → coin:lockedfeature:end flow still resolves; this only removes the waiting. Returns the number of cells that were in flight.

Returns

number


symbolAt()

symbolAt(cell: HwCell): ReelSymbol;

Defined in: board/HoldAndWinBoard.ts:150

Live symbol instance currently shown in a cell.

Parameters

ParameterType
cellHwCell

Returns

ReelSymbol