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);
            }
        }
    }
    public static void SetMoveShopFlags(this IMoveShop8Mastery shop, PKM pk)
    {
        Span <int> moves = stackalloc int[4];

        pk.GetMoves(moves);
        shop.SetMoveShopFlags(moves, pk);
    }
    public static void SetMoveShopFlagsAll(this IMoveShop8Mastery shop, PKM pk)
    {
        var index   = PersonalTable.LA.GetFormIndex(pk.Species, pk.Form);
        var learn   = Legal.LevelUpLA[index];
        var mastery = Legal.MasteryLA[index];
        var level   = pk.CurrentLevel;

        shop.SetMoveShopFlagsAll(learn, mastery, level);
    }
    public static void ClearMoveShopFlagsMastered(this IMoveShop8Mastery shop)
    {
        var bits = shop.MoveShopPermitFlags;

        for (int i = 0; i < bits.Length; i++)
        {
            shop.SetMasteredRecordFlag(i, false);
        }
    }
Exemple #5
0
    public static void SetMoveShopFlagsMastered(this IMoveShop8Mastery shop)
    {
        var bits = shop.MoveShopPermitFlags;

        for (int i = 0; i < bits.Length; i++)
        {
            shop.SetMasteredRecordFlag(i, shop.GetPurchasedRecordFlag(i));
        }
    }
Exemple #6
0
    public MoveShopEditor(IMoveShop8 s, IMoveShop8Mastery m, PKM pk)
    {
        Entity = s;
        Master = m;
        pkm    = pk;
        InitializeComponent();
        WinFormsUtil.TranslateInterface(this, Main.CurrentLanguage);

        Setup();
        PopulateRecords();
        LoadRecords();
    }
Exemple #7
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);
    }
    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 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 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);
        }
    }