Skip to content

Map the book event game type onto the frontend's vocabulary - #38

Open
soulrap wants to merge 1 commit into
engineio:mainfrom
soulrap:gametype-mapping
Open

Map the book event game type onto the frontend's vocabulary#38
soulrap wants to merge 1 commit into
engineio:mainfrom
soulrap:gametype-mapping

Conversation

@soulrap

@soulrap soulrap commented Aug 28, 2026

Copy link
Copy Markdown

Problem

The whole free spins feature plays on a black screen: no background at all,
base or feature. The scene reappears the instant the round ends.

Background.svelte picks the scene from stateGame.gameType:

const showBaseBackground    = $derived(context.stateGame.gameType === 'basegame');
const showFeatureBackground = $derived(context.stateGame.gameType === 'freeSpins');

bookEventHandlerMap.ts assigns that value straight from the book event:

reveal: async (bookEvent, { bookEvents }) => {
    ...
    stateGame.gameType = bookEvent.gameType;

But the two SDKs do not agree on the vocabulary:

base feature
math-sdk — Config in src/config/config.py basegame freegame
this app — keys of config.paddingReels, which is what GameType is derived from basegame freeSpins

So during a feature round gameType is 'freegame', which matches neither
branch. Both FadeContainers stay hidden and what shows through is the black
Rectangle behind them.

freeSpinTrigger does set the correct value:

stateGame.gameType = 'freeSpins';

…but the next reveal immediately overwrites it. And freeSpinEnd sets
'basegame', which is exactly why the background comes back the moment the
round finishes — the scene that returns is the base one, not the feature one,
so the feature scene is never seen at all.

Measured against the published books for 0_0_scatter:

books_bonus : 4060 reveal events with gameType 'freegame'
books_base  :  400 reveal events with gameType 'basegame'

GameType cannot catch this: the book event is parsed from JSON, so the raw
string flows in untyped.

Change

Map the incoming value onto the frontend's vocabulary at the point of
assignment:

const toGameType = (raw: string): GameType =>
	raw === 'freegame' ? 'freeSpins' : (raw as GameType);

Nothing else changes — freeSpinTrigger and freeSpinEnd already assign the
right literals directly.

Scope

This is not specific to one game. basegame / freegame are the math-sdk
defaults, so any game whose frontend config names the feature freeSpins has
the same silent failure. The other samples in this repo are worth a look; I
only had scatter set up against a live RGS session to confirm it.

If you would rather fix it the other way — rename the config key to freegame
so the two SDKs agree — that works too, but it changes GameType and every
'freeSpins' literal in the app, so I went with the narrower change.

math-sdk names its game types basegame / freegame - `Config.freegame_type`
in src/config/config.py - while this game's config names them basegame /
freeSpins: `GameType` is `keyof typeof config.paddingReels`, and those keys
are `basegame` and `freeSpins`.

The reveal handler assigned `bookEvent.gameType` straight through, so during
a feature round `stateGame.gameType` sat at 'freegame'. Background.svelte
shows the base scene when it is 'basegame' and the feature scene when it is
'freeSpins', so neither branch matched: both FadeContainers stayed hidden and
the entire feature played on a black screen.

freeSpinTrigger does set 'freeSpins', but the next reveal overwrote it, and
freeSpinEnd sets 'basegame' - which is why the scene reappears the moment the
round ends, and why this reads as "the background comes back at the end".

Measured against the published books for 0_0_scatter: 4060 reveal events in
books_bonus carry gameType 'freegame', 400 in books_base carry 'basegame'.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant