/// <summary> /// Adds a participant /// </summary> public static void AddParticipant(Guid id) { var client = ClientHandler.GetById(id); if (client == null) { return; } if (Participants.Contains(client)) { return; } if (Spectators.Contains(client)) { Console.WriteLine($"Removed {client.Id}|{client.Name} from the game of {CurrentGameType} as Spectator"); ClientHandler.BroadcastServerMessage($"{client.Name} is no longer spectating."); Spectators.Remove(client); } Participants.Add(client); Console.WriteLine($"Participant {client.Id}|{client.Name} added to the game of {CurrentGameType}"); ClientHandler.BroadcastServerMessage($"{client.Name} has joined the game."); }
public void RemoveSpectator(PlayerMobile pm, bool teleport) { if (!IsSpectator(pm)) { return; } Spectators.Remove(pm); if (teleport) { var bounce = BounceInfo.GetValue(pm); if (bounce != null && !bounce.InternalOrZero) { Teleport(pm, bounce, bounce); BounceInfo.Remove(pm); } else { Teleport(pm, Options.Locations.Eject, Options.Locations.Eject); } } OnSpectatorRemoved(pm); }
public void RemoveSpectator(PlayerMobile pm, bool teleport) { if (!IsSpectator(pm)) { return; } Spectators.Remove(pm); if (teleport) { Teleport(pm, Options.Locations.Eject, Options.Locations.Eject.Map); } OnSpectatorRemoved(pm); }
/// <summary> /// Invokes the <see cref="UserDropping"/> event from derived classes. /// </summary> protected void OnDroppingUser(IUser user) { if (Players.Contains(user, DiscordComparers.UserComparer)) { Players = Players.Remove(user, DiscordComparers.UserComparer); } else if (Spectators.Contains(user, DiscordComparers.UserComparer)) { Spectators = Spectators.Remove(user, DiscordComparers.UserComparer); } else { throw new ArgumentException("The given user is not playing in or spectating this game.", nameof(user)); } UserDropping?.Invoke(this, new UserDroppingEventArgs(user)); }
public bool Disconnect(string id) { if (!Spectators.Remove(id)) { Player player = Players.Find(p => p.Id == id); if (player != null) { if (player.IsTurn) { NextTurn(); } if (Players.IndexOf(player) < PlayerTurn) { PlayerTurn--; } Players.Remove(player); return(true); } } return(false); }