From 8a75435dc036a7ac24bd19ce1a542a6b18a809ff Mon Sep 17 00:00:00 2001 From: Kurt Date: Mon, 2 Aug 2021 23:54:44 -0700 Subject: [PATCH] Add crossover from-to stub for anubis --- PKHeX.Core/Legality/Areas/EncounterArea8.cs | 33 ++++++++++++++++--- PKHeX.Core/Legality/Verifiers/MarkVerifier.cs | 4 +-- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/PKHeX.Core/Legality/Areas/EncounterArea8.cs b/PKHeX.Core/Legality/Areas/EncounterArea8.cs index 4b8ccc35a..88ada3069 100644 --- a/PKHeX.Core/Legality/Areas/EncounterArea8.cs +++ b/PKHeX.Core/Legality/Areas/EncounterArea8.cs @@ -41,15 +41,16 @@ public override bool IsMatchLocation(int location) public override IEnumerable GetMatchingSlots(PKM pkm, IReadOnlyList chain) { + var metLocation = pkm.Met_Location; // wild area gets boosted up to level 60 post-game var met = pkm.Met_Level; bool isBoosted = met == BoostLevel && IsBoostedArea60(Location); if (isBoosted) - return GetBoostedMatches(chain); - return GetUnboostedMatches(chain, met); + return GetBoostedMatches(chain, metLocation); + return GetUnboostedMatches(chain, met, metLocation); } - private IEnumerable GetUnboostedMatches(IReadOnlyList chain, int met) + private IEnumerable GetUnboostedMatches(IReadOnlyList chain, int metLevel, int metLocation) { foreach (var slot in Slots) { @@ -58,7 +59,7 @@ private IEnumerable GetUnboostedMatches(IReadOnlyList GetUnboostedMatches(IReadOnlyList GetBoostedMatches(IReadOnlyList chain) + private IEnumerable GetBoostedMatches(IReadOnlyList chain, int metLocation) { foreach (var slot in Slots) { @@ -89,12 +93,22 @@ private IEnumerable GetBoostedMatches(IReadOnlyList if (slot.Form != evo.Form && !FormInfo.WildChangeFormAfter.Contains(evo.Species)) break; + if (Location != metLocation && !CanCrossoverTo(Location, metLocation, slot.SlotType)) + break; + yield return slot; break; } } } + private static bool CanCrossoverTo(int fromLocation, int toLocation, AreaSlotType8 type) + { + if (!type.CanCrossover()) + return false; + return true; + } + public const int BoostLevel = 60; public static bool IsWildArea(int location) => IsWildArea8(location) || IsWildArea8Armor(location) || IsWildArea8Crown(location); @@ -328,6 +342,8 @@ private IEnumerable GetBoostedMatches(IReadOnlyList { 230, All_CT }, // Ballimere Lake from Giant's Bed }; + public static bool IsCrossoverBleedPossible(AreaSlotType8 type, int fromLocation, int toLocation) => true; + public static bool IsWeatherBleedPossible(AreaSlotType8 type, AreaWeather8 permit, int location) => type switch { SymbolMain or SymbolMain2 or SymbolMain3 => WeatherBleedSymbol .TryGetValue(location, out var weather) && weather.HasFlag(permit), @@ -454,4 +470,11 @@ public enum AreaSlotType8 : byte OnlyFishing, // more restricted hidden table that ignores the weather slots like grass Tentacool. Inaccessible, } + + public static class AreaSlotType8Extensions + { + public static bool CanCrossover(this AreaSlotType8 type) => type is SymbolMain or SymbolMain2 or SymbolMain3; + public static bool CanEncounterViaFishing(this AreaSlotType8 type, AreaWeather8 weather) => type is OnlyFishing || weather is Fishing; + public static bool CanEncounterViaCurry(this AreaSlotType8 type) => type is HiddenMain or HiddenMain2; + } } diff --git a/PKHeX.Core/Legality/Verifiers/MarkVerifier.cs b/PKHeX.Core/Legality/Verifiers/MarkVerifier.cs index 7d20eb4a9..8b8398b4f 100644 --- a/PKHeX.Core/Legality/Verifiers/MarkVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/MarkVerifier.cs @@ -118,7 +118,7 @@ private static bool IsSlotWeatherPermitted(AreaWeather8 permit, EncounterSlot8 s public static bool IsMarkAllowedCurry(PKM pkm, IEncounterTemplate enc) { // Curry are only encounter slots, from the hidden table (not symbol). Slots taken from area's current weather(?). - if (enc is not EncounterSlot8 {SlotType: AreaSlotType8.HiddenMain} s) + if (enc is not EncounterSlot8 s || !s.SlotType.CanEncounterViaCurry()) return false; var weather = s.Weather; @@ -137,7 +137,7 @@ public static bool IsMarkAllowedFishing(IEncounterTemplate enc) if (enc is not EncounterSlot8 s) return false; - return s.SlotType is AreaSlotType8.HiddenMain or AreaSlotType8.OnlyFishing; + return s.SlotType.CanEncounterViaFishing(s.Weather); } private void VerifyAffixedRibbonMark(LegalityAnalysis data, IRibbonIndex m)