Skip to content

Link round income to health and update results → export flow#35

Open
Spbd1 wants to merge 1 commit into
codex/improve-game-stage-ui/uxfrom
codex/fix-health-linked-income-and-button-flow
Open

Link round income to health and update results → export flow#35
Spbd1 wants to merge 1 commit into
codex/improve-game-stage-ui/uxfrom
codex/fix-health-linked-income-and-button-flow

Conversation

@Spbd1

@Spbd1 Spbd1 commented May 12, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Make health meaningfully affect later scoring by reducing per-round income when health is lower, improving game logic and downstream metrics visibility.
  • Prevent participants from being misdirected to additional survey questions after completing the game summary and instead send them to results/export when appropriate.

Description

  • Added health-linked income helpers in utils/game.ts: getHealthIncomeMultiplier(healthPoints) and getRoundIncomeForHealth(healthPoints), using the requested tiers (>=90:1, >=75:0.85, >=50:0.65, >=25:0.4, <25:0.2) and rounding to 2 decimals, and documented that healthBefore is used for the round income calculation.
  • Updated scoring to use scoreAfter = scoreBefore + roundIncome - paidCost and saved per-round roundIncome, baseRoundIncome, and healthIncomeMultiplier into GameRoundData when a choice is recorded; replay mode continues to store replay data separately and uses the same income rule.
  • Updated the game UI (components/HiddenCostGame.tsx) to show base and health-adjusted income on the event card and choice preview, to label treatment cost clearly, to show estimated financial/health after choice, and to add the helper note: “Lower health can reduce the points earned in later rounds.”
  • Changed summary and metrics to use actual earned round income: added calculateActualRoundIncomeTotal, made calculateTotalIncome use actual round incomes, exposed totalActualRoundIncome, theoreticalBaseIncome, and healthAdjustedIncomeLoss in GameSummary/exports, and surfaced healthAdjustedIncomeLoss in computed metrics.
  • Updated export validation/schema (lib/researchExportSchema.ts), admin CSV mapping (lib/adminSubmissions.ts), and the sample export (sample-data/complete-research-export.example.json, schema bumped to hidden-cost-game-research-schema-7) to include the new fields while keeping per-round fields optional to preserve compatibility with older exports/localStorage.
  • Clarified results-stage navigation (components/ResultsTable.tsx) so a completed participant sees a single clear action: “Review results and export data” → /individual-results, and preserved the original pre-reveal/debrief/follow-up routing for participants still mid-flow.

Testing

  • Ran npm run typecheck with no TypeScript errors (success).
  • Ran npm run lint (ESLint) with no warnings/errors (success).
  • Ran npm run build (Next build) and the app compiled and prerendered successfully (success).
  • Ran npm run validate:sample to validate the updated sample export against the Zod schema and it succeeded (success).

Notes: per requirements, fields added to round data and the export schema are optional where practical so older localStorage sessions and prior exports are tolerated; replay logic uses the same health-based income rule and writes to replayGame without overwriting the original run.


Codex Task

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant