Ejemplo n.º 1
0
 public static EncounterArea[] getArray(byte[][] entries)
 {
     EncounterArea[] data = new EncounterArea[entries.Length];
     for (int i = 0; i < data.Length; i++)
     {
         data[i] = new EncounterArea(entries[i]);
     }
     return(data);
 }
        public static EncounterArea[] getArray(byte[][] entries)
        {
            if (entries == null)
                return null;

            EncounterArea[] data = new EncounterArea[entries.Length];
            for (int i = 0; i < data.Length; i++)
                data[i] = new EncounterArea(entries[i]);
            return data;
        }
Ejemplo n.º 3
0
 private static EncounterArea[] getDexNavSlots(EncounterArea[] GameSlots)
 {
     EncounterArea[] eA = new EncounterArea[GameSlots.Length];
     for (int i = 0; i < eA.Length; i++)
     {
         eA[i]       = GameSlots[i];
         eA[i].Slots = eA[i].Slots.Take(20).Concat(eA[i].Slots.Skip(25)).ToArray(); // Skip 5 Rock Smash slots.
     }
     return(eA);
 }
Ejemplo n.º 4
0
 private static EncounterArea[] addExtraTableSlots(EncounterArea[] GameSlots, EncounterArea[] SpecialSlots)
 {
     foreach (EncounterArea g in GameSlots)
     {
         EncounterArea slots = SpecialSlots.FirstOrDefault(l => l.Location == g.Location);
         if (slots != null)
         {
             g.Slots = g.Slots.Concat(slots.Slots).ToArray();
         }
     }
     return(GameSlots);
 }
Ejemplo n.º 5
0
        internal static EncounterSlot[] getValidEncounterSlots(PK6 pk6, EncounterArea loc)
        {
            // Get Valid levels
            DexLevel[] vs = getValidPreEvolutions(pk6);
            // Get slots where pokemon can exist
            EncounterSlot[] slots = loc.Slots.Where(slot => vs.Any(evo => evo.Species == slot.Species && evo.Level >= slot.LevelMin)).ToArray();

            // Filter for Form Specific
            if (WildForms.Contains(pk6.Species))
            {
                slots = slots.Where(slot => slot.Form == pk6.AltForm).ToArray();
            }
            return(slots);
        }
Ejemplo n.º 6
0
 private static EncounterArea[] getDexNavSlots(EncounterArea[] GameSlots)
 {
     EncounterArea[] eA = new EncounterArea[GameSlots.Length];
     for (int i = 0; i < eA.Length; i++)
     {
         eA[i] = new EncounterArea {
             Location = GameSlots[i].Location, Slots = GameSlots[i].Slots
         };
         eA[i].Slots = eA[i].Slots.Where(s => s.Type != SlotType.Rock_Smash).ToArray(); // Skip Rock Smash slots.
         foreach (var slot in eA[i].Slots)
         {
             slot.DexNav = true;
         }
     }
     return(eA);
 }
Ejemplo n.º 7
0
        private static EncounterArea[] getEncounterTables(GameVersion Game)
        {
            string ident = null;

            byte[] tables = null;
            switch (Game)
            {
            case GameVersion.X:
                ident  = "xy";
                tables = Properties.Resources.encounter_x;
                break;

            case GameVersion.Y:
                ident  = "xy";
                tables = Properties.Resources.encounter_y;
                break;

            case GameVersion.AS:
                ident  = "ao";
                tables = Properties.Resources.encounter_a;
                break;

            case GameVersion.OR:
                ident  = "ao";
                tables = Properties.Resources.encounter_o;
                break;

            case GameVersion.SN:
                ident  = "sm";
                tables = Properties.Resources.encounter_sn;
                break;

            case GameVersion.MN:
                ident  = "sm";
                tables = Properties.Resources.encounter_mn;
                break;
            }
            if (ident == null)
            {
                return(null);
            }

            return(EncounterArea.getArray(Data.unpackMini(tables, ident)));
        }
Ejemplo n.º 8
0
        private static IEnumerable <EncounterSlot> getValidEncounterSlots(PK6 pk6, EncounterArea loc, bool DexNav)
        {
            // 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));

            // Filter for Met Level
            int lvl = pk6.Met_Level;

            slots = DexNav
                ? slots.Where(slot => slot.LevelMin <= lvl && lvl <= slot.LevelMax + 30) // DexNav Boost Range ??
                : slots.Where(slot => slot.LevelMin <= lvl && lvl <= slot.LevelMax);     // Non-boosted Level

            // Filter for Form Specific
            if (WildForms.Contains(pk6.Species))
            {
                slots = slots.Where(slot => slot.Form == pk6.AltForm);
            }
            return(slots);
        }
Ejemplo n.º 9
0
 private static EncounterArea[] getEncounterTables(byte[] mini, string ident)
 {
     return(EncounterArea.getArray(Data.unpackMini(mini, ident)));
 }
