From 054d49861942cf27d1cecdfcfa5e64540317e26d Mon Sep 17 00:00:00 2001 From: Kurt Date: Wed, 3 Apr 2019 20:13:30 -0700 Subject: [PATCH] Add vc transfer nature checks Closes #2279 thanks @SadisticMystic ! --- PKHeX.Core/Legality/Analysis.cs | 2 + PKHeX.Core/Legality/LegalityCheckStrings.cs | 1 + .../Legality/Verifiers/TransferVerifier.cs | 44 +++++++++++++++++++ .../text/de/LegalityCheckStrings_de.txt | 1 + .../text/en/LegalityCheckStrings_en.txt | 1 + .../text/es/LegalityCheckStrings_es.txt | 1 + .../text/fr/LegalityCheckStrings_fr.txt | 1 + .../text/it/LegalityCheckStrings_it.txt | 1 + .../text/ja/LegalityCheckStrings_ja.txt | 1 + .../text/ko/LegalityCheckStrings_ko.txt | 1 + .../Resources/text/ko/MessageStrings_ko.txt | 2 +- .../text/zh/LegalityCheckStrings_zh.txt | 1 + .../Resources/text/zh/MessageStrings_zh.txt | 2 +- 13 files changed, 57 insertions(+), 2 deletions(-) diff --git a/PKHeX.Core/Legality/Analysis.cs b/PKHeX.Core/Legality/Analysis.cs index 76f32e1aa..34fd237f2 100644 --- a/PKHeX.Core/Legality/Analysis.cs +++ b/PKHeX.Core/Legality/Analysis.cs @@ -251,6 +251,8 @@ namespace PKHeX.Core foreach (var z in Transfer.VerifyVCEncounter(pkm, EncounterOriginalGB, s, Info.Moves)) AddLine(z); + + Transfer.VerifyTransferLegalityG12(this); } private void UpdateInfo() diff --git a/PKHeX.Core/Legality/LegalityCheckStrings.cs b/PKHeX.Core/Legality/LegalityCheckStrings.cs index c35b401fc..d29a2ae87 100644 --- a/PKHeX.Core/Legality/LegalityCheckStrings.cs +++ b/PKHeX.Core/Legality/LegalityCheckStrings.cs @@ -432,6 +432,7 @@ namespace PKHeX.Core public static string LTransferMove { get; set; } = "Incompatible transfer move."; public static string LTransferMoveG4HM { get; set; } = "Defog and whirpool. One of the two moves should have been removed before transfered to Generation 5."; public static string LTransferMoveHM { get; set; } = "Generation {0} HM. Should have been removed before transfered to Generation {1}."; + public static string LTransferNature { get; set; } = "Invalid Nature for transfer Experience."; public static string LTransferOriginFInvalid0_1 { get; set; } = "{0} origin cannot exist in the currently loaded ({1}) savegame."; public static string LTransferPIDECBitFlip { get; set; } = "PID should be equal to EC [with top bit flipped]!"; public static string LTransferPIDECEquals { get; set; } = "PID should be equal to EC!"; diff --git a/PKHeX.Core/Legality/Verifiers/TransferVerifier.cs b/PKHeX.Core/Legality/Verifiers/TransferVerifier.cs index d7042461d..7779867da 100644 --- a/PKHeX.Core/Legality/Verifiers/TransferVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/TransferVerifier.cs @@ -16,6 +16,50 @@ namespace PKHeX.Core throw new NotImplementedException(); } + public void VerifyTransferLegalityG12(LegalityAnalysis data) + { + VerifyTransferVCNatureEXP(data); + } + + private void VerifyTransferVCNatureEXP(LegalityAnalysis data) + { + var pkm = data.pkm; + var met = pkm.Met_Level; + + if (met == 100) // check for precise match, can't receive EXP after transfer. + { + var nature = Experience.GetNatureVC(pkm.EXP); + if (nature != pkm.Nature) + data.AddLine(GetInvalid(LTransferNature)); + return; + } + if (met <= 2) // Not enough EXP to have every nature -- check for exclusions! + { + var pi = pkm.PersonalInfo; + var growth = pi.EXPGrowth; + var nature = pkm.Nature; + bool valid = VerifyVCNature(growth, nature); + if (!valid) + data.AddLine(GetInvalid(LTransferNature)); + } + } + + private static bool VerifyVCNature(int growth, int nature) + { + // exp % 25 with a limited amount of EXP does not allow for every nature + switch (growth) + { + case 0: // MediumFast -- Can't be Brave, Adamant, Naughty, Bold, Docile, or Relaxed + return nature < (int)Nature.Brave || nature > (int)Nature.Relaxed; + case 4: // Fast -- Can't be Gentle, Sassy, Careful, Quirky, Hardy, Lonely, Brave, Adamant, Naughty, or Bold + return nature < (int)Nature.Gentle && nature > (int)Nature.Bold; + case 5: // Slow -- Can't be Impish or Lax + return nature != (int)Nature.Impish && nature != (int)Nature.Lax; + default: + return true; + } + } + public void VerifyTransferLegalityG3(LegalityAnalysis data) { var pkm = data.pkm; diff --git a/PKHeX.Core/Resources/text/de/LegalityCheckStrings_de.txt b/PKHeX.Core/Resources/text/de/LegalityCheckStrings_de.txt index 9c2e8add3..3a0ddb0aa 100644 --- a/PKHeX.Core/Resources/text/de/LegalityCheckStrings_de.txt +++ b/PKHeX.Core/Resources/text/de/LegalityCheckStrings_de.txt @@ -350,6 +350,7 @@ LTransferMetLocation = Invalid Transfer Met Location. LTransferMove = Incompatible transfer move. LTransferMoveG4HM = Defog and whirpool. One of the two moves should have been removed before transfered to Generation 5. LTransferMoveHM = Generation {0} HM. Should have been removed before transfered to Generation {1}. +LTransferNature = Invalid Nature for transfer Experience. LTransferOriginFInvalid0_1 = {0} origin cannot exist in the currently loaded ({1}) savegame. LTransferPIDECBitFlip = PID should be equal to EC [with top bit flipped]! LTransferPIDECEquals = PID should be equal to EC! diff --git a/PKHeX.Core/Resources/text/en/LegalityCheckStrings_en.txt b/PKHeX.Core/Resources/text/en/LegalityCheckStrings_en.txt index 8ba3240b1..c7b1fd893 100644 --- a/PKHeX.Core/Resources/text/en/LegalityCheckStrings_en.txt +++ b/PKHeX.Core/Resources/text/en/LegalityCheckStrings_en.txt @@ -350,6 +350,7 @@ LTransferMetLocation = Invalid Transfer Met Location. LTransferMove = Incompatible transfer move. LTransferMoveG4HM = Defog and whirpool. One of the two moves should have been removed before transfered to Generation 5. LTransferMoveHM = Generation {0} HM. Should have been removed before transfered to Generation {1}. +LTransferNature = Invalid Nature for transfer Experience. LTransferOriginFInvalid0_1 = {0} origin cannot exist in the currently loaded ({1}) savegame. LTransferPIDECBitFlip = PID should be equal to EC [with top bit flipped]! LTransferPIDECEquals = PID should be equal to EC! diff --git a/PKHeX.Core/Resources/text/es/LegalityCheckStrings_es.txt b/PKHeX.Core/Resources/text/es/LegalityCheckStrings_es.txt index 28b35b5fb..27384e985 100644 --- a/PKHeX.Core/Resources/text/es/LegalityCheckStrings_es.txt +++ b/PKHeX.Core/Resources/text/es/LegalityCheckStrings_es.txt @@ -350,6 +350,7 @@ LTransferMetLocation = Lugar de Encuentro mediante transferencia inválido. LTransferMove = Movimiento de transferencia incompatible. LTransferMoveG4HM = Despejar y Torbellino. Uno de estos movimientos debe de ser eliminado antes de ser transferido a la Generación 5. LTransferMoveHM = MO de la {0} generación. Debería de haber sido eliminado antes de ser transferido a la Generación {1}. +LTransferNature = Invalid Nature for transfer Experience. LTransferOriginFInvalid0_1 = {0} origen no puede existir en la partida cargada ({1}) actualmente. LTransferPIDECBitFlip = ¡El PID debería de ser igual al EC [Con el primer dígito invertido]! LTransferPIDECEquals = ¡El PID debería de ser igual al EC! diff --git a/PKHeX.Core/Resources/text/fr/LegalityCheckStrings_fr.txt b/PKHeX.Core/Resources/text/fr/LegalityCheckStrings_fr.txt index f2e04e64d..b4f4c80a5 100644 --- a/PKHeX.Core/Resources/text/fr/LegalityCheckStrings_fr.txt +++ b/PKHeX.Core/Resources/text/fr/LegalityCheckStrings_fr.txt @@ -350,6 +350,7 @@ LTransferMetLocation = Pokémon transféré, endroit de rencontre invalide. LTransferMove = Attaque de transfert incompatible. LTransferMoveG4HM = Anti-Brume ou Siphon doivent être oubliées avant tout transfert vers la Génération 5. LTransferMoveHM = CS de Génération {0}. Elle doit être oubliée avant de transférer le Pokémon vers la génération {1}. +LTransferNature = Invalid Nature for transfer Experience. LTransferOriginFInvalid0_1 = L'origine de {0} ne peut pas exister dans cette sauvegarde ({1}). LTransferPIDECBitFlip = PID should be equal to EC [with top bit flipped]! LTransferPIDECEquals = PID should be equal to EC! diff --git a/PKHeX.Core/Resources/text/it/LegalityCheckStrings_it.txt b/PKHeX.Core/Resources/text/it/LegalityCheckStrings_it.txt index 9c2e8add3..3a0ddb0aa 100644 --- a/PKHeX.Core/Resources/text/it/LegalityCheckStrings_it.txt +++ b/PKHeX.Core/Resources/text/it/LegalityCheckStrings_it.txt @@ -350,6 +350,7 @@ LTransferMetLocation = Invalid Transfer Met Location. LTransferMove = Incompatible transfer move. LTransferMoveG4HM = Defog and whirpool. One of the two moves should have been removed before transfered to Generation 5. LTransferMoveHM = Generation {0} HM. Should have been removed before transfered to Generation {1}. +LTransferNature = Invalid Nature for transfer Experience. LTransferOriginFInvalid0_1 = {0} origin cannot exist in the currently loaded ({1}) savegame. LTransferPIDECBitFlip = PID should be equal to EC [with top bit flipped]! LTransferPIDECEquals = PID should be equal to EC! diff --git a/PKHeX.Core/Resources/text/ja/LegalityCheckStrings_ja.txt b/PKHeX.Core/Resources/text/ja/LegalityCheckStrings_ja.txt index 61422e7d9..228c2eb2a 100644 --- a/PKHeX.Core/Resources/text/ja/LegalityCheckStrings_ja.txt +++ b/PKHeX.Core/Resources/text/ja/LegalityCheckStrings_ja.txt @@ -350,6 +350,7 @@ LTransferMetLocation = Invalid Transfer Met Location. LTransferMove = Incompatible transfer move. LTransferMoveG4HM = Defog and whirpool. One of the two moves should have been removed before transfered to Generation 5. LTransferMoveHM = Generation {0} HM. Should have been removed before transfered to Generation {1}. +LTransferNature = Invalid Nature for transfer Experience. LTransferOriginFInvalid0_1 = {0} origin cannot exist in the currently loaded ({1}) savegame. LTransferPIDECBitFlip = PID should be equal to EC [with top bit flipped]! LTransferPIDECEquals = PID should be equal to EC! diff --git a/PKHeX.Core/Resources/text/ko/LegalityCheckStrings_ko.txt b/PKHeX.Core/Resources/text/ko/LegalityCheckStrings_ko.txt index 008209a2c..10fc71f20 100644 --- a/PKHeX.Core/Resources/text/ko/LegalityCheckStrings_ko.txt +++ b/PKHeX.Core/Resources/text/ko/LegalityCheckStrings_ko.txt @@ -350,6 +350,7 @@ LTransferMetLocation = 옮겨진 만난 장소가 잘못되었습니다. LTransferMove = 호환되지 않는 전송 공격. LTransferMoveG4HM = 안개제거와 바다회오리가 함께 존재합니다. 둘 중 하나는 5세대로 옮기기 전에 제거해야 합니다. LTransferMoveHM = {0}세대 비전머신입니다. {1}세대로 옮기기 전에 제거해야 합니다. +LTransferNature = Invalid Nature for transfer Experience. LTransferOriginFInvalid0_1 = 현재 로드한 세이브파일 ({1}) 에서는 {0} 버전에서 만난 포켓몬이 존재할 수 없습니다. LTransferPIDECBitFlip = PID는 Top bit가 뒤집힌 암호화 상수와 동일해야 합니다! LTransferPIDECEquals = PID는 암호화 상수와 동일해야 합니다! diff --git a/PKHeX.Core/Resources/text/ko/MessageStrings_ko.txt b/PKHeX.Core/Resources/text/ko/MessageStrings_ko.txt index 0fb53432f..a666fcbd9 100644 --- a/PKHeX.Core/Resources/text/ko/MessageStrings_ko.txt +++ b/PKHeX.Core/Resources/text/ko/MessageStrings_ko.txt @@ -1,4 +1,4 @@ -MsgProgramRestart = Please restart the program. +MsgProgramRestart = Please restart the program. MsgProgramIllegalModeBehave = Please behave. MsgProgramIllegalModeActive = Illegal mode activated. MsgProgramUpdateAvailable = New Update Available! diff --git a/PKHeX.Core/Resources/text/zh/LegalityCheckStrings_zh.txt b/PKHeX.Core/Resources/text/zh/LegalityCheckStrings_zh.txt index adb12f75a..c65e20424 100644 --- a/PKHeX.Core/Resources/text/zh/LegalityCheckStrings_zh.txt +++ b/PKHeX.Core/Resources/text/zh/LegalityCheckStrings_zh.txt @@ -350,6 +350,7 @@ LTransferMetLocation = 传送相遇地点不合法。 LTransferMove = 不兼容的虚拟传送招式。 LTransferMoveG4HM = 清除浓雾与潮旋。两者在传到5代以前必须被移除。 LTransferMoveHM = 第{0}世代秘传学习器(HM招式)。应在传至第{1}世代前被移除。 +LTransferNature = Invalid Nature for transfer Experience. LTransferOriginFInvalid0_1 = {0}来源的宝可梦不能存在于({1})的游戏记录。 LTransferPIDECBitFlip = PID应与加密常数相等[第一位反转]! LTransferPIDECEquals = PID应与加密常数相等! diff --git a/PKHeX.Core/Resources/text/zh/MessageStrings_zh.txt b/PKHeX.Core/Resources/text/zh/MessageStrings_zh.txt index 61f4dce6b..a33a39c3c 100644 --- a/PKHeX.Core/Resources/text/zh/MessageStrings_zh.txt +++ b/PKHeX.Core/Resources/text/zh/MessageStrings_zh.txt @@ -1,4 +1,4 @@ -MsgProgramRestart = 请重启程序。 +MsgProgramRestart = 请重启程序。 MsgProgramIllegalModeBehave = 请自重。 MsgProgramIllegalModeActive = 不合法模式启动。 MsgProgramUpdateAvailable = 有新版本!