private void GetMatchToCheck()
 {
     _checkingMatch = true;
     using (Repository repository = new Repository(_dbOptions)) {
         var match = repository.OngoingMatches.Include(m => m.Players).Where(m => m.Started.AddMinutes(Startup.Config.MatchCheckMinDuration) < DateTime.UtcNow && m.LastCheck.AddMinutes(1) < DateTime.UtcNow).ToList().OrderBy(m => m.LastCheck).FirstOrDefault();
         if (match != null)
         {
             _match         = match;
             _lastCheckTime = DateTime.UtcNow;
             _playerMatches = new Dictionary <string, List <string> >();
             foreach (var player in match.Players)
             {
                 if (!_playerMatches.ContainsKey(player.AccountId))
                 {
                     _playerMatches.Add(player.AccountId, null);
                 }
             }
             //_logger.Info("Checking lobby: " + match?.LobbyId);
         }
         else
         {
             _checkingMatch = false;
         }
     }
 }
 private void StopMatchChecking()
 {
     try {
         //_logger.Info("Stopping match checking");
         _checkingMatch         = false;
         _finalizingMatch       = false;
         _lastCheckTime         = null;
         _lastHistoryRequest    = null;
         _currentHistoryRequest = 0;
         _matchId       = 0;
         _playerMatches = null;
         _match         = null;
     } catch (Exception e) {
         _logger.Error("Error while stopping match checking", e);
     }
 }
Esempio n. 3
0
        public void RemoveMember(Player player)
        {
            lock (Players)
            {
                Players.RemoveAll(x => x == player);
            }

            VersionID++;
            player.SetActiveGroup(null);

            NotifyGroupUpdate();

            if (Lobby == null && (OngoingMatch == null || !OngoingMatch.Active) && (Players.Count == 0 || player == Leader))
            {
                Disband();
                OngoingMatch?.StopGameLoop();
            }
        }
Esempio n. 4
0
 public void DeleteOngoingMatch(OngoingMatch ongoingMatch)
 {
     OngoingMatches.Remove(ongoingMatch);
 }
Esempio n. 5
0
 public void AddOngoingMatch(OngoingMatch ongoingMatch)
 {
     OngoingMatches.Add(ongoingMatch);
 }