Ejemplo n.º 1
0
 public LevelUpRestriction(PKM pkm, LegalInfo info)
 {
     MinimumLevelGen1 = pkm.GenNumber <= 2 ? info.EncounterMatch.LevelMin + 1 : 0;
     MinimumLevelGen2 = ParseSettings.AllowGen2MoveReminder(pkm) ? 1 : info.EncounterMatch.LevelMin + 1;
     EncounterSpecies = info.EncounterMatch.Species;
     EvolutionChains  = info.EvoChainsAllGens;
 }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
Archivo: Core.cs Proyecto: LLNet/PKHeX
 private static int GetEvoMoveMinLevel2(PKM pkm, int Generation, int minLvLG2, EvoCriteria evo)
 {
     if (Generation != 2 || ParseSettings.AllowGen2MoveReminder(pkm))
     {
         return(1);
     }
     if (evo.MinLevel > 1)
     {
         return(Math.Min(pkm.CurrentLevel, evo.MinLevel));
     }
     return(minLvLG2);
 }
Ejemplo n.º 4
0
 private static int GetEvoMoveMinLevel2(PKM pkm, int generation, int minLvLG2, EvoCriteria evo)
 {
     if (generation != 2 || ParseSettings.AllowGen2MoveReminder(pkm))
     {
         return(1);
     }
     // For evolutions, return the lower of the two; current level should legally be >=
     if (evo.MinLevel > 1)
     {
         return(Math.Min(pkm.CurrentLevel, evo.MinLevel));
     }
     return(minLvLG2);
 }
Ejemplo n.º 5
0
        private static CheckMoveResult[] ParseMovesPre3DS(PKM pkm, IReadOnlyList <int> currentMoves, LegalInfo info)
        {
            if (info.EncounterMatch is EncounterEgg e)
            {
                return(pkm.IsEgg
                    ? ParseMovesIsEggPreRelearn(pkm, currentMoves, e)
                    : ParseMovesWasEggPreRelearn(pkm, currentMoves, info, e));
            }

            int gen = info.EncounterMatch.Generation;

            if (gen <= 2 && (gen == 1 || (gen == 2 && !ParseSettings.AllowGen2MoveReminder(pkm)))) // fixed encounter moves without relearning
            {
                return(ParseMovesGenGB(pkm, currentMoves, info));
            }

            return(ParseMovesSpecialMoveset(pkm, currentMoves, info));
        }
Ejemplo n.º 6
0
        private static CheckMoveResult[] ParseMovesPre3DS(PKM pkm, int[] Moves, LegalInfo info)
        {
            if (pkm.IsEgg && info.EncounterMatch is EncounterEgg egg)
            {
                var SpecialMoves = GetSpecialMoves(info.EncounterMatch);
                return(ParseMovesIsEggPreRelearn(pkm, Moves, SpecialMoves, egg));
            }
            if (info.EncounterMatch is EncounterEgg e)
            {
                return(ParseMovesWasEggPreRelearn(pkm, Moves, info, e));
            }

            int gen = info.EncounterMatch.Generation;

            if (gen <= 2 && (gen == 1 || (gen == 2 && !ParseSettings.AllowGen2MoveReminder(pkm)))) // fixed encounter moves without relearning
            {
                return(ParseMovesGenGB(pkm, Moves, info));
            }

            return(ParseMovesSpecialMoveset(pkm, Moves, info));
        }