diff --git a/PKHeX/Game/GameInfo.cs b/PKHeX/Game/GameInfo.cs index 00f5a90e7..e3045f274 100644 --- a/PKHeX/Game/GameInfo.cs +++ b/PKHeX/Game/GameInfo.cs @@ -267,6 +267,7 @@ public string[] getItemStrings(int generation, GameVersion game) public static List MoveDataSource, ItemDataSource, SpeciesDataSource, BallDataSource, NatureDataSource, AbilityDataSource, VersionDataSource; public static List HaXMoveDataSource; private static List metGen2, metGen3, metGen3CXD, metGen4, metGen5, metGen6, metGen7; + public static void InitializeDataSources(GameStrings s) { int[] ball_nums = { 007, 576, 013, 492, 497, 014, 495, 493, 496, 494, 011, 498, 008, 006, 012, 015, 009, 005, 499, 010, 001, 016, 851 }; @@ -275,7 +276,7 @@ public static void InitializeDataSources(GameStrings s) SpeciesDataSource = Util.getCBList(s.specieslist, null); NatureDataSource = Util.getCBList(s.natures, null); AbilityDataSource = Util.getCBList(s.abilitylist, null); - VersionDataSource = Util.getCBList(s.gamelist, Legal.Games_7sm, Legal.Games_6oras, Legal.Games_6xy, Legal.Games_5, Legal.Games_4, Legal.Games_4e, Legal.Games_4r, Legal.Games_3, Legal.Games_3e, Legal.Games_3r, Legal.Games_3s); + VersionDataSource = Util.getCBList(s.gamelist, Legal.Games_7vc, Legal.Games_7go, Legal.Games_7sm, Legal.Games_6oras, Legal.Games_6xy, Legal.Games_5, Legal.Games_4, Legal.Games_4e, Legal.Games_4r, Legal.Games_3, Legal.Games_3e, Legal.Games_3r, Legal.Games_3s); HaXMoveDataSource = Util.getCBList(s.movelist, null); MoveDataSource = HaXMoveDataSource.Where(m => !Legal.Z_Moves.Contains(m.Value)).ToList(); @@ -415,6 +416,10 @@ public static List getLocationList(GameVersion Version, int SaveForma case GameVersion.SN: case GameVersion.MN: + case GameVersion.RD: + case GameVersion.BU: + case GameVersion.YW: + case GameVersion.GN: return metGen7.Take(3).Concat(metGen7.Skip(3).OrderByDescending(loc => loc.Value < 200)).ToList(); // Secret Base } diff --git a/PKHeX/Game/GameUtil.cs b/PKHeX/Game/GameUtil.cs index a0e9ebb4d..c11ead796 100644 --- a/PKHeX/Game/GameUtil.cs +++ b/PKHeX/Game/GameUtil.cs @@ -12,7 +12,14 @@ public static GameVersion getMetLocationVersionGroup(GameVersion Version) case GameVersion.CXD: return GameVersion.CXD; + case GameVersion.GO: + return GameVersion.GO; + case GameVersion.RBY: + case GameVersion.RD: + case GameVersion.BU: + case GameVersion.YW: + case GameVersion.GN: return GameVersion.RBY; case GameVersion.GS: diff --git a/PKHeX/Game/GameVersion.cs b/PKHeX/Game/GameVersion.cs index 1b64595de..893244541 100644 --- a/PKHeX/Game/GameVersion.cs +++ b/PKHeX/Game/GameVersion.cs @@ -21,6 +21,8 @@ public enum GameVersion /*Gen5*/ W = 20, B = 21, W2 = 22, B2 = 23, /*Gen6*/ X = 24, Y = 25, AS = 26, OR = 27, /*Gen7*/ SN = 30, MN = 31, + /* GO */ GO = 34, + /* VC */ RD = 35, BU = 36, GN = 37, YW = 38, // Game Groupings (SaveFile type) RBY = 98, diff --git a/PKHeX/Legality/Tables.cs b/PKHeX/Legality/Tables.cs index 7a48b0873..4ffd0820b 100644 --- a/PKHeX/Legality/Tables.cs +++ b/PKHeX/Legality/Tables.cs @@ -215,6 +215,8 @@ public static partial class Legal #region Games + public static readonly int[] Games_7vc = { 35, 36, 37, 38 }; + public static readonly int[] Games_7go = { 34 }; public static readonly int[] Games_7sm = { 30, 31 }; public static readonly int[] Games_6xy = { 24, 25 }; public static readonly int[] Games_6oras = { 26, 27 }; diff --git a/PKHeX/PKM/PK1.cs b/PKHeX/PKM/PK1.cs index edbd1df5f..9a7c9fe08 100644 --- a/PKHeX/PKM/PK1.cs +++ b/PKHeX/PKM/PK1.cs @@ -111,6 +111,16 @@ public override bool IsNicknamed set { } } + public bool IsNicknamedBank + { + get + { + var spName = PKX.getSpeciesName(Species, Japanese ? 1 : 2).ToUpper(); + spName = spName.Replace(" ", ""); // Gen I/II didn't have a space for Mr. Mime + return Nickname != spName; + } + } + public void setNotNicknamed() { string spName = PKX.getSpeciesName(Species, Japanese ? 1 : 2).ToUpper(); @@ -299,6 +309,78 @@ public PK2 convertToPK2() return pk2; } + + public PK7 convertToPK7() + { + var pk7 = new PK7 + { + EncryptionConstant = Util.rnd32(), + Species = Species, + TID = TID, + EXP = EXP, + CurrentLevel = CurrentLevel, + Met_Level = CurrentLevel, + Nature = (int) (EXP%25), + PID = Util.rnd32(), + AbilityNumber = 4, + Ball = 4, + MetDate = DateTime.Now, + Version = (int)GameVersion.RD, // Default to red, for now? + Move1 = Move1, + Move2 = Move2, + Move3 = Move3, + Move4 = Move4, + Move1_PPUps = Move1_PPUps, + Move2_PPUps = Move2_PPUps, + Move3_PPUps = Move3_PPUps, + Move4_PPUps = Move4_PPUps, + Move1_PP = Move1_PP, + Move2_PP = Move2_PP, + Move3_PP = Move3_PP, + Move4_PP = Move4_PP, + CurrentFriendship = PersonalTable.SM[Species].BaseFriendship, + Met_Location = 30013, // "Kanto region", hardcoded. + Gender = PersonalTable.SM[Species].RandomGender, + OT_Name = PKX.getG1ConvertedString(otname, Japanese), + Nickname = Util.getSpeciesList(Japanese ? "jp" : "en")[Species], + IsNicknamed = false + }; + + + // IVs + var new_ivs = new int[6]; + for (var i = 0; i < new_ivs.Length; i++) new_ivs[i] = (int)(Util.rnd32() & 31); + for (var i = 0; i < (Species == 151 ? 5 : 3); i++) new_ivs[i] = 31; + Util.Shuffle(new_ivs); + pk7.IVs = new_ivs; + + // Really? :( + if (IsShiny) + pk7.setShinyPID(); + + if (new[] {92, 93, 94, 151, 109, 110}.Contains(Species)) + pk7.AbilityNumber = 1; + + if (IsNicknamedBank) + { + pk7.IsNicknamed = true; + pk7.Nickname = PKX.getG1ConvertedString(nick, Japanese); + } + + // TODO: Language, 3DS Country/Region Info, Memories (Link Trade/Somewhere, remembers feeling {rnd}) + + if (Species == 151) // Mew gets special treatment. + { + pk7.FatefulEncounter = true; + pk7.AbilityNumber = 1; + pk7.Egg_Location = 0; + pk7.Nickname = Util.getSpeciesList(Japanese ? "jp" : "en")[Species]; + pk7.IsNicknamed = false; + } + + pk7.RefreshChecksum(); + return pk7; + } } public class PokemonList1 diff --git a/PKHeX/PKM/PKM.cs b/PKHeX/PKM/PKM.cs index 62c5e9b00..b24f6b9ee 100644 --- a/PKHeX/PKM/PKM.cs +++ b/PKHeX/PKM/PKM.cs @@ -620,26 +620,6 @@ public PKM convertToPK3() return pk; } - public PKM convertPK1toPK7() - { - if (Format != 1) - return null; - if (Species > 151) - return null; - - var pk = new PK7(); - TransferPropertiesWithReflection(this, pk); - pk.EVs = new int[6]; - pk.Nature = IVs.Sum() % 25; - pk.IVs = new[] {31,31,31,31,31,31}; - pk.RefreshChecksum(); - if (!IsNicknamed) - pk.Nickname = Nickname.ToLower(); - pk.Version = -1; - pk.Ability = PersonalTable.SM[Species].Abilities[0]; - do PID = PKX.getRandomPID(Species, Gender, Version, Nature, AltForm, PID); while (!IsShiny); - return pk; - } protected void TransferPropertiesWithReflection(PKM Source, PKM Destination) { var SourceProperties = ReflectUtil.getPropertiesCanWritePublic(Source.GetType()); diff --git a/PKHeX/PKM/PKMConverter.cs b/PKHeX/PKM/PKMConverter.cs index 7c9551bb2..a09c5623a 100644 --- a/PKHeX/PKM/PKMConverter.cs +++ b/PKHeX/PKM/PKMConverter.cs @@ -160,7 +160,7 @@ public static PKM convertToFormat(PKM pk, Type PKMType, out string comment) break; } if (toFormat == 7) - pkm = null; // pkm.convertPK1toPK7(); + pkm = ((PK1) pk).convertToPK7(); break; case nameof(PK2): if (PKMType == typeof (PK1)) diff --git a/PKHeX/PKM/PKX.cs b/PKHeX/PKM/PKX.cs index 274ef7c92..3e82dc293 100644 --- a/PKHeX/PKM/PKX.cs +++ b/PKHeX/PKM/PKX.cs @@ -2408,6 +2408,14 @@ public static string getG1Str(byte[] strdata, bool jp) .Aggregate("", (current, cur) => current + cur); } + public static string getG1ConvertedString(byte[] strdata, bool jp) + { + var us_table = new ushort[] { 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0000, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059, 0x005A, 0x0028, 0x0029, 0x003A, 0x003B, 0x0028, 0x0029, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007A, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x00C4, 0x00D6, 0x00DC, 0x00E4, 0x00F6, 0x00FC, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0050, 0x004D, 0x002D, 0x0020, 0x0020, 0x003F, 0x0021, 0x002D, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0xE08E, 0x0020, 0x0078, 0x002E, 0x002F, 0x002C, 0xE08F, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020 }; + var jp_table = new ushort[] { 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x30AC, 0x30AE, 0x30B0, 0x30B2, 0x30B4, 0x30B6, 0x30B8, 0x30BA, 0x30BC, 0x30BE, 0x30C0, 0x30C2, 0x30C5, 0x30C7, 0x30C9, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x30D0, 0x30D3, 0x30D6, 0x30DC, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x304C, 0x304E, 0x3050, 0x3052, 0x3054, 0x3056, 0x3058, 0x305A, 0x305C, 0x305E, 0x3060, 0x3062, 0x3065, 0x3067, 0x3069, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3070, 0x3073, 0x3076, 0x30D9, 0x307C, 0x3000, 0x30D1, 0x30D4, 0x30D7, 0x30DD, 0x3071, 0x3074, 0x3077, 0x30DA, 0x307D, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x0000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x30A2, 0x30A4, 0x30A6, 0x30A8, 0x30AA, 0x30AB, 0x30AD, 0x30AF, 0x30B1, 0x30B3, 0x30B5, 0x30B7, 0x30B9, 0x30BB, 0x30BD, 0x30BF, 0x30C1, 0x30C4, 0x30C6, 0x30C8, 0x30CA, 0x30CB, 0x30CC, 0x30CD, 0x30CE, 0x30CF, 0x30D2, 0x30D5, 0x30DB, 0x30DE, 0x30DF, 0x30E0, 0x30E1, 0x30E2, 0x30E4, 0x30E6, 0x30E8, 0x30E9, 0x30EB, 0x30EC, 0x30ED, 0x30EF, 0x30F2, 0x30F3, 0x30C3, 0x30E3, 0x30E5, 0x30E7, 0x30A3, 0x3042, 0x3044, 0x3046, 0x3048, 0x304A, 0x304B, 0x304D, 0x304F, 0x3051, 0x3053, 0x3055, 0x3057, 0x3059, 0x305B, 0x305D, 0x305F, 0x3061, 0x3064, 0x3066, 0x3068, 0x306A, 0x306B, 0x306C, 0x306D, 0x306E, 0x306F, 0x3072, 0x3075, 0x30D8, 0x307B, 0x307E, 0x307F, 0x3080, 0x3081, 0x3082, 0x3084, 0x3086, 0x3088, 0x3089, 0x30EA, 0x308B, 0x308C, 0x308D, 0x308F, 0x3092, 0x3093, 0x3063, 0x3083, 0x3085, 0x3087, 0x30FC, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x30A1, 0x30A5, 0x30A7, 0x3000, 0x3000, 0x3000, 0x2642, 0x3000, 0x3000, 0x3000, 0x3000, 0x30A9, 0x2640, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000 }; + var table = jp ? jp_table : us_table; + return Util.TrimFromZero(new string(strdata.Select(b => (char)table[b]).ToArray())); + } + public static byte[] setG1Str(string str, bool jp) { Dictionary dict = jp ? U2RBY_J : U2RBY_U; diff --git a/PKHeX/Resources/text/en/text_Games_en.txt b/PKHeX/Resources/text/en/text_Games_en.txt index 6bb903c29..d448fbd61 100644 --- a/PKHeX/Resources/text/en/text_Games_en.txt +++ b/PKHeX/Resources/text/en/text_Games_en.txt @@ -29,4 +29,11 @@ OR Sun -Moon \ No newline at end of file +Moon + + +Go +Red +Blue +Green +Yellow \ No newline at end of file diff --git a/PKHeX/Saves/SAV7.cs b/PKHeX/Saves/SAV7.cs index f38d0866d..838bf0404 100644 --- a/PKHeX/Saves/SAV7.cs +++ b/PKHeX/Saves/SAV7.cs @@ -85,7 +85,7 @@ public SAV7(byte[] data = null) public override int MaxItemID => 920; public override int MaxAbilityID => 232; public override int MaxBallID => 0x1A; // 26 - public override int MaxGameID => 31; // MN + public override int MaxGameID => 38; // Yellow VC public int QRSaveData; diff --git a/PKHeX/Util/DataUtil.cs b/PKHeX/Util/DataUtil.cs index c052027c9..768f2357c 100644 --- a/PKHeX/Util/DataUtil.cs +++ b/PKHeX/Util/DataUtil.cs @@ -205,12 +205,23 @@ public static List getOffsetCBList(List cbList, string[] i Array.Copy(unsortedChoices, sortedChoices, unsortedChoices.Length); Array.Sort(sortedChoices); + var indices = new Dictionary(); + foreach (var str in unsortedChoices.Where(str => !indices.ContainsKey(str))) + indices.Add(str, 0); + // Add the rest of the items - cbList.AddRange(sortedChoices.Select(s => new ComboItem + foreach (var s in sortedChoices) { - Text = s, - Value = allowed[Array.IndexOf(unsortedChoices, s)] - })); + var index = Array.IndexOf(unsortedChoices, s, indices[s]); + cbList.Add(new ComboItem + { + Text = s, + Value = allowed[index] + }); + indices[s] = index + 1; + } + + return cbList; } public static List getVariedCBList(string[] inStrings, int[] stringNum, int[] stringVal)