Add form argument legality checks

Closes #2611 (Alcremie)
Closes #2604 (Runerigus)
This commit is contained in:
Kurt 2020-01-10 16:33:40 -08:00
parent 507868ce58
commit d3f6d5935f
2 changed files with 74 additions and 0 deletions

View file

@ -188,6 +188,10 @@ namespace PKHeX.Core
public static string LFavoriteMarkingUnavailable { get; set; } = "Favorite Marking is not available."; public static string LFavoriteMarkingUnavailable { get; set; } = "Favorite Marking is not available.";
public static string LFormArgumentHigh { get; set; } = "Form argument is too high for current form.";
public static string LFormArgumentLow { get; set; } = "Form argument is too low for current form.";
public static string LFormArgumentNotAllowed { get; set; } = "Form argument is not allowed for this encounter.";
public static string LFormArgumentValid { get; set; } = "Form argument is valid.";
public static string LFormBattle { get; set; } = "Form cannot exist outside of a battle."; public static string LFormBattle { get; set; } = "Form cannot exist outside of a battle.";
public static string LFormEternal { get; set; } = "Valid Eternal Flower encounter."; public static string LFormEternal { get; set; } = "Valid Eternal Flower encounter.";
public static string LFormEternalInvalid { get; set; } = "Invalid Eternal Flower encounter."; public static string LFormEternalInvalid { get; set; } = "Invalid Eternal Flower encounter.";

View file

@ -18,6 +18,9 @@ namespace PKHeX.Core
return; // no forms exist return; // no forms exist
var result = VerifyForm(data); var result = VerifyForm(data);
data.AddLine(result); data.AddLine(result);
if (pkm is IFormArgument f)
data.AddLine(VerifyFormArgument(data, f));
} }
private CheckResult VALID => GetValid(LFormValid); private CheckResult VALID => GetValid(LFormValid);
@ -250,5 +253,72 @@ namespace PKHeX.Core
break; break;
} }
} }
private CheckResult VerifyFormArgument(LegalityAnalysis data, IFormArgument f)
{
var pkm = data.pkm;
switch (data.pkm.Species)
{
default:
{
if (f.FormArgument != 0)
return GetInvalid(LFormArgumentNotAllowed);
break;
}
case (int)Species.Furfrou:
{
if (f.FormArgument > 5)
return GetInvalid(LFormArgumentHigh);
if (f.FormArgument == 0 && pkm.AltForm != 0)
return GetInvalid(LFormArgumentNotAllowed);
if (f.FormArgument != 0 && pkm.AltForm == 0)
return GetInvalid(LFormArgumentNotAllowed);
break;
}
case (int)Species.Hoopa:
{
if (f.FormArgument > 3)
return GetInvalid(LFormArgumentHigh);
if (f.FormArgument == 0 && pkm.AltForm != 0)
return GetInvalid(LFormArgumentNotAllowed);
if (f.FormArgument != 0 && pkm.AltForm == 0)
return GetInvalid(LFormArgumentNotAllowed);
break;
}
case (int)Species.Runerigus:
{
if (data.EncounterMatch.Species == (int)Species.Runerigus)
{
if (f.FormArgument != 0)
return GetInvalid(LFormArgumentNotAllowed);
}
else
{
if (f.FormArgument < 49)
return GetInvalid(LFormArgumentLow);
if (f.FormArgument > 320) // calculate Yamask HP maximum? Arbitrary bound check.
return GetInvalid(LFormArgumentHigh);
}
break;
}
case (int)Species.Alcremie:
{
if (data.EncounterMatch.Species == (int)Species.Alcremie)
{
if (f.FormArgument != 0)
return GetInvalid(LFormArgumentNotAllowed);
}
else
{
if (f.FormArgument > (uint)AlcremieDecoration.Ribbon)
return GetInvalid(LFormArgumentHigh);
}
break;
}
}
return GetValid(LFormArgumentValid);
}
} }
} }