Make random a bit less random, but already sung songs shouldn't be suggested frequently.

This commit is contained in:
Florian Küpper committed 2013-12-19 08:50:46 +01:00
1 parent 2d4cedbf8a
commit 524d0bee75
4 files changed
+24 -2

No files matched your search

@@ -513,12 +513,18 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
return false;
}
//Calc avarage sing-count
int totalCounts = 0;
foreach (CSong song in visibleSongs)
totalCounts += song.NumPlayedSession;
int averageCount = totalCounts / visibleSongs.Count;
// ReSharper disable LoopCanBeConvertedToQuery
foreach (CSong song in visibleSongs)
{
foreach (EGameMode mode in song.AvailableGameModes)
{
if (mode == EGameMode.TR_GAMEMODE_MEDLEY)
if (mode == EGameMode.TR_GAMEMODE_MEDLEY && song.NumPlayedSession <= averageCount)
ids.Add(song.ID);
}
}
+14 -1
View File
@@ -217,7 +217,20 @@ namespace Vocaluxe.Base
public static void UpdateRandomSongList()
{
_SongsForRandom.Clear();
_SongsForRandom.AddRange(VisibleSongs);
//Calc avarage sing-count
int totalCounts = 0;
foreach (CSong song in VisibleSongs)
totalCounts += song.NumPlayedSession;
int averageCount = totalCounts / NumSongsVisible;
foreach(CSong song in VisibleSongs)
{
if (song.NumPlayedSession <= averageCount)
_SongsForRandom.Add(song);
}
if(_SongsForRandom.Count == 0)
_SongsForRandom.AddRange(VisibleSongs);
}
public static int GetRandomCategory()
+1
View File
@@ -409,6 +409,7 @@ namespace Vocaluxe.Screens
CSong song = CSongs.GetSong(players[p].SongID);
CDataBase.IncreaseSongCounter(song.DataBaseSongID);
song.NumPlayed++;
song.NumPlayedSession++;
break;
}
}
+2
View File
@@ -174,6 +174,7 @@ namespace VocaluxeLib.Songs
public int DataBaseSongID = -1;
public string DateAdded = "";
public int NumPlayed;
public int NumPlayedSession;
// Notes
public readonly CNotes Notes = new CNotes();
@@ -266,6 +267,7 @@ namespace VocaluxeLib.Songs
DataBaseSongID = song.DataBaseSongID;
DateAdded = song.DateAdded;
NumPlayed = song.NumPlayed;
NumPlayedSession = song.NumPlayedSession;
Notes = new CNotes(song.Notes);
}