Skip to content

Commit

Permalink
Merge pull request #27 from Syriiin/handle-zero-object-maps
Browse files Browse the repository at this point in the history
Handle zero object maps by defaulting acc to 100%
  • Loading branch information
Syriiin authored Jun 7, 2024
2 parents ee6597b + 93ce210 commit 0848c34
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Difficalcy.Catch/Services/CatchCalculatorService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ private static double CalculateAccuracy(Dictionary<HitResult, int> statistics)
double hits = statistics[HitResult.Great] + statistics[HitResult.LargeTickHit] + statistics[HitResult.SmallTickHit];
double total = hits + statistics[HitResult.Miss] + statistics[HitResult.SmallTickMiss];

if (total == 0)
return 1;

return hits / total;
}

Expand Down
3 changes: 3 additions & 0 deletions Difficalcy.Mania/Services/ManiaCalculatorService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ private static double CalculateAccuracy(Dictionary<HitResult, int> statistics)
var countMiss = statistics[HitResult.Miss];
var total = countPerfect + countGreat + countGood + countOk + countMeh + countMiss;

if (total == 0)
return 1;

return (double)((6 * countPerfect) + (6 * countGreat) + (4 * countGood) + (2 * countOk) + countMeh) / (6 * total);
}

Expand Down
3 changes: 3 additions & 0 deletions Difficalcy.Osu/Services/OsuCalculatorService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ private static double CalculateAccuracy(Dictionary<HitResult, int> statistics)
var countMiss = statistics[HitResult.Miss];
var total = countGreat + countOk + countMeh + countMiss;

if (total == 0)
return 1;

return (double)((6 * countGreat) + (2 * countOk) + countMeh) / (6 * total);
}

Expand Down
3 changes: 3 additions & 0 deletions Difficalcy.Taiko/Services/TaikoCalculatorService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ private static double CalculateAccuracy(Dictionary<HitResult, int> statistics)
var countMiss = statistics[HitResult.Miss];
var total = countGreat + countOk + countMiss;

if (total == 0)
return 1;

return (double)((2 * countGreat) + countOk) / (2 * total);
}

Expand Down

0 comments on commit 0848c34

Please sign in to comment.