Esempio n. 1
0
        private static byte[] GetZoneBytes(EncounterTable8 zone, IReadOnlyDictionary <ulong, byte> zoneLoc)
        {
            byte locID = zoneLoc[zone.ZoneID];
            var  list  = new List <Slot8>();

            for (int i = 0; i < zone.SubTables.Length; i++)
            {
                var weather = (SWSHEncounterType)(1 << i);
                var table   = zone.SubTables[i];
                var min     = table.LevelMin;
                var max     = table.LevelMax;
                foreach (var s in table.Slots)
                {
                    var s8 = new Slot8(s.Species, s.Form, min, max)
                    {
                        EncounterType = weather
                    };
                    var match = list.Find(z => z.Equals(s8));
                    if (match == null)
                    {
                        list.Add(s8);
                    }
                    else
                    {
                        match.EncounterType |= weather;
                    }
                }
            }

            return(SerializeSlot8(locID, list));
        }
Esempio n. 2
0
        private static DumpableLocation GetDumpable(EncounterTable8 zone, IReadOnlyDictionary <ulong, byte> zoneLoc)
        {
            // Don't dump data that we can't correlate to a zone
            if (!zoneLoc.TryGetValue(zone.ZoneID, out var tmp))
            {
                return(DumpableLocation.Empty);
            }

            byte locID = tmp;
            var  list  = new List <Slot8>();

            for (int i = 0; i < zone.SubTables.Length; i++)
            {
                var weather = (SWSHEncounterType)(1 << i);
                var table   = zone.SubTables[i];
                var min     = table.LevelMin;
                var max     = table.LevelMax;
                foreach (var s in table.Slots)
                {
                    if (s.Species == 0)
                    {
                        continue;
                    }

                    var s8 = new Slot8(s.Species, s.Form, min, max)
                    {
                        EncounterType = weather
                    };
                    var match = list.Find(z => z.Equals(s8));
                    if (match == null)
                    {
                        list.Add(s8);
                    }
                    else
                    {
                        match.EncounterType |= weather;
                    }
                }
            }

            return(new DumpableLocation(list, locID));
        }