Fix crash if list is empty
This commit is contained in:
@@ -23,18 +23,24 @@ namespace LobbyServer
|
||||
else
|
||||
{
|
||||
_scores = new List<ScoreEntry>();
|
||||
_scores.Add(new ScoreEntry("QuadraLudi", 0));
|
||||
}
|
||||
}
|
||||
|
||||
public void Add(ScoreEntry entry)
|
||||
{
|
||||
_scores.Add(entry);
|
||||
_scores.OrderByDescending(x => x.Score);
|
||||
Sort();
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
File.WriteAllText(FilePath, JsonConvert.SerializeObject(_scores));
|
||||
}
|
||||
|
||||
private void Sort()
|
||||
{
|
||||
_scores = _scores.OrderByDescending(x => x.Score).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user