Fix 9-hole course handicap formula to use HI÷2 per WHS spec
Dedicated 9-hole courses have 9-hole ratings and pars, so the WHS formula is: round((HI÷2) × (slope/113) + (rating − par)). The previous code used the full HI, giving roughly double the correct result (e.g. 22 instead of 11 on Augwil White Male for HI 18). The three cases are now handled correctly: - Dedicated 9-hole course: HI÷2 with 9-hole ratings - 9 holes on 18-hole course: full HI with 18-hole ratings, result halved - Full 18 holes: full HI with 18-hole ratings Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -67,10 +67,13 @@
|
||||
const course = COURSES_DATA.find(c => c.id === this.courseId);
|
||||
if (!course || !tee || player.handicap == null) return null;
|
||||
const nineOfEighteen = parseInt(this.holesCount) === 9 && course.holes === 18;
|
||||
// For 9-of-18, use par_9×2 as the 18-hole par so back-nine holes don't need to be in DB.
|
||||
const nineHoleDedicated = parseInt(this.holesCount) === 9 && course.holes === 9;
|
||||
// For 9-of-18: use par_9×2 as the 18-hole par, compute full CH then halve.
|
||||
// For dedicated 9-hole: WHS formula uses HI÷2 directly with 9-hole ratings.
|
||||
const par = nineOfEighteen ? course.par_9 * 2 : course.par;
|
||||
if (!par) return null;
|
||||
const ph = Math.round(player.handicap * (tee.slope / 113) + (tee.rating - par));
|
||||
const hcForFormula = nineHoleDedicated ? player.handicap / 2 : player.handicap;
|
||||
const ph = Math.round(hcForFormula * (tee.slope / 113) + (tee.rating - par));
|
||||
return nineOfEighteen ? Math.round(ph / 2) : ph;
|
||||
},
|
||||
goToConfirm() { this.step = 3; },
|
||||
|
||||
Reference in New Issue
Block a user