mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-10-02 00:48:49 -05:00
More descriptive version indication wc6/wc7
Skip yield if not matching version Handle defer/partial for gen7
This commit is contained in:
@@ -29,7 +29,7 @@ public IEnumerable<IEncounterable> GetPossible(PKM _, EvoCriteria[] chain, GameV
|
||||
yield return RangerManaphy;
|
||||
|
||||
var table = EncounterEvent.MGDB_G4;
|
||||
foreach (var enc in GetPossibleGifts(chain, table))
|
||||
foreach (var enc in GetPossibleGifts(chain, table, game))
|
||||
yield return enc;
|
||||
}
|
||||
if (groups.HasFlag(Egg))
|
||||
@@ -58,10 +58,12 @@ public IEnumerable<IEncounterable> GetPossible(PKM _, EvoCriteria[] chain, GameV
|
||||
}
|
||||
}
|
||||
|
||||
private static IEnumerable<IEncounterable> GetPossibleGifts(EvoCriteria[] chain, IReadOnlyList<PCD> table)
|
||||
private static IEnumerable<IEncounterable> GetPossibleGifts(EvoCriteria[] chain, IReadOnlyList<PCD> table, GameVersion game)
|
||||
{
|
||||
foreach (var enc in table)
|
||||
{
|
||||
if (!enc.CanBeReceivedByVersion((int)game))
|
||||
continue;
|
||||
foreach (var evo in chain)
|
||||
{
|
||||
if (evo.Species != enc.Species)
|
||||
|
||||
@@ -22,7 +22,7 @@ public IEnumerable<IEncounterable> GetPossible(PKM _, EvoCriteria[] chain, GameV
|
||||
if (groups.HasFlag(Mystery))
|
||||
{
|
||||
var table = EncounterEvent.MGDB_G5;
|
||||
foreach (var enc in GetPossibleGifts(chain, table))
|
||||
foreach (var enc in GetPossibleGifts(chain, table, game))
|
||||
yield return enc;
|
||||
}
|
||||
if (groups.HasFlag(Egg))
|
||||
@@ -51,10 +51,12 @@ public IEnumerable<IEncounterable> GetPossible(PKM _, EvoCriteria[] chain, GameV
|
||||
}
|
||||
}
|
||||
|
||||
private static IEnumerable<IEncounterable> GetPossibleGifts(EvoCriteria[] chain, IReadOnlyList<PGF> table)
|
||||
private static IEnumerable<IEncounterable> GetPossibleGifts(EvoCriteria[] chain, IReadOnlyList<PGF> table, GameVersion game)
|
||||
{
|
||||
foreach (var enc in table)
|
||||
{
|
||||
if (!enc.CanBeReceivedByVersion((int)game))
|
||||
continue;
|
||||
foreach (var evo in chain)
|
||||
{
|
||||
if (evo.Species != enc.Species)
|
||||
|
||||
@@ -16,7 +16,7 @@ public IEnumerable<IEncounterable> GetPossible(PKM pk, EvoCriteria[] chain, Game
|
||||
if (groups.HasFlag(Mystery))
|
||||
{
|
||||
var table = EncounterEvent.MGDB_G6;
|
||||
foreach (var enc in GetPossibleGifts(chain, table))
|
||||
foreach (var enc in GetPossibleGifts(chain, table, game))
|
||||
yield return enc;
|
||||
}
|
||||
if (groups.HasFlag(Egg))
|
||||
@@ -54,10 +54,12 @@ public IEnumerable<IEncounterable> GetPossible(PKM pk, EvoCriteria[] chain, Game
|
||||
}
|
||||
}
|
||||
|
||||
private static IEnumerable<IEncounterable> GetPossibleGifts(EvoCriteria[] chain, IReadOnlyList<WC6> table)
|
||||
private static IEnumerable<IEncounterable> GetPossibleGifts(EvoCriteria[] chain, IReadOnlyList<WC6> table, GameVersion game)
|
||||
{
|
||||
foreach (var enc in table)
|
||||
{
|
||||
if (!enc.CanBeReceivedByVersion((int)game))
|
||||
continue;
|
||||
foreach (var evo in chain)
|
||||
{
|
||||
if (evo.Species != enc.Species)
|
||||
@@ -146,28 +148,21 @@ public IEnumerable<IEncounterable> GetEncounters(PKM pk, EvoCriteria[] chain, Le
|
||||
bool yielded = false;
|
||||
if (pk.FatefulEncounter || pk.Met_Location == Locations.LinkGift6)
|
||||
{
|
||||
foreach (var mg in EncounterEvent.MGDB_G6)
|
||||
foreach (var z in EncounterEvent.MGDB_G6)
|
||||
{
|
||||
foreach (var evo in chain)
|
||||
{
|
||||
if (mg.Species != evo.Species)
|
||||
if (z.Species != evo.Species)
|
||||
continue;
|
||||
if (!mg.IsMatchExact(pk, evo))
|
||||
if (!z.IsMatchExact(pk, evo))
|
||||
break;
|
||||
|
||||
var match = mg.GetMatchRating(pk);
|
||||
if (match == Match)
|
||||
var match = z.GetMatchRating(pk);
|
||||
switch (match)
|
||||
{
|
||||
yield return mg;
|
||||
yielded = true;
|
||||
}
|
||||
else if (match == Deferred)
|
||||
{
|
||||
deferred ??= mg;
|
||||
}
|
||||
else if (match == PartialMatch)
|
||||
{
|
||||
partial ??= mg;
|
||||
case Match: yield return z; yielded = true; break;
|
||||
case Deferred: deferred ??= z; break;
|
||||
case PartialMatch: partial ??= z; break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ public IEnumerable<IEncounterable> GetPossible(PKM pk, EvoCriteria[] chain, Game
|
||||
if (groups.HasFlag(Mystery))
|
||||
{
|
||||
var table = EncounterEvent.MGDB_G7;
|
||||
foreach (var enc in GetPossibleGifts(chain, table))
|
||||
foreach (var enc in GetPossibleGifts(chain, table, game))
|
||||
yield return enc;
|
||||
}
|
||||
if (groups.HasFlag(Egg))
|
||||
@@ -45,10 +45,12 @@ public IEnumerable<IEncounterable> GetPossible(PKM pk, EvoCriteria[] chain, Game
|
||||
}
|
||||
}
|
||||
|
||||
private static IEnumerable<IEncounterable> GetPossibleGifts(EvoCriteria[] chain, IReadOnlyList<WC7> table)
|
||||
private static IEnumerable<IEncounterable> GetPossibleGifts(EvoCriteria[] chain, IReadOnlyList<WC7> table, GameVersion game)
|
||||
{
|
||||
foreach (var enc in table)
|
||||
{
|
||||
if (!enc.CanBeReceivedByVersion((int)game))
|
||||
continue;
|
||||
foreach (var evo in chain)
|
||||
{
|
||||
if (evo.Species != enc.Species)
|
||||
@@ -109,23 +111,44 @@ public IEnumerable<IEncounterable> GetEncounters(PKM pk, EvoCriteria[] chain, Le
|
||||
var game = (GameVersion)pk.Version;
|
||||
|
||||
bool yielded = false;
|
||||
IEncounterable? deferred = null;
|
||||
IEncounterable? partial = null;
|
||||
|
||||
if (pk.FatefulEncounter)
|
||||
{
|
||||
foreach (var mg in EncounterEvent.MGDB_G7)
|
||||
foreach (var z in EncounterEvent.MGDB_G7)
|
||||
{
|
||||
foreach (var evo in chain)
|
||||
{
|
||||
if (mg.Species != evo.Species)
|
||||
if (z.Species != evo.Species)
|
||||
continue;
|
||||
|
||||
if (mg.IsMatchExact(pk, evo))
|
||||
if (!z.IsMatchExact(pk, evo))
|
||||
break;
|
||||
|
||||
var match = z.GetMatchRating(pk);
|
||||
switch (match)
|
||||
{
|
||||
yield return mg;
|
||||
yielded = true;
|
||||
case Match: yield return z; yielded = true; break;
|
||||
case Deferred: deferred ??= z; break;
|
||||
case PartialMatch: partial ??= z; break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!yielded)
|
||||
{
|
||||
if (deferred != null)
|
||||
{
|
||||
yield return deferred;
|
||||
yielded = true;
|
||||
}
|
||||
if (partial != null)
|
||||
{
|
||||
yield return partial;
|
||||
yielded = true;
|
||||
}
|
||||
}
|
||||
if (yielded)
|
||||
yield break;
|
||||
}
|
||||
@@ -139,9 +162,6 @@ public IEnumerable<IEncounterable> GetEncounters(PKM pk, EvoCriteria[] chain, Le
|
||||
yield break;
|
||||
}
|
||||
|
||||
IEncounterable? deferred = null;
|
||||
IEncounterable? partial = null;
|
||||
|
||||
var table = GetStatic(game);
|
||||
foreach (var z in table)
|
||||
{
|
||||
|
||||
@@ -330,7 +330,7 @@ private static CheckResult VerifyEncounterEvent(PKM pk, MysteryGift gift)
|
||||
switch (gift)
|
||||
{
|
||||
case PCD pcd:
|
||||
if (!pcd.CanBeReceivedBy(pk.Version) && pcd.Gift.PK.Version == 0)
|
||||
if (!pcd.CanBeReceivedByVersion(pk.Version) && pcd.Gift.PK.Version == 0)
|
||||
return new CheckResult(Severity.Invalid, string.Format(L_XMatches0_1, gift.CardHeader, $"-- {LEncGiftVersionNotDistributed}"), CheckIdentifier.Encounter);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ public override PK4 ConvertToPKM(ITrainerInfo tr, EncounterCriteria criteria)
|
||||
return Gift.ConvertToPKM(tr, criteria);
|
||||
}
|
||||
|
||||
public bool CanBeReceivedBy(int pkmVersion) => ((CardCompatibility >> pkmVersion) & 1) == 1;
|
||||
public bool CanBeReceivedByVersion(int pkmVersion) => ((CardCompatibility >> pkmVersion) & 1) == 1;
|
||||
|
||||
public override bool IsMatchExact(PKM pk, EvoCriteria evo)
|
||||
{
|
||||
@@ -193,7 +193,7 @@ public override bool IsMatchExact(PKM pk, EvoCriteria evo)
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override bool IsMatchPartial(PKM pk) => CanBeReceivedBy(pk.Version);
|
||||
protected override bool IsMatchPartial(PKM pk) => !CanBeReceivedByVersion(pk.Version);
|
||||
protected override bool IsMatchDeferred(PKM pk) => Species != pk.Species;
|
||||
|
||||
public bool RibbonEarth { get => Gift.RibbonEarth; set => Gift.RibbonEarth = value; }
|
||||
|
||||
@@ -413,6 +413,7 @@ public override bool IsMatchExact(PKM pk, EvoCriteria evo)
|
||||
}
|
||||
|
||||
protected override bool IsMatchDeferred(PKM pk) => Species != pk.Species;
|
||||
protected override bool IsMatchPartial(PKM pk) => CanBeReceivedBy(pk.Version);
|
||||
private static bool CanBeReceivedBy(int _) => true;
|
||||
protected override bool IsMatchPartial(PKM pk) => !CanBeReceivedByVersion(pk.Version);
|
||||
|
||||
public bool CanBeReceivedByVersion(int game) => OriginGame == 0 || OriginGame == game;
|
||||
}
|
||||
|
||||
@@ -586,6 +586,21 @@ protected override bool IsMatchDeferred(PKM pk)
|
||||
return Species != pk.Species;
|
||||
}
|
||||
|
||||
public override GameVersion Version
|
||||
{
|
||||
get => RestrictVersion switch
|
||||
{
|
||||
1 => GameVersion.X,
|
||||
2 => GameVersion.Y,
|
||||
3 => GameVersion.XY,
|
||||
4 => GameVersion.AS,
|
||||
8 => GameVersion.OR,
|
||||
12 => GameVersion.ORAS,
|
||||
_ => GameVersion.Gen6,
|
||||
};
|
||||
set { }
|
||||
}
|
||||
|
||||
protected override bool IsMatchPartial(PKM pk)
|
||||
{
|
||||
if (RestrictLanguage != 0 && RestrictLanguage != pk.Language)
|
||||
|
||||
@@ -23,6 +23,8 @@ public bool CanBeReceivedByVersion(int v)
|
||||
{
|
||||
if (v is < (int)GameVersion.SN or > (int)GameVersion.UM)
|
||||
return false;
|
||||
if (CardID is 2046)
|
||||
return v is (int)GameVersion.SN or (int)GameVersion.MN;
|
||||
if (RestrictVersion == 0)
|
||||
return true; // no data
|
||||
var bitIndex = v - (int)GameVersion.SN;
|
||||
@@ -620,7 +622,21 @@ public override bool IsMatchExact(PKM pk, EvoCriteria evo)
|
||||
|
||||
public override GameVersion Version
|
||||
{
|
||||
get => CardID == 2046 ? GameVersion.SM : GameVersion.Gen7;
|
||||
get
|
||||
{
|
||||
if (CardID == 2046)
|
||||
return GameVersion.SM;
|
||||
return RestrictVersion switch
|
||||
{
|
||||
1 => GameVersion.SN,
|
||||
2 => GameVersion.MN,
|
||||
3 => GameVersion.SM,
|
||||
4 => GameVersion.US,
|
||||
8 => GameVersion.UM,
|
||||
12 => GameVersion.USUM,
|
||||
_ => GameVersion.Gen7,
|
||||
};
|
||||
}
|
||||
set { }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user