Example #1
0
 public void WonMatch(TournyMatch match)
 {
     this.AddLog("Match won.");
 }
Example #2
0
 public void LostMatch(TournyMatch match)
 {
     this.AddLog("Match lost.");
 }
Example #3
0
        public void HandleWon(Arena arena, TournyMatch match, TournyParticipant winner)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("The match is complete. ");
            sb.Append(winner.NameList);

            if (winner.Players.Count > 1)
                sb.Append(" have bested ");
            else
                sb.Append(" has bested ");

            if (match.Participants.Count > 2)
                sb.AppendFormat("{0} other {1}: ", match.Participants.Count - 1, winner.Players.Count == 1 ? "players" : "teams");

            bool hasAppended = false;

            for (int j = 0; j < match.Participants.Count; ++j)
            {
                TournyParticipant part = (TournyParticipant)match.Participants[j];

                if (part == winner)
                    continue;

                this.m_Undefeated.Remove(part);

                if (hasAppended)
                    sb.Append(", ");

                sb.Append(part.NameList);
                hasAppended = true;
            }

            sb.Append(".");

            if (this.m_TournyType == TournyType.Standard)
                this.Alert(arena, sb.ToString());
        }
Example #4
0
        public void HandleTie(Arena arena, TournyMatch match, ArrayList remaining)
        {
            if (remaining.Count == 1)
                this.HandleWon(arena, match, (TournyParticipant)remaining[0]);

            if (remaining.Count < 2)
                return;

            StringBuilder sb = new StringBuilder();

            sb.Append("The match has ended in a tie ");

            if (remaining.Count == 2)
                sb.Append("between ");
            else
                sb.Append("among ");

            sb.Append(remaining.Count);

            if (((TournyParticipant)remaining[0]).Players.Count == 1)
                sb.Append(" players: ");
            else
                sb.Append(" teams: ");

            bool hasAppended = false;

            for (int j = 0; j < match.Participants.Count; ++j)
            {
                TournyParticipant part = (TournyParticipant)match.Participants[j];

                if (remaining.Contains(part))
                {
                    if (hasAppended)
                        sb.Append(", ");

                    sb.Append(part.NameList);
                    hasAppended = true;
                }
                else
                {
                    this.m_Undefeated.Remove(part);
                }
            }

            sb.Append(". ");

            string whole = (remaining.Count == 2 ? "both" : "all");

            TieType tieType = this.m_TieType;

            if (tieType == TieType.FullElimination && remaining.Count >= this.m_Undefeated.Count)
                tieType = TieType.FullAdvancement;

            switch ( this.m_TieType )
            {
                case TieType.FullAdvancement:
                    {
                        sb.AppendFormat("In accordance with the rules, {0} parties are advanced.", whole);
                        break;
                    }
                case TieType.FullElimination:
                    {
                        for (int j = 0; j < remaining.Count; ++j)
                            this.m_Undefeated.Remove(remaining[j]);

                        sb.AppendFormat("In accordance with the rules, {0} parties are eliminated.", whole);
                        break;
                    }
                case TieType.Random:
                    {
                        TournyParticipant advanced = (TournyParticipant)remaining[Utility.Random(remaining.Count)];

                        for (int i = 0; i < remaining.Count; ++i)
                        {
                            if (remaining[i] != advanced)
                                this.m_Undefeated.Remove(remaining[i]);
                        }

                        if (advanced != null)
                            sb.AppendFormat("In accordance with the rules, {0} {1} advanced.", advanced.NameList, advanced.Players.Count == 1 ? "is" : "are");

                        break;
                    }
                case TieType.Highest:
                    {
                        TournyParticipant advanced = null;

                        for (int i = 0; i < remaining.Count; ++i)
                        {
                            TournyParticipant part = (TournyParticipant)remaining[i];

                            if (advanced == null || part.TotalLadderXP > advanced.TotalLadderXP)
                                advanced = part;
                        }

                        for (int i = 0; i < remaining.Count; ++i)
                        {
                            if (remaining[i] != advanced)
                                this.m_Undefeated.Remove(remaining[i]);
                        }

                        if (advanced != null)
                            sb.AppendFormat("In accordance with the rules, {0} {1} advanced.", advanced.NameList, advanced.Players.Count == 1 ? "is" : "are");

                        break;
                    }
                case TieType.Lowest:
                    {
                        TournyParticipant advanced = null;

                        for (int i = 0; i < remaining.Count; ++i)
                        {
                            TournyParticipant part = (TournyParticipant)remaining[i];

                            if (advanced == null || part.TotalLadderXP < advanced.TotalLadderXP)
                                advanced = part;
                        }

                        for (int i = 0; i < remaining.Count; ++i)
                        {
                            if (remaining[i] != advanced)
                                this.m_Undefeated.Remove(remaining[i]);
                        }

                        if (advanced != null)
                            sb.AppendFormat("In accordance with the rules, {0} {1} advanced.", advanced.NameList, advanced.Players.Count == 1 ? "is" : "are");

                        break;
                    }
            }

            this.Alert(arena, sb.ToString());
        }
Example #5
0
 public void LostMatch(TournyMatch match)
 {
     Points += 20;
     AddLog("Match lost.");
 }
Example #6
0
 public void WonMatch(TournyMatch match)
 {
     Points += 30;
     AddLog("Match won.");
 }