Exemple #1
0
 public StartEntry(Tournament tourny)
     : base(5113)
 {
     this.m_Tournament = tourny;
 }
Exemple #2
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            switch ( version )
            {
                case 0:
                    {
                        this.m_Tournament = new Tournament(reader);
                        break;
                    }
            }

            m_Instances.Add(this);
        }
Exemple #3
0
 public EditEntry(Tournament tourny)
     : base(5101)
 {
     this.m_Tournament = tourny;
 }
Exemple #4
0
        public TournamentBracketGump(Mobile from, Tournament tourny, TournyBracketGumpType type, ArrayList list, int page, object obj)
            : base(50, 50)
        {
            this.m_From = from;
            this.m_Tournament = tourny;
            this.m_Type = type;
            this.m_List = list;
            this.m_Page = page;
            this.m_Object = obj;
            this.m_PerPage = 12;

            switch ( type )
            {
                case TournyBracketGumpType.Index:
                    {
                        this.AddPage(0);
                        this.AddBackground(0, 0, 300, 300, 9380);

                        StringBuilder sb = new StringBuilder();

                        if (tourny.TournyType == TournyType.FreeForAll)
                        {
                            sb.Append("FFA");
                        }
                        else if (tourny.TournyType == TournyType.RandomTeam)
                        {
                            sb.Append("Team");
                        }
                        else if (tourny.TournyType == TournyType.RedVsBlue)
                        {
                            sb.Append("Red v Blue");
                        }
                        else
                        {
                            for (int i = 0; i < tourny.ParticipantsPerMatch; ++i)
                            {
                                if (sb.Length > 0)
                                    sb.Append('v');

                                sb.Append(tourny.PlayersPerParticipant);
                            }
                        }

                        if (tourny.EventController != null)
                            sb.Append(' ').Append(tourny.EventController.Title);

                        sb.Append(" Tournament Bracket");

                        this.AddHtml(25, 35, 250, 20, this.Center(sb.ToString()), false, false);

                        this.AddRightArrow(25, 53, this.ToButtonID(0, 4), "Rules");
                        this.AddRightArrow(25, 71, this.ToButtonID(0, 1), "Participants");

                        if (this.m_Tournament.Stage == TournamentStage.Signup)
                        {
                            TimeSpan until = (this.m_Tournament.SignupStart + this.m_Tournament.SignupPeriod) - DateTime.Now;
                            string text;
                            int secs = (int)until.TotalSeconds;

                            if (secs > 0)
                            {
                                int mins = secs / 60;
                                secs %= 60;

                                if (mins > 0 && secs > 0)
                                    text = String.Format("The tournament will begin in {0} minute{1} and {2} second{3}.", mins, mins == 1 ? "" : "s", secs, secs == 1 ? "" : "s");
                                else if (mins > 0)
                                    text = String.Format("The tournament will begin in {0} minute{1}.", mins, mins == 1 ? "" : "s");
                                else if (secs > 0)
                                    text = String.Format("The tournament will begin in {0} second{1}.", secs, secs == 1 ? "" : "s");
                                else
                                    text = "The tournament will begin shortly.";
                            }
                            else
                            {
                                text = "The tournament will begin shortly.";
                            }

                            this.AddHtml(25, 92, 250, 40, text, false, false);
                        }
                        else
                        {
                            this.AddRightArrow(25, 89, this.ToButtonID(0, 2), "Rounds");
                        }

                        break;
                    }
                case TournyBracketGumpType.Rules_Info:
                    {
                        Ruleset ruleset = tourny.Ruleset;
                        Ruleset basedef = ruleset.Base;

                        BitArray defs;

                        if (ruleset.Flavors.Count > 0)
                        {
                            defs = new BitArray(basedef.Options);

                            for (int i = 0; i < ruleset.Flavors.Count; ++i)
                                defs.Or(((Ruleset)ruleset.Flavors[i]).Options);
                        }
                        else
                        {
                            defs = basedef.Options;
                        }

                        int changes = 0;

                        BitArray opts = ruleset.Options;

                        for (int i = 0; i < opts.Length; ++i)
                        {
                            if (defs[i] != opts[i])
                                ++changes;
                        }

                        this.AddPage(0);
                        this.AddBackground(0, 0, 300, 60 + 18 + 20 + 20 + 20 + 8 + 20 + (ruleset.Flavors.Count * 18) + 4 + 20 + (changes * 22) + 6, 9380);

                        this.AddLeftArrow(25, 11, this.ToButtonID(0, 0));
                        this.AddHtml(25, 35, 250, 20, this.Center("Rules"), false, false);

                        int y = 53;

                        string groupText = null;

                        switch ( tourny.GroupType )
                        {
                            case GroupingType.HighVsLow:
                                groupText = "High vs Low";
                                break;
                            case GroupingType.Nearest:
                                groupText = "Closest opponent";
                                break;
                            case GroupingType.Random:
                                groupText = "Random";
                                break;
                        }

                        this.AddHtml(35, y, 190, 20, String.Format("Grouping: {0}", groupText), false, false);
                        y += 20;

                        string tieText = null;

                        switch ( tourny.TieType )
                        {
                            case TieType.Random:
                                tieText = "Random";
                                break;
                            case TieType.Highest:
                                tieText = "Highest advances";
                                break;
                            case TieType.Lowest:
                                tieText = "Lowest advances";
                                break;
                            case TieType.FullAdvancement:
                                tieText = (tourny.ParticipantsPerMatch == 2 ? "Both advance" : "Everyone advances");
                                break;
                            case TieType.FullElimination:
                                tieText = (tourny.ParticipantsPerMatch == 2 ? "Both eliminated" : "Everyone eliminated");
                                break;
                        }

                        this.AddHtml(35, y, 190, 20, String.Format("Tiebreaker: {0}", tieText), false, false);
                        y += 20;

                        string sdText = "Off";

                        if (tourny.SuddenDeath > TimeSpan.Zero)
                        {
                            sdText = String.Format("{0}:{1:D2}", (int)tourny.SuddenDeath.TotalMinutes, tourny.SuddenDeath.Seconds);

                            if (tourny.SuddenDeathRounds > 0)
                                sdText = String.Format("{0} (first {1} rounds)", sdText, tourny.SuddenDeathRounds);
                            else
                                sdText = String.Format("{0} (all rounds)", sdText);
                        }

                        this.AddHtml(35, y, 240, 20, String.Format("Sudden Death: {0}", sdText), false, false);
                        y += 20;

                        y += 8;

                        this.AddHtml(35, y, 190, 20, String.Format("Ruleset: {0}", basedef.Title), false, false);
                        y += 20;

                        for (int i = 0; i < ruleset.Flavors.Count; ++i, y += 18)
                            this.AddHtml(35, y, 190, 20, String.Format(" + {0}", ((Ruleset)ruleset.Flavors[i]).Title), false, false);

                        y += 4;

                        if (changes > 0)
                        {
                            this.AddHtml(35, y, 190, 20, "Modifications:", false, false);
                            y += 20;

                            for (int i = 0; i < opts.Length; ++i)
                            {
                                if (defs[i] != opts[i])
                                {
                                    string name = ruleset.Layout.FindByIndex(i);

                                    if (name != null) // sanity
                                    {
                                        this.AddImage(35, y, opts[i] ? 0xD3 : 0xD2);
                                        this.AddHtml(60, y, 165, 22, name, false, false);
                                    }

                                    y += 22;
                                }
                            }
                        }
                        else
                        {
                            this.AddHtml(35, y, 190, 20, "Modifications: None", false, false);
                            y += 20;
                        }

                        break;
                    }
                case TournyBracketGumpType.Participant_List:
                    {
                        this.AddPage(0);
                        this.AddBackground(0, 0, 300, 300, 9380);

                        if (this.m_List == null)
                            this.m_List = new ArrayList(tourny.Participants);

                        this.AddLeftArrow(25, 11, this.ToButtonID(0, 0));
                        this.AddHtml(25, 35, 250, 20, this.Center(String.Format("{0} Participant{1}", m_List.Count, m_List.Count == 1 ? "" : "s")), false, false);

                        int index, count, y;
                        this.StartPage(out index, out count, out y, 12);

                        for (int i = 0; i < count; ++i, y += 18)
                        {
                            TournyParticipant part = (TournyParticipant)this.m_List[index + i];
                            string name = part.NameList;

                            if (this.m_Tournament.TournyType != TournyType.Standard && part.Players.Count == 1)
                            {
                                PlayerMobile pm = part.Players[0] as PlayerMobile;

                                if (pm != null && pm.DuelPlayer != null)
                                    name = this.Color(name, pm.DuelPlayer.Eliminated ? 0x6633333 : 0x336666);
                            }

                            this.AddRightArrow(25, y, this.ToButtonID(2, index + i), name);
                        }

                        break;
                    }
                case TournyBracketGumpType.Participant_Info:
                    {
                        TournyParticipant part = obj as TournyParticipant;

                        if (part == null)
                            break;

                        this.AddPage(0);
                        this.AddBackground(0, 0, 300, 60 + 18 + 20 + (part.Players.Count * 18) + 20 + 20 + 160, 9380);

                        this.AddLeftArrow(25, 11, this.ToButtonID(0, 1));
                        this.AddHtml(25, 35, 250, 20, this.Center("Participants"), false, false);

                        int y = 53;

                        this.AddHtml(25, y, 200, 20, part.Players.Count == 1 ? "Players" : "Team", false, false);
                        y += 20;

                        for (int i = 0; i < part.Players.Count; ++i)
                        {
                            Mobile mob = (Mobile)part.Players[i];
                            string name = mob.Name;

                            if (this.m_Tournament.TournyType != TournyType.Standard)
                            {
                                PlayerMobile pm = mob as PlayerMobile;

                                if (pm != null && pm.DuelPlayer != null)
                                    name = this.Color(name, pm.DuelPlayer.Eliminated ? 0x6633333 : 0x336666);
                            }

                            this.AddRightArrow(35, y, this.ToButtonID(4, i), name);
                            y += 18;
                        }

                        this.AddHtml(25, y, 200, 20, String.Format("Free Advances: {0}", part.FreeAdvances == 0 ? "None" : part.FreeAdvances.ToString()), false, false);
                        y += 20;

                        this.AddHtml(25, y, 200, 20, "Log:", false, false);
                        y += 20;

                        StringBuilder sb = new StringBuilder();

                        for (int i = 0; i < part.Log.Count; ++i)
                        {
                            if (sb.Length > 0)
                                sb.Append("<br>");

                            sb.Append(part.Log[i]);
                        }

                        if (sb.Length == 0)
                            sb.Append("Nothing logged yet.");

                        this.AddHtml(25, y, 250, 150, this.Color(sb.ToString(), BlackColor32), false, true);

                        break;
                    }
                case TournyBracketGumpType.Player_Info:
                    {
                        this.AddPage(0);
                        this.AddBackground(0, 0, 300, 300, 9380);

                        this.AddLeftArrow(25, 11, this.ToButtonID(0, 3));
                        this.AddHtml(25, 35, 250, 20, this.Center("Participants"), false, false);

                        Mobile mob = obj as Mobile;

                        if (mob == null)
                            break;

                        Ladder ladder = Ladder.Instance;
                        LadderEntry entry = (ladder == null ? null : ladder.Find(mob));

                        this.AddHtml(25, 53, 250, 20, String.Format("Name: {0}", mob.Name), false, false);
                        this.AddHtml(25, 73, 250, 20, String.Format("Guild: {0}", mob.Guild == null ? "None" : mob.Guild.Name + " [" + mob.Guild.Abbreviation + "]"), false, false);
                        this.AddHtml(25, 93, 250, 20, String.Format("Rank: {0}", entry == null ? "N/A" : LadderGump.Rank(entry.Index + 1)), false, false);
                        this.AddHtml(25, 113, 250, 20, String.Format("Level: {0}", entry == null ? 0 : Ladder.GetLevel(entry.Experience)), false, false);
                        this.AddHtml(25, 133, 250, 20, String.Format("Wins: {0:N0}", entry == null ? 0 : entry.Wins), false, false);
                        this.AddHtml(25, 153, 250, 20, String.Format("Losses: {0:N0}", entry == null ? 0 : entry.Losses), false, false);

                        break;
                    }
                case TournyBracketGumpType.Round_List:
                    {
                        this.AddPage(0);
                        this.AddBackground(0, 0, 300, 300, 9380);

                        this.AddLeftArrow(25, 11, this.ToButtonID(0, 0));
                        this.AddHtml(25, 35, 250, 20, this.Center("Rounds"), false, false);

                        if (this.m_List == null)
                            this.m_List = new ArrayList(tourny.Pyramid.Levels);

                        int index, count, y;
                        this.StartPage(out index, out count, out y, 12);

                        for (int i = 0; i < count; ++i, y += 18)
                        {
                            PyramidLevel level = (PyramidLevel)this.m_List[index + i];

                            this.AddRightArrow(25, y, this.ToButtonID(3, index + i), "Round #" + (index + i + 1));
                        }

                        break;
                    }
                case TournyBracketGumpType.Round_Info:
                    {
                        this.AddPage(0);
                        this.AddBackground(0, 0, 300, 300, 9380);

                        this.AddLeftArrow(25, 11, this.ToButtonID(0, 2));
                        this.AddHtml(25, 35, 250, 20, this.Center("Rounds"), false, false);

                        PyramidLevel level = this.m_Object as PyramidLevel;

                        if (level == null)
                            break;

                        if (this.m_List == null)
                            this.m_List = new ArrayList(level.Matches);

                        this.AddRightArrow(25, 53, this.ToButtonID(5, 0), String.Format("Free Advance: {0}", level.FreeAdvance == null ? "None" : level.FreeAdvance.NameList));

                        this.AddHtml(25, 73, 200, 20, String.Format("{0} Match{1}", m_List.Count, m_List.Count == 1 ? "" : "es"), false, false);

                        int index, count, y;
                        this.StartPage(out index, out count, out y, 10);

                        for (int i = 0; i < count; ++i, y += 18)
                        {
                            TournyMatch match = (TournyMatch)this.m_List[index + i];

                            int color = -1;

                            if (match.InProgress)
                                color = 0x336666;
                            else if (match.Context != null && match.Winner == null)
                                color = 0x666666;

                            StringBuilder sb = new StringBuilder();

                            if (this.m_Tournament.TournyType == TournyType.Standard)
                            {
                                for (int j = 0; j < match.Participants.Count; ++j)
                                {
                                    if (sb.Length > 0)
                                        sb.Append(" vs ");

                                    TournyParticipant part = (TournyParticipant)match.Participants[j];
                                    string txt = part.NameList;

                                    if (color == -1 && match.Context != null && match.Winner == part)
                                        txt = this.Color(txt, 0x336633);
                                    else if (color == -1 && match.Context != null)
                                        txt = this.Color(txt, 0x663333);

                                    sb.Append(txt);
                                }
                            }
                            else if (this.m_Tournament.EventController != null || this.m_Tournament.TournyType == TournyType.RandomTeam || this.m_Tournament.TournyType == TournyType.RedVsBlue)
                            {
                                for (int j = 0; j < match.Participants.Count; ++j)
                                {
                                    if (sb.Length > 0)
                                        sb.Append(" vs ");

                                    TournyParticipant part = (TournyParticipant)match.Participants[j];
                                    string txt;

                                    if (this.m_Tournament.EventController != null)
                                        txt = String.Format("Team {0} ({1})", this.m_Tournament.EventController.GetTeamName(j), part.Players.Count);
                                    else if (this.m_Tournament.TournyType == TournyType.RandomTeam)
                                        txt = String.Format("Team {0} ({1})", j + 1, part.Players.Count);
                                    else
                                        txt = String.Format("Team {0} ({1})", j == 0 ? "Red" : "Blue", part.Players.Count);

                                    if (color == -1 && match.Context != null && match.Winner == part)
                                        txt = this.Color(txt, 0x336633);
                                    else if (color == -1 && match.Context != null)
                                        txt = this.Color(txt, 0x663333);

                                    sb.Append(txt);
                                }
                            }
                            else if (this.m_Tournament.TournyType == TournyType.FreeForAll)
                            {
                                sb.Append("Free For All");
                            }

                            string str = sb.ToString();

                            if (color >= 0)
                                str = this.Color(str, color);

                            this.AddRightArrow(25, y, this.ToButtonID(5, index + i + 1), str);
                        }

                        break;
                    }
                case TournyBracketGumpType.Match_Info:
                    {
                        TournyMatch match = obj as TournyMatch;

                        if (match == null)
                            break;

                        int ct = (this.m_Tournament.TournyType == TournyType.FreeForAll ? 2 : match.Participants.Count);

                        this.AddPage(0);
                        this.AddBackground(0, 0, 300, 60 + 18 + 20 + 20 + 20 + (ct * 18) + 6, 9380);

                        this.AddLeftArrow(25, 11, this.ToButtonID(0, 5));
                        this.AddHtml(25, 35, 250, 20, this.Center("Rounds"), false, false);

                        this.AddHtml(25, 53, 250, 20, String.Format("Winner: {0}", match.Winner == null ? "N/A" : match.Winner.NameList), false, false);
                        this.AddHtml(25, 73, 250, 20, String.Format("State: {0}", match.InProgress ? "In progress" : match.Context != null ? "Complete" : "Waiting"), false, false);
                        this.AddHtml(25, 93, 250, 20, String.Format("Participants:"), false, false);

                        if (this.m_Tournament.TournyType == TournyType.Standard)
                        {
                            for (int i = 0; i < match.Participants.Count; ++i)
                            {
                                TournyParticipant part = (TournyParticipant)match.Participants[i];

                                this.AddRightArrow(25, 113 + (i * 18), this.ToButtonID(6, i), part.NameList);
                            }
                        }
                        else if (this.m_Tournament.EventController != null || this.m_Tournament.TournyType == TournyType.RandomTeam || this.m_Tournament.TournyType == TournyType.RedVsBlue)
                        {
                            for (int i = 0; i < match.Participants.Count; ++i)
                            {
                                TournyParticipant part = (TournyParticipant)match.Participants[i];

                                if (this.m_Tournament.EventController != null)
                                    this.AddRightArrow(25, 113 + (i * 18), this.ToButtonID(6, i), String.Format("Team {0} ({1})", m_Tournament.EventController.GetTeamName(i), part.Players.Count));
                                else if (this.m_Tournament.TournyType == TournyType.RandomTeam)
                                    this.AddRightArrow(25, 113 + (i * 18), this.ToButtonID(6, i), String.Format("Team {0} ({1})", i + 1, part.Players.Count));
                                else
                                    this.AddRightArrow(25, 113 + (i * 18), this.ToButtonID(6, i), String.Format("Team {0} ({1})", i == 0 ? "Red" : "Blue", part.Players.Count));
                            }
                        }
                        else if (this.m_Tournament.TournyType == TournyType.FreeForAll)
                        {
                            this.AddHtml(25, 113, 250, 20, "Free For All", false, false);
                        }

                        break;
                    }
            }
        }
