Skip to content

Drift Foundry: derive RunPhase from the shared run loop readout (adoption cleanup) #2352

Closed

Description

@Noisemaker111

Adoption cleanup, not an engine gap.

drift-foundry/src/game/run/session.ts keeps RunPhase = "start" | "running" | "won" | "crushed" beside createRunLoop, which already answers the same question through loop.read() (RunReadout). The game settles through loop.settle(...) and saves loop.snapshot(), so the phase is a second copy of state the shared loop owns, and a lane reading the phase cannot tell which one is authoritative.

Fix:

  • derive the won/crushed state from loop.read() instead of the local phase;
  • keep the title-vs-running distinction only if the shared readout cannot express it, and say why in one comment.

No engine change unless deriving the phase needs a field the readout lacks; if it does, name that field here and this becomes a small engine gap.

bun run check:framework does not flag this: a module that imports @jgengine/core/run/runLoop is composing the shared loop, and the duplicate state is tracked here instead of as a gate red.

Part of #2312 (run and session loop).

Activity

  1. Noisemaker111 commented on Oct 24, 2026

    @Noisemaker111
    OwnerAuthor

    Done in jgengine-games#206 (Drift Foundry: the pit is the shared game menu). session.ts no longer stores a phase: won/crushed now come from the outcome the shared run loop returns from settle(...) (the readout has no outcome field, and banked/lost totals cannot tell a zero-haul escape from a zero-haul wreck); start-vs-running is the one retained bit, because the loop opens a run at the pit before the engine starts, and the comment says so. No engine change needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions