|
|
|
@ -10,27 +10,26 @@ namespace QwirkleClassLibrary.Players
|
|
|
|
|
{
|
|
|
|
|
public class Leaderboard
|
|
|
|
|
{
|
|
|
|
|
public ReadOnlyCollection<Score> LB => leaderb.AsReadOnly();
|
|
|
|
|
private readonly List<Score> leaderb = new();
|
|
|
|
|
public Leaderboard() { }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ReadOnlyCollection<Score> Lb => leaderboard.AsReadOnly();
|
|
|
|
|
private readonly List<Score> leaderboard = new();
|
|
|
|
|
|
|
|
|
|
public int IsPlayerIn(Player player)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < leaderb.Count; i++)
|
|
|
|
|
for (int i = 0; i < leaderboard.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
if (player.NameTag == leaderb[i].PlayerName)
|
|
|
|
|
if (player.NameTag == leaderboard[i].PlayerName)
|
|
|
|
|
{
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
public void AddScoreInLead(ReadOnlyDictionary<Player, int> ScoreBoard)
|
|
|
|
|
|
|
|
|
|
public void AddScoreInLead(ReadOnlyDictionary<Player, int> scoreBoard)
|
|
|
|
|
{
|
|
|
|
|
DateTime now = DateTime.Today;
|
|
|
|
|
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.NameTag);
|
|
|
|
|
|
|
|
|
|
foreach (KeyValuePair<Player, int> pair in sb)
|
|
|
|
|
{
|
|
|
|
@ -39,14 +38,14 @@ namespace QwirkleClassLibrary.Players
|
|
|
|
|
|
|
|
|
|
if (i != -1)
|
|
|
|
|
{
|
|
|
|
|
leaderb[i].Date = now;
|
|
|
|
|
leaderboard[i].Date = now;
|
|
|
|
|
|
|
|
|
|
if (first)
|
|
|
|
|
{
|
|
|
|
|
leaderb[i].Victories++;
|
|
|
|
|
leaderboard[i].Victories++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
leaderb[i].Points = pair.Value;
|
|
|
|
|
leaderboard[i].Points = pair.Value;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
@ -57,7 +56,7 @@ namespace QwirkleClassLibrary.Players
|
|
|
|
|
v = 1;
|
|
|
|
|
}
|
|
|
|
|
Score score = new Score(pair.Key.NameTag, now, pair.Value, v);
|
|
|
|
|
leaderb.Add(score);
|
|
|
|
|
leaderboard.Add(score);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
first = false;
|
|
|
|
|