using static PKHeX.Core.LegalityCheckStrings; namespace PKHeX.Core { /// /// Verifies the values for markings. /// public sealed class MarkVerifier : Verifier { protected override CheckIdentifier Identifier => CheckIdentifier.RibbonMark; public override void Verify(LegalityAnalysis data) { var pkm = data.pkm; if (!(pkm is IRibbonIndex m)) return; if (data.Info.Generation != 8) VerifyNoMarksPresent(data, m); else VerifyMarksPresent(data, m); } private void VerifyNoMarksPresent(LegalityAnalysis data, IRibbonIndex m) { for (var x = RibbonIndex.MarkLunchtime; x <= RibbonIndex.MarkSlump; x++) { if (m.GetRibbon((int)x)) data.AddLine(GetInvalid(string.Format(LRibbonMarkingFInvalid_0, x))); } } private void VerifyMarksPresent(LegalityAnalysis data, IRibbonIndex m) { bool hasOne = false; for (var mark = RibbonIndex.MarkLunchtime; mark <= RibbonIndex.MarkSlump; mark++) { bool has = m.GetRibbon((int) mark); if (!has) continue; if (hasOne) { data.AddLine(GetInvalid(string.Format(LRibbonMarkingFInvalid_0, mark))); return; } bool result = VerifyMarking(data, mark); if (!result) { data.AddLine(GetInvalid(string.Format(LRibbonMarkingFInvalid_0, mark))); return; } hasOne = true; } if (m is PK8 pk8 && pk8.AffixedRibbon != -1) { if (pk8.AffixedRibbon > (int)RibbonIndex.MarkSlump) data.AddLine(GetInvalid(string.Format(LRibbonMarkingAffixedF_0, pk8.AffixedRibbon))); else if (!hasOne) data.AddLine(GetInvalid(string.Format(LRibbonMarkingAffixedF_0, (RibbonIndex)pk8.AffixedRibbon))); } } private static bool VerifyMarking(LegalityAnalysis data, RibbonIndex mark) { var pkm = data.pkm; switch (mark) { case RibbonIndex.MarkCurry: { var ball = pkm.Ball; if (!(2 <= ball && ball <= 4)) // Poke,Great,Ultra only return false; break; } } return true; } } }