Exemple #1
0
 /// <summary>
 /// Adds a new player.
 /// </summary>
 /// <returns><c>true</c>, if player was added, <c>false</c> otherwise.</returns>
 /// <param name="name">Name.</param>
 /// <param name="alias">Alias.</param>
 public bool AddPlayer(string name, string alias)
 {
     if (FindPlayerByName(name) < 0)
     {
         var NewPlayer = new DataManager.Player();
         NewPlayer.name       = name;
         NewPlayer.aliases    = new List <string>(alias.Split(new char[0]));
         NewPlayer.draws      = 0;
         NewPlayer.index      = DataManager.Data.Players.Count;
         NewPlayer.id         = Convert.ToBase64String(Guid.NewGuid().ToByteArray());
         NewPlayer.rating     = 1000.00;
         NewPlayer.totalgames = 0;
         NewPlayer.wins       = 0;
         DataManager.Data.Players.Add(NewPlayer);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemple #2
0
 public void AdjustElo(DataManager.Player P1, DataManager.Player P2, int winner)
 {
     double[] NewElo = EloManager.CalculateElo(P1.rating, P2.rating, winner);
     EditPlayerElo(P1.id, NewElo[0]);
     EditPlayerElo(P2.id, NewElo[1]);
 }