コード例 #1
0
        protected void CopyUpEvolutionsHelper(Action <Pokemon> bpAction, Action <Pokemon, Pokemon, bool> epAction)
        {
            foreach (var pk in ValidPokemons)
            {
                if (pk != null)
                {
                    pk.TemporaryFlag = false;
                }
            }

            //  Get evolution data.
            var dontCopyPokes = RomFunctions.GetBasicOrNoCopyPokemon(ValidPokemons);
            var middleEvos    = RomFunctions.GetMiddleEvolutions(ValidPokemons);

            foreach (var pk in dontCopyPokes)
            {
                bpAction(pk);
                pk.TemporaryFlag = true;
            }

            //  go "up" evolutions looking for pre-evos to do first
            foreach (var pk in ValidPokemons)
            {
                if (pk == null || pk.TemporaryFlag)
                {
                    continue;
                }

                //  Non-randomized pokes at this point must have
                //  a linear chain of single evolutions down to
                //  a randomized poke.
                var currentStack = new Stack <Evolution>();
                var ev           = pk.EvolutionsTo[0];
                while (!ev.From.TemporaryFlag)
                {
                    currentStack.Push(ev);
                    ev = ev.From.EvolutionsTo[0];
                }

                //  Now "ev" is set to an evolution from a Pokemon that has had
                //  the base action done on it to one that hasn't.
                //  Do the evolution action for everything left on the stack.
                epAction(ev.From, ev.To, !middleEvos.Contains(ev.To));
                ev.To.TemporaryFlag = true;
                while (currentStack.Count != 0)
                {
                    ev = currentStack.Pop();
                    epAction(ev.From, ev.To, !middleEvos.Contains(ev.To));
                    ev.To.TemporaryFlag = true;
                }
            }
        }