1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 06:47:24 +08:00
osu-lazer/osu.Game/Rulesets/Mods/ModAccuracyChallenge.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

89 lines
3.3 KiB
C#
Raw Normal View History

2022-05-24 22:23:44 +08:00
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
2022-06-09 12:15:15 +08:00
using System.Globalization;
2022-05-24 22:23:44 +08:00
using System.Linq;
using osu.Framework.Bindables;
using osu.Framework.Localisation;
2022-05-24 22:23:44 +08:00
using osu.Game.Configuration;
using osu.Game.Localisation.HUD;
2022-05-24 22:23:44 +08:00
using osu.Game.Overlays.Settings;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Judgements;
using osu.Game.Scoring;
2022-05-24 22:23:44 +08:00
namespace osu.Game.Rulesets.Mods
{
public class ModAccuracyChallenge : ModFailCondition, IApplicableToScoreProcessor
2022-05-24 22:23:44 +08:00
{
public override string Name => "Accuracy Challenge";
2022-05-24 22:23:44 +08:00
public override string Acronym => "AC";
public override LocalisableString Description => "Fail if your accuracy drops too low!";
2022-05-24 22:23:44 +08:00
public override ModType Type => ModType.DifficultyIncrease;
2022-05-24 22:23:44 +08:00
public override double ScoreMultiplier => 1.0;
2022-05-25 08:04:57 +08:00
public override Type[] IncompatibleMods => base.IncompatibleMods.Concat(new[] { typeof(ModEasyWithExtraLives), typeof(ModPerfect) }).ToArray();
2022-05-25 08:04:57 +08:00
public override bool RequiresConfiguration => false;
public override bool Ranked => true;
2022-06-09 12:15:15 +08:00
public override string SettingDescription => base.SettingDescription.Replace(MinimumAccuracy.ToString(), MinimumAccuracy.Value.ToString("##%", NumberFormatInfo.InvariantInfo));
2022-05-24 22:23:44 +08:00
[SettingSource("Minimum accuracy", "Trigger a failure if your accuracy goes below this value.", SettingControlType = typeof(SettingsPercentageSlider<double>))]
2022-05-24 22:23:44 +08:00
public BindableNumber<double> MinimumAccuracy { get; } = new BindableDouble
{
2023-01-24 13:31:46 +08:00
MinValue = 0.60,
MaxValue = 0.99,
Precision = 0.01,
2022-05-24 22:23:44 +08:00
Default = 0.9,
Value = 0.9,
};
2023-05-30 04:12:37 +08:00
[SettingSource("Accuracy mode", "The mode of accuracy that will trigger failure.")]
public Bindable<AccuracyMode> AccuracyJudgeMode { get; } = new Bindable<AccuracyMode>();
private readonly Bindable<double> currentAccuracy = new Bindable<double>();
public void ApplyToScoreProcessor(ScoreProcessor scoreProcessor)
2022-05-24 22:23:44 +08:00
{
switch (AccuracyJudgeMode.Value)
{
case AccuracyMode.Standard:
currentAccuracy.BindTo(scoreProcessor.Accuracy);
break;
case AccuracyMode.MaximumAchievable:
currentAccuracy.BindTo(scoreProcessor.MaximumAccuracy);
break;
}
currentAccuracy.BindValueChanged(s =>
{
if (s.NewValue < MinimumAccuracy.Value)
{
TriggerFailure();
}
});
}
public ScoreRank AdjustRank(ScoreRank rank, double accuracy) => rank;
protected override bool FailCondition(HealthProcessor healthProcessor, JudgementResult result) => false;
public enum AccuracyMode
{
[LocalisableDescription(typeof(GameplayAccuracyCounterStrings), nameof(GameplayAccuracyCounterStrings.AccuracyDisplayModeMax))]
MaximumAchievable,
2023-05-27 20:27:32 +08:00
[LocalisableDescription(typeof(GameplayAccuracyCounterStrings), nameof(GameplayAccuracyCounterStrings.AccuracyDisplayModeStandard))]
Standard,
2022-05-24 22:23:44 +08:00
}
}
}