diff --git a/src/data/pokemon-species.ts b/src/data/pokemon-species.ts index f925f3fb1d0..3645cb03c60 100644 --- a/src/data/pokemon-species.ts +++ b/src/data/pokemon-species.ts @@ -657,6 +657,24 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali return this.getSpeciesForLevel(level, allowEvolving, true, strength, currentWave); } + /** + * @see {@linkcode getSpeciesForLevel} uses an ease in and ease out sine function: + * @see {@link https://easings.net/#easeInSine} + * @see {@link https://easings.net/#easeOutSine} + * Ease in is similar to an exponential function with slower growth, as in, x is directly related to y, and increase in y is higher for higher x. + * Ease out looks more similar to a logarithmic function shifted to the left. It's still a direct relation but it plateaus instead of increasing in growth. + * + * This function is used to calculate the x given to these functions, which is used for evolution chance. + * + * First is maxLevelDiff, which is a denominator for evolution chance for mons without wild evolution delay. + * This means a lower value of x will lead to a higher evolution chance. + * + * It's also used for preferredMinLevel, which is used when an evolution delay exists. + * The calculation with evolution delay is a weighted average of the easeIn and easeOut functions where preferredMinLevel is the denominator. + * This also means a lower value of x will lead to a higher evolution chance. + * @param strength {@linkcode PartyMemberStrength} The strength of the party member in question + * @returns {@linkcode integer} The level difference from expected evolution level tolerated for a mon to be unevolved. Lower value = higher evolution chance. + */ private getStrengthLevelDiff(strength: PartyMemberStrength): integer { switch (Math.min(strength, PartyMemberStrength.STRONGER)) { case PartyMemberStrength.WEAKEST: @@ -716,7 +734,7 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali if (strength === PartyMemberStrength.STRONGER) { evolutionChance = 1; } else { - const maxLevelDiff = this.getStrengthLevelDiff(strength); + const maxLevelDiff = this.getStrengthLevelDiff(strength); //The maximum distance from the evolution level tolerated for the mon to not evolve const minChance: number = 0.875 - 0.125 * strength; evolutionChance = Math.min(minChance + easeInFunc(Math.min(level - ev.level, maxLevelDiff) / maxLevelDiff) * (1 - minChance), 1);