Fix 9-hole handicap calculation when back-nine holes are missing from DB
When only front-nine holes are entered in course_holes (common setup), course_par_full summed to ~36 instead of ~72, inflating the 9-hole playing handicap by roughly 2x before halving. Fix by using course_par_played×2 as the 18-hole par estimate in both the backend create_game and the new_game confirmation preview. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -65,9 +65,12 @@
|
||||
const player = this.getPlayer(uid);
|
||||
const tee = this.getTee(uid);
|
||||
const course = COURSES_DATA.find(c => c.id === this.courseId);
|
||||
if (!course || !tee || player.handicap == null || !course.par) return null;
|
||||
if (!course || !tee || player.handicap == null) return null;
|
||||
const nineOfEighteen = parseInt(this.holesCount) === 9 && course.holes === 18;
|
||||
const ph = Math.round(player.handicap * (tee.slope / 113) + (tee.rating - course.par));
|
||||
// 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 par = nineOfEighteen ? course.par_9 * 2 : course.par;
|
||||
if (!par) return null;
|
||||
const ph = Math.round(player.handicap * (tee.slope / 113) + (tee.rating - par));
|
||||
return nineOfEighteen ? Math.round(ph / 2) : ph;
|
||||
},
|
||||
goToConfirm() { this.step = 3; },
|
||||
|
||||
Reference in New Issue
Block a user