예제 #1
0
        /// <summary>
        /// Tries to modify the <see cref="PKM"/>.
        /// </summary>
        /// <param name="pkm">Object to modify.</param>
        /// <param name="filters">Filters which must be satisfied prior to any modifications being made.</param>
        /// <param name="modifications">Modifications to perform on the <see cref="pkm"/>.</param>
        /// <returns>Result of the attempted modification.</returns>
        public bool ProcessPKM(PKM pkm, IEnumerable <StringInstruction> filters, IEnumerable <StringInstruction> modifications)
        {
            if (pkm.Species <= 0)
            {
                return(false);
            }
            if (!pkm.Valid || pkm.Locked)
            {
                Iterated++;
                var reason = pkm.Locked ? "Locked." : "Not Valid.";
                Debug.WriteLine($"{MsgBEModifyFailBlocked} {reason}");
                return(false);
            }

            var r = BatchEditing.TryModifyPKM(pkm, filters, modifications);

            if (r != ModifyResult.Invalid)
            {
                Iterated++;
            }
            if (r == ModifyResult.Error)
            {
                Errored++;
            }
            if (r != ModifyResult.Modified)
            {
                return(false);
            }

            pkm.RefreshChecksum();
            Modified++;
            return(true);
        }
예제 #2
0
        /// <summary>
        /// Applies junk data to a <see cref="SaveFile.BlankPKM"/>, which is preferable to a completely empty entity.
        /// </summary>
        /// <param name="pk">Blank data</param>
        /// <param name="tr">Trainer info to apply</param>
        public static void TemplateFields(PKM pk, ITrainerInfo tr)
        {
            pk.Move1 = (int)Move.Pound;
            pk.HealPP();
            pk.Ball    = 4;
            pk.MetDate = DateTime.Today;

            if (tr.Game >= 0)
            {
                pk.Version = tr.Game;
            }

            pk.Species  = GetTemplateSpecies(pk, tr);
            pk.Language = GetTemplateLanguage(tr);
            pk.Gender   = pk.GetSaneGender();

            pk.ClearNickname();

            pk.OT_Name   = tr.OT;
            pk.OT_Gender = tr.Gender;
            pk.TID       = tr.TID;
            pk.SID       = tr.SID;
            if (tr is IRegionOrigin o && pk is IRegionOrigin gt)
            {
                gt.ConsoleRegion = o.ConsoleRegion;
                gt.Country       = o.Country;
                gt.Region        = o.Region;
            }

            ApplyTrashBytes(pk, tr);
            pk.RefreshChecksum();
        }
예제 #3
0
        /// <summary>
        /// Applies junk data to a <see cref="SaveFile.BlankPKM"/>, which is preferable to a completely empty entity.
        /// </summary>
        /// <param name="pk">Blank data</param>
        /// <param name="tr">Trainer info to apply</param>
        public static void TemplateFields(PKM pk, ITrainerInfo tr)
        {
            pk.Move1    = 1;
            pk.Move1_PP = 40;
            pk.Ball     = 4;
            pk.MetDate  = DateTime.Today;

            if (tr.Game >= 0)
            {
                pk.Version = tr.Game;
            }
            int spec = ((GameVersion)pk.Version).GetMaxSpeciesID();

            if (spec <= 0)
            {
                spec = pk.MaxSpeciesID;
            }
            pk.Species = spec;
            var lang = tr.Language;

            if (lang <= 0)
            {
                lang = (int)LanguageID.English;
            }
            pk.Language = lang;
            pk.Gender   = pk.GetSaneGender();

            pk.ClearNickname();

            pk.OT_Name   = tr.OT;
            pk.OT_Gender = tr.Gender;
            pk.TID       = tr.TID;
            pk.SID       = tr.SID;
            if (tr.ConsoleRegion >= 0)
            {
                pk.ConsoleRegion = tr.ConsoleRegion;
                pk.Country       = tr.Country;
                pk.Region        = tr.SubRegion;
            }

            // Copy OT trash bytes for sensitive games (Gen1/2)
            if (pk is GBPKM pk12)
            {
                switch (tr)
                {
                case SAV1 s1:
                    pk12.OT_Trash = s1.OT_Trash;
                    break;

                case SAV2 s2:
                    pk12.OT_Trash = s2.OT_Trash;
                    break;
                }
            }

            pk.RefreshChecksum();
        }
