Skip to content

feat(demo): add kiosk idle-detection and How-to-Play tutorial demo mode#2978

Open
macan88 wants to merge 3 commits intoFreezingMoon:masterfrom
macan88:felix/fix-2976
Open

feat(demo): add kiosk idle-detection and How-to-Play tutorial demo mode#2978
macan88 wants to merge 3 commits intoFreezingMoon:masterfrom
macan88:felix/fix-2976

Conversation

@macan88
Copy link
Copy Markdown

@macan88 macan88 commented Apr 7, 2026

Problem

When AncientBeast runs in kiosk / attract mode with no active players, the screen simply waits with no visual feedback, missing an opportunity to onboard new players and keep the display engaging (issue #2976, related #933).

Solution

Introduces a DemoMode class (src/demo/DemoMode.ts) that:

  • Idle detection – arms a 2-minute setTimeout; any pointermove, pointerdown, or keydown event resets the countdown while the game is idle.
  • Meaningful-action guard – exposes notifyMeaningfulActivity() so the game board can reset the timer only on real game actions (creature moves, ability use) rather than passive camera pans.
  • Cycling tutorial sequence – on timeout, plays the built-in HOW_TO_PLAY_STEPS array (5 slides, 8 s each) via game.onDemoStep() callbacks; easy to extend without touching engine code.
  • Instant cancel – attaches a capture-phase listener on demo start so the very first pointerdown or keydown calls game.onDemoCancel() synchronously, guaranteeing no residual game state.
  • Kiosk guardenable() / disable() ensure the demo timer is never armed during a live match.
  • Phase 2/3 stubsDemoSequenceType.AI_BATTLE and HISTORIC_REPLAY are declared and routed through the sequence picker; they return empty step arrays today and will be filled once the state-machine PR merges.

Integration (game.ts)

Add three hook methods to Game:

onDemoStart(seq: DemoSequenceType): void  // show demo overlay
onDemoStep(step: DemoStep, idx: number, total: number): void  // render slide
onDemoCancel(): void  // hide overlay, navigate to main menu

Then in the kiosk entry point:

this.demoMode = new DemoMode(this);
this.demoMode.enable();

And on meaningful board actions:

this.demoMode?.notifyMeaningfulActivity();

Testing

  • Added src/demo/DemoMode.test.ts with four focused Jest tests using fake timers:
    1. Demo starts after exactly 2-minute idle
    2. Pointer tap mid-demo cancels instantly and re-arms idle timer
    3. Demo never starts when enable() was not called (non-kiosk guard)
    4. notifyMeaningfulActivity() correctly resets the idle countdown

Closes #2976

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 7, 2026

@macan88 is attempting to deploy a commit to the FreezingMoon Team on Vercel.

A member of the Team first needs to authorize it.

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.

demo mode [bounty: 100 XTR]

1 participant