minj / foxtrick

FoxTrick is a browser extension for the Hattrick online football manager game, currently available for Firefox, Google Chrome, as well as for Opera.
https://www.foxtrick.org
GNU General Public License v3.0
69 stars 48 forks source link

Wrong formula in HTMS Potential #1714

Open CarlosML27 opened 10 months ago

CarlosML27 commented 10 months ago

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...