Skip to content

Commit 93ce210

Browse files
committed
Handle zero object maps by defaulting acc to 100%
1 parent ee6597b commit 93ce210

File tree

4 files changed

+12
-0
lines changed

4 files changed

+12
-0
lines changed

Difficalcy.Catch/Services/CatchCalculatorService.cs

+3
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ private static double CalculateAccuracy(Dictionary<HitResult, int> statistics)
134134
double hits = statistics[HitResult.Great] + statistics[HitResult.LargeTickHit] + statistics[HitResult.SmallTickHit];
135135
double total = hits + statistics[HitResult.Miss] + statistics[HitResult.SmallTickMiss];
136136

137+
if (total == 0)
138+
return 1;
139+
137140
return hits / total;
138141
}
139142

Difficalcy.Mania/Services/ManiaCalculatorService.cs

+3
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ private static double CalculateAccuracy(Dictionary<HitResult, int> statistics)
127127
var countMiss = statistics[HitResult.Miss];
128128
var total = countPerfect + countGreat + countGood + countOk + countMeh + countMiss;
129129

130+
if (total == 0)
131+
return 1;
132+
130133
return (double)((6 * countPerfect) + (6 * countGreat) + (4 * countGood) + (2 * countOk) + countMeh) / (6 * total);
131134
}
132135

Difficalcy.Osu/Services/OsuCalculatorService.cs

+3
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ private static double CalculateAccuracy(Dictionary<HitResult, int> statistics)
132132
var countMiss = statistics[HitResult.Miss];
133133
var total = countGreat + countOk + countMeh + countMiss;
134134

135+
if (total == 0)
136+
return 1;
137+
135138
return (double)((6 * countGreat) + (2 * countOk) + countMeh) / (6 * total);
136139
}
137140

Difficalcy.Taiko/Services/TaikoCalculatorService.cs

+3
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ private static double CalculateAccuracy(Dictionary<HitResult, int> statistics)
128128
var countMiss = statistics[HitResult.Miss];
129129
var total = countGreat + countOk + countMiss;
130130

131+
if (total == 0)
132+
return 1;
133+
131134
return (double)((2 * countGreat) + countOk) / (2 * total);
132135
}
133136

0 commit comments

Comments
 (0)