Пример #1
0
        public static ModifyResult SetSuggestedMetData(BatchInfo info)
        {
            var pk        = info.Entity;
            var encounter = EncounterSuggestion.GetSuggestedMetInfo(pk);

            if (encounter == null)
            {
                return(ModifyResult.Error);
            }

            int level        = encounter.LevelMin;
            int location     = encounter.Location;
            int minimumLevel = EncounterSuggestion.GetLowestLevel(pk, encounter.LevelMin);

            pk.Met_Level    = level;
            pk.Met_Location = location;
            pk.CurrentLevel = Math.Max(minimumLevel, level);

            return(ModifyResult.Modified);
        }
Пример #2
0
        /// <summary>
        /// Sets the <see cref="PKM"/> data with a suggested value based on its <see cref="LegalityAnalysis"/>.
        /// </summary>
        /// <param name="name">Property to modify.</param>
        /// <param name="info">Cached info storing Legal data.</param>
        /// <param name="propValue">Suggestion string which starts with <see cref="CONST_SUGGEST"/></param>
        private static ModifyResult SetSuggestedPKMProperty(string name, PKMInfo info, string propValue)
        {
            bool isAll() => propValue.EndsWith("All", true, CultureInfo.CurrentCulture);
            bool isNone() => propValue.EndsWith("None", true, CultureInfo.CurrentCulture);

            var pk = info.Entity;

            switch (name)
            {
            // pb7 only
            case nameof(PB7.Stat_CP) when pk is PB7 pb7:
                pb7.ResetCP();
                return(ModifyResult.Modified);

            case nameof(PB7.HeightAbsolute) when pk is PB7 pb7:
                pb7.HeightAbsolute = pb7.CalcHeightAbsolute;
                return(ModifyResult.Modified);

            case nameof(PB7.WeightAbsolute) when pk is PB7 pb7:
                pb7.WeightAbsolute = pb7.CalcWeightAbsolute;
                return(ModifyResult.Modified);

            // Date Copy
            case nameof(PKM.EggMetDate):
                pk.EggMetDate = pk.MetDate;
                return(ModifyResult.Modified);

            case nameof(PKM.MetDate):
                pk.MetDate = pk.EggMetDate;
                return(ModifyResult.Modified);

            case nameof(PKM.Nature) when pk.Format >= 8:
                pk.Nature = pk.StatNature;
                return(ModifyResult.Modified);

            case nameof(PKM.StatNature) when pk.Format >= 8:
                pk.StatNature = pk.Nature;
                return(ModifyResult.Modified);

            case nameof(PKM.Stats):
                pk.ResetPartyStats();
                return(ModifyResult.Modified);

            case nameof(IHyperTrain.HyperTrainFlags):
                pk.SetSuggestedHyperTrainingData();
                return(ModifyResult.Modified);

            case nameof(PKM.RelearnMoves):
                if (pk.Format >= 8)
                {
                    pk.ClearRecordFlags();
                    if (isAll())
                    {
                        pk.SetRecordFlags();     // all
                    }
                    else if (!isNone())
                    {
                        pk.SetRecordFlags(pk.Moves);     // whatever fit the current moves
                    }
                }
                pk.SetRelearnMoves(info.SuggestedRelearn);
                return(ModifyResult.Modified);

            case PROP_RIBBONS:
                if (isNone())
                {
                    RibbonApplicator.RemoveAllValidRibbons(pk);
                }
                else     // All
                {
                    RibbonApplicator.SetAllValidRibbons(pk);
                }
                return(ModifyResult.Modified);

            case nameof(PKM.Met_Location):
                var encounter = EncounterSuggestion.GetSuggestedMetInfo(pk);
                if (encounter == null)
                {
                    return(ModifyResult.Error);
                }

                int level    = encounter.LevelMin;
                int location = encounter.Location;
                int minlvl   = EncounterSuggestion.GetLowestLevel(pk, encounter.LevelMin);

                pk.Met_Level    = level;
                pk.Met_Location = location;
                pk.CurrentLevel = Math.Max(minlvl, level);

                return(ModifyResult.Modified);

            case nameof(PKM.Heal):
                pk.Heal();
                return(ModifyResult.Modified);

            case nameof(PKM.HealPP):
                pk.HealPP();
                return(ModifyResult.Modified);

            case nameof(PKM.Move1_PP):
            case nameof(PKM.Move2_PP):
            case nameof(PKM.Move3_PP):
            case nameof(PKM.Move4_PP):
                pk.SetSuggestedMovePP(name[4] - '1');     // 0-3 int32
                return(ModifyResult.Modified);

            case nameof(PKM.Moves):
                return(SetMoves(pk, info.Legality.GetMoveSet()));

            case nameof(PKM.Ball):
                BallApplicator.ApplyBallLegalByColor(pk);
                return(ModifyResult.Modified);

            default:
                return(ModifyResult.Error);
            }
        }