Ejemplo n.º 1
0
        public static void RefreshMGDB(params string[] paths)
        {
            var g4 = GetPCDDB(Util.GetBinaryResource("wc4.pkl"));
            var g5 = GetPGFDB(Util.GetBinaryResource("pgf.pkl"));
            var g6 = GetWC6DB(Util.GetBinaryResource("wc6.pkl"), Util.GetBinaryResource("wc6full.pkl"));
            var g7 = GetWC7DB(Util.GetBinaryResource("wc7.pkl"), Util.GetBinaryResource("wc7full.pkl"));
            var b7 = GetWB7DB(Util.GetBinaryResource("wb7full.pkl"));
            var g8 = GetWC8DB(Util.GetBinaryResource("wc8.pkl"));

            foreach (var gift in paths.Where(Directory.Exists).SelectMany(MysteryUtil.GetGiftsFromFolder))
            {
                switch (gift)
                {
                case PCD pcd: g4.Add(pcd); continue;

                case PGF pgf: g5.Add(pgf); continue;

                case WC6 wc6: g6.Add(wc6); continue;

                case WC7 wc7: g7.Add(wc7); continue;

                case WB7 wb7: b7.Add(wb7); continue;

                case WC8 wc8: g8.Add(wc8); continue;
                }
            }

            MGDB_G3   = Encounter_WC3; // hardcoded
            MGDB_G4   = g4.ToArray();
            MGDB_G5   = g5.ToArray();
            MGDB_G6   = g6.ToArray();
            MGDB_G7   = g7.ToArray();
            MGDB_G7GG = b7.ToArray();
            MGDB_G8   = g8.ToArray();
        }
Ejemplo n.º 2
0
        private static EncounterArea[] GetAreas()
        {
            var red_gw   = EncounterArea.GetArray1_GW(Util.GetBinaryResource("encounter_red.pkl"));
            var blu_gw   = EncounterArea.GetArray1_GW(Util.GetBinaryResource("encounter_blue.pkl"));
            var ylw_gw   = EncounterArea.GetArray1_GW(Util.GetBinaryResource("encounter_yellow.pkl"));
            var rb_fish  = EncounterArea.GetArray1_F(Util.GetBinaryResource("encounter_rb_f.pkl"));
            var ylw_fish = EncounterArea.GetArray1_FY(Util.GetBinaryResource("encounter_yellow_f.pkl"));

            MarkEncountersVersion(red_gw, GameVersion.RD);
            MarkEncountersVersion(blu_gw, GameVersion.BU);
            MarkEncountersVersion(ylw_gw, GameVersion.YW);
            MarkEncountersVersion(rb_fish, GameVersion.RB);
            MarkEncountersVersion(ylw_fish, GameVersion.YW);

            var table = AddExtraTableSlots(red_gw, blu_gw, ylw_gw, rb_fish, ylw_fish);

            Array.Resize(ref table, table.Length + 1);
            table[table.Length - 1] = FishOldGood_RBY;

            foreach (var arr in table)
            {
                foreach (var slot in arr.Slots)
                {
                    slot.Area = arr;
                }
            }
            return(table);
        }
Ejemplo n.º 3
0
        private static EncounterArea1[] GetAreas()
        {
            var red_gw   = EncounterArea1.GetArray1GrassWater(Util.GetBinaryResource("encounter_red.pkl"), 248);
            var blu_gw   = EncounterArea1.GetArray1GrassWater(Util.GetBinaryResource("encounter_blue.pkl"), 248);
            var ylw_gw   = EncounterArea1.GetArray1GrassWater(Util.GetBinaryResource("encounter_yellow.pkl"), 249);
            var rb_fish  = EncounterArea1.GetArray1Fishing(Util.GetBinaryResource("encounter_rb_f.pkl"), 33);
            var ylw_fish = EncounterArea1.GetArray1FishingYellow(Util.GetBinaryResource("encounter_yellow_f.pkl"));

            MarkEncountersVersion(red_gw, RD);
            MarkEncountersVersion(blu_gw, BU);
            MarkEncountersVersion(ylw_gw, YW);
            MarkEncountersVersion(rb_fish, RB);
            MarkEncountersVersion(ylw_fish, YW);

            var table = AddExtraTableSlots(red_gw, blu_gw, ylw_gw, rb_fish, ylw_fish);

            Array.Resize(ref table, table.Length + 1);
            table[table.Length - 1] = FishOldGood_RBY;

            foreach (var arr in table)
            {
                foreach (var slot in arr.Slots)
                {
                    slot.Area = arr;
                }
            }

            return(table);
        }