Exemple #5
0
        public TournamentController()
            : base(0x1B7A)
        {
            this.Visible = false;
            this.Movable = false;

            this.m_Tournament = new Tournament();
            m_Instances.Add(this);
        }
Exemple #6
0
        public void Start(Arena arena, Tournament tourney)
        {
            TourneyParticipant first = Participants[0];

            DuelContext dc = new DuelContext(first.Players[0], tourney.Ruleset.Layout, false);

            dc.Ruleset.Options.SetAll(false);
            dc.Ruleset.Options.Or(tourney.Ruleset.Options);

            for (int i = 0; i < Participants.Count; ++i)
            {
                TourneyParticipant tourneyPart = Participants[i];
                Participant        duelPart    = new Participant(dc, tourneyPart.Players.Count)
                {
                    TourneyPart = tourneyPart
                };

                for (int j = 0; j < tourneyPart.Players.Count; ++j)
                {
                    duelPart.Add(tourneyPart.Players[j]);
                }

                for (int j = 0; j < duelPart.Players.Length; ++j)
                {
                    if (duelPart.Players[j] != null)
                    {
                        duelPart.Players[j].Ready = true;
                    }
                }

                dc.Participants.Add(duelPart);
            }

            if (tourney.EventController != null)
            {
                dc.m_EventGame = tourney.EventController.Construct(dc);
            }

            dc.m_Tournament = tourney;
            dc.m_Match      = this;

            dc.m_OverrideArena = arena;

            if (tourney.SuddenDeath > TimeSpan.Zero &&
                (tourney.SuddenDeathRounds == 0 || tourney.Pyramid.Levels.Count <= tourney.SuddenDeathRounds))
            {
                dc.StartSuddenDeath(tourney.SuddenDeath);
            }

            dc.SendReadyGump(0);

            if (dc.StartedBeginCountdown)
            {
                Context = dc;

                for (int i = 0; i < Participants.Count; ++i)
                {
                    TourneyParticipant p = Participants[i];

                    for (int j = 0; j < p.Players.Count; ++j)
                    {
                        Mobile mob = p.Players[j];

                        foreach (Mobile view in mob.GetMobilesInRange(18))
                        {
                            if (!mob.CanSee(view))
                            {
                                mob.Send(view.RemovePacket);
                            }
                        }

                        mob.LocalOverheadMessage(MessageType.Emote, 0x3B2, false,
                                                 "* Your mind focuses intently on the fight and all other distractions fade away *");
                    }
                }
            }
            else
            {
                dc.Unregister();
                dc.StopCountdown();
            }
        }
