Standardise Judgement across all rulesets

This commit is contained in:
smoogipoo 2020-09-29 14:26:12 +09:00
parent 07226c79b6
commit 519f376e7b
1 changed files with 108 additions and 14 deletions

View File

@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
using System;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
@ -11,31 +12,69 @@ namespace osu.Game.Rulesets.Judgements
/// </summary> /// </summary>
public class Judgement public class Judgement
{ {
/// <summary>
/// The score awarded for a small bonus.
/// </summary>
public const double SMALL_BONUS_SCORE = 10;
/// <summary>
/// The score awarded for a large bonus.
/// </summary>
public const double LARGE_BONUS_SCORE = 50;
/// <summary> /// <summary>
/// The default health increase for a maximum judgement, as a proportion of total health. /// The default health increase for a maximum judgement, as a proportion of total health.
/// By default, each maximum judgement restores 5% of total health. /// By default, each maximum judgement restores 5% of total health.
/// </summary> /// </summary>
protected const double DEFAULT_MAX_HEALTH_INCREASE = 0.05; protected const double DEFAULT_MAX_HEALTH_INCREASE = 0.05;
/// <summary>
/// Whether this <see cref="Judgement"/> should affect the current combo.
/// </summary>
[Obsolete("Has no effect. Use HitResult members instead (e.g. use small-tick or bonus to not affect combo).")] // Can be removed 20210328
public virtual bool AffectsCombo => true;
/// <summary>
/// Whether this <see cref="Judgement"/> should be counted as base (combo) or bonus score.
/// </summary>
[Obsolete("Has no effect. Use HitResult members instead (e.g. use small-tick or bonus to not affect combo).")] // Can be removed 20210328
public virtual bool IsBonus => !AffectsCombo;
/// <summary> /// <summary>
/// The maximum <see cref="HitResult"/> that can be achieved. /// The maximum <see cref="HitResult"/> that can be achieved.
/// </summary> /// </summary>
public virtual HitResult MaxResult => HitResult.Perfect; public virtual HitResult MaxResult => HitResult.Perfect;
/// <summary> /// <summary>
/// Whether this <see cref="Judgement"/> should affect the current combo. /// The minimum <see cref="HitResult"/> that can be achieved - the inverse of <see cref="MaxResult"/>.
/// </summary> /// </summary>
public virtual bool AffectsCombo => true; public HitResult MinResult
{
get
{
switch (MaxResult)
{
case HitResult.SmallBonus:
case HitResult.LargeBonus:
case HitResult.IgnoreHit:
return HitResult.IgnoreMiss;
/// <summary> case HitResult.SmallTickHit:
/// Whether this <see cref="Judgement"/> should be counted as base (combo) or bonus score. return HitResult.SmallTickMiss;
/// </summary>
public virtual bool IsBonus => !AffectsCombo; case HitResult.LargeTickHit:
return HitResult.LargeTickMiss;
default:
return HitResult.Miss;
}
}
}
/// <summary> /// <summary>
/// The numeric score representation for the maximum achievable result. /// The numeric score representation for the maximum achievable result.
/// </summary> /// </summary>
public int MaxNumericResult => NumericResultFor(MaxResult); public double MaxNumericResult => ToNumericResult(MaxResult);
/// <summary> /// <summary>
/// The health increase for the maximum achievable result. /// The health increase for the maximum achievable result.
@ -43,18 +82,19 @@ public class Judgement
public double MaxHealthIncrease => HealthIncreaseFor(MaxResult); public double MaxHealthIncrease => HealthIncreaseFor(MaxResult);
/// <summary> /// <summary>
/// Retrieves the numeric score representation of a <see cref="HitResult"/>. /// Retrieves the numeric score representation of a <see cref="JudgementResult"/>.
/// </summary> /// </summary>
/// <param name="result">The <see cref="HitResult"/> to find the numeric score representation for.</param> /// <param name="result">The <see cref="JudgementResult"/> to find the numeric score representation for.</param>
/// <returns>The numeric score representation of <paramref name="result"/>.</returns> /// <returns>The numeric score representation of <paramref name="result"/>.</returns>
protected virtual int NumericResultFor(HitResult result) => result > HitResult.Miss ? 1 : 0; [Obsolete("Has no effect. Use ToNumericResult(HitResult) (standardised across all rulesets).")] // Can be removed 20210328
protected virtual int NumericResultFor(HitResult result) => result == HitResult.Miss ? 0 : 1;
/// <summary> /// <summary>
/// Retrieves the numeric score representation of a <see cref="JudgementResult"/>. /// Retrieves the numeric score representation of a <see cref="JudgementResult"/>.
/// </summary> /// </summary>
/// <param name="result">The <see cref="JudgementResult"/> to find the numeric score representation for.</param> /// <param name="result">The <see cref="JudgementResult"/> to find the numeric score representation for.</param>
/// <returns>The numeric score representation of <paramref name="result"/>.</returns> /// <returns>The numeric score representation of <paramref name="result"/>.</returns>
public int NumericResultFor(JudgementResult result) => NumericResultFor(result.Type); public double NumericResultFor(JudgementResult result) => ToNumericResult(result.Type);
/// <summary> /// <summary>
/// Retrieves the numeric health increase of a <see cref="HitResult"/>. /// Retrieves the numeric health increase of a <see cref="HitResult"/>.
@ -65,6 +105,21 @@ protected virtual double HealthIncreaseFor(HitResult result)
{ {
switch (result) switch (result)
{ {
default:
return 0;
case HitResult.SmallTickHit:
return DEFAULT_MAX_HEALTH_INCREASE * 0.05;
case HitResult.SmallTickMiss:
return -DEFAULT_MAX_HEALTH_INCREASE * 0.05;
case HitResult.LargeTickHit:
return DEFAULT_MAX_HEALTH_INCREASE * 0.1;
case HitResult.LargeTickMiss:
return -DEFAULT_MAX_HEALTH_INCREASE * 0.1;
case HitResult.Miss: case HitResult.Miss:
return -DEFAULT_MAX_HEALTH_INCREASE; return -DEFAULT_MAX_HEALTH_INCREASE;
@ -83,8 +138,11 @@ protected virtual double HealthIncreaseFor(HitResult result)
case HitResult.Perfect: case HitResult.Perfect:
return DEFAULT_MAX_HEALTH_INCREASE * 1.05; return DEFAULT_MAX_HEALTH_INCREASE * 1.05;
default: case HitResult.SmallBonus:
return 0; return DEFAULT_MAX_HEALTH_INCREASE * 0.1;
case HitResult.LargeBonus:
return DEFAULT_MAX_HEALTH_INCREASE * 0.2;
} }
} }
@ -95,6 +153,42 @@ protected virtual double HealthIncreaseFor(HitResult result)
/// <returns>The numeric health increase of <paramref name="result"/>.</returns> /// <returns>The numeric health increase of <paramref name="result"/>.</returns>
public double HealthIncreaseFor(JudgementResult result) => HealthIncreaseFor(result.Type); public double HealthIncreaseFor(JudgementResult result) => HealthIncreaseFor(result.Type);
public override string ToString() => $"AffectsCombo:{AffectsCombo} MaxResult:{MaxResult} MaxScore:{MaxNumericResult}"; public override string ToString() => $"MaxResult:{MaxResult} MaxScore:{MaxNumericResult}";
public static double ToNumericResult(HitResult result)
{
switch (result)
{
default:
return 0;
case HitResult.SmallTickHit:
return 1 / 30d;
case HitResult.LargeTickHit:
return 1 / 10d;
case HitResult.Meh:
return 1 / 6d;
case HitResult.Ok:
return 1 / 3d;
case HitResult.Good:
return 2 / 3d;
case HitResult.Great:
return 1d;
case HitResult.Perfect:
return 7 / 6d;
case HitResult.SmallBonus:
return SMALL_BONUS_SCORE;
case HitResult.LargeBonus:
return LARGE_BONUS_SCORE;
}
}
} }
} }