From 7edff72194e31cbf4ca1ea365e904ce2ad5087b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20K=C3=BCpper?= Date: Sat, 2 Sep 2017 23:13:59 +0200 Subject: [PATCH] Calculate player rating based on last sung line --- Vocaluxe/Base/CGame.cs | 9 ++++++++- VocaluxeLib/Structs.cs | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Vocaluxe/Base/CGame.cs b/Vocaluxe/Base/CGame.cs index 187ac2bf..4e4a7b21 100644 --- a/Vocaluxe/Base/CGame.cs +++ b/Vocaluxe/Base/CGame.cs @@ -199,6 +199,7 @@ namespace Vocaluxe.Base Players[i].Points = 0f; Players[i].PointsLineBonus = 0f; Players[i].PointsGoldenNotes = 0f; + Players[i].Rating = 0.5f; Players[i].VoiceNr = 0; Players[i].NoteDiff = 0; Players[i].SungLines = new List(); @@ -343,10 +344,11 @@ namespace Vocaluxe.Base } } - // Line Bonus + // Check if line ended int numLinesWithPoints = song.Notes.GetNumLinesWithPoints(Players[p].VoiceNr); if (beat == lines[line].LastNoteBeat && lines[line].Points > 0 && numLinesWithPoints > 0) { + // Line Bonus double factor = Players[p].SungLines[line].Points / (double)lines[line].Points; if (factor <= 0.4) factor = 0.0; @@ -363,6 +365,11 @@ namespace Vocaluxe.Base Players[p].Points += points; Players[p].PointsLineBonus += points; Players[p].SungLines[line].BonusPoints += points; + + //Calculate rating + double stretchFactor = 0.2; + double current = Players[p].SungLines[line].Points / (double)lines[line].Points; + Players[p].Rating = (Players[p].Rating + (current * stretchFactor - 0.1)).Clamp(0, 1); } } } diff --git a/VocaluxeLib/Structs.cs b/VocaluxeLib/Structs.cs index 09a1b960..9c1d4a0b 100644 --- a/VocaluxeLib/Structs.cs +++ b/VocaluxeLib/Structs.cs @@ -362,6 +362,7 @@ namespace VocaluxeLib public double Points; public double PointsLineBonus; public double PointsGoldenNotes; + public double Rating; public int NoteDiff; public int VoiceNr; public List SungLines;