Exemple #7
0
        public ConfirmSignupGump( Mobile from, Mobile registrar, Tournament tourny, ArrayList players )
            : base(50, 50)
        {
            m_From = from;
            m_Registrar = registrar;
            m_Tournament = tourny;
            m_Players = players;

            m_From.CloseGump( typeof( AcceptTeamGump ) );
            m_From.CloseGump( typeof( AcceptDuelGump ) );
            m_From.CloseGump( typeof( DuelContextGump ) );
            m_From.CloseGump( typeof( ConfirmSignupGump ) );

            #region Rules
            Ruleset ruleset = tourny.Ruleset;
            Ruleset basedef = ruleset.Base;

            int height = 185 + 60 + 12;

            int changes = 0;

            BitArray defs;

            if ( ruleset.Flavors.Count > 0 )
            {
                defs = new BitArray( basedef.Options );

                for ( int i = 0; i < ruleset.Flavors.Count; ++i )
                    defs.Or( ((Ruleset)ruleset.Flavors[i]).Options );

                height += ruleset.Flavors.Count * 18;
            }
            else
            {
                defs = basedef.Options;
            }

            BitArray opts = ruleset.Options;

            for ( int i = 0; i < opts.Length; ++i )
            {
                if ( defs[i] != opts[i] )
                    ++changes;
            }

            height += (changes * 22);

            height += 10 + 22 + 25 + 25;

            if ( tourny.PlayersPerParticipant > 1 )
                height += 36 + (tourny.PlayersPerParticipant * 20);
            #endregion

            Closable = false;

            AddPage( 0 );

            //AddBackground( 0, 0, 400, 220, 9150 );
            AddBackground( 1, 1, 398, height, 3600 );
            //AddBackground( 16, 15, 369, 189, 9100 );

            AddImageTiled( 16, 15, 369, height - 29, 3604 );
            AddAlphaRegion( 16, 15, 369, height - 29 );

            AddImage( 215, -43, 0xEE40 );
            //AddImage( 330, 141, 0x8BA );

            StringBuilder sb = new StringBuilder();

            if ( tourny.TournyType == TournyType.FreeForAll )
            {
                sb.Append( "FFA" );
            }
            else if ( tourny.TournyType == TournyType.RandomTeam )
            {
                sb.Append( "Team" );
            }
            else if ( tourny.TournyType == TournyType.RedVsBlue )
            {
                sb.Append( "Red v Blue" );
            }
            else
            {
                for ( int i = 0; i < tourny.ParticipantsPerMatch; ++i )
                {
                    if ( sb.Length > 0 )
                        sb.Append( 'v' );

                    sb.Append( tourny.PlayersPerParticipant );
                }
            }

            if ( tourny.EventController != null )
                sb.Append( ' ' ).Append( tourny.EventController.Title );

            sb.Append( " Tournament Signup" );

            AddBorderedText( 22, 22, 294, 20, Center( sb.ToString() ), LabelColor32, BlackColor32 );
            AddBorderedText( 22, 50, 294, 40, "You have requested to join the tournament. Do you accept the rules?", 0xB0C868, BlackColor32 );

            AddImageTiled( 32, 88, 264, 1, 9107 );
            AddImageTiled( 42, 90, 264, 1, 9157 );

            #region Rules
            int y = 100;

            string groupText = null;

            switch ( tourny.GroupType )
            {
                case GroupingType.HighVsLow: groupText = "High vs Low"; break;
                case GroupingType.Nearest: groupText = "Closest opponent"; break;
                case GroupingType.Random: groupText = "Random"; break;
            }

            AddBorderedText( 35, y, 190, 20, String.Format( "Grouping: {0}", groupText ), LabelColor32, BlackColor32 );
            y += 20;

            string tieText = null;

            switch ( tourny.TieType )
            {
                case TieType.Random: tieText = "Random"; break;
                case TieType.Highest: tieText = "Highest advances"; break;
                case TieType.Lowest: tieText = "Lowest advances"; break;
                case TieType.FullAdvancement: tieText = ( tourny.ParticipantsPerMatch == 2 ? "Both advance" : "Everyone advances" ); break;
                case TieType.FullElimination: tieText = ( tourny.ParticipantsPerMatch == 2 ? "Both eliminated" : "Everyone eliminated" ); break;
            }

            AddBorderedText( 35, y, 190, 20, String.Format( "Tiebreaker: {0}", tieText ), LabelColor32, BlackColor32 );
            y += 20;

            string sdText = "Off";

            if ( tourny.SuddenDeath > TimeSpan.Zero )
            {
                sdText = String.Format( "{0}:{1:D2}", (int) tourny.SuddenDeath.TotalMinutes, tourny.SuddenDeath.Seconds );

                if ( tourny.SuddenDeathRounds > 0 )
                    sdText = String.Format( "{0} (first {1} rounds)", sdText, tourny.SuddenDeathRounds );
                else
                    sdText = String.Format( "{0} (all rounds)", sdText );
            }

            AddBorderedText( 35, y, 240, 20, String.Format( "Sudden Death: {0}", sdText ), LabelColor32, BlackColor32 );
            y += 20;

            y += 6;
            AddImageTiled( 32, y-1, 264, 1, 9107 );
            AddImageTiled( 42, y+1, 264, 1, 9157 );
            y += 6;

            AddBorderedText( 35, y, 190, 20, String.Format( "Ruleset: {0}", basedef.Title ), LabelColor32, BlackColor32 );
            y += 20;

            for ( int i = 0; i < ruleset.Flavors.Count; ++i, y += 18 )
                AddBorderedText( 35, y, 190, 20, String.Format( " + {0}", ((Ruleset)ruleset.Flavors[i]).Title ), LabelColor32, BlackColor32 );

            y += 4;

            if ( changes > 0 )
            {
                AddBorderedText( 35, y, 190, 20, "Modifications:", LabelColor32, BlackColor32 );
                y += 20;

                for ( int i = 0; i < opts.Length; ++i )
                {
                    if ( defs[i] != opts[i] )
                    {
                        string name = ruleset.Layout.FindByIndex( i );

                        if ( name != null ) // sanity
                        {
                            AddImage( 35, y, opts[i] ? 0xD3 : 0xD2 );
                            AddBorderedText( 60, y, 165, 22, name, LabelColor32, BlackColor32 );
                        }

                        y += 22;
                    }
                }
            }
            else
            {
                AddBorderedText( 35, y, 190, 20, "Modifications: None", LabelColor32, BlackColor32 );
                y += 20;
            }
            #endregion

            #region Team
            if ( tourny.PlayersPerParticipant > 1 )
            {
                y += 8;
                AddImageTiled( 32, y-1, 264, 1, 9107 );
                AddImageTiled( 42, y+1, 264, 1, 9157 );
                y += 8;

                AddBorderedText( 35, y, 190, 20, "Your Team", LabelColor32, BlackColor32 );
                y += 20;

                for ( int i = 0; i < players.Count; ++i, y += 20 )
                {
                    if ( i == 0 )
                        AddImage( 35, y, 0xD2 );
                    else
                        AddGoldenButton( 35, y, 1 + i );

                    AddBorderedText( 60, y, 200, 20, ((Mobile)players[i]).Name, LabelColor32, BlackColor32 );
                }

                for ( int i = players.Count; i < tourny.PlayersPerParticipant; ++i, y += 20 )
                {
                    if ( i == 0 )
                        AddImage( 35, y, 0xD2 );
                    else
                        AddGoldenButton( 35, y, 1 + i );

                    AddBorderedText( 60, y, 200, 20, "(Empty)", LabelColor32, BlackColor32 );
                }
            }
            #endregion

            y += 8;
            AddImageTiled( 32, y-1, 264, 1, 9107 );
            AddImageTiled( 42, y+1, 264, 1, 9157 );
            y += 8;

            AddRadio( 24, y, 9727, 9730, true, 1 );
            AddBorderedText( 60, y+5, 250, 20, "Yes, I wish to join the tournament.", LabelColor32, BlackColor32 );
            y += 35;

            AddRadio( 24, y, 9727, 9730, false, 2 );
            AddBorderedText( 60, y+5, 250, 20, "No, I do not wish to join.", LabelColor32, BlackColor32 );
            y += 35;

            y -= 3;
            AddButton( 314, y, 247, 248, 1, GumpButtonType.Reply, 0 );
        }
