Link round income to health and update results → export flow#35
Open
Spbd1 wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Description
utils/game.ts:getHealthIncomeMultiplier(healthPoints)andgetRoundIncomeForHealth(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 thathealthBeforeis used for the round income calculation.scoreAfter = scoreBefore + roundIncome - paidCostand saved per-roundroundIncome,baseRoundIncome, andhealthIncomeMultiplierintoGameRoundDatawhen a choice is recorded; replay mode continues to store replay data separately and uses the same income rule.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.”calculateActualRoundIncomeTotal, madecalculateTotalIncomeuse actual round incomes, exposedtotalActualRoundIncome,theoreticalBaseIncome, andhealthAdjustedIncomeLossinGameSummary/exports, and surfacedhealthAdjustedIncomeLossin computed metrics.lib/researchExportSchema.ts), admin CSV mapping (lib/adminSubmissions.ts), and the sample export (sample-data/complete-research-export.example.json, schema bumped tohidden-cost-game-research-schema-7) to include the new fields while keeping per-round fields optional to preserve compatibility with older exports/localStorage.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
npm run typecheckwith no TypeScript errors (success).npm run lint(ESLint) with no warnings/errors (success).npm run build(Next build) and the app compiled and prerendered successfully (success).npm run validate:sampleto 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
replayGamewithout overwriting the original run.Codex Task