Esempio n. 1
0
        /// <summary>
        /// Filter down the gamelist to search based on requested sets
        /// </summary>
        /// <param name="template">Template pokemon with basic details set</param>
        /// <param name="destVer">Version in which the pokemon needs to be imported</param>
        /// <returns>List of filtered games to check encounters for</returns>
        private static GameVersion[] FilteredGameList(PKM template, GameVersion destVer, IReadOnlyList <StringInstruction>?filters)
        {
            var gamelist = GameUtil.GetVersionsWithinRange(template, template.Format).OrderByDescending(c => c.GetGeneration()).ToArray();

            if (filters != null)
            {
                foreach (var f in filters)
                {
                    if (f.PropertyName == nameof(PKM.Version) && int.TryParse(f.PropertyValue, out int gv))
                    {
                        gamelist = f.Evaluator ? new GameVersion[] { (GameVersion)gv }
                    }
                    : gamelist.Where(z => z != (GameVersion)gv).ToArray();
                }
            }
            if (PrioritizeGame)
            {
                gamelist = PrioritizeGameVersion == GameVersion.Any ? PrioritizeVersion(gamelist, destVer) : PrioritizeVersion(gamelist, PrioritizeGameVersion);
            }
            if (template.AbilityNumber == 4 && destVer.GetGeneration() < 8)
            {
                gamelist = gamelist.Where(z => z.GetGeneration() is not 3 and not 4).ToArray();
            }
            return(gamelist);
        }
        private static Learnset GetDeoxysLearn3(int form, GameVersion ver = Any)
        {
            if (ver == Any)
            {
                switch (form)
                {
                case 0: return(LevelUpRS[386]);   // Normal

                case 1: return(LevelUpFR[386]);   // Attack

                case 2: return(LevelUpLG[386]);   // Defense

                case 3: return(LevelUpE[386]);    // Speed

                default: return(null);
                }
            }

            var gen = ver.GetGeneration();

            if (gen != 3)
            {
                return(GetDeoxysLearn3(form));
            }
            return(GameData.GetLearnsets(ver)[386]);
        }
Esempio n. 3
0
 public SimpleTrainerInfo(GameVersion game = GameVersion.SW)
 {
     Game = (int)game;
     if (GameVersion.Gen7b.Contains(game) || game.GetGeneration() >= 8)
     {
         ConsoleRegion = Region = Country = 0;
     }
 }
Esempio n. 4
0
        [InlineData(OR, Rotom, 0, ThunderWave, ThunderShock, ConfuseRay, Discharge)] // no inheriting levelup
        public void CheckBad(GameVersion game, Species species, int form, params Move[] movelist)
        {
            var gen   = game.GetGeneration();
            var moves = GetMoves(movelist);
            var test  = MoveBreed.Process(gen, (int)species, form, game, moves);

            test.Should().BeFalse();
        }
            static IEnumerable <EncounterStatic> GetEvents(GameVersion g)
            {
                if (g.GetGeneration() == 1)
                {
                    return(!ParseSettings.AllowGBCartEra ? Encounters1.StaticEventsVC : Encounters1.StaticEventsGB);
                }

                return(!ParseSettings.AllowGBCartEra ? Encounters2.StaticEventsVC : Encounters2.StaticEventsGB);
            }
Esempio n. 6
0
        public static EggMoves New(GameVersion version)
        {
            switch (version.GetGeneration())
            {
            case GameGeneration.Generation7:
                return(new Gen7.EggMoves(version));

            default:
                return(new Gen6.EggMoves(version));
            }
        }
        public static EvolutionSet New(GameVersion version)
        {
            switch (version.GetGeneration())
            {
            case GameGeneration.Generation7:
                return(new Gen7.EvolutionSet(version));

            default:
                return(new Gen6.EvolutionSet(version));
            }
        }
Esempio n. 8
0
 public SpeciesSetting(GameVersion game)
 {
     Game       = game;
     Generation = Game.GetGeneration();
     Gen1       = Generation <= 1;
     Gen2       = Generation <= 2;
     Gen3       = Generation <= 3;
     Gen4       = Generation <= 4;
     Gen5       = Generation <= 5;
     Gen6       = Generation <= 6;
     Gen7       = Generation <= 7;
 }
Esempio n. 9
0
        private static string MutateOT(string OT, LanguageID?lang, GameVersion game)
        {
            if (game.GetGeneration() >= 8 || lang == null)
            {
                return(OT);
            }
            var full = lang == LanguageID.Japanese || lang == LanguageID.Korean || lang == LanguageID.ChineseS || lang == LanguageID.ChineseT;

            if (full && GlyphLegality.ContainsHalfWidth(OT))
            {
                var max      = Legal.GetMaxLengthOT(game.GetGeneration(), (LanguageID)lang);
                var modified = GlyphLegality.StringConvert(OT, StringConversionType.FullWidth);
                return(modified.Substring(0, Math.Min(modified.Length, max)));
            }
            if (!full && GlyphLegality.ContainsFullWidth(OT))
            {
                var max      = Legal.GetMaxLengthOT(game.GetGeneration(), (LanguageID)lang);
                var modified = GlyphLegality.StringConvert(OT, StringConversionType.HalfWidth);
                return(modified.Substring(0, Math.Min(modified.Length, max)));
            }
            return(OT);
        }
