public static IReadOnlyCollection <PBEMove> GetLegalMoves(PBESpecies species, PBEForm form, byte level)
        {
            List <(PBESpecies, PBEForm)> speciesToStealFrom = GetSpecies(species, form);

            var moves = new List <PBEMove>();

            foreach ((PBESpecies spe, PBEForm fo) in speciesToStealFrom)
            {
                IPBEDDPokemonDataExtended pData = PBEDefaultDataProvider.Instance.GetPokemonDataExtended(spe, fo);
                // Disallow moves learned after the current level
                moves.AddRange(pData.LevelUpMoves.Where(t => t.Level <= level).Select(t => t.Move));
                // Disallow form-specific moves from other forms (Rotom)
                moves.AddRange(pData.OtherMoves.Where(t => (spe == species && fo == form) || t.ObtainMethod != PBEDDMoveObtainMethod.Form).Select(t => t.Move));
                // Event Pokémon checking is extremely basic and wrong, but the goal is not to be super restricting or accurate
                if (PBEDDEventPokemon.Events.TryGetValue(spe, out ReadOnlyCollection <PBEDDEventPokemon>?events))
                {
                    // Disallow moves learned after the current level
                    moves.AddRange(events.Where(e => e.Level <= level).SelectMany(e => e.Moves).Where(m => m != PBEMove.None));
                }
                if (moves.FindIndex(m => PBEDataProvider.Instance.GetMoveData(m, cache: false).Effect == PBEMoveEffect.Sketch) != -1)
                {
                    return(PBEDataUtils.SketchLegalMoves);
                }
            }
            return(moves.Distinct().Where(m => PBEDataUtils.IsMoveUsable(m)).ToArray());
        }
예제 #2
0
        public static IEnumerable <PBEMove> GetEggMoves(PBESpecies species, PBEForm form)
        {
            PBEMove[] arr;

            string resource = "Pokedata." + Utils.GetPkmnDirectoryName(species, form) + ".EggMoves.bin";

            using (var r = new EndianBinaryReader(Utils.GetResourceStream(resource)))
            {
                arr = r.ReadEnums <PBEMove>(r.ReadByte());
            }

            return(arr.Where(m => PBEDataUtils.IsMoveUsable(m)).Distinct()); // For now
        }
예제 #3
0
        public static IReadOnlyCollection <PBEMove> GetLegalMoves(PBESpecies species, PBEForm form, byte level, PBESettings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }
            if (!settings.IsReadOnly)
            {
                throw new ArgumentException("Settings must be read-only.", nameof(settings));
            }
            ValidateSpecies(species, form, true);
            ValidateLevel(level, settings);
            List <(PBESpecies, PBEForm)> speciesToStealFrom = GetSpecies(species, form);

            var moves = new List <PBEMove>();

            foreach ((PBESpecies spe, PBEForm fo) in speciesToStealFrom)
            {
                IPBEPokemonData pData = PBEDataProvider.Instance.GetPokemonData(spe, fo);
                // Disallow moves learned after the current level
                moves.AddRange(pData.LevelUpMoves.Where(t => t.Level <= level).Select(t => t.Move));
                // Disallow form-specific moves from other forms (Rotom)
                moves.AddRange(pData.OtherMoves.Where(t => (spe == species && fo == form) || t.ObtainMethod != PBEMoveObtainMethod.Form).Select(t => t.Move));
                // Event Pokémon checking is extremely basic and wrong, but the goal is not to be super restricting or accurate
                if (PBEEventPokemon.Events.TryGetValue(spe, out ReadOnlyCollection <PBEEventPokemon> events))
                {
                    // Disallow moves learned after the current level
                    moves.AddRange(events.Where(e => e.Level <= level).SelectMany(e => e.Moves).Where(m => m != PBEMove.None));
                }
                if (moves.Any(m => PBEDataProvider.Instance.GetMoveData(m, cache: false).Effect == PBEMoveEffect.Sketch))
                {
                    return(PBEDataUtils.SketchLegalMoves);
                }
            }
            return(moves.Distinct().Where(m => PBEDataUtils.IsMoveUsable(m)).ToArray());
        }
예제 #4
0
 public static bool IsMoveUsable(this IPBEMoveData mData)
 {
     return(PBEDataUtils.IsMoveUsable(mData.Effect));
 }