diff --git a/PKHeX.Core/Game/GameUtil.cs b/PKHeX.Core/Game/GameUtil.cs index 99eacd6ff..02933cccd 100644 --- a/PKHeX.Core/Game/GameUtil.cs +++ b/PKHeX.Core/Game/GameUtil.cs @@ -129,6 +129,7 @@ namespace PKHeX.Core if (Gen5.Contains(game)) return 5; if (Gen6.Contains(game)) return 6; if (Gen7.Contains(game)) return 7; + if (Gen7b.Contains(game)) return 7; if (Gen8.Contains(game)) return 8; return -1; } diff --git a/PKHeX.Core/Legality/Areas/EncounterArea8g.cs b/PKHeX.Core/Legality/Areas/EncounterArea8g.cs index 56bee0550..5ce81bac9 100644 --- a/PKHeX.Core/Legality/Areas/EncounterArea8g.cs +++ b/PKHeX.Core/Legality/Areas/EncounterArea8g.cs @@ -91,7 +91,8 @@ namespace PKHeX.Core if (pkm.TSV == 0) // HOME doesn't assign TSV=0 to accounts. yield break; - var sf = chain.FirstOrDefault(z => z.Species == Species && z.Form == Form); + var sf = chain.FirstOrDefault(z => z.Species == Species + && (z.Form == Form || AltFormInfo.IsFormChangeable(Species, Form, z.Form, pkm.Format))); if (sf == null) yield break; diff --git a/PKHeX.Core/Legality/Encounters/EncounterSlot/GO/EncounterSlot7GO.cs b/PKHeX.Core/Legality/Encounters/EncounterSlot/GO/EncounterSlot7GO.cs index 9d0fc9ae9..bad1b1bb5 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot/GO/EncounterSlot7GO.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot/GO/EncounterSlot7GO.cs @@ -22,5 +22,12 @@ namespace PKHeX.Core pb.HeightScalar = PokeSizeUtil.GetRandomScalar(); pb.WeightScalar = PokeSizeUtil.GetRandomScalar(); } + + protected override void SetEncounterMoves(PKM pk, GameVersion version, int level) + { + var moves = MoveLevelUp.GetEncounterMoves(pk, level, GameVersion.GG); + pk.SetMoves(moves); + pk.SetMaximumPPCurrent(moves); + } } } diff --git a/PKHeX.Core/Legality/Encounters/EncounterSlot/GO/EncounterSlot8GO.cs b/PKHeX.Core/Legality/Encounters/EncounterSlot/GO/EncounterSlot8GO.cs index e6b753458..3edeeb8af 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot/GO/EncounterSlot8GO.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot/GO/EncounterSlot8GO.cs @@ -35,5 +35,12 @@ namespace PKHeX.Core pk8.HeightScalar = PokeSizeUtil.GetRandomScalar(); pk8.WeightScalar = PokeSizeUtil.GetRandomScalar(); } + + protected override void SetEncounterMoves(PKM pk, GameVersion version, int level) + { + var moves = MoveLevelUp.GetEncounterMoves(pk, level, OriginGroup); + pk.SetMoves(moves); + pk.SetMaximumPPCurrent(moves); + } } } diff --git a/PKHeX.Core/Legality/Encounters/EncounterSlot/GO/EncounterSlotGO.cs b/PKHeX.Core/Legality/Encounters/EncounterSlot/GO/EncounterSlotGO.cs index 8415ab6f5..d2b130382 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot/GO/EncounterSlotGO.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot/GO/EncounterSlotGO.cs @@ -79,9 +79,12 @@ namespace PKHeX.Core if (Start == 0) return End == 0 ? DateTime.Now : GetDate(End); - var end = Math.Max(Start, End); - var delta = end - Start; - var bias = Util.Rand.Next(0, delta + 1); + var start = GetDate(Start); + if (End == 0) + return start; + var end = GetDate(End); + var delta = end - start; + var bias = Util.Rand.Next(0, delta.Days + 1); return GetDate(Start).AddDays(bias); } diff --git a/PKHeX.Core/Legality/Encounters/Generator/EncounterMovesetGenerator.cs b/PKHeX.Core/Legality/Encounters/Generator/EncounterMovesetGenerator.cs index dfa08c184..27f62df55 100644 --- a/PKHeX.Core/Legality/Encounters/Generator/EncounterMovesetGenerator.cs +++ b/PKHeX.Core/Legality/Encounters/Generator/EncounterMovesetGenerator.cs @@ -152,9 +152,14 @@ namespace PKHeX.Core if (pk.Species == (int)Species.Smeargle) return moves.Intersect(Legal.InvalidSketch).ToArray(); // Can learn anything - var gens = VerifyCurrentMoves.GetGenMovesCheckOrder(pk); + // Roughly determine the generation the PKM is originating from + int origin = pk.GenNumber; + if (origin < 0) + origin = ((GameVersion)pk.Version).GetGeneration(); + + var gens = VerifyCurrentMoves.GetGenMovesCheckOrder(pk, origin); var canlearn = gens.SelectMany(z => GetMovesForGeneration(pk, chain, z)); - return moves.Except(canlearn).ToArray(); + return moves.Except(canlearn).Where(z => z != 0).ToArray(); } private static IEnumerable GetMovesForGeneration(PKM pk, IReadOnlyList chain, int generation) @@ -367,21 +372,16 @@ namespace PKHeX.Core { switch (enc.Generation) { - case 4 when enc is EncounterStaticTyped t && enc.Location == 193: - if (t.TypeEncounter == EncounterType.Surfing_Fishing) // Johto Route 45 surfing encounter. Unreachable Water tiles. - return true; // only hits for Roamer Raikou - break; + case 4 when enc is EncounterStaticTyped t && pk.Met_Location == 193: // Johto Route 45 surfing encounter. Unreachable Water tiles. + return t.TypeEncounter == EncounterType.Surfing_Fishing; // Roamer Raikou case 4: - switch (pk.Species) + return enc.Species switch { - case (int)Species.Darkrai when enc.Location == 079 && !pk.Pt: // DP Darkrai - return true; - case (int)Species.Shaymin when enc.Location == 063 && !pk.Pt: // DP Shaymin - return true; - case (int)Species.Arceus when enc.Location == 086: // Azure Flute Arceus - return true; - } - break; + (int)Species.Darkrai when enc.Location == 079 && enc.Version != GameVersion.Pt => true, // DP Darkrai + (int)Species.Shaymin when enc.Location == 063 && enc.Version != GameVersion.Pt => true, // DP Shaymin + (int)Species.Arceus when enc.Location == 086 => true, // Azure Flute Arceus + _ => false + }; } return false; diff --git a/PKHeX.Core/Legality/Encounters/Verifiers/EncounterVerifier.cs b/PKHeX.Core/Legality/Encounters/Verifiers/EncounterVerifier.cs index b0c68b3d2..61b619784 100644 --- a/PKHeX.Core/Legality/Encounters/Verifiers/EncounterVerifier.cs +++ b/PKHeX.Core/Legality/Encounters/Verifiers/EncounterVerifier.cs @@ -282,7 +282,7 @@ namespace PKHeX.Core case (int)Species.Arceus when s.Location == 086: // Azure Flute Arceus return new CheckResult(Severity.Invalid, LEncUnreleasedHoOArceus, CheckIdentifier.Encounter); } - if (s.Location == 193 && s is EncounterStaticTyped t && t.TypeEncounter == EncounterType.Surfing_Fishing) // Roaming pokemon surfing in Johto Route 45 + if (pkm.Met_Location == 193 && s is EncounterStaticTyped t && t.TypeEncounter == EncounterType.Surfing_Fishing) // Roaming pokemon surfing in Johto Route 45 return new CheckResult(Severity.Invalid, LG4InvalidTileR45Surf, CheckIdentifier.Encounter); break; case 7: diff --git a/PKHeX.Core/Legality/Encounters/Verifiers/VerifyCurrentMoves.cs b/PKHeX.Core/Legality/Encounters/Verifiers/VerifyCurrentMoves.cs index 997adbd05..7f4fa8f6a 100644 --- a/PKHeX.Core/Legality/Encounters/Verifiers/VerifyCurrentMoves.cs +++ b/PKHeX.Core/Legality/Encounters/Verifiers/VerifyCurrentMoves.cs @@ -268,7 +268,7 @@ namespace PKHeX.Core // Encapsulate arguments to simplify method calls var moveInfo = new LearnInfo(pkm, source); // Check moves going backwards, marking the move valid in the most current generation when it can be learned - int[] generations = GetGenMovesCheckOrder(pkm); + int[] generations = GetGenMovesCheckOrder(pkm, info.EncounterOriginal.Generation); if (pkm.Format <= 2) generations = generations.Where(z => z < info.EncounterMoves.LevelUpMoves.Length).ToArray(); if (reset != 0) @@ -887,14 +887,13 @@ namespace PKHeX.Core /// /// Gets the generation numbers in descending order for iterating over. /// - public static int[] GetGenMovesCheckOrder(PKM pkm) + public static int[] GetGenMovesCheckOrder(PKM pkm, int origin) { if (pkm.Format < 3) return GetGenMovesCheckOrderGB(pkm, pkm.Format); if (pkm.VC) return GetGenMovesOrderVC(pkm); - - return GetGenMovesOrder(pkm.Format, pkm.GenNumber); + return GetGenMovesOrder(pkm.Format, origin); } private static int[] GetGenMovesOrderVC(PKM pkm)