Add mysterygift version receivability check for PCD

Closes #1242
This commit is contained in:
Kurt 2017-06-17 23:09:00 -07:00
parent 7b2e3c59bf
commit a16aa827e4
7 changed files with 27 additions and 13 deletions

View file

@ -918,11 +918,10 @@ namespace PKHeX.Core
var wc = mg.Gift.PK;
if (pkm.Egg_Location == 0) // Not Egg
{
if (wc.SID != pkm.SID) continue;
if (wc.TID != pkm.TID) continue;
if (wc.SID != pkm.SID) continue;
if (wc.OT_Name != pkm.OT_Name) continue;
if (wc.OT_Gender != pkm.OT_Gender) continue;
if (wc.Version != 0 && wc.Version != pkm.Version) continue;
if (wc.Language != 0 && wc.Language != pkm.Language) continue;
}
if (wc.AltForm != pkm.AltForm && vs.All(dl => !IsFormChangeable(pkm, dl.Species))) continue;
@ -966,7 +965,8 @@ namespace PKHeX.Core
// if (wc.Level > pkm.CurrentLevel) continue; // Defer to level legality
// RIBBONS: Defer to ribbon legality
if (wc.Species == pkm.Species) // best match
bool receivable = mg.CanBeReceivedBy(pkm.Version);
if (wc.Species == pkm.Species && receivable) // best match
yield return mg;
else
validPCD.Add(mg);

View file

@ -258,6 +258,13 @@ namespace PKHeX.Core
}
private static CheckResult VerifyEncounterEvent(PKM pkm, MysteryGift MatchedGift)
{
switch (MatchedGift)
{
case PCD pcd:
if (!pcd.CanBeReceivedBy(pkm.Version))
return new CheckResult(Severity.Invalid, string.Format(V21, MatchedGift.CardHeader, "-- " + V416), CheckIdentifier.Encounter);
break;
}
// Strict matching already performed by EncounterGenerator. May be worth moving some checks here to better flag invalid gifts.
return new CheckResult(Severity.Valid, string.Format(V21, MatchedGift.CardHeader, ""), CheckIdentifier.Encounter);
}

View file

@ -374,7 +374,7 @@ namespace PKHeX.Core
public static string V365 {get; set;} = "Incompatible evolution moves. {0} Move learned at a lower level than other {1} moves.";
public static string V366 {get; set;} = "Incompatible evolution moves. {1} Move learned at a higher level than other {0} moves.";
public static string V367 {get; set;} = "Individual EV for a level 100 encounter in Generation 4 cannot be greater than 100.";
public static string V368 {get; set;} = "Eggs can not be infected with Pokérus."; // Invalid
public static string V368 {get; set;} = "Eggs cannot be infected with Pokérus."; // Invalid
public static string V369 {get; set;} = "Invalid E-Reader Berry.";
public static string V370 {get; set;} = "Japanese E-Reader Berry in international savegame.";
public static string V371 {get; set;} = "American E-Reader Berry in Japanese savegame.";
@ -407,8 +407,9 @@ namespace PKHeX.Core
public static string V410 {get; set;} = "Mystery Gift fixed PID mismatch.";
public static string V411 {get; set;} = "Encounter Type PID mismatch.";
public static string V412 {get; set;} = "Non-tradeback pre evolution move. Incompatible with Generation 1 exclusive moves.";
public static string V414 {get; set;} = "Eggs can not have Shiny Leaf/Crown."; // Invalid
public static string V415 {get; set;} = "Eggs can not have Pokéathlon stats."; // Invalid
public static string V414 {get; set;} = "Eggs cannot have Shiny Leaf/Crown."; // Invalid
public static string V415 {get; set;} = "Eggs cannot have Pokéathlon stats."; // Invalid
public static string V416 {get; set;} = "Mystery Gift cannot be received by this version."; // Invalid
#endregion
}

View file

@ -71,6 +71,7 @@ namespace PKHeX.Core
data.CopyTo(Data, 0x104);
}
}
public ushort CardCompatibility => BitConverter.ToUInt16(Data, 0x14C); // rest of bytes we don't really care about
public override int Species { get => Gift.IsManaphyEgg ? 490 : Gift.Species; set => Gift.Species = value; }
public override int[] Moves { get => Gift.Moves; set => Gift.Moves = value; }
@ -99,6 +100,8 @@ namespace PKHeX.Core
{
return Gift.ConvertToPKM(SAV);
}
public bool CanBeReceivedBy(int pkmVersion) => (CardCompatibility >> pkmVersion & 1) == 1;
}
public sealed class PGT : MysteryGift
{

View file

@ -310,7 +310,7 @@ V363 = Incompatible moves. Learned at the same level in Red/Blue and Yellow.
V365 = Incompatible evolution moves. {0} Move learned at a lower level than other {1} moves.
V366 = Incompatible evolution moves. {1} Move learned at a higher level than other {0} moves.
V367 = Individual EV for a level 100 encounter in Generation 4 cannot be greater than 100.public static string
V368 = Eggs can not be infected with Pokérus.
V368 = Eggs can not be infected with Pokérus.
V369 = Invalid E-Reader Berry.
V370 = Japanese E-Reader Berry in international savegame.
V371 = American E-Reader Berry in Japanese savegame.
@ -344,5 +344,6 @@ V410 = Mystery Gift fixed PID mismatch.
V411 = Encounter Type PID mismatch.
V412 = Non-tradeback pre evolution move. Incompatible with Generation 1 exclusive moves.
V413 = Unreleased event.
V414 = Eggs can not have Shiny Leaf/Crown.
V415 = Eggs can not have Pokéathlon stats.
V414 = Eggs cannot have Shiny Leaf/Crown.
V415 = Eggs cannot have Pokéathlon stats.
V416 = Mystery Gift cannot be received by this version.

View file

@ -344,5 +344,6 @@ V410 = 이상한소포의 고정된 PID가 일치하지 않습니다.
V411 = 인카운터 유형 PID가 일치하지 않습니다.
V412 = 이전 세대로 옮길 수 없는 진화 전 기술입니다. 1세대 전용 기술과 함께 존재할 수 없습니다.
V413 = Unreleased event.
V414 = Eggs can not have Shiny Leaf/Crown.
V415 = Eggs can not have Pokéathlon stats.
V414 = Eggs cannot have Shiny Leaf/Crown.
V415 = Eggs cannot have Pokéathlon stats.
V416 = Mystery Gift cannot be received by this version.

View file

@ -344,5 +344,6 @@ V410 = Mystery Gift fixed PID mismatch.
V411 = Encounter Type PID mismatch.
V412 = Non-tradeback pre evolution move. Incompatible with generation 1 exclusive moves.
V413 = Unreleased event.
V414 = Eggs can not have Shiny Leaf/Crown.
V415 = Eggs can not have Pokéathlon stats.
V414 = Eggs cannot have Shiny Leaf/Crown.
V415 = Eggs cannot have Pokéathlon stats.
V416 = Mystery Gift cannot be received by this version.