mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 23:47:24 +08:00
1b1c255394
Make the Easy mod's extra life count customizable
70 lines
2.1 KiB
C#
70 lines
2.1 KiB
C#
// 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;
|
|
using osu.Framework.Bindables;
|
|
using osu.Framework.Graphics.Sprites;
|
|
using osu.Game.Beatmaps;
|
|
using osu.Game.Configuration;
|
|
using osu.Game.Graphics;
|
|
using osu.Game.Rulesets.Scoring;
|
|
using osu.Game.Scoring;
|
|
|
|
namespace osu.Game.Rulesets.Mods
|
|
{
|
|
public abstract class ModEasy : Mod, IApplicableToDifficulty, IApplicableFailOverride, IApplicableToScoreProcessor
|
|
{
|
|
public override string Name => "Easy";
|
|
public override string Acronym => "EZ";
|
|
public override IconUsage Icon => OsuIcon.ModEasy;
|
|
public override ModType Type => ModType.DifficultyReduction;
|
|
public override double ScoreMultiplier => 0.5;
|
|
public override bool Ranked => true;
|
|
public override Type[] IncompatibleMods => new[] { typeof(ModHardRock), typeof(ModDifficultyAdjust) };
|
|
|
|
[SettingSource("Extra Lives", "Number of extra lives")]
|
|
public Bindable<int> Retries { get; } = new BindableInt(2)
|
|
{
|
|
MinValue = 0,
|
|
MaxValue = 10
|
|
};
|
|
|
|
private int retries;
|
|
|
|
private BindableNumber<double> health;
|
|
|
|
public void ApplyToDifficulty(BeatmapDifficulty difficulty)
|
|
{
|
|
const float ratio = 0.5f;
|
|
difficulty.CircleSize *= ratio;
|
|
difficulty.ApproachRate *= ratio;
|
|
difficulty.DrainRate *= ratio;
|
|
difficulty.OverallDifficulty *= ratio;
|
|
|
|
retries = Retries.Value;
|
|
}
|
|
|
|
public bool AllowFail
|
|
{
|
|
get
|
|
{
|
|
if (retries == 0) return true;
|
|
|
|
health.Value = health.MaxValue;
|
|
retries--;
|
|
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public bool RestartOnFail => false;
|
|
|
|
public void ApplyToScoreProcessor(ScoreProcessor scoreProcessor)
|
|
{
|
|
health = scoreProcessor.Health.GetBoundCopy();
|
|
}
|
|
|
|
public ScoreRank AdjustRank(ScoreRank rank, double accuracy) => rank;
|
|
}
|
|
}
|