Example #1
0
        internal static Move[] getMoves()
        {
            if (Main.oras)
                CTR.mini.unpackMini(Directory.GetFiles("move")[0], "WD");
            string[] f2 = Directory.GetFiles("move");
            Move[] moves = new Move[f2.Length];
            for (int i = 0; i < f2.Length; i++)
                moves[i] = new Move(File.ReadAllBytes(f2[i]));

            if (Main.oras)
                CTR.mini.packMini("move", "WD", "0", ".bin");

            return moves;
        }
Example #2
0
        private static bool ScreenMoves(int[] moves, int[] Types, Move[] moveData, bool rDMG, int rDMGCount, bool rSTAB, int rSTABCount)
        {
            if (rDMG && rDMGCount > moves.Count(move => moveData[move].Category != 0))
                return false;
            if (rSTAB && rSTABCount > moves.Count(move => Types.Contains(moveData[move].Type)))
                return false;

            return true;
        }
Example #3
0
        internal static int[] getRandomMoves(int[] Types, Move[] moveData, bool rDMG, int rDMGCount, bool rSTAB, int rSTABCount)
        {
            int maxmove = Main.Config.XY ? 617
                : Main.Config.ORAS ? 620
                : 718; // SM
            maxmove += 1;
            int[] moves = new int[4];
            int loopctr = 0;
            const int maxLoop = 666;

            getMoves:
            switch (Main.Config.Generation)
            {
                case 6:
                    for (int i = 0; i < 4; i++)
                        moves[i] = (int)(Util.rnd32() % maxmove);
                    break;

                case 7:
                    int m = 0;
                    while (m != 4)
                    {
                        moves[m] = (int)(Util.rnd32() % maxmove);
                        if (!Legal.Z_Moves.Contains(moves[m]))
                            m++; // Valid
                    }
                    break;

                default:
                    return moves;
            }
            if (loopctr++ < maxLoop || ScreenMoves(moves, Types, moveData, rDMG, rDMGCount, rSTAB, rSTABCount))
                return moves;
            goto getMoves;
        }