Пример #1
0
        public static ModifyResult SetSuggestedRibbons(BatchInfo info, string value)
        {
            var pk = info.Entity;

            if (IsNone(value))
            {
                RibbonApplicator.RemoveAllValidRibbons(pk);
            }
            else // All
            {
                RibbonApplicator.SetAllValidRibbons(pk);
            }
            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);

            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 = info.SuggestedEncounter;
                if (encounter == null)
                {
                    return(ModifyResult.Error);
                }

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

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

                return(ModifyResult.Modified);

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

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

            default:
                return(ModifyResult.Error);
            }
        }