Minor tweaks

Flag enigma berry on ck3/xk3
Suggest national ribbon if missing
Flag N's pkm if any IV is != 30, even if sum is 180.
This commit is contained in:
Kurt 2022-08-19 22:37:27 -07:00
parent db0b77c493
commit d0ca8403a9
8 changed files with 45 additions and 46 deletions

View file

@ -113,11 +113,12 @@ public sealed class BallVerifier : Verifier
};
}
private CheckResult VerifyBallInherited(LegalityAnalysis data) => data.Info.Generation switch
private CheckResult VerifyBallInherited(LegalityAnalysis data) => data.Info.EncounterMatch.Context switch
{
6 => VerifyBallEggGen6(data), // Gen6 Inheritance Rules
7 => VerifyBallEggGen7(data), // Gen7 Inheritance Rules
8 => data.Entity.BDSP ? VerifyBallEggGen8BDSP(data) : VerifyBallEggGen8(data),
EntityContext.Gen6 => VerifyBallEggGen6(data), // Gen6 Inheritance Rules
EntityContext.Gen7 => VerifyBallEggGen7(data), // Gen7 Inheritance Rules
EntityContext.Gen8 => VerifyBallEggGen8(data),
EntityContext.Gen8b => VerifyBallEggGen8BDSP(data),
_ => NONE,
};

View file

