Ejemplo n.º 1
0
        /// <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.");
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
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));
        }
Ejemplo n.º 5
0
 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);
 }