Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Quaver.API/Maps/Processors/Scoring/ScoreProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ public abstract class ScoreProcessor
{Judgement.Miss, 0}
};

/// <summary>
/// The amount of mine hits the user got.
/// </summary>
public int CountMineHit { get; set; } = 0;

/// <summary>
/// The judgement windows defined per mode.
/// </summary>
Expand Down Expand Up @@ -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();
Expand Down
16 changes: 15 additions & 1 deletion Quaver.API/Maps/Processors/Scoring/ScoreProcessorKeys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ public sealed class ScoreProcessorKeys : ScoreProcessor
/// </summary>
private int TotalJudgements { get; }

/// <summary>
/// Total number of mines in the map.
/// </summary>
private int MineCount { get; }

/// <summary>
/// See: ScoreProcessorKeys.CalculateSummedScore();
/// </summary>
Expand Down Expand Up @@ -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();
}
Expand All @@ -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();
}
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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
Expand Down
28 changes: 27 additions & 1 deletion Quaver.API/Replays/Replay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ public class Replay
/// <summary>
/// The version of the replay.
/// </summary>
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);

/// <summary>
/// The game mode this replay is for.
Expand Down Expand Up @@ -115,6 +117,11 @@ public class Replay
/// Amount of miss judgements.
/// </summary>
public int CountMiss { get; set; }

/// <summary>
/// Amount of mine hits.
/// </summary>
public int CountMineHit { get; set; }

/// <summary>
/// The amount of times paused in the play.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;
}

/// <summary>
Expand Down Expand Up @@ -481,6 +501,12 @@ public List<ReplayKeyPressInfo> GetKeyPresses()
/// <returns></returns>
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}");
Expand Down
11 changes: 2 additions & 9 deletions Quaver.API/Replays/Virtual/VirtualReplayPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
Loading