Defer go slots with IV sets as there might be other encs

Move the logic to the class
Update go binaries
This commit is contained in:
Kurt 2020-12-29 16:07:29 -08:00
parent 4d1832b124
commit b19688b13d
7 changed files with 38 additions and 37 deletions

View file

@ -117,8 +117,10 @@ namespace PKHeX.Core
}
}
private static bool IsDeferredSlot(IEncounterable slot, PKM pk)
private static bool IsDeferredSlot(EncounterSlotGO slot, PKM pk)
{
if (!slot.GetIVsValid(pk))
return true;
if (slot.Species == (int) Core.Species.Wurmple)
return !WurmpleUtil.IsWurmpleEvoValid(pk);

View file

@ -24,6 +24,21 @@ namespace PKHeX.Core
pb.WeightScalar = PokeSizeUtil.GetRandomScalar();
}
public override bool GetIVsValid(PKM pkm)
{
// Stamina*2 | 1 -> HP
// ATK * 2 | 1 -> ATK&SPA
// DEF * 2 | 1 -> DEF&SPD
// Speed is random.
// All IVs must be odd (except speed) and equal to their counterpart.
if ((pkm.GetIV(1) & 1) != 1 || pkm.GetIV(1) != pkm.GetIV(4)) // ATK=SPA
return false;
if ((pkm.GetIV(2) & 1) != 1 || pkm.GetIV(2) != pkm.GetIV(5)) // DEF=SPD
return false;
return (pkm.GetIV(0) & 1) == 1; // HP
}
protected override void SetEncounterMoves(PKM pk, GameVersion version, int level)
{
var moves = MoveLevelUp.GetEncounterMoves(pk, level, GameVersion.GG);

View file

@ -52,11 +52,26 @@ namespace PKHeX.Core
pk8.WeightScalar = PokeSizeUtil.GetRandomScalar();
}
public override bool GetIVsValid(PKM pkm)
{
var minIV = GetMinIV();
return IsGoIVSetValid(pkm, minIV);
}
protected override void SetEncounterMoves(PKM pk, GameVersion version, int level)
{
var moves = MoveLevelUp.GetEncounterMoves(pk, level, OriginGroup);
pk.SetMoves(moves);
pk.SetMaximumPPCurrent(moves);
}
private static bool IsGoIVSetValid(PKM pkm, int min)
{
if (pkm.IV_ATK >> 1 < min) // ATK
return false;
if (pkm.IV_DEF >> 1 < min) // DEF
return false;
return pkm.IV_HP >> 1 >= min; // HP
}
}
}

View file

@ -90,5 +90,7 @@ namespace PKHeX.Core
pk.MetDate = GetRandomValidDate();
pk.SetRandomIVsGO(Type.GetMinIV());
}
public abstract bool GetIVsValid(PKM pkm);
}
}
}

View file

@ -109,41 +109,8 @@ namespace PKHeX.Core
private void VerifyIVsGoTransfer(LegalityAnalysis data)
{
var pkm = data.pkm;
if (!IsGoIVSetValid(pkm))
{
if (data.EncounterMatch is EncounterSlotGO g && !g.GetIVsValid(data.pkm))
data.AddLine(GetInvalid(LIVNotCorrect));
}
else if (data.EncounterMatch is EncounterSlot8GO g)
{
var minIV = g.GetMinIV();
if (!IsGoIVSetValid(pkm, minIV))
data.AddLine(GetInvalid(LIVNotCorrect));
}
}
private static bool IsGoIVSetValid(PKM pkm)
{
// Stamina*2 | 1 -> HP
// ATK * 2 | 1 -> ATK&SPA
// DEF * 2 | 1 -> DEF&SPD
// Speed is random.
// All IVs must be odd (except speed) and equal to their counterpart.
if ((pkm.GetIV(1) & 1) != 1 || pkm.GetIV(1) != pkm.GetIV(4)) // ATK=SPA
return false;
if ((pkm.GetIV(2) & 1) != 1 || pkm.GetIV(2) != pkm.GetIV(5)) // DEF=SPD
return false;
return (pkm.GetIV(0) & 1) == 1; // HP
}
private static bool IsGoIVSetValid(PKM pkm, int min)
{
if (pkm.IV_ATK >> 1 < min) // ATK
return false;
if (pkm.IV_DEF >> 1 < min) // DEF
return false;
return pkm.IV_HP >> 1 >= min; // HP
}
}
}
}