mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-16 17:18:00 +00:00
858aa50689
exercise in deferred execution/state machine, only calculate possible
matches until a sufficiently valid match is obtained. Previous setup
would try to calculate the 'best match' and had band-aid workarounds in
cases where a subsequent check may determine it to be a false match.
There's still more ways to improve speed:
- precalculate relationships for Encounter Slots rather than iterating
over every area
- yielding individual slots instead of an entire area
- group non-egg wondercards by ID in a dict/hashtable for faster
retrieval
reworked some internals:
- EncounterMatch is always an IEncounterable instead of an object, for
easy pattern matching.
- Splitbreed checking is done per encounter and is stored in the
EncounterEgg result
- Encounter validation uses Encounter/Move/RelearnMove/Evolution to
whittle to the final encounter.
As a part of the encounter matching, a lazy peek is used to check if an
invalid encounter should be retained instead of discarded; if another
encounter has not been checked, it'll stop the invalid checks and move
on. If it is the last encounter, no other valid encounters exist so it
will keep the parse for the invalid encounter.
If no encounters are yielded, then there is no encountermatch. An
EncounterInvalid is created to store basic details, and the parse is
carried out.
Breaks some legality checking features for flagging invalid moves in
more detail, but those can be re-added in a separate check (if
splitbreed & any move invalid -> check for other split moves).
Should now be easier to follow the flow & maintain 😄
19 lines
567 B
C#
19 lines
567 B
C#
namespace PKHeX.Core
|
|
{
|
|
public class CheckResult
|
|
{
|
|
internal readonly Severity Judgement = Severity.Valid;
|
|
internal string Comment = LegalityCheckStrings.V;
|
|
public bool Valid => Judgement >= Severity.Fishy;
|
|
public bool Flag;
|
|
internal readonly CheckIdentifier Identifier;
|
|
|
|
internal CheckResult(CheckIdentifier i) { Identifier = i; }
|
|
internal CheckResult(Severity s, string c, CheckIdentifier i)
|
|
{
|
|
Judgement = s;
|
|
Comment = c;
|
|
Identifier = i;
|
|
}
|
|
}
|
|
}
|