Beispiel #1
0
        /// <summary>
        /// Trims all mods from a given <see cref="Mod"/> array which do not adjust difficulty.
        /// This is used to match osu!stable/osu!web calculations for the time being, until such a point that these mods do get considered.
        /// </summary>
        public static Mod[] TrimNonDifficultyAdjustmentMods(Ruleset ruleset, Mod[] mods)
        {
            var beatmap = new EmptyWorkingBeatmap
            {
                BeatmapInfo =
                {
                    Ruleset        = ruleset.RulesetInfo,
                    BaseDifficulty = new BeatmapDifficulty()
                }
            };

            var difficultyAdjustmentMods = ModUtils.FlattenMods(
                ruleset.CreateDifficultyCalculator(beatmap).CreateDifficultyAdjustmentModCombinations())
                                           .Select(m => m.GetType())
                                           .Distinct()
                                           .ToHashSet();

            // Special case for DT/NC.
            if (mods.Any(m => m is ModDoubleTime))
            {
                difficultyAdjustmentMods.Add(ruleset.GetAllMods().Single(m => m is ModNightcore).GetType());
            }

            return(mods.Where(m => difficultyAdjustmentMods.Contains(m.GetType())).ToArray());
        }
Beispiel #2
0
        /// <summary>
        /// Transforms a given <see cref="Mod"/> combination into one which is applicable to legacy scores.
        /// This is used to match osu!stable/osu!web calculations for the time being, until such a point that these mods do get considered.
        /// </summary>
        public static Mod[] ConvertToLegacyDifficultyAdjustmentMods(Ruleset ruleset, Mod[] mods)
        {
            var beatmap = new EmptyWorkingBeatmap
            {
                BeatmapInfo =
                {
                    Ruleset    = ruleset.RulesetInfo,
                    Difficulty = new BeatmapDifficulty()
                }
            };

            var allMods = ruleset.CreateAllMods().ToArray();

            var allowedMods = ModUtils.FlattenMods(
                ruleset.CreateDifficultyCalculator(beatmap).CreateDifficultyAdjustmentModCombinations())
                              .Select(m => m.GetType())
                              .Distinct()
                              .ToHashSet();

            // Special case to allow either DT or NC.
            if (mods.Any(m => m is ModDoubleTime))
            {
                allowedMods.Add(allMods.Single(m => m is ModNightcore).GetType());
            }

            var result = new List <Mod>();

            var classicMod = allMods.SingleOrDefault(m => m is ModClassic);

            if (classicMod != null)
            {
                result.Add(classicMod);
            }

            result.AddRange(mods.Where(m => allowedMods.Contains(m.GetType())));

            return(result.ToArray());
        }