Ejemplo n.º 1
0
        /// <summary>
        /// Saves all data for the program.
        /// </summary>
        /// <param name="binDestinationPath">Path to save the pickles</param>
        /// <param name="entries">Object containing all encounter data objects</param>
        /// <param name="listJsonPath">Encounter json path to save to. If left null, will not be saved.</param>
        public static void SaveAllData(string binDestinationPath, PogoEncounterList entries, string?listJsonPath = null)
        {
            var clone = JsonConvert.DeserializeObject <PogoEncounterList>(JsonConvert.SerializeObject(entries));

            if (clone is null || clone.Data.Count != entries.Data.Count)
            {
                throw new NullReferenceException("Should have been able to create a clone from original object.");
            }

            clone.Clean();
            if (listJsonPath != null)
            {
                SaveList(listJsonPath, clone);
            }

            clone.Propagate();

            var data = PogoPickler.WritePickle(clone);

            File.WriteAllBytes(Path.Combine(binDestinationPath, "encounter_go_home.pkl"), data);

            var lgpe = PogoPickler.WritePickleLGPE(clone);

            File.WriteAllBytes(Path.Combine(binDestinationPath, "encounter_go_lgpe.pkl"), lgpe);
        }
Ejemplo n.º 2
0
        private static void SaveList(string jsonPath, PogoEncounterList clone)
        {
            var settings = GetSettings();

            settings.Converters.Add(new FlatConverter <PogoEntry>());
            var contents = JsonConvert.SerializeObject(clone, settings);

            File.WriteAllText(jsonPath, contents);
        }
Ejemplo n.º 3
0
        public static void AddRaidBosses(PogoEncounterList list)
        {
            var T1     = new[] { (int)Bulbasaur };
            var T3     = new[] { (int)Bulbasaur };
            var T5     = Array.Empty <int>(); // usually manually added
            var bosses = T1.Concat(T3).Concat(T5);

            foreach (var pkm in bosses)
            {
                var form = pkm switch
                {
                    (int)Rattata => 1,
                    _ => 0,
                };

                var species = list.GetDetails(pkm, form);
                var entry   = new PogoEntry
                {
                    Start = new PogoDate {
                        Y = 2000, M = 1, D = 1
                    },
                    End = new PogoDate {
                        Y = 2000, M = 1, D = 1
                    },
                    Type           = PogoType.Raid,
                    LocalizedStart = true,
                    // NoEndTolerance = true,
                    // Gender = pkm is (int)Frillish ? PogoGender.MaleOnly : PogoGender.Random,
                };

                if (pkm is not((int)Bulbasaur))
                {
                    entry.Shiny = PogoShiny.Random;
                }

                if (T1.Contains(pkm))
                {
                    entry.Comment = "T1 Raid Boss";
                }
                if (T3.Contains(pkm))
                {
                    entry.Comment = "T3 Raid Boss";
                }
                if (T5.Contains(pkm))
                {
                    entry.Comment = "T5 Raid Boss";
                }

                // set debut species, and any of its evolutions, as available
                if (!species.Available)
                {
                    var evos = EvoUtil.GetEvoSpecForms(pkm, form)
                               .Select(z => new { Species = z & 0x7FF, Form = z >> 11 })
                               .Where(z => EvoUtil.IsAllowedEvolution(pkm, form, z.Species, z.Form)).ToArray();

                    foreach (var evo in evos)
                    {
                        var parent = list.GetDetails(evo.Species, evo.Form);
                        if (!parent.Available)
                        {
                            parent.Available = true;
                        }
                    }
                    species.Available = true;
                }
                species.Add(entry);
            }
Ejemplo n.º 4
0
        public static byte[] WritePickle(PogoEncounterList entries)
        {
            var data = GetEntries(entries.Data);

            return(BinLinker.Pack(data, identifier));
        }