mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-05-09 04:24:36 -05:00
Update gen4/5 mg generators
PGF for movie victini has OTgender=3; only eggs are supposed to set OT details from the SAV. update pattern matchers to abuse this fact. Thanks @odaxis !
This commit is contained in:
parent
dc0a43ae8f
commit
2f3c56e7c5
|
|
@ -960,10 +960,6 @@ private static IEnumerable<MysteryGift> GetMatchingWC3(PKM pkm, IEnumerable<Myst
|
|||
continue;
|
||||
}
|
||||
|
||||
// Some checks are best performed separately as they are caused by users screwing up valid data.
|
||||
// if (wc.Level > pkm.CurrentLevel) continue; // Defer to level legality
|
||||
// RIBBONS: Defer to ribbon legality
|
||||
|
||||
if (wc.Species == pkm.Species) // best match
|
||||
yield return wc;
|
||||
else
|
||||
|
|
@ -988,27 +984,14 @@ private static IEnumerable<MysteryGift> GetMatchingPCD(PKM pkm, IEnumerable<Myst
|
|||
foreach (PCD mg in DB.OfType<PCD>().Where(wc => vs.Any(dl => dl.Species == wc.Species)))
|
||||
{
|
||||
var wc = mg.Gift.PK;
|
||||
if (pkm.Egg_Location == 0) // Not Egg
|
||||
if (!wc.IsEgg)
|
||||
{
|
||||
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.Language != 0 && wc.Language != pkm.Language) continue;
|
||||
}
|
||||
if (wc.AltForm != pkm.AltForm && vs.All(dl => !IsFormChangeable(pkm, dl.Species))) continue;
|
||||
|
||||
if (wc.IsEgg)
|
||||
{
|
||||
if (wc.Egg_Location + 3000 != pkm.Egg_Location && pkm.Egg_Location != 2002) // traded
|
||||
continue;
|
||||
if (wc.CurrentLevel != pkm.Met_Level)
|
||||
continue;
|
||||
if (pkm.IsEgg && !pkm.IsNative)
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pkm.Format != 4) // transferred
|
||||
{
|
||||
// met location: deferred to general transfer check
|
||||
|
|
@ -1020,6 +1003,17 @@ private static IEnumerable<MysteryGift> GetMatchingPCD(PKM pkm, IEnumerable<Myst
|
|||
if (wc.CurrentLevel != pkm.Met_Level) continue;
|
||||
}
|
||||
}
|
||||
else // Egg
|
||||
{
|
||||
if (wc.Egg_Location + 3000 != pkm.Egg_Location && pkm.Egg_Location != 2002) // traded
|
||||
continue;
|
||||
if (wc.CurrentLevel != pkm.Met_Level)
|
||||
continue;
|
||||
if (pkm.IsEgg && !pkm.IsNative)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (wc.AltForm != pkm.AltForm && vs.All(dl => !IsFormChangeable(pkm, dl.Species))) continue;
|
||||
|
||||
if (wc.Ball != pkm.Ball) continue;
|
||||
if (wc.OT_Gender < 3 && wc.OT_Gender != pkm.OT_Gender) continue;
|
||||
|
|
@ -1033,10 +1027,6 @@ private static IEnumerable<MysteryGift> GetMatchingPCD(PKM pkm, IEnumerable<Myst
|
|||
if (wc.CNT_Tough > pkm.CNT_Tough) continue;
|
||||
if (wc.CNT_Sheen > pkm.CNT_Sheen) continue;
|
||||
|
||||
// Some checks are best performed separately as they are caused by users screwing up valid data.
|
||||
// if (wc.Level > pkm.CurrentLevel) continue; // Defer to level legality
|
||||
// RIBBONS: Defer to ribbon legality
|
||||
|
||||
bool receivable = mg.CanBeReceivedBy(pkm.Version);
|
||||
if (wc.Species == pkm.Species && receivable) // best match
|
||||
yield return mg;
|
||||
|
|
@ -1055,35 +1045,33 @@ private static IEnumerable<MysteryGift> GetMatchingPGF(PKM pkm, IEnumerable<Myst
|
|||
var vs = GetValidPreEvolutions(pkm).ToArray();
|
||||
foreach (PGF wc in DB.OfType<PGF>().Where(wc => vs.Any(dl => dl.Species == wc.Species)))
|
||||
{
|
||||
if (pkm.Egg_Location == 0) // Not Egg
|
||||
if (!wc.IsEgg)
|
||||
{
|
||||
if (wc.SID != pkm.SID) continue;
|
||||
if (wc.TID != pkm.TID) continue;
|
||||
if (wc.OT != pkm.OT_Name) continue;
|
||||
if (wc.OTGender < 3 && wc.OTGender != pkm.OT_Gender) continue;
|
||||
if (wc.PID != 0 && pkm.PID != wc.PID) continue;
|
||||
if (wc.PIDType == 0 && pkm.IsShiny) continue;
|
||||
if (wc.PIDType == 2 && !pkm.IsShiny) continue;
|
||||
if (wc.OriginGame != 0 && wc.OriginGame != pkm.Version) continue;
|
||||
if (wc.Language != 0 && wc.Language != pkm.Language) continue;
|
||||
}
|
||||
if (wc.Form != pkm.AltForm && vs.All(dl => !IsFormChangeable(pkm, dl.Species))) continue;
|
||||
|
||||
if (wc.IsEgg)
|
||||
if (wc.EggLocation != pkm.Egg_Location) continue;
|
||||
if (wc.MetLocation != pkm.Met_Location) continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (wc.EggLocation != pkm.Egg_Location && pkm.Egg_Location != 30002) // traded
|
||||
continue;
|
||||
if (pkm.IsEgg && !pkm.IsNative)
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (wc.EggLocation != pkm.Egg_Location) continue;
|
||||
if (wc.MetLocation != pkm.Met_Location) continue;
|
||||
}
|
||||
|
||||
if (wc.Form != pkm.AltForm && vs.All(dl => !IsFormChangeable(pkm, dl.Species))) continue;
|
||||
|
||||
if (wc.Level != pkm.Met_Level) continue;
|
||||
if (wc.Ball != pkm.Ball) continue;
|
||||
if (wc.OTGender < 3 && wc.OTGender != pkm.OT_Gender) continue;
|
||||
if (wc.Nature != 0xFF && wc.Nature != pkm.Nature) continue;
|
||||
if (wc.Gender != 2 && wc.Gender != pkm.Gender) continue;
|
||||
|
||||
|
|
@ -1094,10 +1082,6 @@ private static IEnumerable<MysteryGift> GetMatchingPGF(PKM pkm, IEnumerable<Myst
|
|||
if (wc.CNT_Tough > pkm.CNT_Tough) continue;
|
||||
if (wc.CNT_Sheen > pkm.CNT_Sheen) continue;
|
||||
|
||||
// Some checks are best performed separately as they are caused by users screwing up valid data.
|
||||
// if (wc.Level > pkm.CurrentLevel) continue; // Defer to level legality
|
||||
// RIBBONS: Defer to ribbon legality
|
||||
|
||||
if (wc.Species == pkm.Species) // best match
|
||||
yield return wc;
|
||||
else
|
||||
|
|
@ -1155,13 +1139,6 @@ private static IEnumerable<MysteryGift> GetMatchingWC6(PKM pkm, IEnumerable<Myst
|
|||
if (wc.CNT_Tough > pkm.CNT_Tough) continue;
|
||||
if (wc.CNT_Sheen > pkm.CNT_Sheen) continue;
|
||||
|
||||
// Some checks are best performed separately as they are caused by users screwing up valid data.
|
||||
// if (!wc.RelearnMoves.SequenceEqual(pkm.RelearnMoves)) continue; // Defer to relearn legality
|
||||
// if (wc.OT.Length > 0 && pkm.CurrentHandler != 1) continue; // Defer to ownership legality
|
||||
// if (wc.OT.Length > 0 && pkm.OT_Friendship != PKX.getBaseFriendship(pkm.Species)) continue; // Friendship
|
||||
// if (wc.Level > pkm.CurrentLevel) continue; // Defer to level legality
|
||||
// RIBBONS: Defer to ribbon legality
|
||||
|
||||
if (wc.Species == pkm.Species) // best match
|
||||
yield return wc;
|
||||
else
|
||||
|
|
@ -1230,13 +1207,6 @@ private static IEnumerable<MysteryGift> GetMatchingWC7(PKM pkm, IEnumerable<Myst
|
|||
}
|
||||
if (wc.PIDType == 0 && pkm.PID != wc.PID) continue;
|
||||
|
||||
// Some checks are best performed separately as they are caused by users screwing up valid data.
|
||||
// if (!wc.RelearnMoves.SequenceEqual(pkm.RelearnMoves)) continue; // Defer to relearn legality
|
||||
// if (wc.OT.Length > 0 && pkm.CurrentHandler != 1) continue; // Defer to ownership legality
|
||||
// if (wc.OT.Length > 0 && pkm.OT_Friendship != PKX.getBaseFriendship(pkm.Species)) continue; // Friendship
|
||||
// if (wc.Level > pkm.CurrentLevel) continue; // Defer to level legality
|
||||
// RIBBONS: Defer to ribbon legality
|
||||
|
||||
if (wc.Species == pkm.Species) // best match
|
||||
yield return wc;
|
||||
else
|
||||
|
|
|
|||
|
|
@ -213,19 +213,19 @@ public override PKM ConvertToPKM(SaveFile SAV)
|
|||
pk.Move2_PP = pk.GetMovePP(Move2, 0);
|
||||
pk.Move3_PP = pk.GetMovePP(Move3, 0);
|
||||
pk.Move4_PP = pk.GetMovePP(Move4, 0);
|
||||
if (OTGender == 3) // User's
|
||||
if (IsEgg) // User's
|
||||
{
|
||||
pk.TID = SAV.TID;
|
||||
pk.SID = SAV.SID;
|
||||
pk.OT_Name = SAV.OT;
|
||||
pk.OT_Gender = 1; // Red PKHeX OT
|
||||
}
|
||||
else
|
||||
else // Hardcoded
|
||||
{
|
||||
pk.TID = IsEgg ? SAV.TID : TID;
|
||||
pk.SID = IsEgg ? SAV.SID : SID;
|
||||
pk.OT_Name = OT.Length > 0 ? OT : SAV.OT;
|
||||
pk.OT_Gender = OTGender % 2; // %2 just in case?
|
||||
pk.TID = TID;
|
||||
pk.SID = SID;
|
||||
pk.OT_Name = OT;
|
||||
pk.OT_Gender = (OTGender == 3 ? SAV.Gender : OTGender) & 1; // some events have variable gender based on receiving SaveFile
|
||||
}
|
||||
pk.IsNicknamed = IsNicknamed;
|
||||
pk.Nickname = IsNicknamed ? Nickname : PKX.GetSpeciesNameGeneration(Species, pk.Language, Format);
|
||||
|
|
|
|||
|
|
@ -120,6 +120,8 @@ public SAV_MysteryGiftDB(PKMEditor tabs, SAVEditor sav)
|
|||
private void ClickView(object sender, EventArgs e)
|
||||
{
|
||||
int index = GetSenderIndex(sender);
|
||||
if (index < 0)
|
||||
return;
|
||||
PKME_Tabs.PopulateFields(Results[index].ConvertToPKM(SAV), false);
|
||||
slotSelected = index;
|
||||
slotColor = Properties.Resources.slotView;
|
||||
|
|
@ -129,6 +131,8 @@ private void ClickView(object sender, EventArgs e)
|
|||
private void ClickSavePK(object sender, EventArgs e)
|
||||
{
|
||||
int index = GetSenderIndex(sender);
|
||||
if (index < 0)
|
||||
return;
|
||||
var gift = Results[index];
|
||||
var pk = gift.ConvertToPKM(SAV);
|
||||
WinFormsUtil.SavePKMDialog(pk);
|
||||
|
|
@ -136,6 +140,8 @@ private void ClickSavePK(object sender, EventArgs e)
|
|||
private void ClickSaveMG(object sender, EventArgs e)
|
||||
{
|
||||
int index = GetSenderIndex(sender);
|
||||
if (index < 0)
|
||||
return;
|
||||
var gift = Results[index];
|
||||
WinFormsUtil.SaveMGDialog(gift);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user