From 7797af4baa4612eebe1b764f47ef9274d5ac29b4 Mon Sep 17 00:00:00 2001 From: Kurt Date: Tue, 24 Jan 2017 23:09:34 -0800 Subject: [PATCH] Add gen6->gen7 transfer skeleton Ingame font changed the order of the faces as noted in #734, this is just temp until someone tests. Check old ability & force to new if valid I bet the transfer method doesn't touch the chars (screwing up faces), so it can be removed if proven. --- PKHeX/PKM/PK6.cs | 52 +++++++++++++++++++++++++++++++++++++++ PKHeX/PKM/PKMConverter.cs | 4 +-- 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/PKHeX/PKM/PK6.cs b/PKHeX/PKM/PK6.cs index d93601910..d8c4f0575 100644 --- a/PKHeX/PKM/PK6.cs +++ b/PKHeX/PKM/PK6.cs @@ -601,5 +601,57 @@ namespace PKHeX.Core public override bool WasEventEgg => ((Egg_Location > 40000 && Egg_Location < 50000) || (FatefulEncounter && Egg_Location == 30002)) && Met_Level == 1; public override bool WasTradedEgg => Egg_Location == 30002; public override bool WasIngameTrade => Met_Location == 30001; + + public PK7 convertToPK7() + { + PK7 pk7 = new PK7(Data) + { + Markings = Markings, // Clears old Super Training Bag & Hits Remaining + Data = { [0x2A] = 0 }, // Clears old Marking Value + }; + + switch (AbilityNumber) + { + case 1: case 2: case 4: // Valid Ability Numbers + int index = AbilityNumber >> 1; + if (PersonalInfo.Abilities[index] == Ability) // correct pair + pk7.Ability = pk7.PersonalInfo.Abilities[index]; + break; + } + + // Fix Name Strings + pk7.Nickname = convertString(pk7.Nickname); + pk7.OT_Name = convertString(pk7.OT_Name); + pk7.HT_Name = convertString(pk7.HT_Name); + + // Fix Checksum + pk7.RefreshChecksum(); + + return pk7; // Done! + } + + private static string convertString(string input) + { + string s = ""; + foreach (char c in input) + { + // Faces get shuffled. + switch (c) + { + case '\uE081': + s += c + 3; + break; + case '\uE082': + case '\uE083': + case '\uE084': + s += c - 1; + break; + default: + s += c; + break; + } + } + return s; + } } } diff --git a/PKHeX/PKM/PKMConverter.cs b/PKHeX/PKM/PKMConverter.cs index 839e8b054..7c9551bb2 100644 --- a/PKHeX/PKM/PKMConverter.cs +++ b/PKHeX/PKM/PKMConverter.cs @@ -108,7 +108,7 @@ namespace PKHeX.Core return new PK5(data, ident); case 6: PKM pkx = new PK6(data, ident); - if (pkx.SM) + if (pkx.SM || pkx.VC || pkx.Horohoro) pkx = new PK7(data, ident); return pkx; default: @@ -221,7 +221,7 @@ namespace PKHeX.Core break; goto case nameof(PK6); case nameof(PK6): - pkm = new PK7(pkm.Data, pkm.Identifier); + pkm = ((PK6)pkm).convertToPK7(); if (toFormat == 7) break; goto case nameof(PK7);