Exemple #8
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (info.ButtonID == 1 && info.IsSwitched(1))
            {
                Tournament tourney = m_Tournament;
                Mobile     from    = m_From;

                switch (tourney.Stage)
                {
                case TournamentStage.Fighting:
                {
                    if (m_Registrar != null)
                    {
                        if (m_Tournament.HasParticipant(from))
                        {
                            m_Registrar.PrivateOverheadMessage(MessageType.Regular,
                                                               0x35, false, "Excuse me? You are already signed up.", from.NetState);
                        }
                        else
                        {
                            m_Registrar.PrivateOverheadMessage(MessageType.Regular,
                                                               0x22, false, "The tournament has already begun. You are too late to signup now.",
                                                               from.NetState);
                        }
                    }

                    break;
                }

                case TournamentStage.Inactive:
                {
                    m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
                                                        0x35, false, "The tournament is closed.", from.NetState);

                    break;
                }

                case TournamentStage.Signup:
                {
                    if (m_Players.Count != tourney.PlayersPerParticipant)
                    {
                        m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
                                                            0x35, false, "You have not yet chosen your team.", from.NetState);

                        m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
                        break;
                    }

                    Ladder ladder = Ladder.Instance;

                    for (int i = 0; i < m_Players.Count; ++i)
                    {
                        Mobile mob = m_Players[i];

                        LadderEntry entry = ladder?.Find(mob);

                        if (entry != null && Ladder.GetLevel(entry.Experience) < tourney.LevelRequirement)
                        {
                            if (m_Registrar != null)
                            {
                                if (mob == from)
                                {
                                    m_Registrar.PrivateOverheadMessage(MessageType.Regular,
                                                                       0x35, false, "You have not yet proven yourself a worthy dueler.", from.NetState);
                                }
                                else
                                {
                                    m_Registrar.PrivateOverheadMessage(MessageType.Regular,
                                                                       0x35, false, $"{mob.Name} has not yet proven themselves a worthy dueler.",
                                                                       from.NetState);
                                }
                            }

                            m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
                            return;
                        }

                        if (tourney.IsFactionRestricted && Faction.Find(mob) == null)
                        {
                            m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
                                                                0x35, false, "Only those who have declared their faction allegiance may participate.",
                                                                from.NetState);

                            m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
                            return;
                        }

                        if (tourney.HasParticipant(mob))
                        {
                            if (m_Registrar != null)
                            {
                                if (mob == from)
                                {
                                    m_Registrar.PrivateOverheadMessage(MessageType.Regular,
                                                                       0x35, false, "You have already entered this tournament.", from.NetState);
                                }
                                else
                                {
                                    m_Registrar.PrivateOverheadMessage(MessageType.Regular,
                                                                       0x35, false, $"{mob.Name} has already entered this tournament.", from.NetState);
                                }
                            }

                            m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
                            return;
                        }

                        if (mob is PlayerMobile mobile && mobile.DuelContext != null)
                        {
                            if (mob == from)
                            {
                                m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
                                                                    0x35, false,
                                                                    "You are already assigned to a duel. You must yield it before joining this tournament.",
                                                                    from.NetState);
                            }
                            else
                            {
                                m_Registrar?.PrivateOverheadMessage(MessageType.Regular,
                                                                    0x35, false,
                                                                    $"{mobile.Name} is already assigned to a duel. They must yield it before joining this tournament.",
                                                                    from.NetState);
                            }

                            m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
                            return;
                        }
                    }

                    if (m_Registrar != null)
                    {
                        string fmt;

                        if (tourney.PlayersPerParticipant == 1)
                        {
                            fmt =
                                "As you say m'{0}. I've written your name to the bracket. The tournament will begin {1}.";
                        }
                        else if (tourney.PlayersPerParticipant == 2)
                        {
                            fmt =
                                "As you wish m'{0}. The tournament will begin {1}, but first you must name your partner.";
                        }
                        else
                        {
                            fmt = "As you wish m'{0}. The tournament will begin {1}, but first you must name your team.";
                        }

                        string timeUntil;
                        int    minutesUntil = (int)Math.Round((tourney.SignupStart + tourney.SignupPeriod - DateTime.UtcNow)
                                                              .TotalMinutes);

                        if (minutesUntil == 0)
                        {
                            timeUntil = "momentarily";
                        }
                        else
                        {
                            timeUntil = $"in {minutesUntil} minute{(minutesUntil == 1 ? "" : "s")}";
                        }

                        m_Registrar.PrivateOverheadMessage(MessageType.Regular,
                                                           0x35, false, string.Format(fmt, from.Female ? "Lady" : "Lord", timeUntil), from.NetState);
                    }

                    TourneyParticipant part = new TourneyParticipant(from);
                    part.Players.Clear();
                    part.Players.AddRange(m_Players);

                    tourney.Participants.Add(part);

                    break;
                }
                }
            }
            else if (info.ButtonID > 1)
            {
                int index = info.ButtonID - 1;

                if (index > 0 && index < m_Players.Count)
                {
                    m_Players.RemoveAt(index);
                    m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
                }
                else if (m_Players.Count < m_Tournament.PlayersPerParticipant)
                {
                    m_From.BeginTarget(12, false, TargetFlags.None, AddPlayer_OnTarget);
                    m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
                }
            }
        }
Exemple #9
0
 public CancelEntry( Mobile from, Tournament tourny )
     : base(5114)
 {
     m_Tournament = tourny;
     m_From = from;
 }
Exemple #10
0
        private void Finish_Callback()
        {
            List <CTFTeamInfo> teams = new List <CTFTeamInfo>();

            for (int i = 0; i < m_Context.Participants.Count; ++i)
            {
                CTFTeamInfo teamInfo = m_Controller.TeamInfo[i % 8];

                if (teamInfo == null || teamInfo.Flag == null)
                {
                    continue;
                }

                teams.Add(teamInfo);
            }

            teams.Sort(delegate(CTFTeamInfo a, CTFTeamInfo b)
            {
                return(b.Score - a.Score);
            });

            Tournament tourny = m_Context.m_Tournament;

            StringBuilder sb = new StringBuilder();

            if (tourny != null && tourny.TournyType == TournyType.FreeForAll)
            {
                sb.Append(m_Context.Participants.Count * tourny.PlayersPerParticipant);
                sb.Append("-man FFA");
            }
            else if (tourny != null && tourny.TournyType == TournyType.RandomTeam)
            {
                sb.Append(tourny.ParticipantsPerMatch);
                sb.Append("-team");
            }
            else if (tourny != null && tourny.TournyType == TournyType.RedVsBlue)
            {
                sb.Append("Red v Blue");
            }

            else if (tourny != null)
            {
                for (int i = 0; i < tourny.ParticipantsPerMatch; ++i)
                {
                    if (sb.Length > 0)
                    {
                        sb.Append('v');
                    }

                    sb.Append(tourny.PlayersPerParticipant);
                }
            }

            if (m_Controller != null)
            {
                sb.Append(' ').Append(m_Controller.Title);
            }

            string title = sb.ToString();

            CTFTeamInfo winner = (teams.Count > 0 ? teams[0] : null);

            for (int i = 0; i < teams.Count; ++i)
            {
                TrophyRank rank = TrophyRank.Bronze;

                if (i == 0)
                {
                    rank = TrophyRank.Gold;
                }
                else if (i == 1)
                {
                    rank = TrophyRank.Silver;
                }

                CTFPlayerInfo leader = teams[i].Leader;

                foreach (CTFPlayerInfo pl in teams[i].Players.Values)
                {
                    Mobile mob = pl.Player;

                    if (mob == null)
                    {
                        continue;
                    }

                    //"Red v Blue CTF Champion"

                    sb = new StringBuilder();

                    sb.Append(title);

                    if (pl == leader)
                    {
                        sb.Append(" Leader");
                    }

                    if (pl.Score > 0)
                    {
                        sb.Append(": ");

                        sb.Append(pl.Score.ToString("N0"));
                        sb.Append(pl.Score == 1 ? " point" : " points");

                        if (pl.Kills > 0)
                        {
                            sb.Append(", ");
                            sb.Append(pl.Kills.ToString("N0"));
                            sb.Append(pl.Kills == 1 ? " kill" : " kills");
                        }

                        if (pl.Captures > 0)
                        {
                            sb.Append(", ");
                            sb.Append(pl.Captures.ToString("N0"));
                            sb.Append(pl.Captures == 1 ? " capture" : " captures");
                        }
                    }

                    Item item = new Trophy(sb.ToString(), rank);

                    if (pl == leader)
                    {
                        item.ItemID = 4810;
                    }

                    item.Name = String.Format("{0}, {1} team", item.Name, teams[i].Name.ToLower());

                    if (!mob.PlaceInBackpack(item))
                    {
                        mob.BankBox.DropItem(item);
                    }

                    int cash = pl.Score * 250;

                    if (cash > 0)
                    {
                        item = new BankCheck(cash);

                        if (!mob.PlaceInBackpack(item))
                        {
                            mob.BankBox.DropItem(item);
                        }

                        mob.SendMessage("You have been awarded a {0} trophy and {1:N0}gp for your participation in this tournament.", rank.ToString().ToLower(), cash);
                    }
                    else
                    {
                        mob.SendMessage("You have been awarded a {0} trophy for your participation in this tournament.", rank.ToString().ToLower());
                    }
                }
            }

            for (int i = 0; i < m_Context.Participants.Count; ++i)
            {
                Participant p = m_Context.Participants[i] as Participant;

                for (int j = 0; j < p.Players.Length; ++j)
                {
                    DuelPlayer dp = p.Players[j];

                    if (dp != null && dp.Mobile != null)
                    {
                        dp.Mobile.CloseGump(typeof(CTFBoardGump));
                        dp.Mobile.SendGump(new CTFBoardGump(dp.Mobile, this));
                    }
                }

                if (i == winner.TeamID)
                {
                    continue;
                }

                for (int j = 0; j < p.Players.Length; ++j)
                {
                    if (p.Players[j] != null)
                    {
                        p.Players[j].Eliminated = true;
                    }
                }
            }

            m_Context.Finish(m_Context.Participants[winner.TeamID] as Participant);
        }
