public static EggSource2[] Validate(int species, GameVersion version, int[] moves, out bool valid) { var count = Array.IndexOf(moves, 0); if (count == 0) { valid = false; // empty moveset return(Array.Empty <EggSource2>()); } if (count == -1) { count = moves.Length; } var learn = GameData.GetLearnsets(version); var table = GameData.GetPersonal(version); var learnset = learn[species]; var pi = table[species]; var egg = (version == GameVersion.C ? Legal.EggMovesC : Legal.EggMovesGS)[species].Moves; var value = new BreedInfo <EggSource2>(count, learnset, moves, level); { bool inherit = Breeding.GetCanInheritMoves(species); MarkMovesForOrigin(value, egg, count, inherit, pi, version); valid = RecurseMovesForOrigin(value, count - 1); } if (!valid) { CleanResult(value.Actual, value.Possible); } return(value.Actual); }
private static bool NoHatchFromEggFormGen(int species, int form, GameVersion game) { // Sanity check form for origin var gameInfo = GameData.GetPersonal(game); var entry = gameInfo.GetFormeEntry(species, form); return(form >= entry.FormeCount && !(species == (int)Species.Rotom && form <= 5)); }
private static int[] GetEncounterMoves2(int species, int level, GameVersion version) { var learn = GameData.GetLearnsets(version); var table = GameData.GetPersonal(version); var index = table.GetFormeIndex(species, 0); var lvl0 = learn[species].GetEncounterMoves(1); int start = Math.Max(0, Array.FindIndex(lvl0, z => z == 0)); return(learn[index].GetEncounterMoves(level, lvl0, start)); }
public static int[] GetEncounterMoves(int species, int form, int level, GameVersion version) { if (RBY.Contains(version)) { return(GetEncounterMoves1(species, level, version)); } if (GSC.Contains(version)) { return(GetEncounterMoves2(species, level, version)); } var learn = GameData.GetLearnsets(version); var table = GameData.GetPersonal(version); var index = table.GetFormeIndex(species, form); return(learn[index].GetEncounterMoves(level)); }
public static EggSource6[] Validate(int generation, int species, int form, GameVersion version, ReadOnlySpan <int> moves, out bool valid) { var count = moves.IndexOf(0); if (count == 0) { valid = false; // empty moveset return(Array.Empty <EggSource6>()); } if (count == -1) { count = moves.Length; } var learn = GameData.GetLearnsets(version); var table = GameData.GetPersonal(version); var index = table.GetFormIndex(species, form); var learnset = learn[index]; var egg = MoveEgg.GetEggMoves(generation, species, form, version); var actual = new EggSource6[count]; Span <byte> possible = stackalloc byte[count]; var value = new BreedInfo <EggSource6>(actual, possible, learnset, moves, level); if (species is (int)Species.Pichu && moves[count - 1] is (int)Move.VoltTackle) { actual[--count] = VoltTackle; } if (count == 0) { valid = VerifyBaseMoves(value); } else { bool inherit = Breeding.GetCanInheritMoves(species); MarkMovesForOrigin(value, egg, count, inherit); valid = RecurseMovesForOrigin(value, count - 1); } if (!valid) { CleanResult(actual, possible); } return(value.Actual); }
public static EggSource34[] Validate(int species, GameVersion version, int[] moves, out bool valid) { var count = Array.IndexOf(moves, 0); if (count == 0) { valid = false; // empty moveset return(Array.Empty <EggSource34>()); } if (count == -1) { count = moves.Length; } var learn = GameData.GetLearnsets(version); var table = GameData.GetPersonal(version); var learnset = learn[species]; var pi = table[species]; var egg = Legal.EggMovesRS[species].Moves; var value = new BreedInfo <EggSource34>(count, learnset, moves, level); if (species is (int)Species.Pichu && moves[count - 1] is (int)Move.VoltTackle && version == GameVersion.E) { value.Actual[--count] = VoltTackle; } if (count == 0) { valid = VerifyBaseMoves(value); } else { bool inherit = Breeding.GetCanInheritMoves(species); MarkMovesForOrigin(value, egg, count, inherit, pi); valid = RecurseMovesForOrigin(value, count - 1); } if (!valid) { CleanResult(value.Actual, value.Possible); } return(value.Actual); }
public static EggSource34[] Validate(int species, GameVersion version, ReadOnlySpan <int> moves, out bool valid) { var count = moves.IndexOf(0); if (count == 0) { valid = false; // empty moveset return(Array.Empty <EggSource34>()); } if (count == -1) { count = moves.Length; } var learn = GameData.GetLearnsets(version); var table = GameData.GetPersonal(version); var learnset = learn[species]; var pi = table[species]; var egg = (version is HG or SS ? Legal.EggMovesHGSS : Legal.EggMovesDPPt)[species].Moves;
public static EggSource6[] Validate(int generation, int species, int form, GameVersion version, int[] moves, out bool valid) { var count = Array.IndexOf(moves, 0); if (count == 0) { valid = false; // empty moveset return(Array.Empty <EggSource6>()); } if (count == -1) { count = moves.Length; } var learn = GameData.GetLearnsets(version); var table = GameData.GetPersonal(version); var index = table.GetFormIndex(species, form); var learnset = learn[index]; var egg = MoveEgg.GetEggMoves(generation, species, form, version); var value = new BreedInfo <EggSource6>(count, learnset, moves, 1); if (moves[count - 1] is (int)Move.VoltTackle) { if (--count == 0) { valid = false; // must have base moves; sanity check return(Array.Empty <EggSource6>()); } value.Actual[count] = VoltTackle; } bool inherit = Breeding.GetCanInheritMoves(species); MarkMovesForOrigin(value, egg, count, inherit); valid = RecurseMovesForOrigin(value, count - 1); return(value.Actual); }
public static EggSource5[] Validate(int species, GameVersion version, int[] moves, out bool valid) { var count = Array.IndexOf(moves, 0); if (count == 0) { valid = false; // empty moveset return(Array.Empty <EggSource5>()); } if (count == -1) { count = moves.Length; } var learn = GameData.GetLearnsets(version); var table = GameData.GetPersonal(version); var learnset = learn[species]; var pi = table[species]; var egg = Legal.EggMovesBW[species].Moves; var value = new BreedInfo <EggSource5>(count, learnset, moves, level); if (moves[count - 1] is (int)Move.VoltTackle) { if (--count == 0) { valid = false; // must have base moves; sanity check return(Array.Empty <EggSource5>()); } value.Actual[count] = VoltTackle; } bool inherit = Breeding.GetCanInheritMoves(species); MarkMovesForOrigin(value, egg, count, inherit, pi); valid = RecurseMovesForOrigin(value, count - 1); return(value.Actual); }
private CheckResult VerifyAbility(LegalityAnalysis data) { var pkm = data.pkm; var pi = data.PersonalInfo; // Check ability is possible (within bounds) int ability = pkm.Ability; int abilIndex = pi.GetAbilityIndex(ability); if (abilIndex < 0) { return(GetInvalid(LAbilityUnexpected)); } var abilities = pi.Abilities; int format = pkm.Format; if (format >= 6) { var num = pkm.AbilityNumber; if (!IsValidAbilityBits(num)) { return(INVALID); } // Check AbilityNumber points to ability int an = num >> 1; if (an >= abilities.Count || abilities[an] != ability) { return(INVALID); } // Check AbilityNumber for transfers without unique abilities int gen = data.Info.Generation; if (gen is 3 or 4 or 5 && num != 4) { // To determine AbilityNumber [PK5->PK6], check if the first ability in Personal matches the ability. // It is not possible to flip it to the other index as capsule requires unique abilities. if (abilities[0] == abilities[1] && num != 1) { // Check if any pre-evolution could have it flipped. var evos = data.Info.EvoChainsAllGens[6]; var pt = GameData.GetPersonal(GameUtil.GetVersion(format)); if (!GetWasDual(evos, pt, pkm)) { return(INVALID); } } } } if (format >= 8) // Ability Patch { if (pkm.AbilityNumber == 4 && !pkm.LA) { if (CanAbilityPatch(format, abilities, pkm.Species)) { return(GetValid(LAbilityPatchUsed)); } var e = data.EncounterOriginal; if (e.Species != pkm.Species && CanAbilityPatch(format, PKX.Personal.GetFormEntry(e.Species, e.Form).Abilities, e.Species)) { return(GetValid(LAbilityPatchUsed)); } // Verify later, it may be encountered with its hidden ability without using an ability patch. } } var enc = data.EncounterMatch; if (enc is MysteryGift { Generation : >= 4 } g) { return(VerifyAbilityMG(data, g, abilities)); } if (format < 6) { return(VerifyAbility345(data, enc, abilities, abilIndex)); } return(VerifyAbility(data, abilities, abilIndex)); }
private CheckResult VerifyAbility(LegalityAnalysis data) { var pkm = data.pkm; var pi = data.PersonalInfo; // Check ability is possible (within bounds) int ability = pkm.Ability; int abilval = pi.GetAbilityIndex(ability); if (abilval < 0) { return(GetInvalid(LAbilityUnexpected)); } var abilities = pi.Abilities; int format = pkm.Format; if (format >= 6) { // Check AbilityNumber is a single set bit var num = pkm.AbilityNumber; if (!(num != 0 && (num & (num - 1)) == 0)) // not [!zero, and power of 2] { return(GetInvalid(LAbilityMismatchFlag)); } // Check AbilityNumber points to ability int an = num >> 1; if (an >= abilities.Count || abilities[an] != ability) { return(GetInvalid(LAbilityMismatchFlag)); } // Check AbilityNumber for transfers without unique abilities int gen = data.Info.Generation; if (gen is 3 or 4 or 5 && num != 4) { // To determine AbilityNumber [PK5->PK6], check if the first ability in Personal matches the ability. // It is not possible to flip it to the other index as capsule requires unique abilities. if (abilities[0] == abilities[1] && num != 1) { // Check if any pre-evolution could have it flipped. var evos = data.Info.EvoChainsAllGens[6]; var pt = GameData.GetPersonal(GameUtil.GetVersion(pkm.Format)); if (!GetWasDual(evos, pt, pkm)) { return(GetInvalid(LAbilityMismatchFlag)); } } } } if (format >= 8) // Ability Patch { if (pkm.AbilityNumber == 4 && CanAbilityPatch(format, abilities, pkm.Species)) return(GetValid(LAbilityPatchUsed)); } var enc = data.EncounterMatch; if (enc is MysteryGift { Generation : >= 4 } g) { return(VerifyAbilityMG(data, g, abilities)); } if (format < 6) { return(VerifyAbility345(data, enc, abilities, abilval)); } return(VerifyAbility(data, abilities, abilval)); }