Exemple #1
0
        private static void AddExtraData(SaveFile sav, ConcurrentBag <SlotCache> db)
        {
            var extra = sav.GetExtraSlots(true);

            foreach (var x in extra)
            {
                var pk = x.Read(sav);
                if (pk.Species == 0)
                {
                    continue;
                }

                var result = new SlotCache(x, pk, sav);
                db.Add(result);
            }
        }
Exemple #2
0
        private static void AddPartyData(SaveFile sav, ConcurrentBag <SlotCache> db)
        {
            var pd = sav.PartyData;

            for (var index = 0; index < pd.Count; index++)
            {
                var pk = pd[index];
                if (pk.Species == 0)
                {
                    continue;
                }

                var ident  = new SlotInfoParty(index);
                var result = new SlotCache(ident, pk, sav);
                db.Add(result);
            }
        }
Exemple #3
0
        private static void AddBoxData(SaveFile sav, ConcurrentBag <SlotCache> db)
        {
            var bd  = sav.BoxData;
            var bc  = sav.BoxCount;
            var sc  = sav.BoxSlotCount;
            int ctr = 0;

            for (int box = 0; box < bc; box++)
            {
                for (int slot = 0; slot < sc; slot++, ctr++)
                {
                    var ident  = new SlotInfoBox(box, slot);
                    var result = new SlotCache(ident, bd[ctr], sav);
                    db.Add(result);
                }
            }
        }
Exemple #4
0
        public static void AddBoxData(SaveFile sav, ICollection <SlotCache> db)
        {
            var bd  = sav.BoxData;
            var bc  = sav.BoxCount;
            var sc  = sav.BoxSlotCount;
            int ctr = 0;

            for (int box = 0; box < bc; box++)
            {
                for (int slot = 0; slot < sc; slot++, ctr++)
                {
                    var ident  = new SlotInfoBox(box + 1, slot + 1);
                    var result = new SlotCache(ident, bd[ctr], sav);
                    db.Add(result);
                }
            }
        }
Exemple #5
0
        public static void AddFromLocalFile(string file, ConcurrentBag <SlotCache> db, ITrainerInfo dest, ICollection <string> validExtensions)
        {
            var fi = new FileInfo(file);

            if (!validExtensions.Contains(fi.Extension) || !PKX.IsPKM(fi.Length))
            {
                return;
            }

            var data = File.ReadAllBytes(file);

            _ = FileUtil.TryGetPKM(data, out var pk, fi.Extension, dest);
            if (pk?.Species is not > 0)
            {
                return;
            }

            var info  = new SlotInfoFile(file);
            var entry = new SlotCache(info, pk);

            db.Add(entry);
        }
Exemple #6
0
        public static void AddFromLocalFile(string file, ConcurrentBag <SlotCache> db, ITrainerInfo dest, ICollection <string> validExtensions)
        {
            var fi = new FileInfo(file);

            if (!validExtensions.Contains(fi.Extension) || !PKX.IsPKM(fi.Length))
            {
                return;
            }

            var data   = File.ReadAllBytes(file);
            var prefer = PKX.GetPKMFormatFromExtension(fi.Extension, dest.Generation);
            var pk     = PKMConverter.GetPKMfromBytes(data, prefer);

            if (pk?.Species is not > 0)
            {
                return;
            }

            var info  = new SlotInfoFile(file);
            var entry = new SlotCache(info, pk);

            db.Add(entry);
        }