mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-03-21 17:48:28 -05:00
Implement flavor score and star calculation for donuts (#4661)
* Implement flavor score and star calculation for donuts Added logic to compute the flavor score and assign star ratings based on defined thresholds in the RecalculateDonutStats method. This enhances donut stat recalculation by including flavor and star values. 120 Points: 1 star 240 Points: 2 stars 360 Points: 3 stars 700 Points: 4 stars 960 Points: 5 stars
This commit is contained in:
parent
b3fc5c62bf
commit
58b2c31a66
|
|
@ -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<int> 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<byte> Raw)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user