public void Check() { try { if (RoleplayGameManager.RunningGames.ContainsKey(GameMode.Brawl)) { #region Logged/Kicked Check if (Players.Count > 0 && !GameIsStarting) { List <int> PlayersToRemove = Players.Where(x => RoleplayManager.OfflineCheck(x, true, this)).ToList(); foreach (int playerId in PlayersToRemove) { Players.Remove(playerId); } } #endregion if (GameStarted && !GameIsStarting && Players.Count <= 2) { if (Players.Count == 2) { LastTwo(); } else if (Players.Count == 1) { Winner(); } else { Stop(); } } else if (Players.Count == MaxPlayers && !GameStarted && !GameIsStarting) { Start(); } } } catch (Exception e) { Logging.LogRPGamesError("Error in Check() void: " + e); } }
public void Check() { try { if (RoleplayGameManager.RunningGames.ContainsKey(GameMode.ColourWars)) { #region Room Notification if (1 == 1 /*!GameIsStarting && GameStarted*/) { Counter++; if (Counter >= 150) { Counter = 0; int RoomId = Convert.ToInt32(RoleplayData.GetData("colourwars", "lobbyid")); int MaxUsersPerTeam = Convert.ToInt32(RoleplayData.GetData("colourwars", "maxusersperteam")); var Room = RoleplayManager.GenerateRoom(RoomId); if (Room != null && Room.GetRoomUserManager() != null && Room.GetRoomUserManager().GetRoomUsers() != null) { RoleplayTeam Pink = null; RoleplayTeam Green = null; RoleplayTeam Blue = null; RoleplayTeam Yellow = null; if (Teams.ContainsKey("Pink")) { Pink = Teams["Rosa"]; } if (Teams.ContainsKey("Green")) { Green = Teams["Verde"]; } if (Teams.ContainsKey("Blue")) { Blue = Teams["Azul"]; } if (Teams.ContainsKey("Yellow")) { Yellow = Teams["Amarelo"]; } lock (Room.GetRoomUserManager().GetRoomUsers()) { foreach (var User in Room.GetRoomUserManager().GetRoomUsers()) { if (User == null || User.IsBot || User.GetClient() == null) { continue; } string Message = "Agora temos: " + (Pink == null ? "" : Pink.Members.Count + "/" + MaxUsersPerTeam + " Membros [ROSA], ") + (Green == null ? "" : Green.Members.Count + "/" + MaxUsersPerTeam + " Membros [VERDE], ") + (Blue == null ? "" : Blue.Members.Count + "/" + MaxUsersPerTeam + " Membros [AZUL] ") + (Yellow == null ? "" : Yellow.Members.Count + "/" + MaxUsersPerTeam + " Membros [AMARELO],").TrimEnd(',', ' '); User.GetClient().SendWhisper(Message, 34); } } } } } #endregion #region Logged/Kicked Check if (Players.Count > 0 && !GameIsStarting) { List <int> PlayersToRemove = Players.Where(x => RoleplayManager.OfflineCheck(x, true, this)).ToList(); foreach (int playerId in PlayersToRemove) { List <RoleplayTeam> AllTeams = Teams.Values.ToList(); bool HasTeam = AllTeams.Where(x => x.Members.Contains(playerId)).ToList().Count > 0; if (HasTeam) { RoleplayTeam Team = AllTeams.FirstOrDefault(x => x.Members.Contains(playerId)); if (Team != null) { Team.Members.Remove(playerId); } } Players.Remove(playerId); } } #endregion #region Main Checks if (GameStarted && !GameIsStarting && Teams.Count > 1) { TeamCheck(); } else if (GameStarted && !GameIsStarting && Teams.Count <= 1) { if (Teams.Count < 1) { Stop(); } else { Winner(Teams.Values.FirstOrDefault()); } } if (GameStarted && !GameIsStarting && Players.Count <= 0) { Stop(); } if (Players.Count == MaxPlayers && !GameStarted && !GameIsStarting) { Start(); } #endregion } } catch (Exception e) { Logging.LogRPGamesError("Error in Check() void: " + e); } }