private EncounterArea(byte[] data)
 {
     Location = BitConverter.ToUInt16(data, 0);
     Slots = new EncounterSlot[(data.Length - 2) / 4];
     for (int i = 0; i < Slots.Length; i++)
     {
         ushort SpecForm = BitConverter.ToUInt16(data, 2 + i * 4);
         Slots[i] = new EncounterSlot
         {
             Species = SpecForm & 0x7FF,
             Form = SpecForm >> 11,
             LevelMin = data[4 + i * 4],
             LevelMax = data[5 + i * 4],
         };
     }
 }
Пример #2
0
        private static IEnumerable<EncounterSlot> getValidEncounterSlots(PK6 pk6, EncounterArea loc, bool DexNav)
        {
            const int fluteBoost = 4;
            const int dexnavBoost = 30;
            int df = DexNav ? fluteBoost : 0;
            int dn = DexNav ? fluteBoost + dexnavBoost : 0;
            List<EncounterSlot> slotdata = new List<EncounterSlot>();

            // Get Valid levels
            IEnumerable<DexLevel> vs = getValidPreEvolutions(pk6);
            // Get slots where pokemon can exist
            IEnumerable<EncounterSlot> slots = loc.Slots.Where(slot => vs.Any(evo => evo.Species == slot.Species && evo.Level >= slot.LevelMin - df));

            // Filter for Met Level
            int lvl = pk6.Met_Level;
            var encounterSlots = slots.Where(slot => slot.LevelMin - df <= lvl && lvl <= slot.LevelMax + (slot.AllowDexNav ? dn : df)).ToList();

            // Pressure Slot
            EncounterSlot slotMax = encounterSlots.OrderByDescending(slot => slot.LevelMax).FirstOrDefault();
            if (slotMax != null)
                slotMax = new EncounterSlot(slotMax) { Pressure = true, Form = pk6.AltForm };

            if (!DexNav)
            {
                // Filter for Form Specific
                slotdata.AddRange(WildForms.Contains(pk6.Species)
                    ? encounterSlots.Where(slot => slot.Form == pk6.AltForm)
                    : encounterSlots);
                if (slotMax != null)
                    slotdata.Add(slotMax);
                return slotdata;
            }

            List<EncounterSlot> eslots = encounterSlots.Where(slot => !WildForms.Contains(pk6.Species) || slot.Form == pk6.AltForm).ToList();
            if (slotMax != null)
                eslots.Add(slotMax);
            foreach (EncounterSlot s in eslots)
            {
                bool nav = s.AllowDexNav && (pk6.RelearnMove1 != 0 || pk6.AbilityNumber == 4);
                EncounterSlot slot = new EncounterSlot(s) { DexNav = nav };

                if (slot.LevelMin > lvl)
                    slot.WhiteFlute = true;
                if (slot.LevelMax + 1 <= lvl && lvl <= slot.LevelMax + fluteBoost)
                    slot.BlackFlute = true;
                if (slot.LevelMax != lvl && slot.AllowDexNav)
                    slot.DexNav = true;
                slotdata.Add(slot);
            }
            return slotdata;
        }
Пример #3
0
 public EncounterSlot(EncounterSlot template)
 {
     Species = template.Species;
     AllowDexNav = template.AllowDexNav;
     LevelMax = template.LevelMax;
     LevelMin = template.LevelMin;
     Type = template.Type;
     Pressure = template.Pressure;
 }
Пример #4
0
        internal static EncounterSlot[] getValidFriendSafari(PK6 pk6)
        {
            if (!pk6.XY)
                return null;
            if (pk6.Met_Location != 148) // Friend Safari
                return null;
            if (pk6.Met_Level != 30)
                return null;

            IEnumerable<DexLevel> vs = getValidPreEvolutions(pk6);
            List<EncounterSlot> slots = new List<EncounterSlot>();
            foreach (DexLevel d in vs.Where(d => FriendSafari.Contains(d.Species) && d.Level >= 30))
            {
                var slot = new EncounterSlot
                {
                    Species = d.Species,
                    LevelMin = 30,
                    LevelMax = 30,
                    Form = 0,
                    Type = SlotType.FriendSafari,
                };
                slots.Add(slot);
            }

            return slots.Any() ? slots.ToArray() : null;
        }