diff --git a/Vocaluxe/Base/CDataBase.cs b/Vocaluxe/Base/CDataBase.cs index 2e9c4b65..89b32fb4 100644 --- a/Vocaluxe/Base/CDataBase.cs +++ b/Vocaluxe/Base/CDataBase.cs @@ -71,6 +71,50 @@ namespace Vocaluxe.Base } #region Highscores + + public static void IncreaseSongCounter(SPlayer player) + { + using (SQLiteConnection connection = new SQLiteConnection()) + { + connection.ConnectionString = "Data Source=" + _HighscoreFilePath; + + try + { + connection.Open(); + } + catch (Exception) + { + } + + using (SQLiteCommand command = new SQLiteCommand(connection)) + { + int dataBaseSongID = _GetDataBaseSongID(player, command); + _IncreaseSongCounter(dataBaseSongID, command); + } + } + } + + public static void IncreaseSongCounter(int dataBaseSongID) + { + using (SQLiteConnection connection = new SQLiteConnection()) + { + connection.ConnectionString = "Data Source=" + _HighscoreFilePath; + + try + { + connection.Open(); + } + catch (Exception) + { + } + + using (SQLiteCommand command = new SQLiteCommand(connection)) + { + _IncreaseSongCounter(dataBaseSongID, command); + } + } + } + public static int AddScore(string playerName, int score, int lineNr, long date, int medley, int duet, int shortSong, int difficulty, string artist, string title, int numPlayed, string filePath) { @@ -250,6 +294,13 @@ namespace Vocaluxe.Base } } + private static void _IncreaseSongCounter(int dataBaseSongID, SQLiteCommand command) + { + command.CommandText = "UPDATE Songs SET NumPlayed = NumPlayed + 1 WHERE [id] = @id"; + command.Parameters.Add("@id", DbType.Int32, 0).Value = dataBaseSongID; + command.ExecuteNonQuery(); + } + private static int _GetDataBaseSongID(SPlayer player, SQLiteCommand command) { CSong song = CSongs.GetSong(player.SongID); diff --git a/Vocaluxe/Screens/CScreenScore.cs b/Vocaluxe/Screens/CScreenScore.cs index 94838312..d35396ee 100644 --- a/Vocaluxe/Screens/CScreenScore.cs +++ b/Vocaluxe/Screens/CScreenScore.cs @@ -123,6 +123,8 @@ namespace Vocaluxe.Screens _Round = CGame.NumRounds > 1 ? 0 : 1; _Points = CGame.GetPoints(); + _SavePlayedSongs(); + _SetVisibility(); _UpdateRatings(); } @@ -389,6 +391,23 @@ namespace Vocaluxe.Screens } } + private void _SavePlayedSongs() + { + for (int round = 0; round < _Points.NumRounds; round++) + { + SPlayer[] players = _Points.GetPlayer(round, CGame.NumPlayer); + + for (int p = 0; p < players.Length; p++) + { + //if (players[p].Points > CSettings.MinScoreForDB && players[p].SongFinished) + //{ + CDataBase.IncreaseSongCounter(players[p]); + break; + //} + } + } + } + private void _LeaveScreen() { CParty.LeavingScore();