Esempio n. 10
0
        /// <summary>
        /// Checks if the encounter is even valid before processing it
        /// </summary>
        /// <param name="set">showdown set</param>
        /// <param name="enc">encounter object</param>
        /// <param name="isHidden">is HA requested</param>
        /// <param name="destVer">version to generate in</param>
        /// <param name="ver">version of enc/destVer</param>
        /// <returns>if the encounter is valid or not</returns>
        private static bool IsEncounterValid(IBattleTemplate set, IEncounterable enc, bool isHidden, GameVersion destVer, out GameVersion ver)
        {
            // Pokemon who are in games of generation >= 8 can change non HA to HA via a capsule and vice versa
            isHidden = isHidden && destVer.GetGeneration() < 8;

            // initialize out vars (not calculating here to save time)
            ver = GameVersion.Any;

            // Don't process if encounter min level is higher than requested level
            if (enc.LevelMin > set.Level)
            {
                var isRaid = enc is EncounterStatic8N || enc is EncounterStatic8NC || enc is EncounterStatic8ND || enc is EncounterStatic8U;
                if (!isRaid)
                {
                    return(false);
                }
            }

            // Don't process if Hidden Ability is requested and the PKM is from Gen 3 or Gen 4
            var gen = enc.Generation;

            if (isHidden && (uint)(gen - 3) < 2)  // Gen 3 and Gen 4
            {
                return(false);
            }

            // Don't process if requested PKM is Gigantamax but the Game is not SW/SH
            ver = enc is IVersion v ? v.Version : destVer;
            if (set.CanGigantamax && !GameVersion.SWSH.Contains(ver))
            {
                return(false);
            }

            // Don't process if Game is LGPE and requested PKM is not Kanto / Meltan / Melmetal
            // Don't process if Game is SWSH and requested PKM is not from the Galar Dex (Zukan8.DexLookup)
            if (GameVersion.GG.Contains(destVer))
            {
                return(set.Species <= 151 || set.Species == 808 || set.Species == 809);
            }
            if (GameVersion.SWSH.Contains(destVer))
            {
                return(((PersonalInfoSWSH)PersonalTable.SWSH.GetFormeEntry(set.Species, set.FormIndex)).IsPresentInGame || SimpleEdits.Zukan8Additions.Contains(set.Species));
            }
            if (set.Species > destVer.GetMaxSpeciesID())
            {
                return(false);
            }

            // Encounter should hopefully be possible
            return(true);
        }
Esempio n. 11
0
        private static GameVersion[] FilteredGameList(PKM template, GameVersion destVer)
        {
            var gamelist = GameUtil.GetVersionsWithinRange(template, template.Format).OrderByDescending(c => c.GetGeneration()).ToArray();

            if (PrioritizeGame)
            {
                gamelist = PrioritizeGameVersion == GameVersion.Any ? PrioritizeVersion(gamelist, destVer) : PrioritizeVersion(gamelist, PrioritizeGameVersion);
            }
            if (template.AbilityNumber == 4 && destVer.GetGeneration() < 8)
            {
                gamelist = gamelist.Where(z => z.GetGeneration() is not 3 and not 4).ToArray();
            }
            return(gamelist);
        }
