private static CheckMoveResult[] ParseMovesRelearn(PKM pkm, int[] Moves, LegalInfo info) { var emptyegg = new int[0]; var e = info.EncounterMatch as EncounterEgg; var EggMoves = e != null?Legal.GetEggMoves(pkm, e.Species, pkm.AltForm) : emptyegg; var TradebackPreevo = pkm.Format == 2 && info.EncounterMatch.Species > 151 && pkm.InhabitedGeneration(1); var NonTradebackLvlMoves = TradebackPreevo ? Legal.GetExclusivePreEvolutionMoves(pkm, info.EncounterMatch.Species, info.EvoChainsAllGens[2], 2, e.Game).Where(m => m > Legal.MaxMoveID_1).ToArray() : new int[0]; int[] RelearnMoves = pkm.RelearnMoves; int[] SpecialMoves = GetSpecialMoves(info.EncounterMatch); CheckMoveResult[] res = ParseMoves(pkm, Moves, SpecialMoves, new int[0], EggMoves, NonTradebackLvlMoves, new int[0], new int[0], info); for (int i = 0; i < 4; i++) { if ((pkm.IsEgg || res[i].Flag) && !RelearnMoves.Contains(Moves[i])) { res[i] = new CheckMoveResult(res[i], Severity.Invalid, string.Format(V170, res[i].Comment), res[i].Identifier); } } return(res); }
public EggInfoSource(PKM pkm, IEnumerable <int> specialMoves, EncounterEgg e) { // Eggs with special moves cannot inherit levelup moves as the current moves are predefined. Special = specialMoves.Where(m => m != 0).ToList(); bool notSpecial = Special.Count == 0; AllowInherited = notSpecial && !pkm.WasGiftEgg && pkm.Species != 489 && pkm.Species != 490; // Level up moves can only be inherited if ditto is not the mother. bool AllowLevelUp = Legal.GetCanInheritMoves(pkm, e); Base = Legal.GetBaseEggMoves(pkm, e.Species, e.Version, e.Level); Egg = Legal.GetEggMoves(pkm, e.Species, pkm.AltForm, e.Version); LevelUp = AllowLevelUp ? Legal.GetBaseEggMoves(pkm, e.Species, e.Version, 100).Except(Base).ToList() : new List <int>(); Tutor = e.Version == GameVersion.C ? MoveTutor.GetTutorMoves(pkm, pkm.Species, pkm.AltForm, false, 2).ToList() : new List <int>(); // Only TM/HM moves from the source game of the egg, not any other games from the same generation TMHM = MoveTechnicalMachine.GetTMHM(pkm, pkm.Species, pkm.AltForm, pkm.GenNumber, e.Version).ToList(); // Non-Base moves that can magically appear in the regular movepool bool volt = notSpecial && (pkm.GenNumber > 3 || e.Version == GameVersion.E) && Legal.LightBall.Contains(pkm.Species); if (volt) { Egg.Add(344); // Volt Tackle } }
private static CheckMoveResult[] ParseMovesRelearn(PKM pkm, int[] Moves, LegalInfo info) { var source = new MoveParseSource { CurrentMoves = Moves, SpecialSource = GetSpecialMoves(info.EncounterMatch), }; if (info.EncounterMatch is EncounterEgg e) { source.EggMoveSource = Legal.GetEggMoves(pkm, e.Species, pkm.AltForm); } CheckMoveResult[] res = ParseMoves(pkm, source, info); int[] RelearnMoves = pkm.RelearnMoves; for (int i = 0; i < 4; i++) { if ((pkm.IsEgg || res[i].Flag) && !RelearnMoves.Contains(Moves[i])) { res[i] = new CheckMoveResult(res[i], Severity.Invalid, string.Format(V170, res[i].Comment), res[i].Identifier); } } return(res); }
private static CheckMoveResult[] ParseMovesWasEggPreRelearn(PKM pkm, int[] Moves, LegalInfo info, EncounterEgg e) { var EventEggMoves = GetSpecialMoves(info.EncounterMatch); // Level up moves could not be inherited if Ditto is parent, // that means genderless species and male only species except Nidoran and Volbeat (they breed with female nidoran and illumise) could not have level up moves as an egg var AllowLevelUp = pkm.PersonalInfo.Gender > 0 && pkm.PersonalInfo.Gender < 255 || Legal.MixedGenderBreeding.Contains(e.Species); int BaseLevel = AllowLevelUp ? 100 : e.LevelMin; var LevelUp = Legal.GetBaseEggMoves(pkm, e.Species, e.Game, BaseLevel); var TradebackPreevo = pkm.Format == 2 && info.EncounterMatch.Species > 151; var NonTradebackLvlMoves = new int[0]; if (TradebackPreevo) { NonTradebackLvlMoves = Legal.GetExclusivePreEvolutionMoves(pkm, info.EncounterMatch.Species, info.EvoChainsAllGens[2], 2, e.Game).Where(m => m > Legal.MaxMoveID_1).ToArray(); } var Egg = Legal.GetEggMoves(pkm, e.Species, pkm.AltForm); bool volt = (info.Generation > 3 || e.Game == GameVersion.E) && Legal.LightBall.Contains(pkm.Species); var Special = volt && EventEggMoves.Length == 0 ? new[] { 344 } : new int[0]; // Volt Tackle for bred Pichu line var source = new MoveParseSource { CurrentMoves = Moves, SpecialSource = Special, NonTradeBackLevelUpMoves = NonTradebackLvlMoves, EggLevelUpSource = LevelUp, EggMoveSource = Egg, EggEventSource = EventEggMoves, }; return(ParseMoves(pkm, source, info)); }
private static CheckMoveResult[] ParseMovesRelearn(PKM pkm, int[] Moves, LegalInfo info) { var source = new MoveParseSource { CurrentMoves = Moves, SpecialSource = GetSpecialMoves(info.EncounterMatch), }; if (info.EncounterMatch is EncounterEgg e) { source.EggMoveSource = Legal.GetEggMoves(pkm, e.Species, pkm.AltForm); bool TradebackPreevo = pkm.Format == 2 && info.EncounterMatch.Species > 151 && pkm.InhabitedGeneration(1); if (TradebackPreevo) { source.NonTradeBackLevelUpMoves = Legal.GetExclusivePreEvolutionMoves(pkm, info.EncounterMatch.Species, info.EvoChainsAllGens[2], 2, e.Game) .Where(m => m > Legal.MaxMoveID_1).ToArray(); } } CheckMoveResult[] res = ParseMoves(pkm, source, info); int[] RelearnMoves = pkm.RelearnMoves; for (int i = 0; i < 4; i++) { if ((pkm.IsEgg || res[i].Flag) && !RelearnMoves.Contains(Moves[i])) { res[i] = new CheckMoveResult(res[i], Severity.Invalid, string.Format(V170, res[i].Comment), res[i].Identifier); } } return(res); }
public EggInfoSource(PKM pkm, IEnumerable <int> specialMoves, EncounterEgg e) { // Eggs with special moves cannot inherit levelup moves as the current moves are predefined. Special = specialMoves.Where(m => m != 0).ToList(); bool notSpecial = Special.Count == 0; AllowInherited = notSpecial && !pkm.WasGiftEgg && pkm.Species != 489 && pkm.Species != 490; // Level up moves can only be inherited if ditto is not the mother. var ratio = pkm.PersonalInfo.Gender; // Genderless/Male Only (except a few) cannot inherit. bool AllowLevelUp = ratio > 0 && ratio < 255 || Legal.MixedGenderBreeding.Contains(e.Species); Base = Legal.GetBaseEggMoves(pkm, e.Species, e.Game, e.LevelMin).ToList(); Egg = Legal.GetEggMoves(pkm, e.Species, pkm.AltForm).ToList(); LevelUp = AllowLevelUp ? Legal.GetBaseEggMoves(pkm, e.Species, e.Game, 100).Where(x => !Base.Contains(x)).ToList() : new List <int>(); Tutor = e.Game == GameVersion.C ? Legal.GetTutorMoves(pkm, pkm.Species, pkm.AltForm, false, 2).ToList() : new List <int>(); // Only TM/HM moves from the source game of the egg, not any other games from the same generation TMHM = Legal.GetTMHM(pkm, pkm.Species, pkm.AltForm, pkm.GenNumber, e.Game, false).ToList(); // Non-Base moves that can magically appear in the regular movepool bool volt = notSpecial && (pkm.GenNumber > 3 || e.Game == GameVersion.E) && Legal.LightBall.Contains(pkm.Species); if (volt) { Egg.Add(344); // Volt Tackle } }
private int[] GetCurrentEggMoves(PKM pk) { var moves = Legal.GetEggMoves(pk, Species, pk.AltForm, Version); if (moves.Length == 0) { moves = Legal.GetEncounterMoves(pk, Level, Version); } else if (moves.Length < 4 && pk.Format >= 6) { // Sprinkle in some default level up moves var lvl = Legal.GetBaseEggMoves(pk, Species, Version, Level); moves = lvl.Concat(moves).ToArray(); } return(moves); }
/// <summary> /// Gets possible encounters that allow all moves requested to be learned. /// </summary> /// <param name="pk">Rough Pokémon data which contains the requested species, gender, and form.</param> /// <param name="needs">Moves which cannot be taught by the player.</param> /// <param name="version">Specific version to iterate for. Necessary for retrieving possible Egg Moves.</param> /// <returns>A consumable <see cref="IEncounterable"/> list of possible encounters.</returns> private static IEnumerable <EncounterEgg> GetEggs(PKM pk, IReadOnlyCollection <int> needs, GameVersion version) { var eggs = EncounterEggGenerator.GenerateEggs(pk, all: true); foreach (var egg in eggs) { if (needs.Count == 0) { yield return(egg); continue; } var em = Legal.GetEggMoves(pk, egg.Species, pk.AltForm, version); if (!needs.Except(em).Any()) { yield return(egg); } } }
private static CheckMoveResult[] ParseMovesIsEggPreRelearn(PKM pkm, int[] Moves, int[] SpecialMoves, bool allowinherited, EncounterEgg e) { CheckMoveResult[] res = new CheckMoveResult[4]; var baseEggMoves = Legal.GetBaseEggMoves(pkm, e.Species, e.Game, pkm.GenNumber < 4 ? 5 : 1)?.ToList() ?? new List <int>(); // Level up moves cannot be inherited if Ditto is parent, thus genderless/single gender species cannot have level up moves as an egg bool AllowLvlMoves = pkm.PersonalInfo.Gender > 0 && pkm.PersonalInfo.Gender < 255 || Legal.MixedGenderBreeding.Contains(e.Species); var InheritedLvlMoves = !AllowLvlMoves? new List <int>() : Legal.GetBaseEggMoves(pkm, e.Species, e.Game, 100)?.ToList() ?? new List <int>(); InheritedLvlMoves.RemoveAll(x => baseEggMoves.Contains(x)); var infoset = new MoveInfoSet { EggMoves = Legal.GetEggMoves(pkm, e.Species, pkm.AltForm)?.ToList() ?? new List <int>(), TutorMoves = e.Game == GameVersion.C ? Legal.GetTutorMoves(pkm, pkm.Species, pkm.AltForm, false, 2)?.ToList() : new List <int>(), TMHMMoves = Legal.GetTMHM(pkm, pkm.Species, pkm.AltForm, pkm.GenNumber, e.Game, false)?.ToList(), LvlMoves = InheritedLvlMoves, BaseMoves = baseEggMoves, SpecialMoves = SpecialMoves.Where(m => m != 0).ToList(), AllowInherited = allowinherited }; // Only TM Hm moves from the source game of the egg, not any other games from the same generation if (pkm.Format > 2 || SpecialMoves.Any()) { // For gen 2 is not possible to difference normal eggs from event eggs // If there is no special moves assume normal egg res = VerifyPreRelearnEggBase(pkm, Moves, infoset, e.Game); } else if (pkm.Format == 2) { infoset.SpecialMoves.Clear(); infoset.AllowInherited = true; res = VerifyPreRelearnEggBase(pkm, Moves, infoset, e.Game); } return(res); }
private static CheckMoveResult[] ParseMovesWasEggPreRelearn(PKM pkm, int[] Moves, LegalInfo info, EncounterEgg e) { var EventEggMoves = (info.EncounterMatch as IMoveset)?.Moves ?? new int[0]; // Level up moves could not be inherited if Ditto is parent, // that means genderless species and male only species except Nidoran and Volbet (they breed with female nidoran and illumise) could not have level up moves as an egg var inheritLvlMoves = pkm.PersonalInfo.Gender > 0 && pkm.PersonalInfo.Gender < 255 || Legal.MixedGenderBreeding.Contains(e.Species); int BaseLvlMoves = inheritLvlMoves ? 100 : pkm.GenNumber <= 3 ? 5 : 1; var LvlupEggMoves = Legal.GetBaseEggMoves(pkm, e.Species, e.Game, BaseLvlMoves); var TradebackPreevo = pkm.Format == 2 && info.EncounterMatch.Species > 151; var NonTradebackLvlMoves = new int[0]; if (TradebackPreevo) { NonTradebackLvlMoves = Legal.GetExclusivePreEvolutionMoves(pkm, info.EncounterMatch.Species, info.EvoChainsAllGens[2], 2, e.Game).Where(m => m > Legal.MaxMoveID_1).ToArray(); } var EggMoves = Legal.GetEggMoves(pkm, e.Species, pkm.AltForm); bool volt = (pkm.GenNumber > 3 || e.Game == GameVersion.E) && Legal.LightBall.Contains(pkm.Species); var SpecialMoves = volt && EventEggMoves.Length == 0 ? new[] { 344 } : new int[0]; // Volt Tackle for bred Pichu line return(ParseMoves(pkm, Moves, SpecialMoves, LvlupEggMoves, EggMoves, NonTradebackLvlMoves, EventEggMoves, new int[0], info)); }
/// <summary> /// Gets possible encounters that allow all moves requested to be learned. /// </summary> /// <param name="pk">Rough Pokémon data which contains the requested species, gender, and form.</param> /// <param name="needs">Moves which cannot be taught by the player.</param> /// <param name="version">Specific version to iterate for. Necessary for retrieving possible Egg Moves.</param> /// <returns>A consumable <see cref="IEncounterable"/> list of possible encounters.</returns> private static IEnumerable <EncounterEgg> GetEggs(PKM pk, IReadOnlyCollection <int> needs, GameVersion version) { var eggs = EncounterEggGenerator.GenerateEggs(pk, all: true); foreach (var egg in eggs) { if (needs.Count == 0) { yield return(egg); continue; } IEnumerable <int> em = Legal.GetEggMoves(pk, egg.Species, pk.AltForm, version); if (Legal.LightBall.Contains(egg.Species) && needs.Contains(344)) { em = em.Concat(new[] { 344 }); // Volt Tackle } if (!needs.Except(em).Any()) { yield return(egg); } } }
public PKM ConvertToPKM(ITrainerInfo SAV) { int gen = Math.Max(2, Version.GetGeneration()); var pk = PKMConverter.GetBlank(gen); SAV.ApplyToPKM(pk); pk.Species = Species; pk.Nickname = PKX.GetSpeciesNameGeneration(Species, SAV.Language, gen); pk.CurrentLevel = Level; pk.Version = (int)Version; var moves = Legal.GetEggMoves(pk, Species, pk.AltForm, Version); if (moves.Length == 0) { moves = Legal.GetEncounterMoves(pk, Level, Version); } pk.Moves = moves; pk.SetMaximumPPCurrent(moves); pk.OT_Friendship = pk.PersonalInfo.BaseFriendship; pk.SetRandomIVs(flawless: 3); if (pk.Format <= 2 && Version != GameVersion.C) { return(pk); } pk.Met_Level = EncounterSuggestion.GetSuggestedEncounterEggMetLevel(pk); pk.Met_Location = Math.Max(0, EncounterSuggestion.GetSuggestedEggMetLocation(pk)); if (pk.Format < 3) { return(pk); } pk.Ball = 4; int gender = Util.Rand.Next(2); int nature = Util.Rand.Next(25); gender = pk.GetSaneGender(gender); if (pk.Format <= 5) { pk.SetPIDGender(gender); pk.SetPIDNature(nature); pk.RefreshAbility(pk.PIDAbility); } else { pk.PID = Util.Rand32(); pk.Nature = nature; pk.Gender = gender; pk.RefreshAbility(Util.Rand.Next(2)); } bool traded = (int)Version == SAV.Game; var today = pk.MetDate = DateTime.Today; if (pk.GenNumber >= 4) { pk.Egg_Location = EncounterSuggestion.GetSuggestedEncounterEggLocationEgg(pk, traded); pk.EggMetDate = today; } if (pk.Format < 6) { return(pk); } if (pk.Gen6) { pk.SetHatchMemory6(); } pk.SetRandomEC(); pk.RelearnMoves = moves; return(pk); }