Esempio n. 1
0
 /// <summary>
 /// Clone trainerdata and mutate the language and then return the clone
 /// </summary>
 /// <param name="tr">Trainerdata to clone</param>
 /// <param name="lang">language to mutate</param>
 /// <returns></returns>
 public static ITrainerInfo MutateLanguage(this ITrainerInfo tr, LanguageID?lang, GameVersion ver)
 {
     if (lang is LanguageID.UNUSED_6 or LanguageID.Hacked or null)
     {
         return(tr);
     }
     if (tr is PokeTrainerDetails p)
     {
         var clone = PokeTrainerDetails.Clone(p);
         clone.Language = (int)lang;
         clone.OT       = MutateOT(clone.OT, lang, ver);
         return(clone);
     }
     if (tr is SimpleTrainerInfo s)
     {
         var version = GameUtil.GameVersions.FirstOrDefault(z => ver.Contains(z) && z != GameVersion.BU);
         return(new SimpleTrainerInfo(version)
         {
             OT = MutateOT(s.OT, lang, version),
             TID = s.TID,
             SID = s.SID,
             Gender = s.Gender,
             Language = (int)lang,
             ConsoleRegion = s.ConsoleRegion != 0 ? s.ConsoleRegion : (byte)1,
             Region = s.Region != 0 ? s.Region : (byte)7,
             Country = s.Country != 0 ? s.Country : (byte)49,
             Generation = s.Generation,
         });
     }
     return(tr);
 }
Esempio n. 2
0
        private static IEnumerable <EncounterSlot> GetFilteredSlots12(PKM pkm, int gen, GameVersion Gen1Version, IEnumerable <EncounterSlot> slots, bool RBDragonair)
        {
            switch (gen)
            {
            case 1:
                if (Gen1Version != GameVersion.RBY)
                {
                    slots = slots.Where(slot => Gen1Version.Contains(((EncounterSlot1)slot).Version));
                }

                // Red Blue dragonair or dratini from any gen 1 games
                if (RBDragonair)
                {
                    return(slots.Where(slot => GameVersion.RB.Contains(((EncounterSlot1)slot).Version) || slot.Species == 147));
                }

                return(slots);

            case 2:
                if (pkm is PK2 pk2 && pk2.Met_TimeOfDay != 0)
                {
                    return(slots.Where(slot => ((EncounterSlot1)slot).Time.Contains(pk2.Met_TimeOfDay)));
                }
                return(slots);

            default:
                return(slots);
            }
        }
Esempio n. 3
0
        private static EncounterArea[] GetTables2(GameVersion Version)
        {
            // Fishing
            var f = EncounterArea.GetArray2_F(Util.GetBinaryResource("encounter_gsc_f.pkl"));

            EncounterArea[] Slots = new EncounterArea[0];
            if (Version.Contains(GameVersion.GS))
            {
                Slots = GetSlots_GS(f);
            }
            if (Version.Contains(GameVersion.C))
            {
                Slots = AddExtraTableSlots(Slots, GetSlots_C(f));
            }

            return(Slots);
        }
Esempio n. 4
0
        private static EncounterArea2[] GetTables2(GameVersion Version)
        {
            // Fishing
            var f = EncounterArea2.GetArray2Fishing(Util.GetBinaryResource("encounter_gsc_f.pkl"));

            var Slots = Array.Empty <EncounterArea2>();

            if (Version.Contains(GameVersion.GS))
            {
                Slots = GetSlots_GS(f);
            }
            if (Version.Contains(GameVersion.C))
            {
                Slots = AddExtraTableSlots(Slots, GetSlots_C(f));
            }

            return(Slots);
        }
Esempio n. 5
0
        /// <summary>
        /// Fetches an appropriate trainer based on the requested <see cref="ver"/> group.
        /// </summary>
        /// <param name="ver">Version the trainer should originate from</param>
        /// <returns>Null if no trainer found for this version.</returns>
        private ITrainerInfo GetTrainerFromGroup(GameVersion ver)
        {
            var possible = Database.Where(z => ver.Contains(z.Key)).ToList();

            if (possible.Count == 0)
            {
                return(null);
            }
            var group  = Util.Rand.Next(possible.Count);
            var choice = possible[group];

            return(GetRandomChoice(choice.Value));
        }
Esempio n. 6
0
        /// <summary>
        /// Fetches an appropriate trainer based on the requested <see cref="ver"/> group.
        /// </summary>
        /// <param name="ver">Version the trainer should originate from</param>
        /// <param name="lang">Language to request for</param>
        /// <returns>Null if no trainer found for this version.</returns>
        private ITrainerInfo?GetTrainerFromGroup(GameVersion ver, LanguageID?lang = null)
        {
            var possible = Database.Where(z => ver.Contains(z.Key)).ToList();

            if (lang != null)
            {
                possible = possible.Select(z =>
                {
                    var filtered = z.Value.Where(x => x.Language == (int)lang).ToList();
                    return(new KeyValuePair <GameVersion, List <ITrainerInfo> >(z.Key, filtered));
                }).Where(z => z.Value.Count != 0).ToList();
            }
            return(GetRandomTrainer(possible));
        }
Esempio n. 7
0
        /// <summary>
        /// Gives the currently loaded save priority over other saves in the same generation. Otherwise generational order is preserved
        /// </summary>
        /// <param name="gamelist">Array of gameversions which needs to be prioritized</param>
        /// <param name="game">Gameversion to prioritize</param>
        /// <returns></returns>
        private static GameVersion[] PrioritizeVersion(GameVersion[] gamelist, GameVersion game)
        {
            var matched = 0;
            var retval  = new List <GameVersion>();

            foreach (GameVersion poss in gamelist)
            {
                if (poss == game || game.Contains(poss))
                {
                    retval.Insert(matched, poss);
                    matched++;
                }
                else
                {
                    retval.Add(poss);
                }
            }
            return(retval.ToArray());
        }
Esempio n. 8
0
 /// <summary>
 /// Checks if the <see cref="g1"/> version (or subset versions) is equivalent to <see cref="g2"/>.
 /// </summary>
 /// <param name="g1">Version (set)</param>
 /// <param name="g2">Individual version</param>
 public static bool Contains(this GameVersion g1, int g2) => g1.Contains((GameVersion)g2);
Esempio n. 9
0
        /// <summary>
        /// Fetches an appropriate trainer based on the requested <see cref="ver"/> group.
        /// </summary>
        /// <param name="ver">Version the trainer should originate from</param>
        /// <returns>Null if no trainer found for this version.</returns>
        private ITrainerInfo?GetTrainerFromGroup(GameVersion ver)
        {
            var possible = Database.Where(z => ver.Contains(z.Key)).ToList();

            return(GetRandomTrainer(possible));
        }