Merge pull request #5637 from iiSaLMaN/stop-counting-to-score-after-fail

Disallow adding to score after the player has failed

Co-authored-by: Dan Balasescu <smoogipoo@smgi.me>
Co-authored-by: Dean Herbert <pe@ppy.sh>
This commit is contained in:
Dean Herbert 2019-09-06 17:11:26 +09:00 committed by GitHub
commit e5c3a906d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 75 additions and 24 deletions

View File

@ -1,8 +1,6 @@
// 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.Collections.Generic;
using osu.Framework.Extensions;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects;
@ -22,8 +20,6 @@ namespace osu.Game.Rulesets.Osu.Scoring
private float hpDrainRate;
private readonly Dictionary<ComboResult, int> comboResultCounts = new Dictionary<ComboResult, int>();
protected override void ApplyBeatmap(Beatmap<OsuHitObject> beatmap)
{
base.ApplyBeatmap(beatmap);
@ -31,22 +27,6 @@ namespace osu.Game.Rulesets.Osu.Scoring
hpDrainRate = beatmap.BeatmapInfo.BaseDifficulty.DrainRate;
}
protected override void Reset(bool storeResults)
{
base.Reset(storeResults);
comboResultCounts.Clear();
}
protected override void ApplyResult(JudgementResult result)
{
base.ApplyResult(result);
var osuResult = (OsuJudgementResult)result;
if (result.Type != HitResult.None)
comboResultCounts[osuResult.ComboType] = comboResultCounts.GetOrDefault(osuResult.ComboType) + 1;
}
protected override double HealthAdjustmentFactorFor(JudgementResult result)
{
switch (result.Type)

View File

@ -0,0 +1,52 @@
// 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 System.Linq;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.UI;
using osu.Game.Scoring;
using osu.Game.Screens.Play;
namespace osu.Game.Tests.Visual.Gameplay
{
public class TestSceneFailJudgement : AllPlayersTestScene
{
protected override Player CreatePlayer(Ruleset ruleset)
{
Mods.Value = Array.Empty<Mod>();
var beatmap = Beatmap.Value.GetPlayableBeatmap(ruleset.RulesetInfo, Array.Empty<Mod>());
return new FailPlayer(ruleset.GetAutoplayMod().CreateReplayScore(beatmap));
}
protected override void AddCheckSteps()
{
AddUntilStep("wait for fail", () => Player.HasFailed);
AddUntilStep("wait for multiple judged objects", () => ((FailPlayer)Player).DrawableRuleset.Playfield.AllHitObjects.Count(h => h.AllJudged) > 1);
AddAssert("total judgements == 1", () => ((FailPlayer)Player).ScoreProcessor.JudgedHits == 1);
}
private class FailPlayer : ReplayPlayer
{
public new DrawableRuleset DrawableRuleset => base.DrawableRuleset;
public new ScoreProcessor ScoreProcessor => base.ScoreProcessor;
protected override bool PauseOnFocusLost => false;
public FailPlayer(Score score)
: base(score, false, false)
{
}
protected override void LoadComplete()
{
base.LoadComplete();
ScoreProcessor.FailConditions += (_, __) => true;
}
}
}
}

View File

@ -51,6 +51,11 @@ namespace osu.Game.Rulesets.Judgements
/// </summary>
public double HealthAtJudgement { get; internal set; }
/// <summary>
/// Whether the user was in a failed state prior to this <see cref="JudgementResult"/> occurring.
/// </summary>
public bool FailedAtJudgement { get; internal set; }
/// <summary>
/// Whether a miss or hit occurred.
/// </summary>

View File

@ -92,6 +92,11 @@ namespace osu.Game.Rulesets.Scoring
/// </summary>
public virtual bool HasCompleted => false;
/// <summary>
/// The total number of judged <see cref="HitObject"/>s at the current point in time.
/// </summary>
public int JudgedHits { get; protected set; }
/// <summary>
/// Whether this ScoreProcessor has already triggered the failed state.
/// </summary>
@ -142,6 +147,8 @@ namespace osu.Game.Rulesets.Scoring
Rank.Value = ScoreRank.X;
HighestCombo.Value = 0;
JudgedHits = 0;
HasFailed = false;
}
@ -193,7 +200,7 @@ namespace osu.Game.Rulesets.Scoring
score.Statistics[result] = GetStatistic(result);
}
protected abstract int GetStatistic(HitResult result);
public abstract int GetStatistic(HitResult result);
public abstract double GetStandardisedScore();
}
@ -208,7 +215,6 @@ namespace osu.Game.Rulesets.Scoring
public sealed override bool HasCompleted => JudgedHits == MaxHits;
protected int MaxHits { get; private set; }
protected int JudgedHits { get; private set; }
private double maxHighestCombo;
@ -322,6 +328,10 @@ namespace osu.Game.Rulesets.Scoring
result.ComboAtJudgement = Combo.Value;
result.HighestComboAtJudgement = HighestCombo.Value;
result.HealthAtJudgement = Health.Value;
result.FailedAtJudgement = HasFailed;
if (HasFailed)
return;
JudgedHits++;
@ -369,6 +379,11 @@ namespace osu.Game.Rulesets.Scoring
HighestCombo.Value = result.HighestComboAtJudgement;
Health.Value = result.HealthAtJudgement;
// Todo: Revert HasFailed state with proper player support
if (result.FailedAtJudgement)
return;
JudgedHits--;
if (result.Judgement.IsBonus)
@ -415,7 +430,7 @@ namespace osu.Game.Rulesets.Scoring
}
}
protected override int GetStatistic(HitResult result) => scoreResultCounts.GetOrDefault(result);
public override int GetStatistic(HitResult result) => scoreResultCounts.GetOrDefault(result);
public override double GetStandardisedScore() => getScore(ScoringMode.Standardised);
@ -432,7 +447,6 @@ namespace osu.Game.Rulesets.Scoring
base.Reset(storeResults);
JudgedHits = 0;
baseScore = 0;
rollingMaxBaseScore = 0;
bonusScore = 0;