Exemple #11
0
        public ConfirmSignupGump(Mobile from, Mobile registrar, Tournament tourney, List <Mobile> players) : base(50, 50)
        {
            m_From       = from;
            m_Registrar  = registrar;
            m_Tournament = tourney;
            m_Players    = players;

            m_From.CloseGump <AcceptTeamGump>();
            m_From.CloseGump <AcceptDuelGump>();
            m_From.CloseGump <DuelContextGump>();
            m_From.CloseGump <ConfirmSignupGump>();

            Ruleset ruleset = tourney.Ruleset;
            Ruleset basedef = ruleset.Base;

            int height = 185 + 60 + 12;

            int changes = 0;

            BitArray defs;

            if (ruleset.Flavors.Count > 0)
            {
                defs = new BitArray(basedef.Options);

                for (int i = 0; i < ruleset.Flavors.Count; ++i)
                {
                    defs.Or(ruleset.Flavors[i].Options);
                }

                height += ruleset.Flavors.Count * 18;
            }
            else
            {
                defs = basedef.Options;
            }

            BitArray opts = ruleset.Options;

            for (int i = 0; i < opts.Length; ++i)
            {
                if (defs[i] != opts[i])
                {
                    ++changes;
                }
            }

            height += changes * 22;

            height += 10 + 22 + 25 + 25;

            if (tourney.PlayersPerParticipant > 1)
            {
                height += 36 + tourney.PlayersPerParticipant * 20;
            }

            Closable = false;

            AddPage(0);

            // AddBackground( 0, 0, 400, 220, 9150 );
            AddBackground(1, 1, 398, height, 3600);
            // AddBackground( 16, 15, 369, 189, 9100 );

            AddImageTiled(16, 15, 369, height - 29, 3604);
            AddAlphaRegion(16, 15, 369, height - 29);

            AddImage(215, -43, 0xEE40);
            // AddImage( 330, 141, 0x8BA );

            StringBuilder sb = new StringBuilder();

            if (tourney.TourneyType == TourneyType.FreeForAll)
            {
                sb.Append("FFA");
            }
            else if (tourney.TourneyType == TourneyType.RandomTeam)
            {
                sb.Append(tourney.ParticipantsPerMatch);
                sb.Append("-Team");
            }
            else if (tourney.TourneyType == TourneyType.Faction)
            {
                sb.Append(tourney.ParticipantsPerMatch);
                sb.Append("-Team Faction");
            }
            else if (tourney.TourneyType == TourneyType.RedVsBlue)
            {
                sb.Append("Red v Blue");
            }
            else
            {
                for (int i = 0; i < tourney.ParticipantsPerMatch; ++i)
                {
                    if (sb.Length > 0)
                    {
                        sb.Append('v');
                    }

                    sb.Append(tourney.PlayersPerParticipant);
                }
            }

            if (tourney.EventController != null)
            {
                sb.Append(' ').Append(tourney.EventController.Title);
            }

            sb.Append(" Tournament Signup");

            AddBorderedText(22, 22, 294, 20, Center(sb.ToString()), LabelColor32, BlackColor32);
            AddBorderedText(22, 50, 294, 40, "You have requested to join the tournament. Do you accept the rules?", 0xB0C868,
                            BlackColor32);

            AddImageTiled(32, 88, 264, 1, 9107);
            AddImageTiled(42, 90, 264, 1, 9157);

            int y = 100;

            var groupText = tourney.GroupType switch
            {
                GroupingType.HighVsLow => "High vs Low",
                GroupingType.Nearest => "Closest opponent",
                GroupingType.Random => "Random",
                _ => null
            };

            AddBorderedText(35, y, 190, 20, $"Grouping: {groupText}", LabelColor32, BlackColor32);
            y += 20;

            var tieText = tourney.TieType switch
            {
                TieType.Random => "Random",
                TieType.Highest => "Highest advances",
                TieType.Lowest => "Lowest advances",
                TieType.FullAdvancement => tourney.ParticipantsPerMatch == 2 ? "Both advance" : "Everyone advances",
                TieType.FullElimination => tourney.ParticipantsPerMatch == 2 ? "Both eliminated" : "Everyone eliminated",
                _ => null
            };

            AddBorderedText(35, y, 190, 20, $"Tiebreaker: {tieText}", LabelColor32, BlackColor32);
            y += 20;

            string sdText = "Off";

            if (tourney.SuddenDeath > TimeSpan.Zero)
            {
                sdText = $"{(int)tourney.SuddenDeath.TotalMinutes}:{tourney.SuddenDeath.Seconds:D2}";

                if (tourney.SuddenDeathRounds > 0)
                {
                    sdText = $"{sdText} (first {tourney.SuddenDeathRounds} rounds)";
                }
                else
                {
                    sdText = $"{sdText} (all rounds)";
                }
            }

            AddBorderedText(35, y, 240, 20, $"Sudden Death: {sdText}", LabelColor32, BlackColor32);
            y += 20;

            y += 6;
            AddImageTiled(32, y - 1, 264, 1, 9107);
            AddImageTiled(42, y + 1, 264, 1, 9157);
            y += 6;

            AddBorderedText(35, y, 190, 20, $"Ruleset: {basedef.Title}", LabelColor32, BlackColor32);
            y += 20;

            for (int i = 0; i < ruleset.Flavors.Count; ++i, y += 18)
            {
                AddBorderedText(35, y, 190, 20, $" + {ruleset.Flavors[i].Title}", LabelColor32, BlackColor32);
            }

            y += 4;

            if (changes > 0)
            {
                AddBorderedText(35, y, 190, 20, "Modifications:", LabelColor32, BlackColor32);
                y += 20;

                for (int i = 0; i < opts.Length; ++i)
                {
                    if (defs[i] != opts[i])
                    {
                        string name = ruleset.Layout.FindByIndex(i);

                        if (name != null) // sanity
                        {
                            AddImage(35, y, opts[i] ? 0xD3 : 0xD2);
                            AddBorderedText(60, y, 165, 22, name, LabelColor32, BlackColor32);
                        }

                        y += 22;
                    }
                }
            }
            else
            {
                AddBorderedText(35, y, 190, 20, "Modifications: None", LabelColor32, BlackColor32);
                y += 20;
            }

            if (tourney.PlayersPerParticipant > 1)
            {
                y += 8;
                AddImageTiled(32, y - 1, 264, 1, 9107);
                AddImageTiled(42, y + 1, 264, 1, 9157);
                y += 8;

                AddBorderedText(35, y, 190, 20, "Your Team", LabelColor32, BlackColor32);
                y += 20;

                for (int i = 0; i < players.Count; ++i, y += 20)
                {
                    if (i == 0)
                    {
                        AddImage(35, y, 0xD2);
                    }
                    else
                    {
                        AddGoldenButton(35, y, 1 + i);
                    }

                    AddBorderedText(60, y, 200, 20, players[i].Name, LabelColor32, BlackColor32);
                }

                for (int i = players.Count; i < tourney.PlayersPerParticipant; ++i, y += 20)
                {
                    if (i == 0)
                    {
                        AddImage(35, y, 0xD2);
                    }
                    else
                    {
                        AddGoldenButton(35, y, 1 + i);
                    }

                    AddBorderedText(60, y, 200, 20, "(Empty)", LabelColor32, BlackColor32);
                }
            }

            y += 8;
            AddImageTiled(32, y - 1, 264, 1, 9107);
            AddImageTiled(42, y + 1, 264, 1, 9157);
            y += 8;

            AddRadio(24, y, 9727, 9730, true, 1);
            AddBorderedText(60, y + 5, 250, 20, "Yes, I wish to join the tournament.", LabelColor32, BlackColor32);
            y += 35;

            AddRadio(24, y, 9727, 9730, false, 2);
            AddBorderedText(60, y + 5, 250, 20, "No, I do not wish to join.", LabelColor32, BlackColor32);
            y += 35;

            y -= 3;
            AddButton(314, y, 247, 248, 1);
        }
