|
| 1 | +# BUILD_PR_SHARED_EXTRACTION_38_CODE_TO_LETTER_HIGHSCORE_BATCH |
| 2 | + |
| 3 | +## Purpose |
| 4 | +Centralize duplicated `codeToLetter(code)` implementations across the exact initials-entry batch identified in the duplicate report. |
| 5 | + |
| 6 | +## Single PR Purpose |
| 7 | +Normalize ONLY this helper: |
| 8 | + |
| 9 | +- `codeToLetter(code)` |
| 10 | + |
| 11 | +## Exact Files Allowed |
| 12 | + |
| 13 | +### New shared file |
| 14 | +1. `src/shared/utils/initialsEntryUtils.js` |
| 15 | + |
| 16 | +### Consumer files |
| 17 | +2. `games/Asteroids/systems/AsteroidsInitialsEntry.js` |
| 18 | +3. `games/SpaceDuel/game/SpaceDuelInitialsEntry.js` |
| 19 | +4. `games/SpaceInvaders/game/SpaceInvadersInitialsEntry.js` |
| 20 | + |
| 21 | +Do not edit any other file. |
| 22 | + |
| 23 | +## Source of Truth |
| 24 | +This exact scope comes from the provided duplicate report entry for: |
| 25 | + |
| 26 | +`function codeToLetter(code)` |
| 27 | + |
| 28 | +Only the 3 listed consumer files are in scope. fileciteturn8file0 |
| 29 | + |
| 30 | +## Exact Shared Helper Creation |
| 31 | +Create: |
| 32 | + |
| 33 | +`src/shared/utils/initialsEntryUtils.js` |
| 34 | + |
| 35 | +Export exactly: |
| 36 | + |
| 37 | +```js |
| 38 | +export function codeToLetter(code) { |
| 39 | + // copy one existing implementation exactly |
| 40 | +} |
| 41 | +``` |
| 42 | + |
| 43 | +Implementation rules: |
| 44 | +- use ONE existing local implementation as source-of-truth |
| 45 | +- do NOT merge logic |
| 46 | +- do NOT generalize behavior |
| 47 | +- preserve the function signature exactly: |
| 48 | + - `codeToLetter(code)` |
| 49 | + |
| 50 | +## Exact Consumer Changes |
| 51 | +For each of the 3 listed consumer files: |
| 52 | + |
| 53 | +If the file contains a local function definition matching: |
| 54 | +```js |
| 55 | +function codeToLetter(code) |
| 56 | +``` |
| 57 | +then: |
| 58 | +- remove the local `codeToLetter(code)` function definition |
| 59 | +- import `codeToLetter` from the correct relative path to: |
| 60 | + - `src/shared/utils/initialsEntryUtils.js` |
| 61 | +- if the file already imports from that module, add `codeToLetter` with the minimum safe edit |
| 62 | +- do not duplicate imports |
| 63 | +- do not touch unrelated helpers |
| 64 | +- do not change logic |
| 65 | + |
| 66 | +If a listed file already imports and uses shared `codeToLetter`, leave it unchanged. |
| 67 | + |
| 68 | +## Relative Import Rule |
| 69 | +Use the correct relative path from each consumer file to: |
| 70 | + |
| 71 | +`src/shared/utils/initialsEntryUtils.js` |
| 72 | + |
| 73 | +Do not use aliases. |
| 74 | +Do not change `.js` extension usage. |
| 75 | + |
| 76 | +## Hard Constraints |
| 77 | +- no engine changes |
| 78 | +- no game files outside the 3 listed consumers |
| 79 | +- no sample files |
| 80 | +- no repo-wide initials helper cleanup |
| 81 | +- no behavior changes |
| 82 | +- keep one PR purpose only |
| 83 | + |
| 84 | +## Validation Checklist |
| 85 | +1. Confirm no more than the 4 listed files changed |
| 86 | +2. Confirm `src/shared/utils/initialsEntryUtils.js` exists and exports `codeToLetter` |
| 87 | +3. Confirm local `function codeToLetter(code)` definitions no longer exist in changed listed consumer files |
| 88 | +4. Confirm changed consumer files import `codeToLetter` from the correct relative path to `src/shared/utils/initialsEntryUtils.js` |
| 89 | +5. Confirm no unrelated engine, game, or sample files changed |
| 90 | +6. Confirm no behavior changes were made |
| 91 | + |
| 92 | +## Non-Goals |
| 93 | +- no cleanup of high score service helpers in this PR |
| 94 | +- no cleanup outside the 3 listed consumer files |
| 95 | +- no refactor beyond this exact duplicate-removal batch |
0 commit comments