Exemplo n.º 1
0
        private static CheckMoveResult[] ParseMovesIsEggPreRelearn(PKM pkm, int[] Moves, int[] SpecialMoves, bool allowinherited, EncounterEgg e)
        {
            CheckMoveResult[] res = new CheckMoveResult[4];

            var baseEggMoves = Legal.GetBaseEggMoves(pkm, e.Species, e.Game, pkm.GenNumber < 4 ? 5 : 1)?.ToList() ?? new List <int>();
            // Level up moves cannot be inherited if Ditto is parent, thus genderless/single gender species cannot have level up moves as an egg
            bool AllowLvlMoves     = pkm.PersonalInfo.Gender > 0 && pkm.PersonalInfo.Gender < 255 || Legal.MixedGenderBreeding.Contains(e.Species);
            var  InheritedLvlMoves = !AllowLvlMoves? new List <int>() : Legal.GetBaseEggMoves(pkm, e.Species, e.Game, 100)?.ToList() ?? new List <int>();

            InheritedLvlMoves.RemoveAll(x => baseEggMoves.Contains(x));

            var infoset = new MoveInfoSet
            {
                EggMoves       = Legal.GetEggMoves(pkm, e.Species, pkm.AltForm)?.ToList() ?? new List <int>(),
                TutorMoves     = e.Game == GameVersion.C ? Legal.GetTutorMoves(pkm, pkm.Species, pkm.AltForm, false, 2)?.ToList() : new List <int>(),
                TMHMMoves      = Legal.GetTMHM(pkm, pkm.Species, pkm.AltForm, pkm.GenNumber, e.Game, false)?.ToList(),
                LvlMoves       = InheritedLvlMoves,
                BaseMoves      = baseEggMoves,
                SpecialMoves   = SpecialMoves.Where(m => m != 0).ToList(),
                AllowInherited = allowinherited
            };

            // Only TM Hm moves from the source game of the egg, not any other games from the same generation

            if (pkm.Format > 2 || SpecialMoves.Any())
            {
                // For gen 2 is not possible to difference normal eggs from event eggs
                // If there is no special moves assume normal egg
                res = VerifyPreRelearnEggBase(pkm, Moves, infoset, e.Game);
            }
            else if (pkm.Format == 2)
            {
                infoset.SpecialMoves.Clear();
                infoset.AllowInherited = true;
                res = VerifyPreRelearnEggBase(pkm, Moves, infoset, e.Game);
            }

            return(res);
        }