Exemple #12
0
        public AcceptTeamGump(
            Mobile from, Mobile requested, Tournament tourney, Mobile registrar, List <Mobile> players
            ) : base(50, 50)
        {
            m_From       = from;
            m_Requested  = requested;
            m_Tournament = tourney;
            m_Registrar  = registrar;
            m_Players    = players;

            m_Active = true;

            var ruleset = tourney.Ruleset;
            var basedef = ruleset.Base;

            var height = 185 + 35 + 60 + 12;

            var changes = 0;

            BitArray defs;

            if (ruleset.Flavors.Count > 0)
            {
                defs = new BitArray(basedef.Options);

                for (var i = 0; i < ruleset.Flavors.Count; ++i)
                {
                    defs.Or(ruleset.Flavors[i].Options);
                }

                height += ruleset.Flavors.Count * 18;
            }
            else
            {
                defs = basedef.Options;
            }

            var opts = ruleset.Options;

            for (var i = 0; i < opts.Length; ++i)
            {
                if (defs[i] != opts[i])
                {
                    ++changes;
                }
            }

            height += changes * 22;

            height += 10 + 22 + 25 + 25;

            Closable = false;

            AddPage(0);

            AddBackground(1, 1, 398, height, 3600);

            AddImageTiled(16, 15, 369, height - 29, 3604);
            AddAlphaRegion(16, 15, 369, height - 29);

            AddImage(215, -43, 0xEE40);

            var sb = new StringBuilder();

            if (tourney.TourneyType == TourneyType.FreeForAll)
            {
                sb.Append("FFA");
            }
            else if (tourney.TourneyType == TourneyType.RandomTeam)
            {
                sb.Append(tourney.ParticipantsPerMatch);
                sb.Append("-Team");
            }
            else if (tourney.TourneyType == TourneyType.Faction)
            {
                sb.Append(tourney.ParticipantsPerMatch);
                sb.Append("-Team Faction");
            }
            else if (tourney.TourneyType == TourneyType.RedVsBlue)
            {
                sb.Append("Red v Blue");
            }
            else
            {
                for (var i = 0; i < tourney.ParticipantsPerMatch; ++i)
                {
                    if (sb.Length > 0)
                    {
                        sb.Append('v');
                    }

                    sb.Append(tourney.PlayersPerParticipant);
                }
            }

            if (tourney.EventController != null)
            {
                sb.Append(' ').Append(tourney.EventController.Title);
            }

            sb.Append(" Tournament Invitation");

            AddBorderedText(22, 22, 294, 20, Center(sb.ToString()), LabelColor32, BlackColor32);

            AddBorderedText(
                22,
                50,
                294,
                40,
                $"You have been asked to partner with {from.Name} in a tournament. Do you accept?",
                0xB0C868,
                BlackColor32
                );

            AddImageTiled(32, 88, 264, 1, 9107);
            AddImageTiled(42, 90, 264, 1, 9157);

            var y = 100;

            var groupText = tourney.GroupType switch
            {
                GroupingType.HighVsLow => "High vs Low",
                GroupingType.Nearest => "Closest opponent",
                GroupingType.Random => "Random",
                _ => null
            };

            AddBorderedText(35, y, 190, 20, $"Grouping: {groupText}", LabelColor32, BlackColor32);
            y += 20;

            var tieText = tourney.TieType switch
            {
                TieType.Random => "Random",
                TieType.Highest => "Highest advances",
                TieType.Lowest => "Lowest advances",
                TieType.FullAdvancement => tourney.ParticipantsPerMatch == 2 ? "Both advance" : "Everyone advances",
                TieType.FullElimination => tourney.ParticipantsPerMatch == 2 ? "Both eliminated" : "Everyone eliminated",
                _ => null
            };

            AddBorderedText(35, y, 190, 20, $"Tiebreaker: {tieText}", LabelColor32, BlackColor32);
            y += 20;

            var sdText = "Off";

            if (tourney.SuddenDeath > TimeSpan.Zero)
            {
                sdText = $"{(int)tourney.SuddenDeath.TotalMinutes}:{tourney.SuddenDeath.Seconds:D2}";

                if (tourney.SuddenDeathRounds > 0)
                {
                    sdText = $"{sdText} (first {tourney.SuddenDeathRounds} rounds)";
                }
                else
                {
                    sdText = $"{sdText} (all rounds)";
                }
            }

            AddBorderedText(35, y, 240, 20, $"Sudden Death: {sdText}", LabelColor32, BlackColor32);
            y += 20;

            y += 6;
            AddImageTiled(32, y - 1, 264, 1, 9107);
            AddImageTiled(42, y + 1, 264, 1, 9157);
            y += 6;

            AddBorderedText(35, y, 190, 20, $"Ruleset: {basedef.Title}", LabelColor32, BlackColor32);
            y += 20;

            for (var i = 0; i < ruleset.Flavors.Count; ++i, y += 18)
            {
                AddBorderedText(35, y, 190, 20, $" + {ruleset.Flavors[i].Title}", LabelColor32, BlackColor32);
            }

            y += 4;

            if (changes > 0)
            {
                AddBorderedText(35, y, 190, 20, "Modifications:", LabelColor32, BlackColor32);
                y += 20;

                for (var i = 0; i < opts.Length; ++i)
                {
                    if (defs[i] != opts[i])
                    {
                        var name = ruleset.Layout.FindByIndex(i);

                        if (name != null) // sanity
                        {
                            AddImage(35, y, opts[i] ? 0xD3 : 0xD2);
                            AddBorderedText(60, y, 165, 22, name, LabelColor32, BlackColor32);
                        }

                        y += 22;
                    }
                }
            }
            else
            {
                AddBorderedText(35, y, 190, 20, "Modifications: None", LabelColor32, BlackColor32);
                y += 20;
            }

            y += 8;
            AddImageTiled(32, y - 1, 264, 1, 9107);
            AddImageTiled(42, y + 1, 264, 1, 9157);
            y += 8;

            AddRadio(24, y, 9727, 9730, true, 1);
            AddBorderedText(60, y + 5, 250, 20, "Yes, I will join them.", LabelColor32, BlackColor32);
            y += 35;

            AddRadio(24, y, 9727, 9730, false, 2);
            AddBorderedText(60, y + 5, 250, 20, "No, I do not wish to fight.", LabelColor32, BlackColor32);
            y += 35;

            AddRadio(24, y, 9727, 9730, false, 3);
            AddBorderedText(60, y + 5, 270, 20, "No, most certainly not. Do not ask again.", LabelColor32, BlackColor32);
            y += 35;

            y -= 3;
            AddButton(314, y, 247, 248, 1);

            Timer.DelayCall(TimeSpan.FromSeconds(15.0), AutoReject);
        }
 public StartEntry(Tournament tourney) : base(5113) => m_Tournament = tourney;
 public EditEntry(Tournament tourney) : base(5101) => m_Tournament = tourney;
Exemple #15
0
        public void Start(Arena arena, Tournament tourny)
        {
            TournyParticipant first = (TournyParticipant)this.m_Participants[0];

            DuelContext dc = new DuelContext((Mobile)first.Players[0], tourny.Ruleset.Layout, false);
            dc.Ruleset.Options.SetAll(false);
            dc.Ruleset.Options.Or(tourny.Ruleset.Options);

            for (int i = 0; i < this.m_Participants.Count; ++i)
            {
                TournyParticipant tournyPart = (TournyParticipant)this.m_Participants[i];
                Participant duelPart = new Participant(dc, tournyPart.Players.Count);

                duelPart.TournyPart = tournyPart;

                for (int j = 0; j < tournyPart.Players.Count; ++j)
                    duelPart.Add((Mobile)tournyPart.Players[j]);

                for (int j = 0; j < duelPart.Players.Length; ++j)
                {
                    if (duelPart.Players[j] != null)
                        duelPart.Players[j].Ready = true;
                }

                dc.Participants.Add(duelPart);
            }

            if (tourny.EventController != null)
                dc.m_EventGame = tourny.EventController.Construct(dc);

            dc.m_Tournament = tourny;
            dc.m_Match = this;

            dc.m_OverrideArena = arena;

            if (tourny.SuddenDeath > TimeSpan.Zero && (tourny.SuddenDeathRounds == 0 || tourny.Pyramid.Levels.Count <= tourny.SuddenDeathRounds))
                dc.StartSuddenDeath(tourny.SuddenDeath);

            dc.SendReadyGump(0);

            if (dc.StartedBeginCountdown)
            {
                this.m_Context = dc;

                for (int i = 0; i < this.m_Participants.Count; ++i)
                {
                    TournyParticipant p = (TournyParticipant)this.m_Participants[i];

                    for (int j = 0; j < p.Players.Count; ++j)
                    {
                        Mobile mob = (Mobile)p.Players[j];

                        foreach (Mobile view in mob.GetMobilesInRange(18))
                        {
                            if (!mob.CanSee(view))
                                mob.Send(view.RemovePacket);
                        }

                        mob.LocalOverheadMessage(MessageType.Emote, 0x3B2, false, "* Your mind focuses intently on the fight and all other distractions fade away *");
                    }
                }
            }
            else
            {
                dc.Unregister();
                dc.StopCountdown();
            }
        }
