示例#1
0
        public void CheckForDeathBall()
        {
            Mobile owner = null;

            if (m_DeathBall != null && m_DeathBall.RootParent is Mobile)
            {
                owner = m_DeathBall.RootParent as Mobile;
            }

            // only score if one player is carrying the ball
            if (owner != null)
            {
                IChallengeEntry entry = GetParticipant(owner);

                // dont let players who are in a caution state such as hidden or out of bounds to score
                if (entry != null && entry.Participant != null && entry.Caution == ChallengeStatus.None)
                {
                    // bump their score
                    entry.Score++;

                    // display the score
                    entry.Participant.PublicOverheadMessage(MessageType.Regular, 0, true, entry.Score.ToString());

                    // update all the gumps if you like
                    DeathBallGump.RefreshAllGumps(this, false);

                    // check for win conditions
                    CheckForGameEnd();
                }
            }
            else
            {
                // check to see if someone is carrying it
                if (Participants != null)
                {
                    foreach (IChallengeEntry entry in Participants)
                    {
                        if (entry.Status == ChallengeStatus.Active && entry.Participant != null && entry.Participant.Holding == m_DeathBall)
                        {
                            // bump their score
                            entry.Score++;

                            // display the score
                            entry.Participant.PublicOverheadMessage(MessageType.Regular, 0, true, entry.Score.ToString());

                            // update all the gumps if you like
                            DeathBallGump.RefreshAllGumps(this, false);

                            // check for win conditions
                            CheckForGameEnd();

                            break;
                        }
                    }
                }
            }
        }
示例#2
0
        public override void CheckForGameEnd()
        {
            if (Participants == null || !GameInProgress)
            {
                return;
            }

            int    leftstanding = 0;
            Mobile winner       = null;

            foreach (IChallengeEntry entry in Participants)
            {
                // either being the last participant left
                if (entry.Status == ChallengeStatus.Active)
                {
                    leftstanding++;
                    winner = entry.Participant;
                }

                // or reaching the target score
                if (entry.Score >= TargetScore)
                {
                    winner       = entry.Participant;
                    leftstanding = 1;
                    break;
                }
            }

            // and then check to see if this is the Death Ball
            if (leftstanding == 1 && winner != null)
            {
                // declare the winner and end the game
                XmlPoints.SendText(winner, 100311, ChallengeName);  // "You have won {0}"
                Winner = winner;
                RefreshSymmetricNoto(winner);
                GameBroadcast(100312, winner.Name);  // "The winner is {0}"
                AwardWinnings(winner, TotalPurse);
                EndGame();
                DeathBallGump.RefreshAllGumps(this, true);
            }
            if (leftstanding < 1)
            {
                // declare a tie and keep the fees
                GameBroadcast(100313);  // "The match is a draw"
                EndGame();
                DeathBallGump.RefreshAllGumps(this, true);
            }
        }
示例#3
0
        public void CheckForDisqualification()
        {
            if (Participants == null || !GameInProgress)
            {
                return;
            }

            bool statuschange = false;

            foreach (IChallengeEntry entry in Participants)
            {
                if (entry.Participant == null || entry.Status == ChallengeStatus.Forfeit || entry.Status == ChallengeStatus.Disqualified)
                {
                    continue;
                }

                bool hadcaution = (entry.Caution != ChallengeStatus.None);

                // and a map check
                if (entry.Participant.Map != Map)
                {
                    // check to see if they are offline
                    if (entry.Participant.Map == Map.Internal)
                    {
                        // then give them a little time to return before disqualification
                        if (entry.Caution == ChallengeStatus.Offline)
                        {
                            // were previously out of bounds so check for disqualification
                            // check to see how long they have been out of bounds
                            if (DateTime.UtcNow - entry.LastCaution > MaximumOfflineDuration)
                            {
                                entry.Status = ChallengeStatus.Disqualified;
                                GameBroadcast(100308, entry.Participant.Name);  // "{0} has been disqualified"
                                RefreshSymmetricNoto(entry.Participant);
                                statuschange = true;
                            }
                        }
                        else
                        {
                            entry.LastCaution = DateTime.UtcNow;
                            statuschange      = true;
                        }

                        entry.Caution = ChallengeStatus.Offline;
                    }
                    else
                    {
                        // changing to any other map is instant disqualification
                        entry.Status = ChallengeStatus.Disqualified;
                        GameBroadcast(100308, entry.Participant.Name);  // "{0} has been disqualified"
                        RefreshSymmetricNoto(entry.Participant);
                        statuschange = true;
                    }
                }
                else
                // make a range check
                if (m_ArenaSize > 0 && !Utility.InRange(entry.Participant.Location, Location, m_ArenaSize) ||
                    (IsInChallengeGameRegion && !(Region.Find(entry.Participant.Location, entry.Participant.Map) is ChallengeGameRegion)))
                {
                    if (entry.Caution == ChallengeStatus.OutOfBounds)
                    {
                        // were previously out of bounds so check for disqualification
                        // check to see how long they have been out of bounds
                        if (DateTime.UtcNow - entry.LastCaution > MaximumOutOfBoundsDuration)
                        {
                            entry.Status = ChallengeStatus.Disqualified;
                            GameBroadcast(100308, entry.Participant.Name);  // "{0} has been disqualified"
                            RefreshSymmetricNoto(entry.Participant);
                            statuschange = true;
                        }
                    }
                    else
                    {
                        entry.LastCaution = DateTime.UtcNow;
                        // inform the player
                        XmlPoints.SendText(entry.Participant, 100309, MaximumOutOfBoundsDuration.TotalSeconds);  // "You are out of bounds!  You have {0} seconds to return"
                        statuschange = true;
                    }

                    entry.Caution = ChallengeStatus.OutOfBounds;
                }
                else
                // make a hiding check
                if (entry.Participant.Hidden)
                {
                    if (entry.Caution == ChallengeStatus.Hidden)
                    {
                        // were previously hidden so check for disqualification
                        // check to see how long they have hidden
                        if (DateTime.UtcNow - entry.LastCaution > MaximumHiddenDuration)
                        {
                            entry.Status = ChallengeStatus.Disqualified;
                            GameBroadcast(100308, entry.Participant.Name);  // "{0} has been disqualified"
                            RefreshSymmetricNoto(entry.Participant);
                            statuschange = true;
                        }
                    }
                    else
                    {
                        entry.LastCaution = DateTime.UtcNow;
                        // inform the player
                        XmlPoints.SendText(entry.Participant, 100310, MaximumHiddenDuration.TotalSeconds); // "You have {0} seconds become unhidden"
                        statuschange = true;
                    }

                    entry.Caution = ChallengeStatus.Hidden;
                }
                else
                {
                    entry.Caution = ChallengeStatus.None;
                }

                if (hadcaution && entry.Caution == ChallengeStatus.None)
                {
                    statuschange = true;
                }

                // if they were disqualified, then drop any ball they might have had and boot them from the game
                if (entry.Status == ChallengeStatus.Disqualified)
                {
                    ClearChallenge(entry.Participant);
                    DropBall(entry.Participant, Location, Map);
                }
            }

            if (statuschange)
            {
                // update gumps with the new status
                DeathBallGump.RefreshAllGumps(this, false);
            }

            // it is possible that the game could end like this so check
            CheckForGameEnd();
        }