diff --git a/Quaver.API/Maps/Processors/Scoring/ScoreProcessor.cs b/Quaver.API/Maps/Processors/Scoring/ScoreProcessor.cs index a07dc1db2..14f864bd7 100644 --- a/Quaver.API/Maps/Processors/Scoring/ScoreProcessor.cs +++ b/Quaver.API/Maps/Processors/Scoring/ScoreProcessor.cs @@ -113,6 +113,11 @@ public abstract class ScoreProcessor {Judgement.Miss, 0} }; + /// + /// The amount of mine hits the user got. + /// + public int CountMineHit { get; set; } = 0; + /// /// The judgement windows defined per mode. /// @@ -215,6 +220,7 @@ public ScoreProcessor(Replay replay, JudgementWindows windows = null) CurrentJudgements[Judgement.Good] = replay.CountGood; CurrentJudgements[Judgement.Okay] = replay.CountOkay; CurrentJudgements[Judgement.Miss] = replay.CountMiss; + CountMineHit = replay.CountMineHit; InitializeJudgementWindows(windows); InitializeMods(); diff --git a/Quaver.API/Maps/Processors/Scoring/ScoreProcessorKeys.cs b/Quaver.API/Maps/Processors/Scoring/ScoreProcessorKeys.cs index 47fd8ded6..8d4b66996 100644 --- a/Quaver.API/Maps/Processors/Scoring/ScoreProcessorKeys.cs +++ b/Quaver.API/Maps/Processors/Scoring/ScoreProcessorKeys.cs @@ -33,6 +33,11 @@ public sealed class ScoreProcessorKeys : ScoreProcessor /// private int TotalJudgements { get; } + /// + /// Total number of mines in the map. + /// + private int MineCount { get; } + /// /// See: ScoreProcessorKeys.CalculateSummedScore(); /// @@ -143,6 +148,7 @@ public sealed class ScoreProcessorKeys : ScoreProcessor public ScoreProcessorKeys(Qua map, ModIdentifier mods, JudgementWindows windows = null) : base(map, mods, windows) { TotalJudgements = GetTotalJudgementCount(); + MineCount = map.MineCount; SummedScore = CalculateSummedScore(); InitializeHealthWeighting(); } @@ -157,6 +163,7 @@ public ScoreProcessorKeys(Qua map, ModIdentifier mods, JudgementWindows windows public ScoreProcessorKeys(Qua map, ModIdentifier mods, ScoreProcessorMultiplayer multiplayer, JudgementWindows windows = null) : base(map, mods, multiplayer, windows) { TotalJudgements = GetTotalJudgementCount(); + MineCount = map.MineCount; SummedScore = CalculateSummedScore(); InitializeHealthWeighting(); } @@ -248,6 +255,8 @@ public override void CalculateScore(Judgement judgement, bool isLongNoteRelease // Update Judgement count CurrentJudgements[judgement]++; + if (isMine) CountMineHit++; + // Calculate and set the new accuracy. Accuracy = CalculateAccuracy(); @@ -402,9 +411,14 @@ private int CalculateSummedScore() // Multiplier doesn't increase after this amount. var maxMultiplierCount = MultiplierMaxIndex * MultiplierCountToIncreaseIndex; + // The total number of judgements for a maximum score would be excluding the number of mines. + // This is because both a mine hit (a miss) and a mine clear (nothing) will gain 0 point, + // but a mine hit resets combo, reducing score. + var totalJudgements = TotalJudgements - MineCount; + // Calculate score for notes below max multiplier combo // Note: This block could be a constant for songs that have max combo that exceeds the max multiplier count, but that will mean we will have to manually change the constant everytime we update any single other constant. - for (var i = 1; i <= TotalJudgements && i < maxMultiplierCount; i++) + for (var i = 1; i <= totalJudgements && i < maxMultiplierCount; i++) summedScore += JudgementScoreWeighting[Judgement.Marv] + MultiplierCountToIncreaseIndex * (int) Math.Floor((float)i / MultiplierCountToIncreaseIndex); // Calculate score for notes once max multiplier combo is reached diff --git a/Quaver.API/Replays/Replay.cs b/Quaver.API/Replays/Replay.cs index 707b15e84..86c4fa2a1 100644 --- a/Quaver.API/Replays/Replay.cs +++ b/Quaver.API/Replays/Replay.cs @@ -24,7 +24,9 @@ public class Replay /// /// The version of the replay. /// - public static string CurrentVersion { get; } = "0.0.2"; + public static string CurrentVersion { get; } = "0.0.3"; + + public static readonly Version VersionMineHit = new Version(0, 0, 3); /// /// The game mode this replay is for. @@ -115,6 +117,11 @@ public class Replay /// Amount of miss judgements. /// public int CountMiss { get; set; } + + /// + /// Amount of mine hits. + /// + public int CountMineHit { get; set; } /// /// The amount of times paused in the play. @@ -211,6 +218,12 @@ public Replay(string path, bool readHeaderless = false) CountGood = br.ReadInt32(); CountOkay = br.ReadInt32(); CountMiss = br.ReadInt32(); + + if (Version.TryParse(ReplayVersion, out var ver) && ver >= VersionMineHit) + { + CountMineHit = br.ReadInt32(); + } + PauseCount = br.ReadInt32(); // Versions beyond None @@ -291,6 +304,12 @@ public void Write(string path) bw.Write(CountGood); bw.Write(CountOkay); bw.Write(CountMiss); + + if (Version.TryParse(ReplayVersion, out var ver) && ver >= VersionMineHit) + { + bw.Write(CountMineHit); + } + bw.Write(PauseCount); bw.Write(RandomizeModifierSeed); @@ -318,6 +337,7 @@ public void FromScoreProcessor(ScoreProcessor processor) CountGood = processor.CurrentJudgements[Judgement.Good]; CountOkay = processor.CurrentJudgements[Judgement.Okay]; CountMiss = processor.CurrentJudgements[Judgement.Miss]; + CountMineHit = processor.CountMineHit; } /// @@ -481,6 +501,12 @@ public List GetKeyPresses() /// public string GetMd5(string frames) { + if (Version.TryParse(CurrentVersion, out var ver) && ver >= VersionMineHit) + { + return CryptoHelper.StringToMd5($"{ReplayVersion}-{TimePlayed}-{MapMd5}-{PlayerName}-{(int)Mode}-" + + $"{(int)Mods}-{Score}-{Accuracy}-{MaxCombo}-{CountMarv}-{CountPerf}-" + + $"{CountGreat}-{CountGood}-{CountOkay}-{CountMiss}-{CountMineHit}-{PauseCount}-{RandomizeModifierSeed}-{frames}"); + } return CryptoHelper.StringToMd5($"{ReplayVersion}-{TimePlayed}-{MapMd5}-{PlayerName}-{(int)Mode}-" + $"{(int)Mods}-{Score}-{Accuracy}-{MaxCombo}-{CountMarv}-{CountPerf}-" + $"{CountGreat}-{CountGood}-{CountOkay}-{CountMiss}-{PauseCount}-{RandomizeModifierSeed}-{frames}"); diff --git a/Quaver.API/Replays/Virtual/VirtualReplayPlayer.cs b/Quaver.API/Replays/Virtual/VirtualReplayPlayer.cs index a1887866f..32b79b595 100644 --- a/Quaver.API/Replays/Virtual/VirtualReplayPlayer.cs +++ b/Quaver.API/Replays/Virtual/VirtualReplayPlayer.cs @@ -446,20 +446,13 @@ private void HandleMissedHitObjects() } } // Handle missed mines. - // 'Missed' as in the mines were not triggered, meaning a marvelous judgement should be given. + // 'Missed' as in the mines were not triggered. This will not reward the player by design. foreach (var hitObject in ActiveMines) { var endTime = hitObject.IsLongNote ? hitObject.EndTime : hitObject.StartTime; if (Time > endTime + ScoreProcessor.JudgementWindow[Judgement.Marv]) { - // Create a new HitStat to add to the ScoreProcessor. - // Award a Marvelous for successfully avoiding the mine. - var stat = new HitStat(HitStatType.Hit, KeyPressType.None, hitObject, hitObject.StartTime, Judgement.Marv, 0, - ScoreProcessor.Accuracy, ScoreProcessor.Health); - - ScoreProcessor.CalculateScore(stat); - - ScoreProcessor.Stats.Add(stat); + // Simply remove the mine. We do not count a cleared mine into statistics. ActiveMinesToRemove.Add(hitObject); } else if (Time < hitObject.StartTime - ScoreProcessor.JudgementWindow[Judgement.Marv])