mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-15 00:37:11 +00:00
Improve gen1/2 invalid string detection
also spit out recommended TID/SID for c/xd starters Closes #1443
This commit is contained in:
parent
311ea4bc50
commit
ddf55ee75a
6 changed files with 61 additions and 22 deletions
|
@ -168,14 +168,9 @@ namespace PKHeX.Core
|
|||
return;
|
||||
}
|
||||
|
||||
if (pkm.VC)
|
||||
if (pkm.VC && pkm.IsNicknamed)
|
||||
{
|
||||
string pk = pkm.Nickname;
|
||||
var langset = PKX.SpeciesLang.FirstOrDefault(s => s.Contains(pk)) ?? PKX.SpeciesLang[2];
|
||||
int lang = Array.IndexOf(PKX.SpeciesLang, langset);
|
||||
|
||||
if (pk.Length > (lang != 1 ? 10 : 5))
|
||||
AddLine(Severity.Invalid, V1, CheckIdentifier.Nickname);
|
||||
VerifyG1NicknameWithinBounds(pkm.Nickname);
|
||||
}
|
||||
else if (EncounterMatch is MysteryGift m)
|
||||
{
|
||||
|
@ -485,30 +480,63 @@ namespace PKHeX.Core
|
|||
private void VerifyG1OT()
|
||||
{
|
||||
string tr = pkm.OT_Name;
|
||||
string pk = pkm.Nickname;
|
||||
var langset = PKX.SpeciesLang.FirstOrDefault(s => s.Contains(pk)) ?? PKX.SpeciesLang[2];
|
||||
int lang = Array.IndexOf(PKX.SpeciesLang, langset);
|
||||
|
||||
if (tr.Length > (lang == 2 ? 7 : 5))
|
||||
AddLine(Severity.Invalid, V38, CheckIdentifier.Trainer);
|
||||
VerifyG1OTWithinBounds(tr);
|
||||
if ((EncounterMatch as EncounterStatic)?.Version == GameVersion.Stadium)
|
||||
VerifyG1OTStadium(tr);
|
||||
|
||||
if (pkm.Species == 151)
|
||||
{
|
||||
if (tr != "GF" && tr != "ゲーフリ") // if there are more events with special OTs, may be worth refactoring
|
||||
AddLine(Severity.Invalid, V39, CheckIdentifier.Trainer);
|
||||
}
|
||||
if ((EncounterMatch as EncounterStatic)?.Version == GameVersion.Stadium)
|
||||
{
|
||||
bool jp = (pkm as PK1)?.Japanese ?? (pkm as PK2)?.Japanese ?? pkm.Language != 2;
|
||||
bool valid = GetIsStadiumOTIDValid(jp, tr);
|
||||
if (!valid)
|
||||
AddLine(Severity.Invalid, V402, CheckIdentifier.Trainer);
|
||||
else
|
||||
AddLine(Severity.Valid, jp ? V404 : V403, CheckIdentifier.Trainer);
|
||||
}
|
||||
|
||||
if (pkm.OT_Gender == 1 && (pkm.Format == 2 && pkm.Met_Location == 0 || !Info.Game.Contains(GameVersion.C)))
|
||||
AddLine(Severity.Invalid, V408, CheckIdentifier.Trainer);
|
||||
}
|
||||
private void VerifyG1OTWithinBounds(string str)
|
||||
{
|
||||
if (StringConverter.GetIsG1English(str))
|
||||
{
|
||||
if (str.Length > 7)
|
||||
AddLine(Severity.Invalid, V38, CheckIdentifier.Trainer);
|
||||
}
|
||||
else if (StringConverter.GetIsG1Japanese(str))
|
||||
{
|
||||
if (str.Length > 5)
|
||||
AddLine(Severity.Invalid, V38, CheckIdentifier.Trainer);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddLine(Severity.Invalid, V421, CheckIdentifier.Trainer);
|
||||
}
|
||||
}
|
||||
private void VerifyG1NicknameWithinBounds(string str)
|
||||
{
|
||||
if (StringConverter.GetIsG1English(str))
|
||||
{
|
||||
if (str.Length > 10)
|
||||
AddLine(Severity.Invalid, V1, CheckIdentifier.Trainer);
|
||||
}
|
||||
else if (StringConverter.GetIsG1Japanese(str))
|
||||
{
|
||||
if (str.Length > 5)
|
||||
AddLine(Severity.Invalid, V1, CheckIdentifier.Trainer);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddLine(Severity.Invalid, V422, CheckIdentifier.Trainer);
|
||||
}
|
||||
}
|
||||
private void VerifyG1OTStadium(string tr)
|
||||
{
|
||||
bool jp = (pkm as PK1)?.Japanese ?? (pkm as PK2)?.Japanese ?? pkm.Language != 2;
|
||||
bool valid = GetIsStadiumOTIDValid(jp, tr);
|
||||
if (!valid)
|
||||
AddLine(Severity.Invalid, V402, CheckIdentifier.Trainer);
|
||||
else
|
||||
AddLine(Severity.Valid, jp ? V404 : V403, CheckIdentifier.Trainer);
|
||||
}
|
||||
private bool GetIsStadiumOTIDValid(bool jp, string tr)
|
||||
{
|
||||
if (jp)
|
||||
|
@ -815,7 +843,7 @@ namespace PKHeX.Core
|
|||
var SIDf = pidiv.RNG.Reverse(seed, rev);
|
||||
var TIDf = pidiv.RNG.Prev(SIDf);
|
||||
if (SIDf >> 16 != pkm.SID || TIDf >> 16 != pkm.TID)
|
||||
AddLine(Severity.Invalid, V400, CheckIdentifier.PID);
|
||||
AddLine(Severity.Invalid, V400 + $" {TIDf>>16}/{SIDf>>16}", CheckIdentifier.PID);
|
||||
}
|
||||
|
||||
private void VerifyAbility()
|
||||
|
|
|
@ -402,6 +402,8 @@ namespace PKHeX.Core
|
|||
public static string V418 {get; set;} = "Individual EV without changing EXP cannot be greater than {0}.";
|
||||
public static string V419 {get; set;} = "Eggs cannot hold items.";
|
||||
public static string V420 {get; set;} = "Eggs cannot have modified move PP counts.";
|
||||
public static string V421 {get; set;} = "OT from Generation 1/2 is uses unavailable characters.";
|
||||
public static string V422 {get; set;} = "Nickname from Generation 1/2 is uses unavailable characters.";
|
||||
|
||||
public static string V600 { get; set; } = "Invalid Ribbons: {0}";
|
||||
public static string V601 { get; set; } = "Missing Ribbons: {0}";
|
||||
|
|
|
@ -406,6 +406,9 @@ namespace PKHeX.Core
|
|||
return dict.ContainsKey(key) ? dict[key] : "";
|
||||
}
|
||||
|
||||
public static bool GetIsG1Japanese(string str) => str.All(z => U2RBY_J.ContainsKey(z.ToString()));
|
||||
public static bool GetIsG1English(string str) => str.All(z => U2RBY_U.ContainsKey(z.ToString()));
|
||||
|
||||
/// <summary>
|
||||
/// Converts a Unicode string to Generation 7 in-game chinese string.
|
||||
/// </summary>
|
||||
|
|
|
@ -340,6 +340,8 @@ V417 = Suspicious Original Trainer details.
|
|||
V418 = Individual EV without changing EXP cannot be greater than {0}.
|
||||
V419 = Eggs cannot hold items.
|
||||
V420 = Eggs cannot have modified PP counts.
|
||||
V421 = OT from Generation 1/2 is uses unavailable characters.
|
||||
V422 = Nickname from Generation 1/2 is uses unavailable characters.
|
||||
V602 = All ribbons accounted for.
|
||||
V600 = Missing Ribbons: {0}
|
||||
V601 = Invalid Ribbons: {0}
|
||||
|
|
|
@ -340,6 +340,8 @@ V417 = Suspicious Original Trainer details.
|
|||
V418 = Individual EV without changing EXP cannot be greater than {0}.
|
||||
V419 = Eggs cannot hold items.
|
||||
V420 = Eggs cannot have modified PP counts.
|
||||
V421 = OT from Generation 1/2 is uses unavailable characters.
|
||||
V422 = Nickname from Generation 1/2 is uses unavailable characters.
|
||||
V602 = 모든 리본이 채워졌습니다.
|
||||
V600 = 없는 리본: {0}
|
||||
V601 = 사용할 수 없는 리본: {0}
|
||||
|
|
|
@ -340,6 +340,8 @@ V417 = 可疑的初训家信息。
|
|||
V418 = 有努力值但没有超过{0}的经验值。
|
||||
V419 = 蛋不能有持有物。
|
||||
V420 = 蛋不能有PP数变动。
|
||||
V421 = OT from Generation 1/2 is uses unavailable characters.
|
||||
V422 = Nickname from Generation 1/2 is uses unavailable characters.
|
||||
V602 = 所有奖章合法。
|
||||
V600 = 缺失奖章: {0}
|
||||
V601 = 不合法奖章: {0}
|
||||
|
|
Loading…
Reference in a new issue