private int CalculateQuality(List<HammerHit> hits, List<BlacksmithDot> dots)
{
var total = 0.0;
for (int i = 0; i < hits.Count; ++i)
{
var p1 = dots[i];
var p2 = hits[i];
// Static -30 when not hit at all or timing was wrong
// Time should be between 4k and 5k with time
// displacement 1.
if (!p2.Performed || p2.Timing < 4000 || p2.Timing > 5000)
{
total += 30;
continue;
}
// Calculate distance between dot and hit performed by the player
total += Math.Sqrt(Math.Pow(p1.X - p2.X, 2) + Math.Pow(p1.Y - p2.Y, 2));
}
// Quality = 100 - (Total Distance * 2)
// Min = -100
// Max = 100 (increasing the max would increase the chance for 100 quality)
return Math.Max(-100, 100 - (int)(total * 2));
}