// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System.ComponentModel; using System.Diagnostics; using osu.Game.Utils; namespace osu.Game.Rulesets.Scoring { [HasOrderedElements] public enum HitResult { /// /// Indicates that the object has not been judged yet. /// [Description(@"")] [Order(14)] None = 0, /// /// Indicates that the object has been judged as a miss. /// /// /// This miss window should determine how early a hit can be before it is considered for judgement (as opposed to being ignored as /// "too far in the future). It should also define when a forced miss should be triggered (as a result of no user input in time). /// [Description(@"Miss")] [Order(5)] Miss = 64, [Description(@"Meh")] [Order(4)] Meh, [Description(@"OK")] [Order(3)] Ok, [Description(@"Good")] [Order(2)] Good, [Description(@"Great")] [Order(1)] Great, [Description(@"Perfect")] [Order(0)] Perfect, /// /// Indicates small tick miss. /// [Order(11)] SmallTickMiss = 128, /// /// Indicates a small tick hit. /// [Description(@"S Tick")] [Order(7)] SmallTickHit, /// /// Indicates a large tick miss. /// [Order(10)] LargeTickMiss = 192, /// /// Indicates a large tick hit. /// [Description(@"L Tick")] [Order(6)] LargeTickHit, /// /// Indicates a small bonus. /// [Description("S Bonus")] [Order(9)] SmallBonus = 254, /// /// Indicates a large bonus. /// [Description("L Bonus")] [Order(8)] LargeBonus = 320, /// /// Indicates a miss that should be ignored for scoring purposes. /// [Order(13)] IgnoreMiss = 384, /// /// Indicates a hit that should be ignored for scoring purposes. /// [Order(12)] IgnoreHit, } public static class HitResultExtensions { /// /// Whether a increases/decreases the combo, and affects the combo portion of the score. /// public static bool AffectsCombo(this HitResult result) { switch (result) { case HitResult.Miss: case HitResult.Meh: case HitResult.Ok: case HitResult.Good: case HitResult.Great: case HitResult.Perfect: case HitResult.LargeTickHit: case HitResult.LargeTickMiss: return true; default: return false; } } /// /// Whether a affects the accuracy portion of the score. /// public static bool AffectsAccuracy(this HitResult result) => IsScorable(result) && !IsBonus(result); /// /// Whether a should be counted as bonus score. /// public static bool IsBonus(this HitResult result) { switch (result) { case HitResult.SmallBonus: case HitResult.LargeBonus: return true; default: return false; } } /// /// Whether a represents a successful hit. /// public static bool IsHit(this HitResult result) { switch (result) { case HitResult.None: case HitResult.IgnoreMiss: case HitResult.Miss: case HitResult.SmallTickMiss: case HitResult.LargeTickMiss: return false; default: return true; } } /// /// Whether a is scorable. /// public static bool IsScorable(this HitResult result) => result >= HitResult.Miss && result < HitResult.IgnoreMiss; /// /// Whether a is valid within a given range. /// /// The to check. /// The minimum . /// The maximum . /// Whether falls between and . public static bool IsValidHitResult(this HitResult result, HitResult minResult, HitResult maxResult) { if (result == HitResult.None) return false; if (result == minResult || result == maxResult) return true; Debug.Assert(minResult <= maxResult); return result > minResult && result < maxResult; } } }