Ejemplo n.º 4
0
        private static Dictionary <int, MysteryGiftRestriction> GetRestriction(int generation)
        {
            var resource = RestrictionSetName(generation);
            var data     = Util.GetBinaryResource(resource).AsSpan();
            var dict     = new Dictionary <int, MysteryGiftRestriction>();

            for (int i = 0; i < data.Length; i += 8)
            {
                var entry    = data[i..];
Ejemplo n.º 5
0
        private static void PopulateGen4Tutors()
        {
            var tutors = BinLinker.Unpack(Util.GetBinaryResource("tutors_g4.pkl"), "g4");

            for (int i = 0; i < tutors.Length; i++)
            {
                HGSS[i].AddTypeTutors(tutors[i]);
            }
        }
Ejemplo n.º 6
0
        private static void PopulateGen4Tutors()
        {
            var tutors = Data.UnpackMini(Util.GetBinaryResource("tutors_g4.pkl"), "g4");

            for (int i = 0; i <= Legal.MaxSpeciesID_4; i++)
            {
                HGSS[i].AddTypeTutors(tutors[i]);
            }
        }
Ejemplo n.º 7
0
        public static void RefreshMGDB(params string[] paths)
        {
            ICollection <PCD> g4 = GetPCDDB(Util.GetBinaryResource("wc4.pkl"));
            ICollection <PGF> g5 = GetPGFDB(Util.GetBinaryResource("pgf.pkl"));
            ICollection <WC6> g6 = GetWC6DB(Util.GetBinaryResource("wc6.pkl"), Util.GetBinaryResource("wc6full.pkl"));
            ICollection <WC7> g7 = GetWC7DB(Util.GetBinaryResource("wc7.pkl"), Util.GetBinaryResource("wc7full.pkl"));
            ICollection <WB7> b7 = GetWB7DB(Util.GetBinaryResource("wb7full.pkl"));
            ICollection <WC8> g8 = GetWC8DB(Util.GetBinaryResource("wc8.pkl"));

            foreach (var gift in paths.Where(Directory.Exists).SelectMany(MysteryUtil.GetGiftsFromFolder))
            {
Ejemplo n.º 8
0
        private static void PopulateGen3Tutors()
        {
            // Update Gen3 data with Emerald's data, FR/LG is a subset of Emerald's compatibility.
            var TMHM   = Data.UnpackMini(Util.GetBinaryResource("hmtm_g3.pkl"), "g3");
            var tutors = Data.UnpackMini(Util.GetBinaryResource("tutors_g3.pkl"), "g3");

            for (int i = 0; i <= Legal.MaxSpeciesID_3; i++)
            {
                E[i].AddTMHM(TMHM[i]);
                E[i].AddTypeTutors(tutors[i]);
            }
        }
Ejemplo n.º 9
0
        private static Dictionary <int, MysteryGiftRestriction> GetRestriction(int generation)
        {
            var resource = RestrictionSetName(generation);
            var data     = Util.GetBinaryResource(resource);
            var dict     = new Dictionary <int, MysteryGiftRestriction>();

            for (int i = 0; i < data.Length; i += 8)
            {
                int hash     = BitConverter.ToInt32(data, i + 0);
                var restrict = BitConverter.ToInt32(data, i + 4);
                dict.Add(hash, (MysteryGiftRestriction)restrict);
            }
            return(dict);
        }
Ejemplo n.º 10
0
        static EvolutionTree()
        {
            // Evolution tables need Personal Tables initialized beforehand, hence why the EvolutionTree data is initialized here.
            byte[] get(string resource) => Util.GetBinaryResource($"evos_{resource}.pkl");

            byte[][] unpack(string resource) => Data.UnpackMini(get(resource), resource);

            Evolves1 = new EvolutionTree(new[] { get("rby") }, GameVersion.RBY, PersonalTable.Y, Legal.MaxSpeciesID_1);
            Evolves2 = new EvolutionTree(new[] { get("gsc") }, GameVersion.GSC, PersonalTable.C, Legal.MaxSpeciesID_2);
            Evolves3 = new EvolutionTree(new[] { get("g3") }, GameVersion.RS, PersonalTable.RS, Legal.MaxSpeciesID_3);
            Evolves4 = new EvolutionTree(new[] { get("g4") }, GameVersion.DP, PersonalTable.DP, Legal.MaxSpeciesID_4);
            Evolves5 = new EvolutionTree(new[] { get("g5") }, GameVersion.BW, PersonalTable.BW, Legal.MaxSpeciesID_5);
            Evolves6 = new EvolutionTree(unpack("ao"), GameVersion.ORAS, PersonalTable.AO, Legal.MaxSpeciesID_6);
            Evolves7 = new EvolutionTree(unpack("sm"), GameVersion.SM, PersonalTable.SM, Legal.MaxSpeciesID_7);
        }
Ejemplo n.º 11
0
        private static EncounterArea[] GetTables2(GameVersion Version)
        {
            // Fishing
            var f = EncounterArea.GetArray2_F(Util.GetBinaryResource("encounter_gsc_f.pkl"));

            EncounterArea[] Slots = new EncounterArea[0];
            if (Version.Contains(GameVersion.GS))
            {
                Slots = GetSlots_GS(f);
            }
            if (Version.Contains(GameVersion.C))
            {
                Slots = AddExtraTableSlots(Slots, GetSlots_C(f));
            }

            return(Slots);
        }
Ejemplo n.º 12
0
        private static EncounterArea2[] GetTables2(GameVersion Version)
        {
            // Fishing
            var f = EncounterArea2.GetArray2Fishing(Util.GetBinaryResource("encounter_gsc_f.pkl"));

            var Slots = Array.Empty <EncounterArea2>();

            if (Version.Contains(GameVersion.GS))
            {
                Slots = GetSlots_GS(f);
            }
            if (Version.Contains(GameVersion.C))
            {
                Slots = AddExtraTableSlots(Slots, GetSlots_C(f));
            }

            return(Slots);
        }
Ejemplo n.º 13
0
        static EvolutionTree()
        {
            // Evolution tables need Personal Tables initialized beforehand, hence why the EvolutionTree data is initialized here.
            byte[] get(string resource) => Util.GetBinaryResource($"evos_{resource}.pkl");

            byte[][] unpack(string resource) => Data.UnpackMini(get(resource), resource);

            Evolves1 = new EvolutionTree(new[] { get("rby") }, GameVersion.Gen1, PersonalTable.Y, Legal.MaxSpeciesID_1);
            Evolves2 = new EvolutionTree(new[] { get("gsc") }, GameVersion.Gen2, PersonalTable.C, Legal.MaxSpeciesID_2);
            Evolves3 = new EvolutionTree(new[] { get("g3") }, GameVersion.Gen3, PersonalTable.RS, Legal.MaxSpeciesID_3);
            Evolves4 = new EvolutionTree(new[] { get("g4") }, GameVersion.Gen4, PersonalTable.DP, Legal.MaxSpeciesID_4);
            Evolves5 = new EvolutionTree(new[] { get("g5") }, GameVersion.Gen5, PersonalTable.BW, Legal.MaxSpeciesID_5);
            Evolves6 = new EvolutionTree(unpack("ao"), GameVersion.Gen6, PersonalTable.AO, Legal.MaxSpeciesID_6);
            Evolves7 = new EvolutionTree(unpack("uu"), GameVersion.Gen7, PersonalTable.USUM, Legal.MaxSpeciesID_7_USUM);

            // There's always oddballs.
            Evolves7.FixEvoTreeSM();
        }
Ejemplo n.º 14
0
        private static EncounterArea[] GetSlots_C(EncounterArea[] f)
        {
            // Grass/Water
            var c = EncounterArea.GetArray2_GW(Util.GetBinaryResource("encounter_crystal.pkl"));
            // Headbutt/Rock Smash
            var h_c      = EncounterArea.GetArray2_H(Util.GetBinaryResource("encounter_crystal_h.pkl"));
            var safari_c = EncounterSafari_GSC;
            var bcc_c    = EncounterBCC_GSC;

            MarkEncountersVersion(bcc_c, GameVersion.C);
            MarkEncountersVersion(safari_c, GameVersion.C);
            MarkEncountersVersion(f, GameVersion.C);
            MarkEncountersVersion(c, GameVersion.C);
            MarkEncountersVersion(h_c, GameVersion.C);

            var extra = AddExtraTableSlots(c, h_c, f, bcc_c, safari_c);

            return(extra);
        }
Ejemplo n.º 15
0
        public static void RefreshMGDB(params string[] paths)
        {
            var g4 = GetPCDDB(Util.GetBinaryResource("wc4.pkl"));
            var g5 = GetPGFDB(Util.GetBinaryResource("pgf.pkl"));
            var g6 = GetWC6DB(Util.GetBinaryResource("wc6.pkl"), Util.GetBinaryResource("wc6full.pkl"));
            var g7 = GetWC7DB(Util.GetBinaryResource("wc7.pkl"), Util.GetBinaryResource("wc7full.pkl"));
            var b7 = GetWB7DB(Util.GetBinaryResource("wb7full.pkl"));

            foreach (var path in paths.Where(Directory.Exists))
            {
                foreach (var file in Directory.EnumerateFiles(path, "*", SearchOption.AllDirectories))
                {
                    var fi = new FileInfo(file);
                    if (!MysteryGift.IsMysteryGift(fi.Length))
                    {
                        continue;
                    }

                    var gift = MysteryGift.GetMysteryGift(File.ReadAllBytes(file), fi.Extension);
                    switch (gift)
                    {
                    case PCD pcd: g4.Add(pcd); continue;

                    case PGF pgf: g5.Add(pgf); continue;

                    case WC6 wc6: g6.Add(wc6); continue;

                    case WC7 wc7: g7.Add(wc7); continue;

                    case WB7 wb7: b7.Add(wb7); continue;
                    }
                }
            }

            MGDB_G3   = Encounter_WC3; // hardcoded
            MGDB_G4   = g4.ToArray();
            MGDB_G5   = g5.ToArray();
            MGDB_G6   = g6.ToArray();
            MGDB_G7   = g7.ToArray();
            MGDB_G7GG = b7.ToArray();
        }
Ejemplo n.º 16
0
        private static EncounterArea[] GetSlots_GS(EncounterArea[] f)
        {
            // Grass/Water
            var g = EncounterArea.GetArray2_GW(Util.GetBinaryResource("encounter_gold.pkl"));
            var s = EncounterArea.GetArray2_GW(Util.GetBinaryResource("encounter_silver.pkl"));
            // Headbutt/Rock Smash
            var h_g       = EncounterArea.GetArray2_H(Util.GetBinaryResource("encounter_gold_h.pkl"));
            var h_s       = EncounterArea.GetArray2_H(Util.GetBinaryResource("encounter_silver_h.pkl"));
            var safari_gs = EncounterSafari_GSC;
            var bcc_gs    = EncounterBCC_GSC;

            MarkEncountersVersion(bcc_gs, GameVersion.GS);
            MarkEncountersVersion(f, GameVersion.GS);
            MarkEncountersVersion(g, GameVersion.GD);
            MarkEncountersVersion(s, GameVersion.SV);
            MarkEncountersVersion(h_g, GameVersion.GD);
            MarkEncountersVersion(h_s, GameVersion.SV);
            MarkEncountersVersion(safari_gs, GameVersion.GS);

            return(AddExtraTableSlots(g, s, h_g, h_s, f, bcc_gs, safari_gs));
        }
Ejemplo n.º 17
0
 /// <summary>
 /// Direct fetch for <see cref="EncounterArea"/> data; can also be used to fetch supplementary encounter streams.
 /// </summary>
 /// <param name="ident">Unpacking identification ASCII characters (first two bytes of binary)</param>
 /// <param name="resource">Resource name (will be prefixed with "encounter_"</param>
 /// <returns>Array of encounter areas</returns>
 internal static T[] GetEncounterTables <T>(string ident, string resource) where T : EncounterArea32, new()
 {
     byte[] mini = Util.GetBinaryResource($"encounter_{resource}.pkl");
     return(EncounterArea32.GetArray <T>(Data.UnpackMini(mini, ident)));
 }
Ejemplo n.º 18
0
 // Evolution tables need Personal Tables initialized beforehand, hence why the EvolutionTree data is initialized here.
 static byte[] get(string resource) => Util.GetBinaryResource($"evos_{resource}.pkl");
Ejemplo n.º 19
0
 /// <summary>
 /// Direct fetch for <see cref="EncounterArea"/> data; can also be used to fetch supplementary encounter streams.
 /// </summary>
 /// <param name="ident">Unpacking identification ASCII characters (first two bytes of binary)</param>
 /// <param name="resource">Resource name (will be prefixed with "encounter_"</param>
 /// <returns>Array of encounter areas</returns>
 internal static EncounterArea[] GetEncounterTables(string ident, string resource)
 {
     byte[] mini = Util.GetBinaryResource($"encounter_{resource}.pkl");
     return(EncounterArea.GetArray(Data.UnpackMini(mini, ident)));
 }
Ejemplo n.º 20
0
 private static byte[][] Get(string resource, string ident) => BinLinker.Unpack(Util.GetBinaryResource($"encounter_{resource}.pkl"), ident);
Ejemplo n.º 21
0
 /// <summary>
 /// Direct fetch for <see cref="EncounterArea"/> data; can also be used to fetch supplementary encounter streams.
 /// </summary>
 /// <param name="ident">Unpacking identification ASCII characters (first two bytes of binary)</param>
 /// <param name="resource">Resource name (will be prefixed with "encounter_"</param>
 /// <returns>Array of encounter areas</returns>
 internal static T[] GetEncounterTables8 <T>(string ident, string resource) where T : EncounterAreaSH, new()
 {
     byte[] mini = Util.GetBinaryResource($"encounter_{resource}.pkl");
     return(EncounterAreaSH.GetArray <T>(BinLinker.Unpack(mini, ident)));
 }
Ejemplo n.º 22
0
 private static PersonalTable GetTable(string game, GameVersion format)
 {
     return(new PersonalTable(Util.GetBinaryResource($"personal_{game}"), format));
 }
Ejemplo n.º 23
0
 internal static BinLinkerAccessor Get(string resource, string ident) => BinLinkerAccessor.Get(Util.GetBinaryResource($"encounter_{resource}.pkl"), ident);
Ejemplo n.º 24
0
 private static EncounterArea1[] Get(string name, string ident, GameVersion game) =>
 EncounterArea1.GetAreas(BinLinker.Unpack(Util.GetBinaryResource($"encounter_{name}.pkl"), ident), game);