Esempio n. 1
0
        static void Main(string[] args)
        {
            SquarePool myBoard;

            SquarePool[] pools = new SquarePool[8]
            {
                DataSet.genIpokemon, DataSet.genIcleanedup, DataSet.genIfullyevolved, DataSet.genIIpokemon, GoldSilver.genIIslim, DataSet.genIIIfullyevolved, DataSet.liquidcrystal, RSE.genIIIrse
            };

            int userChoice = 2;

            Console.WriteLine("Pokemon Board Generator\n\n" +
                              "Choose mode:\n" +
                              "   1. Full 151\n" +
                              "   2. Starters Evolved\n" +
                              "   3. All Evolved\n" +
                              "   4. Gen I + II Full\n" +
                              "   5. Gen II Lite - Johto Only for G/S\n" +
                              "   6. Gen III All Evolved\n" +
                              "   7. Liquid Crystal\n" +
                              "   8. R/S/E Full");
            Console.Write("? ");

            try
            {
                userChoice = Convert.ToInt32(Console.ReadLine()) - 1;
            }
            catch
            {
            }
            Console.WriteLine();

            if (userChoice < 0 || userChoice > pools.Length - 1)
            {
                Console.WriteLine("Invalid input. Choosing mode 3.");
                userChoice = 2;
            }
            else
            {
                Console.WriteLine("Mode {0} chosen.", userChoice + 1);
            }

            Console.WriteLine("Generating Pokemon board...");

            BoardGenerator.PickSquares(pools[userChoice], out myBoard, 25, 1);
            string dump = myBoard.JSONout();

            // You can uncomment this if you want to see the board.
            // If you want a surprise, leave it alone!
            //Console.WriteLine(dump);

            Clipboard.SetText(dump);
            Console.WriteLine("Copied board to clipboard!");
            Console.Read();
        }
        public static void PickSquares(SquarePool input, out SquarePool picked, int size, int lMax = 3, int seed = -1)
        {
            SquarePool workingInputPool  = input;
            SquarePool workingOutputPool = new SquarePool();

            workingOutputPool.options = new List <Square>();

            if (seed == -1)
            {
                seed = (int)System.DateTime.UtcNow.Millisecond;
            }

            Random rng = new Random(seed);

            // Pick a Pokemon from the input pool
            int curPokemon;
            int lCount = 0;

            for (int square = 0; square < size; square++)
            {
                curPokemon = rng.Next(0, workingInputPool.options.Count);
                workingOutputPool.options.Add(workingInputPool.options[curPokemon]);

                if (workingInputPool.options[curPokemon].lineage == ObjectiveType.Single)
                {
                    // Non-evolutionary Pokemon just get removed from the input pool
                    workingInputPool.options.RemoveAt(curPokemon);
                }
                else if (workingInputPool.options[curPokemon].lineage == ObjectiveType.Legendary)
                {
                    // Legendaries are limited to lMax value
                    lCount++;
                    if (lCount >= lMax)
                    {
                        workingInputPool.options.RemoveAll(option => option.lineage == ObjectiveType.Legendary);
                    }
                    else
                    {
                        workingInputPool.options.RemoveAt(curPokemon);
                    }
                }
                else
                {
                    // Evolutionary Pokemon get removed with their entire lineage
                    ObjectiveType family = workingInputPool.options[curPokemon].lineage;
                    workingInputPool.options.RemoveAll(option => option.lineage == family);
                }
            }

            picked = workingOutputPool;
        }