Exemple #16
0
            public override void OnClick()
            {
                if ( m_Tournament.Stage != TournamentStage.Inactive )
                {
                    DuelContext dc = null;
                    DuelContext dr = null;

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

                        for (int j = 0; j < part.Players.Count; ++j )
                        {
                            PlayerMobile pm = part.Players[j] as PlayerMobile;

                            dc = pm.DuelContext;

                            if ( pm != null && pm.DuelPlayer != null )
                                pm.DuelPlayer.Eliminated = true;

                            if ( pm != null && dc != null && dc.Arena != null )
                            {
                                dr = dc;
                                //pm.MoveToWorld( dc.Arena.Outside, dc.Arena.Facet );
                                dc.SendOutside( pm );
                                pm.LocalOverheadMessage( MessageType.Regular, 0x22, false, "The event has been cancelled." );
                                pm.DuelPlayer = null;
                            }
                        }
                    }

                    m_Tournament.Undefeated.Clear();
                    m_Tournament.Participants.Clear();
                    m_Tournament.Pyramid.Levels.Clear();

                    if ( dr != null )
                        dr.Finish( null );

                    m_Tournament.Stage = TournamentStage.Inactive;
                    m_Tournament.Alert( "Hear ye! Hear ye!", String.Format( "The tournament has been cancelled by {0}.", m_From.Name ) );
                    m_Tournament = null;
                }
            }
Exemple #17
0
        public AcceptTeamGump(Mobile from, Mobile requested, Tournament tourny, Mobile registrar, ArrayList players)
            : base(50, 50)
        {
            this.m_From = from;
            this.m_Requested = requested;
            this.m_Tournament = tourny;
            this.m_Registrar = registrar;
            this.m_Players = players;

            this.m_Active = true;

            #region Rules
            Ruleset ruleset = tourny.Ruleset;
            Ruleset basedef = ruleset.Base;

            int height = 185 + 35 + 60 + 12;

            int changes = 0;

            BitArray defs;

            if (ruleset.Flavors.Count > 0)
            {
                defs = new BitArray(basedef.Options);

                for (int i = 0; i < ruleset.Flavors.Count; ++i)
                    defs.Or(((Ruleset)ruleset.Flavors[i]).Options);

                height += ruleset.Flavors.Count * 18;
            }
            else
            {
                defs = basedef.Options;
            }

            BitArray opts = ruleset.Options;

            for (int i = 0; i < opts.Length; ++i)
            {
                if (defs[i] != opts[i])
                    ++changes;
            }

            height += (changes * 22);

            height += 10 + 22 + 25 + 25;
            #endregion

            this.Closable = false;

            this.AddPage(0);

            this.AddBackground(1, 1, 398, height, 3600);

            this.AddImageTiled(16, 15, 369, height - 29, 3604);
            this.AddAlphaRegion(16, 15, 369, height - 29);

            this.AddImage(215, -43, 0xEE40);

            StringBuilder sb = new StringBuilder();

            if (tourny.TournyType == TournyType.FreeForAll)
            {
                sb.Append("FFA");
            }
            else if (tourny.TournyType == TournyType.RandomTeam)
            {
                sb.Append(tourny.ParticipantsPerMatch);
                sb.Append("-Team");
            }
            else if (tourny.TournyType == TournyType.RedVsBlue)
            {
                sb.Append("Red v Blue");
            }
            else
            {
                for (int i = 0; i < tourny.ParticipantsPerMatch; ++i)
                {
                    if (sb.Length > 0)
                        sb.Append('v');

                    sb.Append(tourny.PlayersPerParticipant);
                }
            }

            if (tourny.EventController != null)
                sb.Append(' ').Append(tourny.EventController.Title);

            sb.Append(" Tournament Invitation");

            this.AddBorderedText(22, 22, 294, 20, this.Center(sb.ToString()), LabelColor32, BlackColor32);

            this.AddBorderedText(22, 50, 294, 40,
                String.Format("You have been asked to partner with {0} in a tournament. Do you accept?", from.Name),
                0xB0C868, BlackColor32);

            this.AddImageTiled(32, 88, 264, 1, 9107);
            this.AddImageTiled(42, 90, 264, 1, 9157);

            #region Rules
            int y = 100;

            string groupText = null;

            switch ( tourny.GroupType )
            {
                case GroupingType.HighVsLow:
                    groupText = "High vs Low";
                    break;
                case GroupingType.Nearest:
                    groupText = "Closest opponent";
                    break;
                case GroupingType.Random:
                    groupText = "Random";
                    break;
            }

            this.AddBorderedText(35, y, 190, 20, String.Format("Grouping: {0}", groupText), LabelColor32, BlackColor32);
            y += 20;

            string tieText = null;

            switch ( tourny.TieType )
            {
                case TieType.Random:
                    tieText = "Random";
                    break;
                case TieType.Highest:
                    tieText = "Highest advances";
                    break;
                case TieType.Lowest:
                    tieText = "Lowest advances";
                    break;
                case TieType.FullAdvancement:
                    tieText = (tourny.ParticipantsPerMatch == 2 ? "Both advance" : "Everyone advances");
                    break;
                case TieType.FullElimination:
                    tieText = (tourny.ParticipantsPerMatch == 2 ? "Both eliminated" : "Everyone eliminated");
                    break;
            }

            this.AddBorderedText(35, y, 190, 20, String.Format("Tiebreaker: {0}", tieText), LabelColor32, BlackColor32);
            y += 20;

            string sdText = "Off";

            if (tourny.SuddenDeath > TimeSpan.Zero)
            {
                sdText = String.Format("{0}:{1:D2}", (int)tourny.SuddenDeath.TotalMinutes, tourny.SuddenDeath.Seconds);

                if (tourny.SuddenDeathRounds > 0)
                    sdText = String.Format("{0} (first {1} rounds)", sdText, tourny.SuddenDeathRounds);
                else
                    sdText = String.Format("{0} (all rounds)", sdText);
            }

            this.AddBorderedText(35, y, 240, 20, String.Format("Sudden Death: {0}", sdText), LabelColor32, BlackColor32);
            y += 20;

            y += 6;
            this.AddImageTiled(32, y - 1, 264, 1, 9107);
            this.AddImageTiled(42, y + 1, 264, 1, 9157);
            y += 6;

            this.AddBorderedText(35, y, 190, 20, String.Format("Ruleset: {0}", basedef.Title), LabelColor32, BlackColor32);
            y += 20;

            for (int i = 0; i < ruleset.Flavors.Count; ++i, y += 18)
                this.AddBorderedText(35, y, 190, 20, String.Format(" + {0}", ((Ruleset)ruleset.Flavors[i]).Title), LabelColor32, BlackColor32);

            y += 4;

            if (changes > 0)
            {
                this.AddBorderedText(35, y, 190, 20, "Modifications:", LabelColor32, BlackColor32);
                y += 20;

                for (int i = 0; i < opts.Length; ++i)
                {
                    if (defs[i] != opts[i])
                    {
                        string name = ruleset.Layout.FindByIndex(i);

                        if (name != null) // sanity
                        {
                            this.AddImage(35, y, opts[i] ? 0xD3 : 0xD2);
                            this.AddBorderedText(60, y, 165, 22, name, LabelColor32, BlackColor32);
                        }

                        y += 22;
                    }
                }
            }
            else
            {
                this.AddBorderedText(35, y, 190, 20, "Modifications: None", LabelColor32, BlackColor32);
                y += 20;
            }
            #endregion

            y += 8;
            this.AddImageTiled(32, y - 1, 264, 1, 9107);
            this.AddImageTiled(42, y + 1, 264, 1, 9157);
            y += 8;

            this.AddRadio(24, y, 9727, 9730, true, 1);
            this.AddBorderedText(60, y + 5, 250, 20, "Yes, I will join them.", LabelColor32, BlackColor32);
            y += 35;

            this.AddRadio(24, y, 9727, 9730, false, 2);
            this.AddBorderedText(60, y + 5, 250, 20, "No, I do not wish to fight.", LabelColor32, BlackColor32);
            y += 35;

            this.AddRadio(24, y, 9727, 9730, false, 3);
            this.AddBorderedText(60, y + 5, 270, 20, "No, most certainly not. Do not ask again.", LabelColor32, BlackColor32);
            y += 35;

            y -= 3;
            this.AddButton(314, y, 247, 248, 1, GumpButtonType.Reply, 0);

            Timer.DelayCall(TimeSpan.FromSeconds(15.0), new TimerCallback(AutoReject));
        }
