From d794e71175a302dfce24f006147173b8de732808 Mon Sep 17 00:00:00 2001 From: Kurt Date: Wed, 28 Mar 2018 16:07:03 -0700 Subject: [PATCH] Extend contest-affection check to pre-gen6 transfer Closes #1881 Thanks @ijuintekka ! Thanks @sora10pls ! --- PKHeX.Core/Legality/Checks.cs | 8 +++++--- PKHeX.Core/PKM/PK6.cs | 2 +- PKHeX.Core/PKM/PK7.cs | 2 +- PKHeX.WinForms/Subforms/PKM Editors/MemoryAmie.cs | 6 +++--- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/PKHeX.Core/Legality/Checks.cs b/PKHeX.Core/Legality/Checks.cs index 7be214816..9e7ac6e30 100644 --- a/PKHeX.Core/Legality/Checks.cs +++ b/PKHeX.Core/Legality/Checks.cs @@ -1563,12 +1563,15 @@ namespace PKHeX.Core if (!Encounter.Valid) return new CheckResult(Severity.Valid, V127, CheckIdentifier.History); + // ORAS contests mistakenly apply 20 affection to the OT instead of the current handler's value + bool IsInvalidContestAffection() => pkm.OT_Affection != 255 && pkm.OT_Affection % 20 != 0; + if (Info.Generation < 6) { if (pkm.Format < 6) return new CheckResult(Severity.Valid, V128, CheckIdentifier.History); - if (pkm.OT_Affection > 0) + if (pkm.OT_Affection != 0 && IsInvalidContestAffection()) return new CheckResult(Severity.Invalid, V129, CheckIdentifier.History); if (pkm.OT_Memory > 0 || pkm.OT_Feeling > 0 || pkm.OT_Intensity > 0 || pkm.OT_TextVar > 0) return new CheckResult(Severity.Invalid, V130, CheckIdentifier.History); @@ -1584,8 +1587,7 @@ namespace PKHeX.Core { if (pkm.OT_Friendship != PersonalTable.AO[EncounterMatch.Species].BaseFriendship) return new CheckResult(Severity.Invalid, V132, CheckIdentifier.History); - // ORAS contests mistakenly apply 20 affection to the OT instead of the current handler's value - if (pkm.OT_Affection != 0 && ((pkm.AO || !pkm.IsUntraded) && (pkm.OT_Affection == 255 || pkm.OT_Affection % 20 != 0))) + if (pkm.OT_Affection != 0 && (pkm.AO || !pkm.IsUntraded) && IsInvalidContestAffection()) return new CheckResult(Severity.Invalid, V133, CheckIdentifier.History); if (pkm.CurrentHandler != 1) return new CheckResult(Severity.Invalid, V134, CheckIdentifier.History); diff --git a/PKHeX.Core/PKM/PK6.cs b/PKHeX.Core/PKM/PK6.cs index 5f03e536b..b3f7753a3 100644 --- a/PKHeX.Core/PKM/PK6.cs +++ b/PKHeX.Core/PKM/PK6.cs @@ -441,7 +441,7 @@ namespace PKHeX.Core if (IsUntraded) HT_Friendship = HT_Affection = HT_TextVar = HT_Memory = HT_Intensity = HT_Feeling = 0; if (!Gen6) - OT_Affection = OT_TextVar = OT_Memory = OT_Intensity = OT_Feeling = 0; + /* OT_Affection = */ OT_TextVar = OT_Memory = OT_Intensity = OT_Feeling = 0; Geo1_Region = Geo1_Country > 0 ? Geo1_Region : 0; Geo2_Region = Geo2_Country > 0 ? Geo2_Region : 0; diff --git a/PKHeX.Core/PKM/PK7.cs b/PKHeX.Core/PKM/PK7.cs index 8f6e75ff7..82980216f 100644 --- a/PKHeX.Core/PKM/PK7.cs +++ b/PKHeX.Core/PKM/PK7.cs @@ -496,7 +496,7 @@ namespace PKHeX.Core if (IsUntraded) HT_Friendship = HT_Affection = HT_TextVar = HT_Memory = HT_Intensity = HT_Feeling = 0; if (GenNumber < 6) - OT_Affection = OT_TextVar = OT_Memory = OT_Intensity = OT_Feeling = 0; + /* OT_Affection = */ OT_TextVar = OT_Memory = OT_Intensity = OT_Feeling = 0; Geo1_Region = Geo1_Country > 0 ? Geo1_Region : 0; Geo2_Region = Geo2_Country > 0 ? Geo2_Region : 0; diff --git a/PKHeX.WinForms/Subforms/PKM Editors/MemoryAmie.cs b/PKHeX.WinForms/Subforms/PKM Editors/MemoryAmie.cs index 0e8286931..f362ac787 100644 --- a/PKHeX.WinForms/Subforms/PKM Editors/MemoryAmie.cs +++ b/PKHeX.WinForms/Subforms/PKM Editors/MemoryAmie.cs @@ -105,8 +105,7 @@ namespace PKHeX.WinForms GB_M_OT.Text = $"{args[3]} {pkm.OT_Name}: {args[2]}"; // Past Gen OT : OTNAME GB_M_CT.Text = $"{args[4]} {pkm.HT_Name}"; // Memories with : HTNAME enable = false; - // Reset to no memory - M_OT_Affection.Text = "0"; + // Reset to no memory -- don't reset affection as ORAS can raise it CB_OTQual.SelectedIndex = CB_OTFeel.SelectedIndex = 0; CB_OTVar.SelectedValue = CB_OTMemory.SelectedValue = 0; } @@ -125,7 +124,8 @@ namespace PKHeX.WinForms else GB_M_CT.Text = $"{args[4]} {pkm.HT_Name}"; } - RTB_OT.Visible = CB_OTQual.Enabled = CB_OTMemory.Enabled = CB_OTFeel.Enabled = CB_OTVar.Enabled = M_OT_Affection.Enabled = enable; + RTB_OT.Visible = CB_OTQual.Enabled = CB_OTMemory.Enabled = CB_OTFeel.Enabled = CB_OTVar.Enabled = enable; + M_OT_Affection.Enabled = true; } else GB_M_OT.Text = GB_M_CT.Text = $"N/A: {GameInfo.Strings.eggname}";