Exemplo n.º 1
0
        /// <summary>
        /// Adds a spectator
        /// </summary>
        public static void AddSpectator(Guid id)
        {
            var client = ClientHandler.GetById(id);

            if (client == null)
            {
                return;
            }

            if (Spectators.Contains(client))
            {
                return;
            }

            if (Participants.Contains(client))
            {
                Console.WriteLine($"Removed {client.Id}|{client.Name} from the game of {CurrentGameType} as Participant");
                ClientHandler.BroadcastServerMessage($"{client.Name} has left the game.");
                Participants.Remove(client);
            }

            Spectators.Add(client);

            Console.WriteLine($"Spectator {client.Id}|{client.Name} added to the game of {CurrentGameType}");
            ClientHandler.BroadcastServerMessage($"{client.Name} is now spectating.");
        }
Exemplo n.º 2
0
 public bool AddSpectator(string id)
 {
     if (Spectators.Contains(id))
     {
         return(false);
     }
     Spectators.Add(id);
     return(true);
 }
Exemplo n.º 3
0
        /// <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));
        }
Exemplo n.º 4
0
 public void MessageSpectators(Player p, string Content)
 {
     if (!Spectators.Contains(p) && this != p)
     {
         return;
     }
     if (this != p)
     {
         this.AddQueue(Packets.Packets.IrcMessage(Content, p.Username, "#spectator", p.Id));
     }
     for (int i = 0; i < Spectators.Count; i++)
     {
         if (Spectators[i] != p)
         {
             Spectators[i].AddQueue(Packets.Packets.IrcMessage(Content, p.Username, "#spectator", p.Id));
         }
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Adds a participant
        /// </summary>
        public static void AddParticipant(Client client)
        {
            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.");
        }
Exemplo n.º 6
0
 public bool IsSpectator(PlayerMobile pm)
 {
     return(Spectators.Contains(pm));
 }