2019-01-24 08:43:03 +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.
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2022-06-17 07:37:17 +00:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2018-08-06 01:55:38 +00:00
|
|
|
|
using osu.Game.Rulesets.Objects;
|
2017-12-30 20:23:18 +00:00
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-04-18 07:05:58 +00:00
|
|
|
|
namespace osu.Game.Rulesets.Judgements
|
2017-03-15 07:07:40 +00:00
|
|
|
|
{
|
2018-08-06 01:55:38 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The scoring information provided by a <see cref="HitObject"/>.
|
|
|
|
|
/// </summary>
|
2017-09-05 10:44:59 +00:00
|
|
|
|
public class Judgement
|
2017-03-15 07:07:40 +00:00
|
|
|
|
{
|
2019-12-25 10:58:23 +00:00
|
|
|
|
/// <summary>
|
2020-09-29 05:26:12 +00:00
|
|
|
|
/// The score awarded for a small bonus.
|
2019-12-25 10:58:23 +00:00
|
|
|
|
/// </summary>
|
2020-10-01 03:13:24 +00:00
|
|
|
|
public const int SMALL_BONUS_SCORE = 10;
|
2019-12-25 10:58:23 +00:00
|
|
|
|
|
2017-09-05 10:44:59 +00:00
|
|
|
|
/// <summary>
|
2020-09-29 05:26:12 +00:00
|
|
|
|
/// The score awarded for a large bonus.
|
2017-09-05 10:44:59 +00:00
|
|
|
|
/// </summary>
|
2020-10-01 03:13:24 +00:00
|
|
|
|
public const int LARGE_BONUS_SCORE = 50;
|
2020-09-29 05:26:12 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The default health increase for a maximum judgement, as a proportion of total health.
|
|
|
|
|
/// By default, each maximum judgement restores 5% of total health.
|
|
|
|
|
/// </summary>
|
|
|
|
|
protected const double DEFAULT_MAX_HEALTH_INCREASE = 0.05;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2020-09-29 05:26:12 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The maximum <see cref="HitResult"/> that can be achieved.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public virtual HitResult MaxResult => HitResult.Perfect;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The minimum <see cref="HitResult"/> that can be achieved - the inverse of <see cref="MaxResult"/>.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public HitResult MinResult
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
switch (MaxResult)
|
|
|
|
|
{
|
|
|
|
|
case HitResult.SmallBonus:
|
|
|
|
|
case HitResult.LargeBonus:
|
|
|
|
|
case HitResult.IgnoreHit:
|
|
|
|
|
return HitResult.IgnoreMiss;
|
|
|
|
|
|
|
|
|
|
case HitResult.SmallTickHit:
|
|
|
|
|
return HitResult.SmallTickMiss;
|
|
|
|
|
|
|
|
|
|
case HitResult.LargeTickHit:
|
|
|
|
|
return HitResult.LargeTickMiss;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return HitResult.Miss;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-23 03:21:09 +00:00
|
|
|
|
/// <summary>
|
2018-08-02 11:35:54 +00:00
|
|
|
|
/// The numeric score representation for the maximum achievable result.
|
2017-09-05 10:44:59 +00:00
|
|
|
|
/// </summary>
|
2020-10-01 03:13:24 +00:00
|
|
|
|
public int MaxNumericResult => ToNumericResult(MaxResult);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2019-04-22 07:51:38 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The health increase for the maximum achievable result.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public double MaxHealthIncrease => HealthIncreaseFor(MaxResult);
|
|
|
|
|
|
2017-03-23 03:21:09 +00:00
|
|
|
|
/// <summary>
|
2018-08-02 11:35:54 +00:00
|
|
|
|
/// Retrieves the numeric score representation of a <see cref="JudgementResult"/>.
|
2017-03-23 03:21:09 +00:00
|
|
|
|
/// </summary>
|
2018-08-02 11:35:54 +00:00
|
|
|
|
/// <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>
|
2020-10-01 03:13:24 +00:00
|
|
|
|
public int NumericResultFor(JudgementResult result) => ToNumericResult(result.Type);
|
2018-12-06 08:09:42 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Retrieves the numeric health increase of a <see cref="HitResult"/>.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="result">The <see cref="HitResult"/> to find the numeric health increase for.</param>
|
|
|
|
|
/// <returns>The numeric health increase of <paramref name="result"/>.</returns>
|
2019-12-25 10:58:23 +00:00
|
|
|
|
protected virtual double HealthIncreaseFor(HitResult result)
|
|
|
|
|
{
|
|
|
|
|
switch (result)
|
|
|
|
|
{
|
2020-09-29 05:26:12 +00:00
|
|
|
|
default:
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
case HitResult.SmallTickHit:
|
2020-10-03 09:10:08 +00:00
|
|
|
|
return DEFAULT_MAX_HEALTH_INCREASE * 0.5;
|
2020-09-29 05:26:12 +00:00
|
|
|
|
|
|
|
|
|
case HitResult.SmallTickMiss:
|
2020-10-03 09:10:08 +00:00
|
|
|
|
return -DEFAULT_MAX_HEALTH_INCREASE * 0.5;
|
2020-09-29 05:26:12 +00:00
|
|
|
|
|
|
|
|
|
case HitResult.LargeTickHit:
|
2020-10-03 09:10:08 +00:00
|
|
|
|
return DEFAULT_MAX_HEALTH_INCREASE;
|
2020-09-29 05:26:12 +00:00
|
|
|
|
|
|
|
|
|
case HitResult.LargeTickMiss:
|
2020-10-03 09:10:08 +00:00
|
|
|
|
return -DEFAULT_MAX_HEALTH_INCREASE;
|
2020-09-29 05:26:12 +00:00
|
|
|
|
|
2019-12-25 10:58:23 +00:00
|
|
|
|
case HitResult.Miss:
|
2022-05-19 10:55:51 +00:00
|
|
|
|
return -DEFAULT_MAX_HEALTH_INCREASE * 2;
|
2019-12-25 10:58:23 +00:00
|
|
|
|
|
|
|
|
|
case HitResult.Meh:
|
2022-05-17 06:11:22 +00:00
|
|
|
|
return DEFAULT_MAX_HEALTH_INCREASE * 0.05;
|
2019-12-25 10:58:23 +00:00
|
|
|
|
|
|
|
|
|
case HitResult.Ok:
|
2020-10-03 09:08:51 +00:00
|
|
|
|
return DEFAULT_MAX_HEALTH_INCREASE * 0.5;
|
2019-12-25 10:58:23 +00:00
|
|
|
|
|
|
|
|
|
case HitResult.Good:
|
2020-10-03 09:08:51 +00:00
|
|
|
|
return DEFAULT_MAX_HEALTH_INCREASE * 0.75;
|
2019-12-25 10:58:23 +00:00
|
|
|
|
|
|
|
|
|
case HitResult.Great:
|
2020-10-03 09:08:51 +00:00
|
|
|
|
return DEFAULT_MAX_HEALTH_INCREASE;
|
2019-12-25 10:58:23 +00:00
|
|
|
|
|
|
|
|
|
case HitResult.Perfect:
|
2020-10-03 09:08:51 +00:00
|
|
|
|
return DEFAULT_MAX_HEALTH_INCREASE * 1.05;
|
2019-12-25 10:58:23 +00:00
|
|
|
|
|
2020-09-29 05:26:12 +00:00
|
|
|
|
case HitResult.SmallBonus:
|
2020-10-03 09:10:08 +00:00
|
|
|
|
return DEFAULT_MAX_HEALTH_INCREASE * 0.5;
|
2020-09-29 05:26:12 +00:00
|
|
|
|
|
|
|
|
|
case HitResult.LargeBonus:
|
2020-10-03 09:10:08 +00:00
|
|
|
|
return DEFAULT_MAX_HEALTH_INCREASE;
|
2019-12-25 10:58:23 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-12-06 08:09:42 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Retrieves the numeric health increase of a <see cref="JudgementResult"/>.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="result">The <see cref="JudgementResult"/> to find the numeric health increase for.</param>
|
|
|
|
|
/// <returns>The numeric health increase of <paramref name="result"/>.</returns>
|
|
|
|
|
public double HealthIncreaseFor(JudgementResult result) => HealthIncreaseFor(result.Type);
|
2019-02-21 12:22:16 +00:00
|
|
|
|
|
2020-09-29 05:26:12 +00:00
|
|
|
|
public override string ToString() => $"MaxResult:{MaxResult} MaxScore:{MaxNumericResult}";
|
|
|
|
|
|
2020-10-01 03:13:24 +00:00
|
|
|
|
public static int ToNumericResult(HitResult result)
|
2020-09-29 05:26:12 +00:00
|
|
|
|
{
|
|
|
|
|
switch (result)
|
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
case HitResult.SmallTickHit:
|
2020-10-01 03:13:24 +00:00
|
|
|
|
return 10;
|
2020-09-29 05:26:12 +00:00
|
|
|
|
|
|
|
|
|
case HitResult.LargeTickHit:
|
2020-10-01 03:13:24 +00:00
|
|
|
|
return 30;
|
2020-09-29 05:26:12 +00:00
|
|
|
|
|
|
|
|
|
case HitResult.Meh:
|
2020-10-01 03:13:24 +00:00
|
|
|
|
return 50;
|
2020-09-29 05:26:12 +00:00
|
|
|
|
|
|
|
|
|
case HitResult.Ok:
|
2020-10-01 03:13:24 +00:00
|
|
|
|
return 100;
|
2020-09-29 05:26:12 +00:00
|
|
|
|
|
|
|
|
|
case HitResult.Good:
|
2020-10-01 03:13:24 +00:00
|
|
|
|
return 200;
|
2020-09-29 05:26:12 +00:00
|
|
|
|
|
|
|
|
|
case HitResult.Great:
|
2020-10-01 03:13:24 +00:00
|
|
|
|
return 300;
|
2020-09-29 05:26:12 +00:00
|
|
|
|
|
|
|
|
|
case HitResult.Perfect:
|
2021-04-05 04:28:46 +00:00
|
|
|
|
return 315;
|
2020-09-29 05:26:12 +00:00
|
|
|
|
|
|
|
|
|
case HitResult.SmallBonus:
|
|
|
|
|
return SMALL_BONUS_SCORE;
|
|
|
|
|
|
|
|
|
|
case HitResult.LargeBonus:
|
|
|
|
|
return LARGE_BONUS_SCORE;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-03-15 07:07:40 +00:00
|
|
|
|
}
|
2017-09-06 08:02:13 +00:00
|
|
|
|
}
|