Exemple #1
0
        public ArenaParticipant(PlayerMobile player, ArenaMatch arenaMatch, int teamIndex) : base(0x0)
        {
            m_Player     = player;
            m_ArenaMatch = arenaMatch;

            if (m_ArenaMatch == null)
            {
                Delete();
            }

            ArenaTeam team1 = m_ArenaMatch.GetTeam(0);
            ArenaTeam team2 = m_ArenaMatch.GetTeam(1);

            if (team1 != null && teamIndex == 0)
            {
                team1.m_Participants.Add(this);
            }

            if (team2 != null && teamIndex == 1)
            {
                team2.m_Participants.Add(this);
            }

            Visible = false;
            Movable = false;
        }
Exemple #2
0
        public ArenaTeam GetPlayerTeam()
        {
            if (m_Player == null)
            {
                return(null);
            }

            ArenaTeam arenaTeam = null;

            if (!ArenaMatch.IsValidArenaMatch(m_ArenaMatch, null, false))
            {
                return(null);
            }

            foreach (ArenaTeam team in m_ArenaMatch.m_Teams)
            {
                if (team == null)
                {
                    continue;
                }
                if (team.Deleted)
                {
                    continue;
                }

                if (team.GetPlayerParticipant(m_Player) != null)
                {
                    return(team);
                }
            }

            return(arenaTeam);
        }
Exemple #3
0
        public override void OnDelete()
        {
            Queue m_TeamsQueue       = new Queue();
            Queue m_ParticipantQueue = new Queue();

            foreach (ArenaTeam arenaTeam in m_Teams)
            {
                if (arenaTeam == null)
                {
                    continue;
                }

                m_TeamsQueue.Enqueue(arenaTeam);

                foreach (ArenaParticipant participant in arenaTeam.m_Participants)
                {
                    if (participant == null)
                    {
                        continue;
                    }

                    m_ParticipantQueue.Enqueue(participant);

                    if (participant.m_Player != null)
                    {
                        participant.m_Player.m_ArenaPlayerSettings.m_ArenaMatch = null;
                    }
                }
            }

            while (m_ParticipantQueue.Count > 0)
            {
                ArenaParticipant arenaParticipant = (ArenaParticipant)m_ParticipantQueue.Dequeue();

                arenaParticipant.Delete();
            }

            while (m_TeamsQueue.Count > 0)
            {
                ArenaTeam arenaTeam = (ArenaTeam)m_TeamsQueue.Dequeue();

                arenaTeam.Delete();
            }

            if (m_ArenaGroupController != null)
            {
                if (m_ArenaGroupController.m_MatchListings.Contains(this))
                {
                    m_ArenaGroupController.m_MatchListings.Remove(this);
                }
            }

            if (m_ArenaMatchResultEntry != null)
            {
                m_ArenaMatchResultEntry.Delete();
            }

            base.OnDelete();
        }
Exemple #4
0
        public static bool IsValidArenaMatch(ArenaMatch arenaMatch, PlayerMobile player, bool checkIfPlayerCanJoin)
        {
            if (arenaMatch == null)
            {
                return(false);
            }
            if (arenaMatch.Deleted)
            {
                return(false);
            }
            if (arenaMatch.m_ArenaGroupController == null)
            {
                return(false);
            }
            if (arenaMatch.m_ArenaGroupController.Deleted)
            {
                return(false);
            }
            if (arenaMatch.m_Ruleset == null)
            {
                return(false);
            }
            if (arenaMatch.m_Ruleset.Deleted)
            {
                return(false);
            }

            if (checkIfPlayerCanJoin)
            {
                if (!arenaMatch.CanPlayerJoinMatch(player))
                {
                    return(false);
                }
            }

            ArenaTeam arenaTeam1 = arenaMatch.GetTeam(0);
            ArenaTeam arenaTeam2 = arenaMatch.GetTeam(1);

            if (arenaTeam1 == null)
            {
                return(false);
            }
            if (arenaTeam1.Deleted)
            {
                return(false);
            }
            if (arenaTeam2 == null)
            {
                return(false);
            }
            if (arenaTeam2.Deleted)
            {
                return(false);
            }

            return(true);
        }
Exemple #5
0
        public void CancelMatch()
        {
            BroadcastMessage("The current arena match you were in has been canceled.", 1256);

            List <PlayerMobile> m_Players = new List <PlayerMobile>();

            Queue m_TeamsQueue       = new Queue();
            Queue m_ParticipantQueue = new Queue();

            foreach (ArenaTeam arenaTeam in m_Teams)
            {
                if (arenaTeam == null)
                {
                    continue;
                }

                m_TeamsQueue.Enqueue(arenaTeam);

                foreach (ArenaParticipant participant in arenaTeam.m_Participants)
                {
                    if (participant == null)
                    {
                        continue;
                    }

                    m_ParticipantQueue.Enqueue(participant);

                    if (participant.m_Player != null)
                    {
                        m_Players.Add(participant.m_Player);
                    }

                    if (participant.m_Player != null)
                    {
                        participant.m_Player.m_ArenaPlayerSettings.m_ArenaMatch = null;
                    }
                }
            }

            while (m_ParticipantQueue.Count > 0)
            {
                ArenaParticipant arenaParticipant = (ArenaParticipant)m_ParticipantQueue.Dequeue();

                arenaParticipant.Delete();
            }

            while (m_TeamsQueue.Count > 0)
            {
                ArenaTeam arenaTeam = (ArenaTeam)m_TeamsQueue.Dequeue();

                arenaTeam.Delete();
            }

            Delete();

            foreach (PlayerMobile player in m_Players)
            {
                if (player.HasGump(typeof(ArenaGump)) && player.m_ArenaGumpObject != null)
                {
                    player.CloseGump(typeof(ArenaGump));
                    player.SendGump(new ArenaGump(player, player.m_ArenaGumpObject));
                }
            }
        }
Exemple #6
0
        public void LeaveMatch(PlayerMobile player, bool broadcast, bool gumpUpdateParticipants)
        {
            if (!IsValidArenaMatch(this, null, false))
            {
                return;
            }

            if (player == null)
            {
                return;
            }

            string playerName = player.RawName;

            ArenaTeam        playerTeam        = null;
            ArenaParticipant playerParticipant = null;

            foreach (ArenaTeam team in m_Teams)
            {
                if (team == null)
                {
                    continue;
                }
                if (team.Deleted)
                {
                    continue;
                }

                foreach (ArenaParticipant participant in team.m_Participants)
                {
                    if (participant == null)
                    {
                        continue;
                    }
                    if (participant.Deleted)
                    {
                        continue;
                    }
                    if (participant.m_Player == null)
                    {
                        continue;
                    }

                    if (participant.m_Player == player)
                    {
                        playerTeam        = team;
                        playerParticipant = participant;

                        break;
                    }
                }
            }

            if (playerTeam != null && playerParticipant != null)
            {
                if (playerTeam.m_Participants.Contains(playerParticipant))
                {
                    playerTeam.m_Participants.Remove(playerParticipant);
                }

                playerParticipant.Delete();

                player.m_ArenaPlayerSettings.m_ArenaMatch = null;
            }

            if (player == m_Creator)
            {
                CancelMatch();
            }

            else
            {
                if (broadcast)
                {
                    BroadcastMessage(playerName + " has left the match.", 0);
                }
            }

            if (gumpUpdateParticipants)
            {
                ParticipantsForceGumpUpdate();
            }
        }