mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-27 06:20:25 +00:00
Pre-filter memory mismatch on moves
All over the place with prior commits; everything should be correct (and more robust) now.
This commit is contained in:
parent
31ddaf2bc4
commit
934628b077
5 changed files with 23 additions and 27 deletions
|
@ -8,9 +8,6 @@ namespace PKHeX.Core
|
|||
/// <summary> Matches most data, might have a better match later. </summary>
|
||||
Deferred,
|
||||
|
||||
/// <summary> Matches most data, might have a better match later. Less preferred than <see cref="Deferred"/> due to potentially small errors in secondary data. </summary>
|
||||
DeferredSecondary,
|
||||
|
||||
/// <summary> Matches most data, might have a better match later. Less preferred than <see cref="Deferred"/> due to small errors in secondary data. </summary>
|
||||
DeferredErrors,
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using static PKHeX.Core.Encounters8Nest;
|
||||
|
||||
namespace PKHeX.Core
|
||||
|
@ -61,11 +60,6 @@ namespace PKHeX.Core
|
|||
}
|
||||
}
|
||||
|
||||
if (pkm is IMemoryOT m && MemoryPermissions.IsMoveKnowMemory(m.OT_Memory) && !Moves.Contains(m.OT_TextVar))
|
||||
return EncounterMatchRating.DeferredSecondary;
|
||||
if (pkm is IMemoryHT h && MemoryPermissions.IsMoveKnowMemory(h.HT_Memory) && !Moves.Contains(h.HT_TextVar))
|
||||
return EncounterMatchRating.DeferredSecondary;
|
||||
|
||||
return base.IsMatchDeferred(pkm);
|
||||
}
|
||||
|
||||
|
|
|
@ -64,18 +64,14 @@ namespace PKHeX.Core
|
|||
}
|
||||
|
||||
// Static Encounters can collide with wild encounters (close match); don't break if a Static Encounter is yielded.
|
||||
var moveClash = new List<IEncounterable>(1);
|
||||
foreach (var z in GetValidStaticEncounter(pkm, chain))
|
||||
var encs = GetValidStaticEncounter(pkm, chain);
|
||||
foreach (var z in encs)
|
||||
{
|
||||
var match = z.GetMatchRating(pkm);
|
||||
if (match == Match)
|
||||
{
|
||||
yield return z;
|
||||
}
|
||||
else if (match == DeferredSecondary)
|
||||
{
|
||||
moveClash.Add(z);
|
||||
}
|
||||
else if (match < rating)
|
||||
{
|
||||
cache = z;
|
||||
|
@ -97,17 +93,6 @@ namespace PKHeX.Core
|
|||
}
|
||||
}
|
||||
|
||||
if (moveClash.Count != 0)
|
||||
{
|
||||
if (cache != null && rating < DeferredSecondary)
|
||||
yield return cache;
|
||||
|
||||
foreach (var e in moveClash)
|
||||
yield return e;
|
||||
|
||||
yield break;
|
||||
}
|
||||
|
||||
if (cache != null)
|
||||
yield return cache;
|
||||
}
|
||||
|
|
|
@ -103,10 +103,30 @@ namespace PKHeX.Core
|
|||
if (info.Moves.Any(z => !z.Valid) && iterator.PeekIsNext())
|
||||
return false;
|
||||
|
||||
if (info.Parse.Any(z => !z.Valid) && iterator.PeekIsNext())
|
||||
return false;
|
||||
|
||||
var evo = EvolutionVerifier.VerifyEvolution(pkm, info);
|
||||
if (!evo.Valid && iterator.PeekIsNext())
|
||||
return false;
|
||||
|
||||
// Memories of Knowing a move which is later forgotten can be problematic with encounters that have special moves.
|
||||
if (pkm is ITrainerMemories m)
|
||||
{
|
||||
if (m is IMemoryOT o && MemoryPermissions.IsMemoryOfKnownMove(o.OT_Memory))
|
||||
{
|
||||
var mem = MemoryVariableSet.Read(m, 0);
|
||||
if (!MemoryPermissions.CanKnowMove(pkm, mem, info.EncounterMatch.Generation, info))
|
||||
return false;
|
||||
}
|
||||
if (m is IMemoryHT h && MemoryPermissions.IsMemoryOfKnownMove(h.HT_Memory) && !pkm.HasMove(h.HT_TextVar))
|
||||
{
|
||||
var mem = MemoryVariableSet.Read(m, 1);
|
||||
if (!MemoryPermissions.CanKnowMove(pkm, mem, info.EncounterMatch.Generation, info))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
info.Parse.Add(evo);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace PKHeX.Core
|
|||
/// </summary>
|
||||
public static class MemoryPermissions
|
||||
{
|
||||
public static bool IsMoveKnowMemory(int memory) => memory is 16 or 48 or 80 or 81;
|
||||
public static bool IsMemoryOfKnownMove(int memory) => memory is 48 or 80 or 81;
|
||||
|
||||
public static bool CanWinRotoLoto(int generation, int item)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue