Extend contest-affection check to pre-gen6 transfer

Closes #1881
Thanks @ijuintekka !
Thanks @sora10pls !
This commit is contained in:
Kurt 2018-03-28 16:07:03 -07:00
parent a0eb658ef2
commit d794e71175
4 changed files with 10 additions and 8 deletions

View file

@ -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);

View file

@ -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;

View file

@ -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;

View file

@ -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}";