Files
PkmnLib.NET/Plugins/PkmnLib.Plugin.Gen7/Libraries/Battling/Gen7ExperienceGainCalculator.cs
Deukhoofd 90eaeb1a72
All checks were successful
Build / Build (push) Successful in 1m49s
Implements experience gain
2025-11-02 23:20:07 +01:00

40 lines
1.3 KiB
C#

using System.Diagnostics.CodeAnalysis;
using PkmnLib.Dynamic.Libraries;
namespace PkmnLib.Plugin.Gen7.Libraries.Battling;
/// <inheritdoc />
public class Gen7ExperienceGainCalculator : IExperienceGainCalculator
{
/// <inheritdoc />
[SuppressMessage("ReSharper", "UselessBinaryOperation")]
public uint CalculateExperienceGain(IPokemon defeatedPokemon, IPokemon victoriousPokemon)
{
var b = defeatedPokemon.Form.BaseExperience;
var levelFainted = defeatedPokemon.Level;
var levelOpponent = victoriousPokemon.Level;
// TODO: Experience share, in which case s = 2 for Pokemon that did not participate in battle
var s = 1;
var v1 = b * levelFainted / 5 * (1 / s);
var v2 = (2 * levelFainted + 10) / (levelFainted + levelOpponent + 10);
var res = v1 * Math.Pow(v2, 2.5) + 1;
// TODO: t = 1.5 if the Pokemon is traded, and 1.7 is traded and has a different language
var t = 1;
res *= t;
// TODO: script modifier, which is e.
var e = 1;
res *= e;
// TODO: v = 1.2 if the Pokemon is at or past the level where it evolves
var v = 1;
res *= v;
return res switch
{
> uint.MaxValue => uint.MaxValue,
< 0 => 0,
_ => (uint)res,
};
}
}