Exemplo n.º 2
0
        /* Similar to verifyRelearnEgg but in pre relearn generation is the moves what should match the expected order but only if the pokemon is inside an egg */
        private static CheckMoveResult[] VerifyPreRelearnEggBase(PKM pkm, int[] Moves, MoveInfoSet infoset, GameVersion ver)
        {
            CheckMoveResult[] res = new CheckMoveResult[4];
            var gen = pkm.GenNumber;
            // Obtain level1 moves
            int baseCt = infoset.BaseMoves.Count;

            if (baseCt > 4)
            {
                baseCt = 4;
            }

            // Obtain Inherited moves
            var inherited = Moves.Where(m => m != 0 && (!infoset.BaseMoves.Contains(m) || infoset.SpecialMoves.Contains(m) || infoset.EggMoves.Contains(m) || infoset.LvlMoves.Contains(m) || infoset.TMHMMoves.Contains(m) || infoset.TutorMoves.Contains(m))).ToList();
            int inheritCt = inherited.Count;

            // Get required amount of base moves
            int unique  = infoset.BaseMoves.Concat(inherited).Distinct().Count();
            int reqBase = inheritCt == 4 || baseCt + inheritCt > 4 ? 4 - inheritCt : baseCt;

            if (Moves.Where(m => m != 0).Count() < Math.Min(4, infoset.BaseMoves.Count))
            {
                reqBase = Math.Min(4, unique);
            }

            var em = string.Empty;

            // Check if the required amount of Base Egg Moves are present.
            for (int i = 0; i < reqBase; i++)
            {
                if (infoset.BaseMoves.Contains(Moves[i]))
                {
                    res[i] = new CheckMoveResult(MoveSource.Initial, gen, Severity.Valid, V179, CheckIdentifier.Move);
                    continue;
                }

                // mark remaining base egg moves missing
                for (int z = i; z < reqBase; z++)
                {
                    res[z] = new CheckMoveResult(MoveSource.Initial, gen, Severity.Invalid, V180, CheckIdentifier.Move);
                }

                // provide the list of suggested base moves for the last required slot
                em = string.Join(", ", infoset.BaseMoves.Select(m => m >= MoveStrings.Length ? V190 : MoveStrings[m]));
                break;
            }

            int moveoffset = reqBase;
            int endSpecial = moveoffset + infoset.SpecialMoves.Count;

            // Check also if the required amount of Special Egg Moves are present, ir are after base moves
            for (int i = moveoffset; i < endSpecial; i++)
            {
                if (infoset.SpecialMoves.Contains(Moves[i]))
                {
                    res[i] = new CheckMoveResult(MoveSource.SpecialEgg, gen, Severity.Valid, V333, CheckIdentifier.Move);
                    continue;
                }

                // Not in special moves, mark remaining special egg moves missing
                for (int z = i; z < endSpecial; z++)
                {
                    res[z] = new CheckMoveResult(MoveSource.SpecialEgg, gen, Severity.Invalid, V342, CheckIdentifier.Move);
                }

                // provide the list of suggested base moves and species moves for the last required slot
                if (!string.IsNullOrEmpty(em))
                {
                    em += ", ";
                }
                else
                {
                    em = string.Join(", ", infoset.BaseMoves.Select(m => m >= MoveStrings.Length ? V190 : MoveStrings[m])) + ", ";
                }
                em += string.Join(", ", infoset.SpecialMoves.Select(m => m >= MoveStrings.Length ? V190 : MoveStrings[m]));
                break;
            }

            if (!string.IsNullOrEmpty(em))
            {
                res[reqBase > 0 ? reqBase - 1 : 0].Comment = string.Format(Environment.NewLine + V343, em);
            }
            // Non-Base moves that can magically appear in the regular movepool
            if (pkm.GenNumber >= 3 && Legal.LightBall.Contains(pkm.Species))
            {
                infoset.EggMoves.Add(344);
            }

            // Inherited moves appear after the required base moves.
            var AllowInheritedSeverity = infoset.AllowInherited ? Severity.Valid : Severity.Invalid;

            for (int i = reqBase + infoset.SpecialMoves.Count; i < 4; i++)
            {
                if (Moves[i] == 0) // empty
                {
                    res[i] = new CheckMoveResult(MoveSource.None, gen, Severity.Valid, V167, CheckIdentifier.Move);
                }
                else if (infoset.EggMoves.Contains(Moves[i])) // inherited egg move
                {
                    res[i] = new CheckMoveResult(MoveSource.EggMove, gen, AllowInheritedSeverity, infoset.AllowInherited ? V344 : V341, CheckIdentifier.Move);
                }
                else if (infoset.LvlMoves.Contains(Moves[i])) // inherited lvl moves
                {
                    res[i] = new CheckMoveResult(MoveSource.InheritLevelUp, gen, AllowInheritedSeverity, infoset.AllowInherited ? V345 : V347, CheckIdentifier.Move);
                }
                else if (infoset.TMHMMoves.Contains(Moves[i])) // inherited TMHM moves
                {
                    res[i] = new CheckMoveResult(MoveSource.TMHM, gen, AllowInheritedSeverity, infoset.AllowInherited ? V349 : V350, CheckIdentifier.Move);
                }
                else if (infoset.TutorMoves.Contains(Moves[i])) // inherited tutor moves
                {
                    res[i] = new CheckMoveResult(MoveSource.Tutor, gen, AllowInheritedSeverity, infoset.AllowInherited ? V346 : V348, CheckIdentifier.Move);
                }
                else // not inheritable, flag
                {
                    res[i] = new CheckMoveResult(MoveSource.Unknown, gen, Severity.Invalid, V340, CheckIdentifier.Move);
                }
            }

            return(res);
        }