示例#1
0
        private static CheckMoveResult[] ParseMovesForEncounters(PKM pkm, LegalInfo info, IReadOnlyList <int> currentMoves)
        {
            if (pkm.Species == (int)Species.Smeargle)                   // special handling for Smeargle
            {
                return(ParseMovesForSmeargle(pkm, currentMoves, info)); // Smeargle can have any moves except a few
            }
            // gather valid moves for encounter species
            var restrict = new LevelUpRestriction(pkm, info);

            info.EncounterMoves = new ValidEncounterMoves(pkm, restrict, info.EncounterMatch);

            IReadOnlyList <int> defaultG1LevelMoves = Array.Empty <int>();
            IReadOnlyList <int> defaultG2LevelMoves = Array.Empty <int>();
            var  defaultTradeback = pkm.TradebackStatus;
            bool gb  = false;
            int  gen = info.EncounterMatch.Generation;

            if (gen <= 2)
            {
                gb = true;
                defaultG1LevelMoves = info.EncounterMoves.LevelUpMoves[1];
                if (pkm.InhabitedGeneration(2))
                {
                    defaultG2LevelMoves = info.EncounterMoves.LevelUpMoves[2];
                }

                // Generation 1 can have different minimum level in different encounter of the same species; update valid level moves
                UpdateGen1LevelUpMoves(pkm, info.EncounterMoves, restrict.MinimumLevelGen1, gen, info);

                // The same for Generation 2; if move reminder from Stadium 2 is not allowed
                if (!ParseSettings.AllowGen2MoveReminder(pkm) && pkm.InhabitedGeneration(2))
                {
                    UpdateGen2LevelUpMoves(pkm, info.EncounterMoves, restrict.MinimumLevelGen2, gen, info);
                }
            }

            var res = info.Generation < 6
                ? ParseMovesPre3DS(pkm, currentMoves, info)
                : ParseMoves3DS(pkm, currentMoves, info);

            if (res.All(x => x.Valid))
            {
                return(res);
            }

            // not valid
            if (gb) // restore generation 1 and 2 moves
            {
                info.EncounterMoves.LevelUpMoves[1] = defaultG1LevelMoves;
                if (pkm.InhabitedGeneration(2))
                {
                    info.EncounterMoves.LevelUpMoves[2] = defaultG2LevelMoves;
                }
            }
            pkm.TradebackStatus = defaultTradeback;
            return(res);
        }
示例#2
0
        public ValidEncounterMoves(PKM pkm, LevelUpRestriction restrict, IEncounterable encounter)
        {
            var level = MoveList.GetValidMovesAllGens(pkm, restrict.EvolutionChains, minLvLG1: restrict.MinimumLevelGen1, minLvLG2: restrict.MinimumLevelGen2, Tutor: false, Machine: false, RemoveTransferHM: false);

            if (level[encounter.Generation] is List <int> x)
            {
                AddEdgeCaseMoves(x, encounter, pkm);
            }

            LevelUpMoves = level;
            TMHMMoves    = MoveList.GetValidMovesAllGens(pkm, restrict.EvolutionChains, LVL: false, Tutor: false, MoveReminder: false, RemoveTransferHM: false);
            TutorMoves   = MoveList.GetValidMovesAllGens(pkm, restrict.EvolutionChains, LVL: false, Machine: false, MoveReminder: false, RemoveTransferHM: false);
        }
示例#3
0
        public ValidEncounterMoves(PKM pkm, LevelUpRestriction restrict, IEncounterable encounter)
        {
            var level = MoveList.GetValidMovesAllGens(pkm, restrict.EvolutionChains, minLvLG1: restrict.MinimumLevelGen1, minLvLG2: restrict.MinimumLevelGen2, types: MoveSourceType.Encounter, RemoveTransferHM: false);

            int gen = encounter.Generation;

            if ((uint)gen < level.Length && level[gen] is List <int> x)
            {
                AddEdgeCaseMoves(x, encounter, pkm);
            }

            LevelUpMoves = level;
            TMHMMoves    = MoveList.GetValidMovesAllGens(pkm, restrict.EvolutionChains, types: MoveSourceType.AllMachines);
            TutorMoves   = MoveList.GetValidMovesAllGens(pkm, restrict.EvolutionChains, types: MoveSourceType.AllTutors);
        }
示例#4
0
 public ValidEncounterMoves(PKM pkm, LevelUpRestriction restrict)
 {
     LevelUpMoves = Legal.GetValidMovesAllGens(pkm, restrict.EvolutionChains, minLvLG1: restrict.MinimumLevelGen1, minLvLG2: restrict.MinimumLevelGen2, Tutor: false, Machine: false, RemoveTransferHM: false);
     TMHMMoves    = Legal.GetValidMovesAllGens(pkm, restrict.EvolutionChains, LVL: false, Tutor: false, MoveReminder: false, RemoveTransferHM: false);
     TutorMoves   = Legal.GetValidMovesAllGens(pkm, restrict.EvolutionChains, LVL: false, Machine: false, MoveReminder: false, RemoveTransferHM: false);
 }