|
| 1 | +# BUILD_PR_SHARED_EXTRACTION_28_CLAMP_CORE_BATCH |
| 2 | + |
| 3 | +## Purpose |
| 4 | +Centralize duplicated `clamp(value, min, max)` implementations across core/game usage into the engine math utility. |
| 5 | + |
| 6 | +## Single PR Purpose |
| 7 | +Normalize ONLY this helper: |
| 8 | + |
| 9 | +- clamp(value, min, max) |
| 10 | + |
| 11 | +Target batch (core + games using identical signature): |
| 12 | + |
| 13 | +1. games/AITargetDummy/game/AITargetDummyController.js |
| 14 | +2. games/AITargetDummy/game/AITargetDummyInputController.js |
| 15 | +3. games/AITargetDummy/game/AITargetDummyWorld.js |
| 16 | +4. games/Asteroids/game/AsteroidsAttractAdapter.js |
| 17 | +5. games/Bouncing-ball/game/BouncingBallWorld.js |
| 18 | +6. games/Breakout/game/BreakoutWorld.js |
| 19 | +7. games/Gravity/game/GravityInputController.js |
| 20 | +8. games/Gravity/game/GravityWorld.js |
| 21 | +9. games/MultiBallChaos/game/MultiBallChaosWorld.js |
| 22 | +10. games/network_sample_a/game/FakeLoopbackNetworkModel.js |
| 23 | +11. games/network_sample_a/game/NetworkSampleAScene.js |
| 24 | +12. games/network_sample_b/game/FakeHostClientNetworkModel.js |
| 25 | +13. games/network_sample_c/game/FakeDivergenceTraceNetworkModel.js |
| 26 | +14. games/PacmanLite/game/PacmanLitePlayerController.js |
| 27 | +15. games/PaddleIntercept/game/PaddleInterceptWorld.js |
| 28 | +16. games/Pong/game/PongWorld.js |
| 29 | +17. games/SpaceDuel/game/SpaceDuelAttractAdapter.js |
| 30 | +18. games/SpaceInvaders/game/SpaceInvadersInputController.js |
| 31 | +19. games/SpaceInvaders/game/SpaceInvadersWorld.js |
| 32 | +20. games/Thruster/game/ThrusterInputController.js |
| 33 | +21. games/Thruster/game/ThrusterWorld.js |
| 34 | + |
| 35 | +## Exact Files Allowed |
| 36 | + |
| 37 | +### Canonical shared source |
| 38 | +1. src/engine/utils/math.js |
| 39 | + |
| 40 | +### Consumers |
| 41 | +(only the 21 listed files) |
| 42 | + |
| 43 | +## Shared Helper |
| 44 | +Use: |
| 45 | +- src/engine/utils/math.js |
| 46 | + |
| 47 | +Fail fast unless it exports: |
| 48 | +- clamp |
| 49 | + |
| 50 | +If present but not exported correctly → minimal export fix only. |
| 51 | + |
| 52 | +## Change Rules |
| 53 | + |
| 54 | +### Shared file |
| 55 | +Allowed: |
| 56 | +- ensure clamp exists |
| 57 | +- ensure clamp is exported |
| 58 | + |
| 59 | +Not allowed: |
| 60 | +- no behavior change |
| 61 | + |
| 62 | +### Consumer files |
| 63 | +If local: |
| 64 | +```js |
| 65 | +function clamp(value, min, max) |
| 66 | +``` |
| 67 | + |
| 68 | +Then: |
| 69 | +- remove local definition |
| 70 | +- import clamp from src/engine/utils/math.js |
| 71 | +- merge into existing import if present |
| 72 | + |
| 73 | +Do NOT touch: |
| 74 | +- clamp with fallback param |
| 75 | +- clamp variants with different signatures |
| 76 | + |
| 77 | +## Constraints |
| 78 | +- no tools |
| 79 | +- no debug |
| 80 | +- no samples |
| 81 | +- no behavior change |
| 82 | +- exact batch only |
| 83 | + |
| 84 | +## Validation |
| 85 | +- only listed files changed |
| 86 | +- no local clamp definitions remain in listed files |
| 87 | +- imports added correctly |
| 88 | +- no signature mismatch introduced |
| 89 | + |
| 90 | +## Non-Goals |
| 91 | +- no clamp(fallback) variants |
| 92 | +- no tools clamp cleanup |
0 commit comments