|
|
|
@ -21,13 +21,13 @@ namespace QwirkleClassLibrary.Players
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Returns the index of the player in the leaderboard, -1 if the player is not in the leaderboard
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="player"></param>
|
|
|
|
|
/// <param name="playerTag"></param>
|
|
|
|
|
/// <returns>int</returns>
|
|
|
|
|
public int IsPlayerIn(Player player)
|
|
|
|
|
public int IsPlayerIn(string playerTag)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < leaderboard.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
if (player.NameTag == leaderboard[i].PlayerName)
|
|
|
|
|
if (playerTag == leaderboard[i].PlayerName)
|
|
|
|
|
{
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
@ -39,13 +39,13 @@ namespace QwirkleClassLibrary.Players
|
|
|
|
|
/// Adds the score of the players in the leaderboard with the date of the day and the number of victories
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="scoreBoard"></param>
|
|
|
|
|
public void AddScoreInLead(ReadOnlyDictionary<Player, int> scoreBoard)
|
|
|
|
|
public void AddScoreInLead(ReadOnlyDictionary<string, int> scoreBoard)
|
|
|
|
|
{
|
|
|
|
|
DateTime now = DateTime.Now;
|
|
|
|
|
bool first = true;
|
|
|
|
|
var sb = scoreBoard.OrderByDescending(x => x.Value).ThenBy(x => x.Key.NameTag);
|
|
|
|
|
var sb = scoreBoard.OrderByDescending(x => x.Value).ThenBy(x => x.Key);
|
|
|
|
|
|
|
|
|
|
foreach (KeyValuePair<Player, int> pair in sb)
|
|
|
|
|
foreach (KeyValuePair<string, int> pair in sb)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
int i = IsPlayerIn(pair.Key);
|
|
|
|
@ -72,7 +72,7 @@ namespace QwirkleClassLibrary.Players
|
|
|
|
|
{
|
|
|
|
|
v = 1;
|
|
|
|
|
}
|
|
|
|
|
Score score = new Score(pair.Key.NameTag, now, pair.Value, v);
|
|
|
|
|
Score score = new Score(pair.Key, now, pair.Value, v);
|
|
|
|
|
leaderboard.Add(score);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|