public void updateMoveLegality() { try { vMoves = verifyMoves(); } catch { for (int i = 0; i < 4; i++) { vMoves[i] = new LegalityCheck(Severity.Invalid, "Internal error."); } } SecondaryChecked = false; }
public void updateRelearnLegality() { try { vRelearn = verifyRelearn(); } catch { for (int i = 0; i < 4; i++) { vRelearn[i] = new LegalityCheck(Severity.Invalid, "Internal error."); } } SecondaryChecked = false; }
private void updateChecks() { Encounter = verifyEncounter(); ECPID = verifyECPID(); Nickname = verifyNickname(); IDs = verifyID(); IVs = verifyIVs(); EVs = verifyEVs(); Level = verifyLevel(); SecondaryChecked = true; }
private void updateChecks() { Encounter = verifyEncounter(); EncounterType = EncounterMatch?.GetType(); ECPID = verifyECPID(); Nickname = verifyNickname(); IDs = verifyID(); IVs = verifyIVs(); EVs = verifyEVs(); Level = verifyLevel(); Ribbons = verifyRibbons(); Ability = verifyAbility(); Ball = verifyBall(); HandlerMemories = verifyHandlerMemories(); Form = verifyForm(); SecondaryChecked = true; }
private void updateChecks() { Encounter = verifyEncounter(); EncounterType = EncounterMatch?.GetType(); ECPID = verifyECPID(); Nickname = verifyNickname(); IDs = verifyID(); IVs = verifyIVs(); EVs = verifyEVs(); Level = verifyLevel(); Ribbons = verifyRibbons(); Ability = verifyAbility(); Ball = verifyBall(); History = verifyHistory(); OTMemory = verifyOTMemory(); HTMemory = verifyHTMemory(); Region = verifyRegion(); Form = verifyForm(); Misc = verifyMisc(); Gender = verifyGender(); SecondaryChecked = true; }
private LegalityCheck[] verifyRelearn() { LegalityCheck[] res = new LegalityCheck[4]; MatchedWC6 = null; // Reset int[] Moves = pk6.RelearnMoves; if (!pk6.Gen6) { goto noRelearn; } if (pk6.WasLink) { int[] moves = Legal.getLinkMoves(pk6); for (int i = 0; i < 4; i++) { res[i] = moves[i] != Moves[i] ? new LegalityCheck(Severity.Invalid, $"Expected ID:{moves[i]}.") : new LegalityCheck(); } return(res); } if (pk6.WasEvent || pk6.WasEventEgg) { // Get WC6's that match IEnumerable <WC6> vwc6 = Legal.getValidWC6s(pk6); foreach (var wc in vwc6) { int[] moves = wc.RelearnMoves; for (int i = 0; i < 4; i++) { res[i] = moves[i] != Moves[i] ? new LegalityCheck(Severity.Invalid, $"Expected ID:{moves[i]}.") : new LegalityCheck(Severity.Valid, $"Matched WC #{wc.CardID.ToString("0000")}"); } if (res.All(r => r.Valid)) { MatchedWC6 = wc; return(res); } } goto noRelearn; // No WC match } if (pk6.WasEgg) { const int games = 2; bool checkAllGames = pk6.WasTradedEgg; bool splitBreed = Legal.SplitBreed.Contains(pk6.Species); int iterate = (checkAllGames ? games : 1) * (splitBreed ? 2 : 1); for (int i = 0; i < iterate; i++) { int gameSource = !checkAllGames ? -1 : i % iterate / (splitBreed ? 2 : 1); int skipOption = splitBreed && iterate / 2 <= i ? 1 : 0; // Obtain level1 moves List <int> baseMoves = new List <int>(Legal.getBaseEggMoves(pk6, skipOption, gameSource)); int baseCt = baseMoves.Count; if (baseCt > 4) { baseCt = 4; } // Obtain Nonstandard moves var relearnMoves = Legal.getValidRelearn(pk6, skipOption).ToArray(); var relearn = pk6.RelearnMoves.Where(move => move != 0 && (!baseMoves.Contains(move) || relearnMoves.Contains(move)) ).ToArray(); int relearnCt = relearn.Length; // Get Move Window List <int> window = new List <int>(baseMoves); window.AddRange(relearn); int[] moves = window.Skip(baseCt + relearnCt - 4).Take(4).ToArray(); Array.Resize(ref moves, 4); int req; if (relearnCt == 4) { req = 0; } else if (baseCt + relearnCt > 4) { req = 4 - relearnCt; } else { req = baseCt; } // Movepool finalized! Check validity. int[] rl = pk6.RelearnMoves; string em = string.Join(", ", baseMoves); // Base Egg Move for (int j = 0; j < req; j++) { res[j] = !baseMoves.Contains(rl[j]) ? new LegalityCheck(Severity.Invalid, $"Base egg move missing; expected one of: {em}.") : new LegalityCheck(Severity.Valid, "Base egg move."); } // Non-Base if (Legal.LightBall.Contains(pk6.Species)) { relearnMoves = relearnMoves.Concat(new[] { 344 }).ToArray(); } for (int j = req; j < 4; j++) { res[j] = !relearnMoves.Contains(rl[j]) ? new LegalityCheck(Severity.Invalid, "Not an expected relearn move.") : new LegalityCheck(Severity.Valid, "Relearn move."); } if (res.All(r => r.Valid)) { break; } } return(res); } if (Moves[0] != 0) // DexNav only? { // Check DexNav if (!Legal.getDexNavValid(pk6)) { goto noRelearn; } res[0] = !Legal.getValidRelearn(pk6, 0).Contains(Moves[0]) ? new LegalityCheck(Severity.Invalid, "Not an expected DexNav move.") : new LegalityCheck(); for (int i = 1; i < 4; i++) { res[i] = Moves[i] != 0 ? new LegalityCheck(Severity.Invalid, "Expected no Relearn Move in slot.") : new LegalityCheck(); } return(res); } // Should have no relearn moves. noRelearn: for (int i = 0; i < 4; i++) { res[i] = Moves[i] != 0 ? new LegalityCheck(Severity.Invalid, "Expected no Relearn Moves.") : new LegalityCheck(); } return(res); }
private LegalityCheck[] verifyMoves() { int[] Moves = pk6.Moves; LegalityCheck[] res = new LegalityCheck[4]; for (int i = 0; i < 4; i++) { res[i] = new LegalityCheck(); } if (!pk6.Gen6) { return(res); } var validMoves = Legal.getValidMoves(pk6).ToArray(); if (pk6.Species == 235) { for (int i = 0; i < 4; i++) { res[i] = Legal.InvalidSketch.Contains(Moves[i]) ? new LegalityCheck(Severity.Invalid, "Invalid Sketch move.") : new LegalityCheck(); } } else { int[] RelearnMoves = pk6.RelearnMoves; int[] WC6Moves = MatchedWC6?.Moves ?? new int[0]; for (int i = 0; i < 4; i++) { if (Moves[i] == Legal.Struggle) { res[i] = new LegalityCheck(Severity.Invalid, "Invalid Move: Struggle."); } else if (validMoves.Contains(Moves[i])) { res[i] = new LegalityCheck(Severity.Valid, "Level-up."); } else if (RelearnMoves.Contains(Moves[i])) { res[i] = new LegalityCheck(Severity.Valid, "Relearn Move."); } else if (WC6Moves.Contains(Moves[i])) { res[i] = new LegalityCheck(Severity.Valid, "Wondercard Non-Relearn Move."); } else { res[i] = new LegalityCheck(Severity.Invalid, "Invalid Move."); } } } if (Moves[0] == 0) { res[0] = new LegalityCheck(Severity.Invalid, "Invalid Move."); } if (pk6.Species == 647) // Keldeo { if (pk6.AltForm == 1 ^ pk6.Moves.Contains(548)) { res[0] = new LegalityCheck(Severity.Invalid, "Secret Sword / Resolute Keldeo Mismatch."); } } // Duplicate Moves Check for (int i = 0; i < 4; i++) { if (Moves.Count(m => m != 0 && m == Moves[i]) > 1) { res[i] = new LegalityCheck(Severity.Invalid, "Duplicate Move."); } } return(res); }
private LegalityCheck[] verifyRelearn() { RelearnBase = null; LegalityCheck[] res = new LegalityCheck[4]; int[] Moves = pk6.RelearnMoves; if (!pk6.Gen6) { goto noRelearn; } if (pk6.WasLink) { var Link = Legal.getValidLinkGifts(pk6); if (Link == null) { for (int i = 0; i < 4; i++) { res[i] = new LegalityCheck(); } return(res); } EncounterMatch = Link; int[] moves = ((EncounterLink)EncounterMatch).RelearnMoves; RelearnBase = moves; for (int i = 0; i < 4; i++) { res[i] = moves[i] != Moves[i] ? new LegalityCheck(Severity.Invalid, $"Expected: {movelist[moves[i]]}.") : new LegalityCheck(); } return(res); } if (pk6.WasEvent || pk6.WasEventEgg) { // Get WC6's that match CardMatch = new List <WC6>(Legal.getValidWC6s(pk6)); foreach (var wc in CardMatch) { int[] moves = wc.RelearnMoves; for (int i = 0; i < 4; i++) { res[i] = moves[i] != Moves[i] ? new LegalityCheck(Severity.Invalid, $"Expected ID: {movelist[moves[i]]}.") : new LegalityCheck(Severity.Valid, $"Matched WC #{wc.CardID.ToString("0000")}"); } if (res.Any(r => !r.Valid)) { CardMatch.Remove(wc); } } if (CardMatch.Count > 1) { return(res); } if (CardMatch.Count == 1) { EncounterMatch = CardMatch[0]; RelearnBase = CardMatch[0].RelearnMoves; return(res); } EncounterMatch = EncounterType = null; goto noRelearn; // No WC match } if (pk6.WasEgg) { const int games = 2; bool checkAllGames = pk6.WasTradedEgg; bool splitBreed = Legal.SplitBreed.Contains(pk6.Species); int iterate = (checkAllGames ? games : 1) * (splitBreed ? 2 : 1); for (int i = 0; i < iterate; i++) { int gameSource = !checkAllGames ? -1 : i % iterate / (splitBreed ? 2 : 1); int skipOption = splitBreed && iterate / 2 <= i ? 1 : 0; // Obtain level1 moves List <int> baseMoves = new List <int>(Legal.getBaseEggMoves(pk6, skipOption, gameSource)); int baseCt = baseMoves.Count; if (baseCt > 4) { baseCt = 4; } // Obtain Nonstandard moves var relearnMoves = Legal.getValidRelearn(pk6, skipOption).ToArray(); var relearn = pk6.RelearnMoves.Where(move => move != 0 && (!baseMoves.Contains(move) || relearnMoves.Contains(move)) ).ToArray(); int relearnCt = relearn.Length; // Get Move Window List <int> window = new List <int>(baseMoves); window.AddRange(relearn); int[] moves = window.Skip(baseCt + relearnCt - 4).Take(4).ToArray(); Array.Resize(ref moves, 4); int req; if (relearnCt == 4) { req = 0; } else if (baseCt + relearnCt > 4) { req = 4 - relearnCt; } else { req = baseCt; } // Movepool finalized! Check validity. int[] rl = pk6.RelearnMoves; string em = string.Join(", ", baseMoves.Select(r => r >= movelist.Length ? "ERROR" : movelist[r])); RelearnBase = baseMoves.ToArray(); // Base Egg Move for (int j = 0; j < req; j++) { if (baseMoves.Contains(rl[j])) { res[j] = new LegalityCheck(Severity.Valid, "Base egg move."); } else { res[j] = new LegalityCheck(Severity.Invalid, "Base egg move missing."); for (int f = j + 1; f < req; f++) { res[f] = new LegalityCheck(Severity.Invalid, "Base egg move missing."); } res[req - 1].Comment += $"{Environment.NewLine}Expected the following Relearn Moves: {em}."; break; } } // Non-Base if (Legal.LightBall.Contains(pk6.Species)) { relearnMoves = relearnMoves.Concat(new[] { 344 }).ToArray(); } for (int j = req; j < 4; j++) { res[j] = !relearnMoves.Contains(rl[j]) ? new LegalityCheck(Severity.Invalid, "Not an expected relearn move.") : new LegalityCheck(Severity.Valid, rl[j] == 0 ? "Empty" : "Relearn move."); } if (res.All(r => r.Valid)) { break; } } return(res); } if (Moves[0] != 0) // DexNav only? { // Check DexNav if (!Legal.getDexNavValid(pk6)) { goto noRelearn; } res[0] = !Legal.getValidRelearn(pk6, 0).Contains(Moves[0]) ? new LegalityCheck(Severity.Invalid, "Not an expected DexNav move.") : new LegalityCheck(); for (int i = 1; i < 4; i++) { res[i] = Moves[i] != 0 ? new LegalityCheck(Severity.Invalid, "Expected no Relearn Move in slot.") : new LegalityCheck(); } if (res[0].Valid) { RelearnBase = new[] { Moves[0], 0, 0, 0 } } ; return(res); } // Should have no relearn moves. noRelearn: for (int i = 0; i < 4; i++) { res[i] = Moves[i] != 0 ? new LegalityCheck(Severity.Invalid, "Expected no Relearn Moves.") : new LegalityCheck(); } return(res); }
private LegalityCheck[] verifyMoves() { int[] Moves = pk6.Moves; LegalityCheck[] res = new LegalityCheck[4]; for (int i = 0; i < 4; i++) { res[i] = new LegalityCheck(); } if (!pk6.Gen6) { return(res); } var validMoves = Legal.getValidMoves(pk6).ToArray(); if (pk6.Species == 235) { for (int i = 0; i < 4; i++) { res[i] = Legal.InvalidSketch.Contains(Moves[i]) ? new LegalityCheck(Severity.Invalid, "Invalid Sketch move.") : new LegalityCheck(); } } else if (CardMatch?.Count > 1) // Multiple possible WC6 matched { int[] RelearnMoves = pk6.RelearnMoves; foreach (var wc in CardMatch) { for (int i = 0; i < 4; i++) { if (Moves[i] == Legal.Struggle) { res[i] = new LegalityCheck(Severity.Invalid, "Invalid Move: Struggle."); } else if (validMoves.Contains(Moves[i])) { res[i] = new LegalityCheck(Severity.Valid, Moves[i] == 0 ? "Empty" : "Level-up."); } else if (RelearnMoves.Contains(Moves[i])) { res[i] = new LegalityCheck(Severity.Valid, Moves[i] == 0 ? "Empty" : "Relearn Move.") { Flag = true } } ; else if (wc.Moves.Contains(Moves[i])) { res[i] = new LegalityCheck(Severity.Valid, "Wonder Card Non-Relearn Move."); } else { res[i] = new LegalityCheck(Severity.Invalid, "Invalid Move."); } } if (res.All(r => r.Valid)) // Card matched { EncounterMatch = wc; RelearnBase = wc.RelearnMoves; } } } else { int[] RelearnMoves = pk6.RelearnMoves; WC6 MatchedWC6 = EncounterMatch as WC6; int[] WC6Moves = MatchedWC6?.Moves ?? new int[0]; for (int i = 0; i < 4; i++) { if (Moves[i] == Legal.Struggle) { res[i] = new LegalityCheck(Severity.Invalid, "Invalid Move: Struggle."); } else if (validMoves.Contains(Moves[i])) { res[i] = new LegalityCheck(Severity.Valid, Moves[i] == 0 ? "Empty" : "Level-up."); } else if (RelearnMoves.Contains(Moves[i])) { res[i] = new LegalityCheck(Severity.Valid, Moves[i] == 0 ? "Empty" : "Relearn Move.") { Flag = true } } ; else if (WC6Moves.Contains(Moves[i])) { res[i] = new LegalityCheck(Severity.Valid, "Wonder Card Non-Relearn Move."); } else { res[i] = new LegalityCheck(Severity.Invalid, "Invalid Move."); } } } if (Moves[0] == 0) { res[0] = new LegalityCheck(Severity.Invalid, "Invalid Move."); } if (pk6.Species == 647) // Keldeo { if (pk6.AltForm == 1 ^ pk6.Moves.Contains(548)) { res[0] = new LegalityCheck(Severity.Invalid, "Secret Sword / Resolute Keldeo Mismatch."); } } // Duplicate Moves Check for (int i = 0; i < 4; i++) { if (Moves.Count(m => m != 0 && m == Moves[i]) > 1) { res[i] = new LegalityCheck(Severity.Invalid, "Duplicate Move."); } } return(res); }