private int getPkmnLevelUpMovesCount()
 {
     entry = WinFormsUtil.getIndex(CB_Species);
     byte[] input = files[entry];
     if (input.Length <= 4)
     {
         files[entry] = BitConverter.GetBytes(-1); return;
     }
     pkm = new Learnset7(input);
     return(pkm.Count);
 }
Example #2
0
        public static Learnset[] GetArray(byte[] input, int maxSpecies)
        {
            var data = new Learnset[maxSpecies + 1];

            int offset = 0;

            for (int s = 0; s < data.Length; s++)
            {
                data[s] = new Learnset1(input, ref offset);
            }

            return(data);
        }
Example #3
0
        public async Task <IEnumerable <Learnset> > GetLearnsets(bool edited = false)
        {
            var garcLearnsets = await this.GetGarc(GarcNames.Learnsets, edited : edited);

            var files = await garcLearnsets.GetFiles();

            return(files.Select(f => {
                var l = Learnset.New(this.Version);

                l.Read(f);

                return l;
            }));
        }
    public static void SetMoveShopFlagsAll(this IMoveShop8Mastery shop, Learnset learn, Learnset mastery, int level)
    {
        var possible = shop.MoveShopPermitIndexes;
        var permit   = shop.MoveShopPermitFlags;

        for (int index = 0; index < possible.Length; index++)
        {
            var move    = possible[index];
            var allowed = permit[index];
            if (!allowed)
            {
                continue;
            }

            SetMasteredFlag(shop, learn, mastery, level, index, move);
        }
    }
    public static void SetMasteredFlag(this IMoveShop8Mastery shop, Learnset learn, Learnset mastery, int level, int index, int move)
    {
        if (shop.GetMasteredRecordFlag(index))
        {
            return;
        }

        if (level < (uint)learn.GetMoveLevel(move)) // Can't learn it yet; must purchase.
        {
            shop.SetPurchasedRecordFlag(index, true);
            shop.SetMasteredRecordFlag(index, true);
            return;
        }

        if (level < (uint)mastery.GetMoveLevel(move)) // Can't master it yet; must Seed of Mastery
        {
            shop.SetMasteredRecordFlag(index, true);
        }
    }
Example #6
0
        public void LoadLearnset(Learnset pkm)
        {
            cLearnset = pkm;
            dgv.Rows.Clear();
            if (pkm.Count == 0)
            {
                dgv.CancelEdit();
                return;
            }
            dgv.Rows.Add(pkm.Count);

            // Fill Entries
            for (int i = 0; i < pkm.Count; i++)
            {
                dgv.Rows[i].Cells[0].Value = pkm.Levels[i];
                dgv.Rows[i].Cells[1].Value = movelist[pkm.Moves[i]];
            }

            dgv.CancelEdit();
        }
    public static void SetMoveShopFlags(this IMoveShop8Mastery shop, ReadOnlySpan <int> moves, Learnset learn, Learnset mastery, int level)
    {
        var possible = shop.MoveShopPermitIndexes;
        var permit   = shop.MoveShopPermitFlags;

        foreach (var move in moves)
        {
            var index = possible.IndexOf((ushort)move);
            if (index == -1)
            {
                continue;
            }
            if (!permit[index])
            {
                continue;
            }
            SetMasteredFlag(shop, learn, mastery, level, index, move);
        }
    }
    public static void SetEncounterMasteryFlags(this IMoveShop8Mastery shop, ReadOnlySpan <int> moves, Learnset mastery, int level)
    {
        var possible = shop.MoveShopPermitIndexes;
        var permit   = shop.MoveShopPermitFlags;

        foreach (var move in moves)
        {
            var index = possible.IndexOf((ushort)move);
            if (index == -1)
            {
                continue;
            }
            if (!permit[index])
            {
                continue;
            }

            // If the Pokémon is caught with any move shop move in its learnset
            // and it is high enough level to master it, the game will automatically
            // give it the "Mastered" flag but not the "Purchased" flag
            // For moves that are not in the learnset, it returns -1 which is true, thus set as mastered.
            if (level >= mastery.GetMoveLevel(move))
            {
                shop.SetMasteredRecordFlag(index, true);
            }
        }
    }
Example #9
0
    public static bool IsValidMasteredEncounter(this IMoveShop8Mastery shop, Span <int> moves, Learnset learn, Learnset mastery, int level, ushort alpha, bool allowPurchasedAlpha)
    {
        foreach (var move in moves)
        {
            if (move == 0)
            {
                continue;
            }
            var index = shop.MoveShopPermitIndexes.IndexOf((ushort)move);
            if (index == -1)
            {
                continue; // manually mastered for encounter, not a tutor
            }
            bool p = shop.GetPurchasedRecordFlag(index);
            bool m = shop.GetMasteredRecordFlag(index);

            var masteryLevel = mastery.GetMoveLevel(move);
            if (masteryLevel > level && move != alpha) // no master flag set
            {
                if (!p && m)
                {
                    // Check for seed of mastery usage
                    if (learn.GetMoveLevel(move) > level)
                    {
                        return(false);
                    }
                }
            }
            else
            {
                // Pre 1.1 patch, players could purchase the Alpha Move from the move shop.
                // After the patch, the Alpha Move is considered purchased (even without the flag).
                // Players won't be able to waste money after the patch :)
                // For legality, allow the Alpha Move to be flagged as Purchased if it was a pre-patch capture.
                if (p && (move != alpha || !allowPurchasedAlpha))
                {
                    return(false);
                }
                if (!m)
                {
                    return(false);
                }
            }
        }

        return(true);
    }