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); } }
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(); } }
public void DeleteOngoingMatch(OngoingMatch ongoingMatch) { OngoingMatches.Remove(ongoingMatch); }
public void AddOngoingMatch(OngoingMatch ongoingMatch) { OngoingMatches.Add(ongoingMatch); }