@ -1,4 +1,4 @@
using System;
using System;
using static PKHeX.Core.LegalityCheckStrings;
namespace PKHeX.Core;
@ -33,8 +33,6 @@ public sealed class IndividualValueVerifier : Verifier
}
}
public static bool AllIVsEqual(PKM pk) => AllIVsEqual(pk, pk.IV_HP);
private static bool AllIVsEqual(PKM pk, int hpiv)
{
return (pk.IV_ATK == hpiv) && (pk.IV_DEF == hpiv) && (pk.IV_SPA == hpiv) && (pk.IV_SPD == hpiv) && (pk.IV_SPE == hpiv);
@ -94,7 +92,7 @@ public sealed class IndividualValueVerifier : Verifier
{
if (w is EncounterSlot6XY xy)
{
if (PersonalTable.XY[data.EncounterMatch.Species].IsEggGroup(15)) // Undiscovered
if (PersonalTable.XY[xy.Species].IsEggGroup(15)) // Undiscovered
VerifyIVsFlawless(data, 3);
if (xy.IsFriendSafari)
VerifyIVsFlawless(data, 2);

View file

@ -1,4 +1,4 @@
using static PKHeX.Core.LegalityCheckStrings;
using static PKHeX.Core.LegalityCheckStrings;
namespace PKHeX.Core;
@ -12,14 +12,22 @@ public sealed class ItemVerifier : Verifier
public override void Verify(LegalityAnalysis data)
{
var pk = data.Entity;
if (!ItemRestrictions.IsHeldItemAllowed(pk))
data.AddLine(GetInvalid(LItemUnreleased));
if (pk.Format == 3 && pk.HeldItem == 175) // Enigma Berry
VerifyEReaderBerry(data);
if (pk.IsEgg && pk.HeldItem != 0)
var item = pk.HeldItem;
if (pk.IsEgg && item != 0)
data.AddLine(GetInvalid(LItemEgg));
if (!ItemRestrictions.IsHeldItemAllowed(item, context: pk.Context))
{
data.AddLine(GetInvalid(LItemUnreleased));
}
else if (pk.Format == 3 && item == 175) // Enigma Berry
{
// A Pokémon holding this Berry cannot be traded to Pokémon Colosseum or Pokémon XD: Gale of Darkness, nor can it be stored in Pokémon Box Ruby & Sapphire.
if (pk is CK3 or XK3)
data.AddLine(GetInvalid(LItemUnreleased));
else
VerifyEReaderBerry(data);
}
}
private void VerifyEReaderBerry(LegalityAnalysis data)

View file

@ -1,4 +1,4 @@
using static PKHeX.Core.LegalityCheckStrings;
using static PKHeX.Core.LegalityCheckStrings;
namespace PKHeX.Core;
@ -27,7 +27,7 @@ public sealed class NHarmoniaVerifier : Verifier
if (pk.OT_Gender != 0)
data.AddLine(GetInvalid(LG5OTGenderN, CheckIdentifier.Trainer));
if (pk.IVTotal != 30*6)
if (!VerifyNsPKMIVsValid(pk))
data.AddLine(GetInvalid(LG5IVAll30, CheckIdentifier.IVs));
if (!VerifyNsPKMOTValid(pk))
data.AddLine(GetInvalid(LG5ID_N, CheckIdentifier.Trainer));
@ -35,6 +35,12 @@ public sealed class NHarmoniaVerifier : Verifier
data.AddLine(GetInvalid(LG5PIDShinyN, CheckIdentifier.Shiny));
}
private static bool VerifyNsPKMIVsValid(PKM pk)
{
// All are 30.
return pk.IV_HP == 30 && pk.IV_ATK == 30 && pk.IV_DEF == 30 && pk.IV_SPA == 30 && pk.IV_SPD == 30 && pk.IV_SPE == 30;
}
private static bool VerifyNsPKMOTValid(PKM pk)
{
if (pk.TID != 00002 || pk.SID != 00000)

View file

@ -153,25 +153,6 @@ public sealed class PIDVerifier : Verifier
}
}
/// <summary>
/// Returns the expected <see cref="PKM.PID"/> for a Gen3-5 transfer to Gen6.
/// </summary>
/// <param name="pk">Entity to check</param>
/// <param name="pid">PID result</param>
/// <returns>True if the <see cref="pid"/> is appropriate to use.</returns>
public static bool GetTransferPID(PKM pk, out uint pid)
{
var ver = pk.Version;
if (ver is 0 or >= (int) GameVersion.X) // Gen6+ ignored
{
pid = 0;
return false;
}
var _ = GetExpectedTransferPID(pk, out pid);
return true;
}
/// <summary>
/// Returns the expected <see cref="PKM.EncryptionConstant"/> for a Gen3-5 transfer to Gen6.
/// </summary>

View file

@ -2,9 +2,16 @@ using System;
namespace PKHeX.Core;
/// <summary>
/// List using a fixed-size span to store results. Only exposes <see cref="Count"/>; the span is hidden, and only accessible if the span was already a known instance.
/// </summary>
public ref struct RibbonResultList
{
private readonly Span<RibbonResult> Span;
/// <summary>
/// Count of results that were added to the span.
/// </summary>
public int Count { get; private set; }
public RibbonResultList(Span<RibbonResult> span)
@ -13,11 +20,7 @@ public ref struct RibbonResultList
Count = 0;
}
private void Add(RibbonResult item)
{
Span[Count] = item;
++Count;
}
private void Add(RibbonResult item) => Span[Count++] = item;
public void Add(RibbonIndex index, bool missing = false) => Add(new(index, missing));
public void Add(RibbonIndex3 index, bool missing = false) => Add(new(index, missing));

View file

@ -42,8 +42,9 @@ public static class RibbonVerifierEvent3
if (r.RibbonEarth && enc.Generation != 3)
list.Add(Earth);
if (r.RibbonNational != RibbonRules.GetValidRibbonStateNational(args.Entity, enc))
list.Add(National);
var nationalRequired = RibbonRules.GetValidRibbonStateNational(args.Entity, enc);
if (r.RibbonNational != nationalRequired)
list.Add(National, nationalRequired);
if (r.RibbonCountry)
list.Add(Country);
if (r.RibbonChampionBattle)

View file

@ -208,11 +208,12 @@ public static class AwakeningUtil
/// <param name="pk">Entity to check</param>
public static void GetExpectedMinimumAVs(Span<byte> result, PB7 pk)
{
// go park transfers have 2 AVs for all stats.
// leveling up in-game applies 1 AV to a "random" index.
// GO Park transfers start with 2 AVs for all stats.
// Every other encounter is either all 0, or can legally start at 0 (trades).
if (pk.Version == (int)GameVersion.GO)
result.Fill(2);
// Leveling up in-game applies 1 AV to a "random" index.
var start = pk.Met_Level;
var end = pk.CurrentLevel;
if (start == end)