2019-12-25 12:16:40 +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.
|
|
|
|
|
2020-03-02 04:24:55 +00:00
|
|
|
using System;
|
2019-12-25 12:16:40 +00:00
|
|
|
using System.Linq;
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.Rulesets.Judgements;
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
|
|
|
using osu.Game.Rulesets.Taiko.Objects;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Taiko.Scoring
|
|
|
|
{
|
2019-12-26 06:28:30 +00:00
|
|
|
/// <summary>
|
|
|
|
/// A <see cref="HealthProcessor"/> for the taiko ruleset.
|
|
|
|
/// Taiko fails if the player has not half-filled their health by the end of the map.
|
|
|
|
/// </summary>
|
2019-12-25 12:16:40 +00:00
|
|
|
public class TaikoHealthProcessor : AccumulatingHealthProcessor
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// A value used for calculating <see cref="hpMultiplier"/>.
|
|
|
|
/// </summary>
|
|
|
|
private const double object_count_factor = 3;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// HP multiplier for a successful <see cref="HitResult"/>.
|
|
|
|
/// </summary>
|
|
|
|
private double hpMultiplier;
|
|
|
|
|
|
|
|
/// <summary>
|
2020-10-02 20:57:49 +00:00
|
|
|
/// HP multiplier for a <see cref="HitResult"/> that does not satisfy <see cref="HitResultExtensions.IsHit"/>.
|
2019-12-25 12:16:40 +00:00
|
|
|
/// </summary>
|
|
|
|
private double hpMissMultiplier;
|
|
|
|
|
2019-12-27 07:14:49 +00:00
|
|
|
public TaikoHealthProcessor()
|
|
|
|
: base(0.5)
|
2019-12-25 12:16:40 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public override void ApplyBeatmap(IBeatmap beatmap)
|
|
|
|
{
|
|
|
|
base.ApplyBeatmap(beatmap);
|
|
|
|
|
2021-10-02 03:34:29 +00:00
|
|
|
hpMultiplier = 1 / (object_count_factor * Math.Max(1, beatmap.HitObjects.OfType<Hit>().Count()) * IBeatmapDifficultyInfo.DifficultyRange(beatmap.Difficulty.DrainRate, 0.5, 0.75, 0.98));
|
|
|
|
hpMissMultiplier = IBeatmapDifficultyInfo.DifficultyRange(beatmap.Difficulty.DrainRate, 0.0018, 0.0075, 0.0120);
|
2019-12-25 12:16:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override double GetHealthIncreaseFor(JudgementResult result)
|
2020-10-02 20:57:49 +00:00
|
|
|
=> base.GetHealthIncreaseFor(result) * (result.IsHit ? hpMultiplier : hpMissMultiplier);
|
2019-12-25 12:16:40 +00:00
|
|
|
}
|
|
|
|
}
|