Esempio n. 1
0
        private void RemoveUserAndGamesFromDb(int userId)
        {
            var games = _gameDataProxy.GetAllUserActiveGames(userId);

            games.ForEach(g =>
            {
                var players = g.GetPlayersInRoom();
                players.ForEach(p =>
                {
                    IUser user = p.user;
                    _userDataProxy.DeleteActiveGameOfUser(user.Id(), g.Id, g.GameNumber);
                    _userDataProxy.DeleteUserById(user.Id());
                });

                var specs = g.GetSpectetorInRoom();
                specs.ForEach(s =>
                {
                    IUser user = s.user;
                    _userDataProxy.DeleteSpectetorGameOfUSer(user.Id(), g.Id, g.GameNumber);
                    _userDataProxy.DeleteUserById(user.Id());
                });
                ReplayManager.DeleteGameReplay(g.Id, g.GameNumber);
                ReplayManager.DeleteGameReplay(g.Id, g.GameNumber);
                _gameDataProxy.DeleteGameRoomPref(g.Id);
                _gameDataProxy.DeleteGameRoom(g.Id, g.GameNumber);
            });
        }
Esempio n. 2
0
        public void Cleanup(int gameNum, int roomId, int userId1)
        {
            _userDataProxy.DeleteUserById(userId1);

            replayManager.DeleteGameReplay(roomId, 0);
            replayManager.DeleteGameReplay(roomId, 1);
            proxy.DeleteGameRoomPref(roomId);
            proxy.DeleteGameRoom(roomId, gameNum);
        }
Esempio n. 3
0
 //remove room form games list - remove the room remove the game from active game list and spectetor in user
 public bool RemoveRoom(int roomId)
 {
     lock (padlock)
     {
         bool  toReturn = false;
         IGame toRemove = GetRoomById(roomId);
         try
         {
             //games.Remove(toRemove);
             bool ans  = proxyDB.DeleteGameRoomPref(roomId);
             bool ans2 = proxyDB.DeleteGameRoom(roomId, ((GameRoom)toRemove).GetGameNum());
             toReturn = ans & ans2;
         }
         catch (Exception e)
         {
             ErrorLog log = new ErrorLog("Error while trying to remove game room");
             logControl.AddErrorLog(log);
             toReturn = false;
         }
         return(toReturn);
     }
 }