Exemple #18
0
        public TournamentBracketGump(Mobile from, Tournament tourney, TourneyBracketGumpType type,
                                     List <object> list = null, int page = 0, object obj = null) : base(50, 50)
        {
            m_From       = from;
            m_Tournament = tourney;
            m_Type       = type;
            m_List       = list;
            m_Page       = page;
            m_Object     = obj;
            m_PerPage    = 12;

            switch (type)
            {
            case TourneyBracketGumpType.Index:
            {
                AddPage(0);
                AddBackground(0, 0, 300, 300, 9380);

                StringBuilder sb = new StringBuilder();

                if (tourney.TourneyType == TourneyType.FreeForAll)
                {
                    sb.Append("FFA");
                }
                else if (tourney.TourneyType == TourneyType.RandomTeam)
                {
                    sb.Append(tourney.ParticipantsPerMatch);
                    sb.Append("-Team");
                }
                else if (tourney.TourneyType == TourneyType.RedVsBlue)
                {
                    sb.Append("Red v Blue");
                }
                else if (tourney.TourneyType == TourneyType.Faction)
                {
                    sb.Append(tourney.ParticipantsPerMatch);
                    sb.Append("-Team Faction");
                }
                else
                {
                    for (int i = 0; i < tourney.ParticipantsPerMatch; ++i)
                    {
                        if (sb.Length > 0)
                        {
                            sb.Append('v');
                        }

                        sb.Append(tourney.PlayersPerParticipant);
                    }
                }

                if (tourney.EventController != null)
                {
                    sb.Append(' ').Append(tourney.EventController.Title);
                }

                sb.Append(" Tournament Bracket");

                AddHtml(25, 35, 250, 20, Center(sb.ToString()));

                AddRightArrow(25, 53, ToButtonID(0, 4), "Rules");
                AddRightArrow(25, 71, ToButtonID(0, 1), "Participants");

                if (m_Tournament.Stage == TournamentStage.Signup)
                {
                    TimeSpan until = m_Tournament.SignupStart + m_Tournament.SignupPeriod - DateTime.UtcNow;
                    string   text;
                    int      secs = (int)until.TotalSeconds;

                    if (secs > 0)
                    {
                        int mins = secs / 60;
                        secs %= 60;

                        if (mins > 0 && secs > 0)
                        {
                            text =
                                $"The tournament will begin in {mins} minute{(mins == 1 ? "" : "s")} and {secs} second{(secs == 1 ? "" : "s")}.";
                        }
                        else if (mins > 0)
                        {
                            text = $"The tournament will begin in {mins} minute{(mins == 1 ? "" : "s")}.";
                        }
                        else if (secs > 0)
                        {
                            text = $"The tournament will begin in {secs} second{(secs == 1 ? "" : "s")}.";
                        }
                        else
                        {
                            text = "The tournament will begin shortly.";
                        }
                    }
                    else
                    {
                        text = "The tournament will begin shortly.";
                    }

                    AddHtml(25, 92, 250, 40, text);
                }
                else
                {
                    AddRightArrow(25, 89, ToButtonID(0, 2), "Rounds");
                }

                break;
            }

            case TourneyBracketGumpType.Rules_Info:
            {
                Ruleset ruleset = tourney.Ruleset;
                Ruleset basedef = ruleset.Base;

                BitArray defs;

                if (ruleset.Flavors.Count > 0)
                {
                    defs = new BitArray(basedef.Options);

                    for (int i = 0; i < ruleset.Flavors.Count; ++i)
                    {
                        defs.Or(ruleset.Flavors[i].Options);
                    }
                }
                else
                {
                    defs = basedef.Options;
                }

                int changes = 0;

                BitArray opts = ruleset.Options;

                for (int i = 0; i < opts.Length; ++i)
                {
                    if (defs[i] != opts[i])
                    {
                        ++changes;
                    }
                }

                AddPage(0);
                AddBackground(0, 0, 300,
                              60 + 18 + 20 + 20 + 20 + 8 + 20 + ruleset.Flavors.Count * 18 + 4 + 20 + changes * 22 + 6, 9380);

                AddLeftArrow(25, 11, ToButtonID(0, 0));
                AddHtml(25, 35, 250, 20, Center("Rules"));

                int y = 53;

                var groupText = tourney.GroupType switch
                {
                    GroupingType.HighVsLow => "High vs Low",
                    GroupingType.Nearest => "Closest opponent",
                    GroupingType.Random => "Random",
                    _ => null
                };

                AddHtml(35, y, 190, 20, $"Grouping: {groupText}");
                y += 20;

                var tieText = tourney.TieType switch
                {
                    TieType.Random => "Random",
                    TieType.Highest => "Highest advances",
                    TieType.Lowest => "Lowest advances",
                    TieType.FullAdvancement => tourney.ParticipantsPerMatch == 2 ? "Both advance" : "Everyone advances",
                    TieType.FullElimination => tourney.ParticipantsPerMatch == 2 ? "Both eliminated" : "Everyone eliminated",
                    _ => null
                };

                AddHtml(35, y, 190, 20, $"Tiebreaker: {tieText}");
                y += 20;

                string sdText = "Off";

                if (tourney.SuddenDeath > TimeSpan.Zero)
                {
                    sdText = $"{(int)tourney.SuddenDeath.TotalMinutes}:{tourney.SuddenDeath.Seconds:D2}";

                    if (tourney.SuddenDeathRounds > 0)
                    {
                        sdText = $"{sdText} (first {tourney.SuddenDeathRounds} rounds)";
                    }
                    else
                    {
                        sdText = $"{sdText} (all rounds)";
                    }
                }

                AddHtml(35, y, 240, 20, $"Sudden Death: {sdText}");
                y += 20;

                y += 8;

                AddHtml(35, y, 190, 20, $"Ruleset: {basedef.Title}");
                y += 20;

                for (int i = 0; i < ruleset.Flavors.Count; ++i, y += 18)
                {
                    AddHtml(35, y, 190, 20, $" + {ruleset.Flavors[i].Title}");
                }

                y += 4;

                if (changes > 0)
                {
                    AddHtml(35, y, 190, 20, "Modifications:");
                    y += 20;

                    for (int i = 0; i < opts.Length; ++i)
                    {
                        if (defs[i] != opts[i])
                        {
                            string name = ruleset.Layout.FindByIndex(i);

                            if (name != null) // sanity
                            {
                                AddImage(35, y, opts[i] ? 0xD3 : 0xD2);
                                AddHtml(60, y, 165, 22, name);
                            }

                            y += 22;
                        }
                    }
                }
                else
                {
                    AddHtml(35, y, 190, 20, "Modifications: None");
                }

                break;
            }

            case TourneyBracketGumpType.Participant_List:
            {
                AddPage(0);
                AddBackground(0, 0, 300, 300, 9380);

                List <TourneyParticipant> pList = m_List != null
              ? Utility.CastListCovariant <object, TourneyParticipant>(m_List)
              : new List <TourneyParticipant>(tourney.Participants);

                AddLeftArrow(25, 11, ToButtonID(0, 0));
                AddHtml(25, 35, 250, 20, Center($"{pList.Count} Participant{(pList.Count == 1 ? "" : "s")}"));

                StartPage(out int index, out int count, out int y, 12);

                for (int i = 0; i < count; ++i, y += 18)
                {
                    TourneyParticipant part = pList[index + i];
                    string             name = part.NameList;

                    if (m_Tournament.TourneyType != TourneyType.Standard && part.Players.Count == 1)
                    {
                        if (part.Players[0] is PlayerMobile pm && pm.DuelPlayer != null)
                        {
                            name = Color(name, pm.DuelPlayer.Eliminated ? 0x6633333 : 0x336666);
                        }
                    }

                    AddRightArrow(25, y, ToButtonID(2, index + i), name);
                }

                break;
            }

            case TourneyBracketGumpType.Participant_Info:
            {
                if (!(obj is TourneyParticipant part))
                {
                    break;
                }

                AddPage(0);
                AddBackground(0, 0, 300, 60 + 18 + 20 + part.Players.Count * 18 + 20 + 20 + 160, 9380);

                AddLeftArrow(25, 11, ToButtonID(0, 1));
                AddHtml(25, 35, 250, 20, Center("Participants"));

                int y = 53;

                AddHtml(25, y, 200, 20, part.Players.Count == 1 ? "Players" : "Team");
                y += 20;

                for (int i = 0; i < part.Players.Count; ++i)
                {
                    Mobile mob  = part.Players[i];
                    string name = mob.Name;

                    if (m_Tournament.TourneyType != TourneyType.Standard)
                    {
                        if (mob is PlayerMobile pm && pm.DuelPlayer != null)
                        {
                            name = Color(name, pm.DuelPlayer.Eliminated ? 0x6633333 : 0x336666);
                        }
                    }

                    AddRightArrow(35, y, ToButtonID(4, i), name);
                    y += 18;
                }

                AddHtml(25, y, 200, 20,
                        $"Free Advances: {(part.FreeAdvances == 0 ? "None" : part.FreeAdvances.ToString())}");
                y += 20;

                AddHtml(25, y, 200, 20, "Log:");
                y += 20;

                StringBuilder sb = new StringBuilder();

                for (int i = 0; i < part.Log.Count; ++i)
                {
                    if (sb.Length > 0)
                    {
                        sb.Append("<br>");
                    }

                    sb.Append(part.Log[i]);
                }

                if (sb.Length == 0)
                {
                    sb.Append("Nothing logged yet.");
                }

                AddHtml(25, y, 250, 150, Color(sb.ToString(), BlackColor32), false, true);

                break;
            }

            case TourneyBracketGumpType.Player_Info:
            {
                AddPage(0);
                AddBackground(0, 0, 300, 300, 9380);

                AddLeftArrow(25, 11, ToButtonID(0, 3));
                AddHtml(25, 35, 250, 20, Center("Participants"));

                if (!(obj is Mobile mob))
                {
                    break;
                }

                Ladder      ladder = Ladder.Instance;
                LadderEntry entry  = ladder?.Find(mob);

                AddHtml(25, 53, 250, 20, $"Name: {mob.Name}");
                AddHtml(25, 73, 250, 20,
                        $"Guild: {(mob.Guild == null ? "None" : $"{mob.Guild.Name} [{mob.Guild.Abbreviation}]")}");
                AddHtml(25, 93, 250, 20, $"Rank: {(entry == null ? "N/A" : LadderGump.Rank(entry.Index + 1))}");
                AddHtml(25, 113, 250, 20, $"Level: {(entry == null ? 0 : Ladder.GetLevel(entry.Experience))}");
                AddHtml(25, 133, 250, 20, $"Wins: {entry?.Wins ?? 0:N0}");
                AddHtml(25, 153, 250, 20, $"Losses: {entry?.Losses ?? 0:N0}");

                break;
            }