diff --git a/PKHeX.Core/Saves/Substructures/Gen9/ZA/DonutPocket9a.cs b/PKHeX.Core/Saves/Substructures/Gen9/ZA/DonutPocket9a.cs index af86cf9a0..18f8366cc 100644 --- a/PKHeX.Core/Saves/Substructures/Gen9/ZA/DonutPocket9a.cs +++ b/PKHeX.Core/Saves/Substructures/Gen9/ZA/DonutPocket9a.cs @@ -210,20 +210,31 @@ public static void RecalculateDonutStats(this Donut9a donut) var boost = 1; var calories = 0; var berries = donut.GetBerries(); + var flavorScore = 0; foreach (var berry in berries) { if (!TryGetBerry(berry, out var detail)) continue; calories += detail.Calories; boost += detail.Boost; + flavorScore += detail.FlavorScore; } - donut.Calories = (ushort)((calories > 9999) ? 9999 : (ushort)calories); + donut.Calories = (ushort)Math.Min(calories, 9999); donut.LevelBoost = (byte)boost; - // Stars?? - // Flavors?? + donut.Stars = GetDonutStarCount(flavorScore); } + public static byte GetDonutStarCount(int flavorScore) => flavorScore switch + { + >= 960 => 5, + >= 700 => 4, + >= 360 => 3, + >= 240 => 2, + >= 120 => 1, + _ => 0 + }; + public static void RecalculateDonutFlavors(this Donut9a donut, Span flavors) { var berries = donut.GetBerries(); @@ -555,7 +566,10 @@ public static bool TryGetFlavorName(ulong hash, [NotNullWhen(true)] out string? public static ulong GetFlavorHash(string text) => FnvHash.HashFnv1a_64(text); } -public readonly record struct DonutBerryDetail(ushort Item, byte Donut, byte Spicy, byte Fresh, byte Sweet, byte Bitter, byte Sour, byte Boost, ushort Calories); +public readonly record struct DonutBerryDetail(ushort Item, byte Donut, byte Spicy, byte Fresh, byte Sweet, byte Bitter, byte Sour, byte Boost, ushort Calories) +{ + public int FlavorScore => Spicy + Fresh + Sweet + Bitter + Sour; +} public readonly record struct Donut9a(Memory Raw) {