2020-11-16 18:42:08 +00: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.
|
|
|
|
|
2022-05-24 14:23:44 +00:00
|
|
|
using System;
|
|
|
|
using System.Linq;
|
2020-11-16 18:42:08 +00:00
|
|
|
using Humanizer;
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.Configuration;
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Mods
|
|
|
|
{
|
|
|
|
public abstract class ModEasyWithExtraLives : ModEasy, IApplicableFailOverride, IApplicableToHealthProcessor
|
|
|
|
{
|
|
|
|
[SettingSource("Extra Lives", "Number of extra lives")]
|
|
|
|
public Bindable<int> Retries { get; } = new BindableInt(2)
|
|
|
|
{
|
|
|
|
MinValue = 0,
|
|
|
|
MaxValue = 10
|
|
|
|
};
|
|
|
|
|
|
|
|
public override string SettingDescription => Retries.IsDefault ? string.Empty : $"{"lives".ToQuantity(Retries.Value)}";
|
2022-05-24 14:23:44 +00:00
|
|
|
public override Type[] IncompatibleMods => base.IncompatibleMods.Append(typeof(ModAccuracyChallenge)).ToArray();
|
2020-11-16 18:42:08 +00:00
|
|
|
|
|
|
|
private int retries;
|
|
|
|
|
2022-07-10 15:16:51 +00:00
|
|
|
private readonly BindableNumber<double> health = new BindableDouble();
|
2020-11-16 18:42:08 +00:00
|
|
|
|
|
|
|
public override void ApplyToDifficulty(BeatmapDifficulty difficulty)
|
|
|
|
{
|
|
|
|
base.ApplyToDifficulty(difficulty);
|
|
|
|
retries = Retries.Value;
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool PerformFail()
|
|
|
|
{
|
|
|
|
if (retries == 0) return true;
|
|
|
|
|
|
|
|
health.Value = health.MaxValue;
|
|
|
|
retries--;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool RestartOnFail => false;
|
|
|
|
|
|
|
|
public void ApplyToHealthProcessor(HealthProcessor healthProcessor)
|
|
|
|
{
|
2022-07-10 15:16:51 +00:00
|
|
|
health.BindTo(healthProcessor.Health);
|
2020-11-16 18:42:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|