Exemplo n.º 1
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>
        private static ModifyResult SetSuggestedPKMProperty(string name, PKMInfo info)
        {
            var pk = info.pkm;

            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.Stats):
                pk.ResetPartyStats();
                return(ModifyResult.Modified);

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

            case nameof(PKM.RelearnMoves):
                pk.SetRelearnMoves(info.SuggestedRelearn);
                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)));

            default:
                return(ModifyResult.Error);
            }
        }
Exemplo n.º 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>
        private static ModifyResult SetSuggestedPKMProperty(string name, PKMInfo info)
        {
            var PKM = info.pkm;

            switch (name)
            {
            case nameof(PKM.Stats):
                PKM.SetStats(PKM.GetStats(PKM.PersonalInfo));
                return(ModifyResult.Modified);

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

            case nameof(PKM.RelearnMoves):
                PKM.RelearnMoves = info.SuggestedRelearn;
                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(PKM, encounter.LevelMin);

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

                return(ModifyResult.Modified);

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

            default:
                return(ModifyResult.Error);
            }
        }
Exemplo n.º 3
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);
            }
        }