Ejemplo n.º 1
0
        public void AddScore(ChallengeEntry entry)
        {
            if (entry == null)
            {
                return;
            }

            entry.Score++;

            // refresh the gumps
            TeamDeathmatchGump.RefreshAllGumps(this, false);
        }
Ejemplo n.º 2
0
        public override void CheckForGameEnd()
        {
            if (Participants == null || !GameInProgress)
            {
                return;
            }

            ArrayList winner = new ArrayList();

            ArrayList teams = GetTeams();

            int leftstanding = 0;

            int maxscore = -99999;

            // has any team reached the target score
            TeamInfo lastt = null;

            foreach (TeamInfo t in teams)
            {
                if (!HasValidMembers(t))
                {
                    continue;
                }

                if (TargetScore > 0 && t.Score >= TargetScore)
                {
                    winner.Add(t);
                    t.Winner = true;
                }

                if (t.Score >= maxscore)
                {
                    maxscore = t.Score;
                }
                leftstanding++;
                lastt = t;
            }

            // check to make sure the team hasnt been disqualified

            // if only one is left then they are the winner
            if (leftstanding == 1 && winner.Count == 0)
            {
                winner.Add(lastt);
                lastt.Winner = true;
            }

            if (winner.Count == 0 && MatchLength > TimeSpan.Zero && (DateTime.Now >= MatchStart + MatchLength))
            {
                // find the highest score
                // has anyone reached the target score

                foreach (TeamInfo t in teams)
                {
                    if (!HasValidMembers(t))
                    {
                        continue;
                    }

                    if (t.Score >= maxscore)
                    {
                        winner.Add(t);
                        t.Winner = true;
                    }
                }
            }

            // and then check to see if this is the Deathmatch
            if (winner.Count > 0)
            {
                // declare the winner(s) and end the game
                foreach (TeamInfo t in winner)
                {
                    // flag all members as winners
                    foreach (IChallengeEntry entry in t.Members)
                    {
                        entry.Winner = true;
                    }
                    GameBroadcast(100414, t.ID);   // "Team {0} is the winner!"
                    AwardTeamWinnings(t.ID, TotalPurse / winner.Count);

                    if (winner.Count == 1)
                    {
                        Winner = t.ID;
                    }
                }

                RefreshAllNoto();

                EndGame();
                TeamDeathmatchGump.RefreshAllGumps(this, true);
            }
        }
Ejemplo n.º 3
0
        public void CheckForDisqualification()
        {
            if (Participants == null || !GameInProgress)
            {
                return;
            }

            bool statuschange = false;

            foreach (ChallengeEntry entry in Participants)
            {
                if (entry.Participant == null || entry.Status != ChallengeStatus.Active)
                {
                    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.Now - entry.LastCaution > MaximumOfflineDuration)
                            {
                                // penalize them
                                SubtractScore(entry);
                                entry.LastCaution = DateTime.Now;
                            }
                        }
                        else
                        {
                            entry.LastCaution = DateTime.Now;
                            statuschange      = true;
                        }

                        entry.Caution = ChallengeStatus.Offline;
                    }
                    else
                    {
                        // changing to any other map results in instant
                        // teleport back to the gauntlet
                        // and point loss
                        RespawnWithPenalty(entry);
                        entry.Caution = ChallengeStatus.None;
                    }
                }
                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.Now - entry.LastCaution > MaximumOutOfBoundsDuration)
                        {
                            // teleport them back to the gauntlet
                            RespawnWithPenalty(entry);
                            GameBroadcast(100401, entry.Participant.Name);  // "{0} was penalized."
                            entry.Caution = ChallengeStatus.None;
                            statuschange  = true;
                        }
                    }
                    else
                    {
                        entry.LastCaution = DateTime.Now;
                        // 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.Now - entry.LastCaution > MaximumHiddenDuration)
                        {
                            // penalize them
                            SubtractScore(entry);
                            entry.Participant.Hidden = false;
                            GameBroadcast(100401, entry.Participant.Name);  // "{0} was penalized."
                            entry.Caution = ChallengeStatus.None;
                            statuschange  = true;
                        }
                    }
                    else
                    {
                        entry.LastCaution = DateTime.Now;
                        // 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 (statuschange)
            {
                // update gumps with the new status
                TeamDeathmatchGump.RefreshAllGumps(this, false);
            }

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