foxtrick icon indicating copy to clipboard operation
foxtrick copied to clipboard

Wrong formula in HTMS Potential

Open CarlosML27 opened this issue 2 years ago • 1 comments

Hello! This is not an issue per se, but I think there's an error in the formula for the HTMS Potential points.

This is the code for calculating the potential in players over the age factor limit:

else if (skills.years <= MAX_AGE) {
	// subtract weeks to previous birthday
	pointsDiff = skills.days / DAYS_IN_WEEK * WEEK_PTS_PER_AGE[skills.years];

	// subtracting 16 weeks per whole year until 28
	for (let i = skills.years; i > AGE_FACTOR; i--)
		pointsDiff += WEEKS_IN_SEASON * WEEK_PTS_PER_AGE[i];

	pointsDiff = -pointsDiff;
}

Shouldn't the loop go from skills.years-1 to AGE_FACTOR, including it?

Let's say we have a player with 30.013 years. First, we'll subtract the days equivalence until we reach a full year (in this case, 30.000). Then we'll have to subtract the full 29.111 to 29.000 year (WEEKS_IN_SEASON * WEEK_PTS_PER_AGE[29]) and finally the 28.111-28.000 year (WEEKS_IN_SEASON * WEEK_PTS_PER_AGE[28]). As it is right now, unless I'm missing something it will be taking the 30 and 29 years, so the calculations are messed up in that part...

CarlosML27 avatar Sep 03 '23 12:09 CarlosML27

@minj Any chances you can take a look at this? I wouldn't mind to do the PR if you give me green light.

CarlosML27 avatar Sep 06 '24 22:09 CarlosML27