예제 #4
0
        /// <summary>
        /// Applies junk data to a <see cref="SaveFile.BlankPKM"/>, which is preferable to a completely empty entity.
        /// </summary>
        /// <param name="pk">Blank data</param>
        /// <param name="tr">Trainer info to apply</param>
        public static void TemplateFields(PKM pk, ITrainerInfo tr)
        {
            pk.Move1 = (int)Move.Pound;
            pk.HealPP();
            pk.Ball    = 4;
            pk.MetDate = DateTime.Today;

            if (tr.Game >= 0)
            {
                pk.Version = tr.Game;
            }
            int species = tr is IGameValueLimit s ? s.MaxSpeciesID : ((GameVersion)pk.Version).GetMaxSpeciesID();

            if (species <= 0)
            {
                species = pk.MaxSpeciesID;
            }
            pk.Species = species;
            var lang = tr.Language;

            if (lang <= 0)
            {
                lang = (int)LanguageID.English;
            }
            pk.Language = lang;
            pk.Gender   = pk.GetSaneGender();

            pk.ClearNickname();

            pk.OT_Name   = tr.OT;
            pk.OT_Gender = tr.Gender;
            pk.TID       = tr.TID;
            pk.SID       = tr.SID;
            if (tr is IRegionOrigin o && pk is IRegionOrigin gt)
            {
                gt.ConsoleRegion = o.ConsoleRegion;
                gt.Country       = o.Country;
                gt.Region        = o.Region;
            }

            // Copy OT trash bytes for sensitive games (Gen1/2)
            if (pk is GBPKM pk12)
            {
                switch (tr)
                {
                case SAV1 s1:
                    pk12.OT_Trash = s1.OT_Trash;
                    break;

                case SAV2 s2:
                    pk12.OT_Trash = s2.OT_Trash;
                    break;
                }
            }

            pk.RefreshChecksum();
        }
예제 #5
0
파일: SAV6.cs 프로젝트: tkfltkgk/PKHeX
 protected override void setPKM(PKM pkm)
 {
     PK6 pk6 = pkm as PK6;
     // Apply to this Save File
     int CT = pk6.CurrentHandler;
     DateTime Date = DateTime.Now;
     pk6.Trade(OT, TID, SID, Country, SubRegion, Gender, false, Date.Day, Date.Month, Date.Year);
     if (CT != pk6.CurrentHandler) // Logic updated Friendship
     {
         // Copy over the Friendship Value only under certain circumstances
         if (pk6.Moves.Contains(216)) // Return
             pk6.CurrentFriendship = pk6.OppositeFriendship;
         else if (pk6.Moves.Contains(218)) // Frustration
             pkm.CurrentFriendship = pk6.OppositeFriendship;
     }
     pkm.RefreshChecksum();
 }
예제 #6
0
파일: SAV6.cs 프로젝트: kwsch/PKHeX
 protected override void setPKM(PKM pkm)
 {
     PK6 pk6 = pkm as PK6;
     // Apply to this Save File
     int CT = pk6.CurrentHandler;
     DateTime Date = DateTime.Now;
     pk6.Trade(OT, TID, SID, Country, SubRegion, Gender, false, Date.Day, Date.Month, Date.Year);
     if (CT != pk6.CurrentHandler) // Logic updated Friendship
     {
         // Copy over the Friendship Value only under certain circumstances
         if (pk6.Moves.Contains(216)) // Return
             pk6.CurrentFriendship = pk6.OppositeFriendship;
         else if (pk6.Moves.Contains(218)) // Frustration
             pkm.CurrentFriendship = pk6.OppositeFriendship;
     }
     pkm.RefreshChecksum();
 }