示例#1
0
        /// <summary>
        /// Checks supplementary info to see if the encounter is still valid.
        /// </summary>
        /// <remarks>
        /// When an encounter is initially validated, only encounter-related checks are performed.
        /// By checking Moves, Evolution, and <see cref="PIDIV"/> data, a best match encounter can be found.
        /// If the encounter is not valid, the method will not reject it unless another encounter is available to check.
        /// </remarks>
        /// <param name="pkm">Source data to check the match for</param>
        /// <param name="info">Information containing the matched encounter</param>
        /// <param name="iterator">Peekable iterator </param>
        /// <returns>Indication whether or not the encounter passes secondary checks</returns>
        private static bool VerifySecondaryChecks(PKM pkm, LegalInfo info, PeekEnumerator <IEncounterable> iterator)
        {
            if (pkm.Format >= 6)
            {
                info.Relearn = VerifyRelearnMoves.VerifyRelearn(pkm, info);
                if (info.Relearn.Any(z => !z.Valid) && iterator.PeekIsNext())
                {
                    return(false);
                }
            }
            else
            {
                for (int i = 0; i < 4; i++)
                {
                    info.Relearn[i] = new CheckResult(CheckIdentifier.RelearnMove);
                }
            }

            info.Moves = VerifyCurrentMoves.VerifyMoves(pkm, info);
            if (info.Moves.Any(z => !z.Valid) && iterator.PeekIsNext())
            {
                return(false);
            }

            var evo = EvolutionVerifier.VerifyEvolution(pkm, info);

            if (!evo.Valid && iterator.PeekIsNext())
            {
                return(false);
            }
            info.Parse.Add(evo);

            return(true);
        }
示例#2
0
        /// <summary>
        /// Returns legality info for an unmatched encounter scenario, including a hint as to what the actual match could be.
        /// </summary>
        /// <param name="pkm">Source data to check the match for</param>
        /// <param name="info">Information containing the unmatched encounter</param>
        /// <returns>Updated information pertaining to the unmatched encounter</returns>
        private static LegalInfo VerifyWithoutEncounter(PKM pkm, LegalInfo info)
        {
            info.EncounterMatch = new EncounterInvalid(pkm);

            string hint; // hint why an encounter was not found

            if (pkm.WasGiftEgg)
            {
                hint = LEncGift;
            }
            else if (pkm.WasEventEgg)
            {
                hint = LEncGiftEggEvent;
            }
            else if (pkm.WasEvent)
            {
                hint = LEncGiftNotFound;
            }
            else
            {
                hint = LEncInvalid;
            }

            info.Parse.Add(new CheckResult(Severity.Invalid, hint, CheckIdentifier.Encounter));
            info.Relearn = VerifyRelearnMoves.VerifyRelearn(pkm, info);
            info.Moves   = VerifyCurrentMoves.VerifyMoves(pkm, info);
            return(info);
        }
        private static int[] GetNeededMoves(PKM pk, IEnumerable <int> moves, IReadOnlyList <EvoCriteria> chain)
        {
            if (pk.Species == (int)Species.Smeargle)
            {
                return(moves.Intersect(Legal.InvalidSketch).ToArray()); // Can learn anything
            }
            // Roughly determine the generation the PKM is originating from
            var ver    = pk.Version;
            int origin = pk.Generation;

            if (origin < 0)
            {
                origin = ((GameVersion)ver).GetGeneration();
            }

            // Temporarily replace the Version for VC1 transfers, so that they can have VC2 moves if needed.
            bool vcBump = origin == 1 && pk.Format >= 7;

            if (vcBump)
            {
                pk.Version = (int)GameVersion.C;
            }

            var gens     = VerifyCurrentMoves.GetGenMovesCheckOrder(pk, origin);
            var canlearn = gens.SelectMany(z => GetMovesForGeneration(pk, chain, z));
            var result   = moves.Except(canlearn).Where(z => z != 0).ToArray();

            if (vcBump)
            {
                pk.Version = ver;
            }

            return(result);
        }
示例#4
0
        /// <summary>
        /// Returns legality info for an unmatched encounter scenario, including a hint as to what the actual match could be.
        /// </summary>
        /// <param name="pkm">Source data to check the match for</param>
        /// <param name="info">Information containing the unmatched encounter</param>
        /// <returns>Updated information pertaining to the unmatched encounter</returns>
        private static LegalInfo VerifyWithoutEncounter(PKM pkm, LegalInfo info)
        {
            info.EncounterMatch = new EncounterInvalid(pkm);
            string hint = GetHintWhyNotFound(pkm);

            info.Parse.Add(new CheckResult(Severity.Invalid, hint, CheckIdentifier.Encounter));
            info.Relearn = VerifyRelearnMoves.VerifyRelearn(pkm, info);
            info.Moves   = VerifyCurrentMoves.VerifyMoves(pkm, info);
            return(info);
        }
        private static int[] GetNeededMoves(PKM pk, IEnumerable <int> moves, IReadOnlyList <EvoCriteria> dl)
        {
            if (pk.Species == 235)                                      // Smeargle
            {
                return(moves.Intersect(Legal.InvalidSketch).ToArray()); // Can learn anything
            }
            var gens     = VerifyCurrentMoves.GetGenMovesCheckOrder(pk);
            var canlearn = gens.SelectMany(z => Legal.GetValidMoves(pk, dl, z));

            return(moves.Except(canlearn).ToArray());
        }
        /// <summary>
        /// Gets possible encounters that allow all moves requested to be learned.
        /// </summary>
        /// <param name="pk">Rough Pokémon data which contains the requested species, gender, and form.</param>
        /// <param name="moves">Moves that the resulting <see cref="IEncounterable"/> must be able to learn.</param>
        /// <param name="version">Specific version to iterate for.</param>
        /// <returns>A consumable <see cref="IEncounterable"/> list of possible encounters.</returns>
        public static IEnumerable <IEncounterable> GenerateVersionEncounters(PKM pk, IEnumerable <int> moves, GameVersion version)
        {
            pk.Version = (int)version;
            var et = EvolutionTree.GetEvolutionTree(PKX.Generation);
            var dl = et.GetValidPreEvolutions(pk, maxLevel: 100, skipChecks: true);

            var gens     = VerifyCurrentMoves.GetGenMovesCheckOrder(pk);
            var canlearn = gens.SelectMany(z => Legal.GetValidMoves(pk, dl, z));
            var needs    = moves.Except(canlearn).ToArray();

            foreach (var enc in GetPossible(pk, needs, version))
            {
                yield return(enc);
            }
        }
        private static int[] GetNeededMoves(PKM pk, IEnumerable <int> moves, IReadOnlyList <EvoCriteria> chain)
        {
            if (pk.Species == (int)Species.Smeargle)
            {
                return(moves.Intersect(Legal.InvalidSketch).ToArray()); // Can learn anything
            }
            // Roughly determine the generation the PKM is originating from
            int origin = pk.GenNumber;

            if (origin < 0)
            {
                origin = ((GameVersion)pk.Version).GetGeneration();
            }

            var gens     = VerifyCurrentMoves.GetGenMovesCheckOrder(pk, origin);
            var canlearn = gens.SelectMany(z => GetMovesForGeneration(pk, chain, z));

            return(moves.Except(canlearn).Where(z => z != 0).ToArray());
        }