Added saving number of played times of a song. ATTENTION: This is not very fast. Maybe someone has a better solution.
This commit is contained in:
1 parent
4a91f39743
commit
de1b7161da
2 files changed
+70
No files matched your search
@@ -71,6 +71,50 @@ namespace Vocaluxe.Base
|
|||||||
}
|
}
|
||||||
|
|
||||||
#region Highscores
|
#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,
|
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)
|
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)
|
private static int _GetDataBaseSongID(SPlayer player, SQLiteCommand command)
|
||||||
{
|
{
|
||||||
CSong song = CSongs.GetSong(player.SongID);
|
CSong song = CSongs.GetSong(player.SongID);
|
||||||
|
|||||||
@@ -123,6 +123,8 @@ namespace Vocaluxe.Screens
|
|||||||
_Round = CGame.NumRounds > 1 ? 0 : 1;
|
_Round = CGame.NumRounds > 1 ? 0 : 1;
|
||||||
_Points = CGame.GetPoints();
|
_Points = CGame.GetPoints();
|
||||||
|
|
||||||
|
_SavePlayedSongs();
|
||||||
|
|
||||||
_SetVisibility();
|
_SetVisibility();
|
||||||
_UpdateRatings();
|
_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()
|
private void _LeaveScreen()
|
||||||
{
|
{
|
||||||
CParty.LeavingScore();
|
CParty.LeavingScore();
|
||||||
|
|||||||
Reference in new issue
Block a user