Esempio n. 12
0
 public static bool IsWallpaperRed(GameVersion version, int wallpaperID)
 {
     switch (version.GetGeneration())
     {
     case 3:
         if (CXD.Contains(version))
         {
             return(wallpaperID == 7);    // flame pattern in XD
         }
         return(wallpaperID switch
         {
             5 => true,          // Volcano
             13 => E == version, // PokéCenter
             _ => false,
         });
Esempio n. 13
0
        [InlineData(UM, Charmander, 0, Ember, BellyDrum, Scratch, Growl)] // swap order, inherit + egg moves
        public void CheckFix(GameVersion game, Species species, int form, params Move[] movelist)
        {
            var gen   = game.GetGeneration();
            var moves = GetMoves(movelist);

            var test = MoveBreed.Process(gen, (int)species, form, game, moves, out var valid);

            valid.Should().BeFalse();
            var reorder = MoveBreed.GetExpectedMoves(gen, (int)species, form, game, moves, test);

            // fixed order should be different now.
            reorder.SequenceEqual(moves).Should().BeFalse();
            // nonzero move count should be same
            reorder.Count(z => z != 0).Should().IsSameOrEqualTo(moves.Count(z => z != 0));
        }
Esempio n. 14
0
        private static string GetResourceSuffix(GameVersion version, int index)
        {
            switch (version.GetGeneration())
            {
            case 8:
                return("swsh");

            case 7 when !GG.Contains(version):
                return("xy");

            case 6:
                return(ORAS.Contains(version) && index > 16 ? "ao" : "xy");

            case 5:
                return(B2W2.Contains(version) && index > 16 ? "b2w2" : "bw");

            case 4:
                if (index > 16)
                {
                    if (Pt == version)
                    {
                        return("pt");
                    }
                    if (HGSS.Contains(version))
                    {
                        return("hgss");
                    }
                }
                return("dp");

            case 3:
                if (E == version)
                {
                    return("e");
                }
                else if (FRLG.Contains(version) && index > 12)
                {
                    return("frlg");
                }
                else
                {
                    return("rs");
                }

            default:
                return(string.Empty);
            }
        }
Esempio n. 15
0
        public IReadOnlyList <GameVersion> GetVersions(SaveFile SAV, GameVersion fallback)
        {
            if (Version > 0)
            {
                return new[] { (GameVersion)Version }
            }
            ;
            if (Generation != 0)
            {
                return(fallback.GetGeneration() == Generation
                    ? GameUtil.GetVersionsWithinRange(SAV, Generation).ToArray()
                    : GameUtil.GameVersions);
            }

            return(GameUtil.GameVersions);
        }
Esempio n. 16
0
        public void VerifyBreed(GameVersion game, Species species, int form, params Move[] movelist)
        {
            var gen   = game.GetGeneration();
            var moves = GetMoves(movelist);
            var test  = MoveBreed.Process(gen, (int)species, form, game, moves, out var valid);

            valid.Should().BeTrue();

            var x = ((byte[])test);

            if (gen != 2)
            {
                x.SequenceEqual(x.OrderBy(z => z)).Should().BeTrue();
            }
            else
            {
                x.SequenceEqual(x.OrderBy(z => z != (byte)EggSource2.Base)).Should().BeTrue();
            }
        }
Esempio n. 17
0
        public static string MutateNickname(string nick, LanguageID?lang, GameVersion game)
        {
            // Length checks are handled later in SetSpeciesLevel
            if (game.GetGeneration() >= 8 || lang == null)
            {
                return(nick);
            }
            var full = lang == LanguageID.Japanese || lang == LanguageID.Korean || lang == LanguageID.ChineseS || lang == LanguageID.ChineseT;

            if (full && GlyphLegality.ContainsHalfWidth(nick))
            {
                return(GlyphLegality.StringConvert(nick, StringConversionType.FullWidth));
            }
            if (!full && GlyphLegality.ContainsFullWidth(nick))
            {
                return(GlyphLegality.StringConvert(nick, StringConversionType.HalfWidth));
            }
            return(nick);
        }
        public static bool IsWallpaperRed(GameVersion version, int wallpaperID)
        {
            switch (version.GetGeneration())
            {
            case 3:
                if (CXD.Contains(version))
                {
                    return(wallpaperID == 7);    // flame pattern in XD
                }
                switch (wallpaperID)
                {
                case 5:         // Volcano
                    return(true);

                case 13:         // PokéCenter
                    return(E == version);

                default:
                    return(false);
                }

            case 4:
                switch (wallpaperID)
                {
                case 5:         // Volcano
                case 12:        // Checks
                case 13:        // PokéCenter
                case 22:        // Special
                    return(true);

                default:
                    return(false);
                }

            case 5:
                switch (wallpaperID)
                {
                case 5:         // Volcano
                case 12:        // Checks
                    return(true);

                case 19:         // PWT
                case 22:         // Reshiram
                    return(B2W2.Contains(version));

                case 21:         // Zoroark
                case 23:         // Musical
                    return(BW.Contains(version));

                default:
                    return(false);
                }

            case 6:
            case 7:
                switch (wallpaperID)
                {
                case 5:         // Volcano
                case 12:        // PokéCenter
                case 20:        // Special5 Flare/Magma
                    return(true);

                default:
                    return(false);
                }

            default:
                return(false);
            }
        }
Esempio n. 19
0
 public static bool IsWallpaperRed(GameVersion version, int wallpaperID) => version.GetGeneration() switch
 {
     3 when CXD.Contains(version) => wallpaperID == 7, // flame pattern in XD
Esempio n. 20
0
 public static GenerationInfo GetInfo(this GameVersion game) => game.GetGeneration().GetInfo();
Esempio n. 21
0
 private static string GetResourceSuffix(GameVersion version, int index) => version.GetGeneration() switch
 {
     3 when version == E => "e",
Esempio n. 22
0
 public static bool IsGen7(this GameVersion game) => game.GetGeneration() == GameGeneration.Generation7;
Esempio n. 23
0
 public GameInfo(GameVersion game)
 {
     Game       = game;
     Generation = game.GetGeneration();
     GetInitMethod(game)();
 }