Ejemplo n.º 10
0
        private static IEnumerable <EncounterSlot> getValidEncounterSlots(PKM pkm, EncounterArea loc, bool DexNav, bool ignoreLevel = false)
        {
            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(pkm);
            // 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) || ignoreLevel);

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

            // Pressure Slot
            EncounterSlot slotMax = encounterSlots.OrderByDescending(slot => slot.LevelMax).FirstOrDefault();

            if (slotMax != null)
            {
                slotMax = new EncounterSlot(slotMax)
                {
                    Pressure = true, Form = pkm.AltForm
                }
            }
            ;

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

            List <EncounterSlot> eslots = encounterSlots.Where(slot => !WildForms.Contains(pkm.Species) || slot.Form == pkm.AltForm).ToList();

            if (slotMax != null)
            {
                eslots.Add(slotMax);
            }
            foreach (EncounterSlot s in eslots)
            {
                bool          nav  = s.AllowDexNav && (pkm.RelearnMove1 != 0 || pkm.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);
        }
Ejemplo n.º 11
0
        static Legal() // Setup
        {
            StaticX = getSpecial(GameVersion.X);
            StaticY = getSpecial(GameVersion.Y);
            StaticA = getSpecial(GameVersion.AS);
            StaticO = getSpecial(GameVersion.OR);

            var XSlots = EncounterArea.getArray(Data.unpackMini(Properties.Resources.encounter_x, "xy"));
            var YSlots = EncounterArea.getArray(Data.unpackMini(Properties.Resources.encounter_y, "xy"));

            // Mark Horde Encounters
            foreach (var area in XSlots)
            {
                int slotct = area.Slots.Length;
                for (int i = slotct - 15; i < slotct; i++)
                {
                    area.Slots[i].Type = SlotType.Horde;
                }
            }
            foreach (var area in YSlots)
            {
                int slotct = area.Slots.Length;
                for (int i = slotct - 15; i < slotct; i++)
                {
                    area.Slots[i].Type = SlotType.Horde;
                }
            }
            SlotsX = addXYAltTiles(XSlots, SlotsXYAlt);
            SlotsY = addXYAltTiles(YSlots, SlotsXYAlt);

            SlotsA = EncounterArea.getArray(Data.unpackMini(Properties.Resources.encounter_a, "ao"));
            SlotsO = EncounterArea.getArray(Data.unpackMini(Properties.Resources.encounter_o, "ao"));

            // Mark Rock Smash Encounters
            foreach (var area in SlotsA)
            {
                for (int i = 32; i < 37; i++)
                {
                    area.Slots[i].Type = SlotType.Rock_Smash;
                }
                int slotct = area.Slots.Length;
                for (int i = slotct - 15; i < slotct; i++)
                {
                    area.Slots[i].Type = SlotType.Horde;
                }
            }
            foreach (var area in SlotsO)
            {
                for (int i = 32; i < 37; i++)
                {
                    area.Slots[i].Type = SlotType.Rock_Smash;
                }
                int slotct = area.Slots.Length;
                for (int i = slotct - 15; i < slotct; i++)
                {
                    area.Slots[i].Type = SlotType.Horde;
                }
            }

            DexNavA = getDexNavSlots(SlotsA);
            DexNavO = getDexNavSlots(SlotsO);
        }
Ejemplo n.º 12
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;
        }
Ejemplo n.º 13
0
 private static EncounterArea[] addXYAltTiles(EncounterArea[] GameSlots, EncounterArea[] SpecialSlots)
 {
     foreach (EncounterArea g in GameSlots)
     {
         EncounterArea slots = SpecialSlots.FirstOrDefault(l => l.Location == g.Location);
         if (slots != null)
             g.Slots = g.Slots.Concat(slots.Slots).ToArray();
     }
     return GameSlots;
 }
Ejemplo n.º 14
0
 private static void MarkG6XYSlots(ref EncounterArea[] Areas)
 {
     foreach (var area in Areas)
     {
         int slotct = area.Slots.Length;
         for (int i = slotct - 15; i < slotct; i++)
             area.Slots[i].Type = SlotType.Horde;
     }
 }
Ejemplo n.º 15
0
        private static void MarkG6AOSlots(ref EncounterArea[] Areas)
        {
            foreach (var area in Areas)
            {
                for (int i = 32; i < 37; i++)
                    area.Slots[i].Type = SlotType.Rock_Smash;
                int slotct = area.Slots.Length;
                for (int i = slotct - 15; i < slotct; i++)
                    area.Slots[i].Type = SlotType.Horde;

                for (int i = 0; i < slotct; i++)
                    area.Slots[i].AllowDexNav = area.Slots[i].Type != SlotType.Rock_Smash;
            }
        }