Adjust head evo max level for 345 vc7 transfers

https://projectpokemon.org/home/forums/topic/63635-pkhex-230709-bugs/
This commit is contained in:
Kurt
2023-07-09 21:06:47 -07:00
parent 478413e8cd
commit 2e0a2ed7eb
6 changed files with 18 additions and 14 deletions

View File

@@ -17,9 +17,9 @@ public int Devolve(Span<EvoCriteria> result, PKM pk, EvolutionOrigin enc)
{
if (pk.Format > Generation && !enc.SkipChecks)
{
var max = pk.Met_Level;
byte max = (byte)pk.Met_Level;
EvolutionUtil.UpdateCeiling(result, max);
enc = enc with { LevelMin = 2, LevelMax = (byte)max };
enc = enc with { LevelMin = 2, LevelMax = max };
}
int present = 1;

View File

@@ -17,9 +17,9 @@ public int Devolve(Span<EvoCriteria> result, PKM pk, EvolutionOrigin enc)
{
if (pk.Format == 4 && !enc.SkipChecks) // 5+ already have been revised
{
var max = pk.Met_Level;
byte max = (byte)pk.Met_Level;
EvolutionUtil.UpdateCeiling(result, max);
enc = enc with { LevelMin = 1, LevelMax = (byte)max };
enc = enc with { LevelMin = 1, LevelMax = max };
}
int present = 1;

View File

@@ -17,9 +17,9 @@ public int Devolve(Span<EvoCriteria> result, PKM pk, EvolutionOrigin enc)
{
if (pk.Format > Generation && !enc.SkipChecks)
{
var max = pk.Met_Level;
byte max = (byte)pk.Met_Level;
EvolutionUtil.UpdateCeiling(result, max);
enc = enc with { LevelMin = 1, LevelMax = (byte)max };
enc = enc with { LevelMin = 1, LevelMax = max };
}
int present = 1;
@@ -47,7 +47,7 @@ public int Evolve(Span<EvoCriteria> result, PKM pk, EvolutionOrigin enc, Evoluti
if (pk.Format > Generation)
enc = enc with { LevelMax = (byte)pk.Met_Level };
else if (enc.Generation < Generation)
EvolutionUtil.UpdateFloor(result, pk.Met_Level);
EvolutionUtil.UpdateFloor(result, (byte)pk.Met_Level, enc.LevelMax);
int present = 1;
for (int i = result.Length - 1; i >= 1; i--)

View File

@@ -38,7 +38,7 @@ public bool TryDevolve(ISpeciesForm head, PKM pk, byte currentMaxLevel, byte lev
public int Evolve(Span<EvoCriteria> result, PKM pk, EvolutionOrigin enc, EvolutionHistory history)
{
if (enc.Generation < Generation)
EvolutionUtil.UpdateFloor(result, pk.Met_Level);
EvolutionUtil.UpdateFloor(result, (byte)pk.Met_Level, enc.LevelMax);
int present = 1;
for (int i = result.Length - 1; i >= 1; i--)

View File

@@ -51,7 +51,7 @@ private static void RevertMutatedForms(ref EvoCriteria evo)
public int Evolve(Span<EvoCriteria> result, PKM pk, EvolutionOrigin enc, EvolutionHistory history)
{
if (enc.Generation <= 2) // VC Transfer
EvolutionUtil.UpdateFloor(result, pk.Met_Level);
EvolutionUtil.UpdateFloor(result, (byte)pk.Met_Level, enc.LevelMax);
int present = 1;
for (int i = result.Length - 1; i >= 1; i--)

View File

@@ -86,26 +86,30 @@ public static int IndexOf(Span<EvoCriteria> result, ushort species)
/// <summary>
/// Revises the <see cref="result"/> to account for a new maximum <see cref="level"/>.
/// </summary>
public static void UpdateCeiling(Span<EvoCriteria> result, int level)
public static void UpdateCeiling(Span<EvoCriteria> result, byte level)
{
foreach (ref var evo in result)
{
if (evo.Species == 0)
break;
evo = evo with { LevelMax = (byte)Math.Min(evo.LevelMax, level) };
evo = evo with { LevelMax = Math.Min(evo.LevelMax, level) };
}
}
/// <summary>
/// Revises the <see cref="result"/> to account for a new minimum <see cref="level"/>.
/// Revises the <see cref="result"/> to account for a new minimum <see cref="levelMin"/>.
/// </summary>
public static void UpdateFloor(Span<EvoCriteria> result, int level)
public static void UpdateFloor(Span<EvoCriteria> result, byte levelMin, byte levelMax)
{
// Reset the head to the new levelMax, then clamp every entry's minimum to the min.
// Evolving non-head evolutions will pick up the new ranges later.
ref var head = ref result[0];
head = head with { LevelMax = levelMax };
foreach (ref var evo in result)
{
if (evo.Species == 0)
break;
evo = evo with { LevelMin = (byte)Math.Max(evo.LevelMin, level) };
evo = evo with { LevelMin = Math.Max(evo.LevelMin, levelMin) };
}
}