HoldAndWinBoard\<TData\>
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 Parameter | Default type |
|---|---|
TData | unknown |
Implements
Constructors
Constructor
new HoldAndWinBoard<TData>(cfg: HoldAndWinBoardConfig<TData>): HoldAndWinBoard<TData>;
Defined in: board/HoldAndWinBoard.ts:88
Parameters
| Parameter | Type |
|---|---|
cfg | HoldAndWinBoardConfig<TData> |
Returns
HoldAndWinBoard<TData>
Properties
| Property | Modifier | Type | Defined in |
|---|---|---|---|
cols | readonly | number | board/HoldAndWinBoard.ts:80 |
events | readonly | EventEmitter<HoldAndWinBoardEvents<TData>> | board/HoldAndWinBoard.ts:79 |
rows | readonly | number | board/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
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
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
| Parameter | Type |
|---|---|
cell | HwCell |
Returns
{
height: number;
width: number;
x: number;
y: number;
}
| Name | Type | Defined in |
|---|---|---|
height | number | board/HoldAndWinBoard.ts:143 |
width | number | board/HoldAndWinBoard.ts:143 |
x | number | board/HoldAndWinBoard.ts:143 |
y | number | board/HoldAndWinBoard.ts:143 |
cellCenter()
cellCenter(cell: HwCell): {
x: number;
y: number;
};
Defined in: board/HoldAndWinBoard.ts:146
Parameters
| Parameter | Type |
|---|---|
cell | HwCell |
Returns
{
x: number;
y: number;
}
| Name | Type | Defined in |
|---|---|---|
x | number | board/HoldAndWinBoard.ts:146 |
y | number | board/HoldAndWinBoard.ts:146 |
destroy()
destroy(): void;
Defined in: board/HoldAndWinBoard.ts:264
Returns
void
Implementation of
enter()
enter(seed: HwCoin<TData>[]): void;
Defined in: board/HoldAndWinBoard.ts:177
Activate the feature with the trigger coins. Seeds land locked, instantly.
Parameters
| Parameter | Type |
|---|---|
seed | HwCoin<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
| Parameter | Type |
|---|---|
cell | HwCell |
Returns
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
| Parameter | Type |
|---|---|
cells | HwCell[] |
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
| Parameter | Type |
|---|---|
hits | HwCoin<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
| Parameter | Type |
|---|---|
cell | HwCell |
id | string |
data? | TData |
Returns
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:locked → feature: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
| Parameter | Type |
|---|---|
cell | HwCell |