public void saveResults() { lock (players) { Matches newMatch = new Matches(); newMatch.TypeOfMatch = (int)this.room.RoomPropertes.GameMode; newMatch.GameSeed = this.room.RoomPropertes.seed; newMatch.TargetsUsed = (int)this.room.RoomPropertes.TargetTypesAllowed; newMatch.CursorUsed = (int)this.room.RoomPropertes.CursorType; List <Tuple <User, UserMatch> > usersAndReuslts = new List <Tuple <User, UserMatch> >(); DataBaseAPI db = new DataBaseAPI(); foreach (var player in players) { User user = db.getUser(player.Value.username); user.Elo += getEarnedElo(user.Username); UserMatch match = new UserMatch(); match.Match = newMatch; match.NumHits = player.Value.numberOfHits; match.NumMiss = player.Value.numbeerOfMisses; match.Points = 100; match.Rank = 1; match.User = user; usersAndReuslts.Add(new Tuple <User, UserMatch>(user, match)); } db.UpdateUsers(usersAndReuslts, newMatch); } }
public bool JoinRoom(string player, ICallBackPlayer callback) { lock (players) { if ((this.RoomPropertes.Settings & RoomSettings.PasswordProtected) != 0) { //Password check } if ((this.RoomPropertes.Settings & RoomSettings.EloRestricted) != 0) { //Elo check } if (players.Count >= this.roomProperties.maxPlayers) { return(false); } DataBaseAPI db = new DataBaseAPI(); User user = db.getUser(player); Shooter newshoter = new Shooter(); newshoter.username = player; newshoter.callback = callback; newshoter.elo = user.Elo; players.Add(player, newshoter); subscriber.PlayersInTheRoom(players); return(true); } }