Beispiel #1
0
		public LadderController() : base( 0x1B7A )
		{
			Visible = false;
			Movable = false;

			m_Ladder = new Ladder();

			if ( Ladder.Instance == null )
				Ladder.Instance = m_Ladder;
		}
Beispiel #2
0
        public LadderController()
            : base(0x1B7A)
        {
            this.Visible = false;
            this.Movable = false;

            this.m_Ladder = new Ladder();

            if (Ladder.Instance == null)
                Ladder.Instance = this.m_Ladder;
        }
Beispiel #3
0
		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );

			int version = reader.ReadInt();

			switch ( version )
			{
				case 1:
				case 0:
				{
					m_Ladder = new Ladder( reader );

					if ( version < 1 || reader.ReadBool() )
						Server.Engines.ConPVP.Ladder.Instance = m_Ladder;

					break;
				}
			}
		}
Beispiel #4
0
        public LadderEntry( GenericReader reader, Ladder ladder, int version )
        {
            m_Ladder = ladder;

            switch ( version )
            {
                case 1:
                case 0:
                {
                    m_Mobile = reader.ReadMobile();
                    m_Experience = reader.ReadEncodedInt();
                    m_Wins = reader.ReadEncodedInt();
                    m_Losses = reader.ReadEncodedInt();

                    break;
                }
            }
        }
Beispiel #5
0
 public LadderEntry( Mobile mob, Ladder ladder )
 {
     m_Ladder = ladder;
     m_Mobile = mob;
 }
Beispiel #6
0
        public LadderGump( Ladder ladder, int page )
            : base(50, 50)
        {
            m_Ladder = ladder;
            m_Page = page;

            AddPage( 0 );

            ArrayList list = ladder.ToArrayList();
            m_List = list;

            int lc = Math.Min( list.Count, 150 );

            int start = page * 15;
            int end = start+15;

            if ( end > lc )
                end = lc;

            int ct = end-start;

            int height = 12 + 20 + (ct*20) + 23 + 12;

            AddBackground( 0, 0, 499, height, 0x2436 );

            for ( int i = start + 1; i < end; i += 2 )
                AddImageTiled( 12, 32 + ((i - start) * 20), 475, 20, 0x2430 );

            AddAlphaRegion( 10, 10, 479, height - 20 );

            if ( page > 0 )
                AddButton( 446, height-12-2-16, 0x15E3, 0x15E7, 1, GumpButtonType.Reply, 0 );
            else
                AddImage( 446, height-12-2-16, 0x2626 );

            if ( ((page+1)*15)<lc )
                AddButton( 466, height-12-2-16, 0x15E1, 0x15E5, 2, GumpButtonType.Reply, 0 );
            else
                AddImage( 466, height-12-2-16, 0x2622 );

            AddHtml( 16, height-12-2-18, 400, 20, Color( String.Format( "Top {3} of {0:N0} duelists, page {1} of {2}", list.Count, page+1, (lc+14)/15, lc ), 0xFFC000 ), false, false );

            AddColumnHeader(  75, "Rank" );
            AddColumnHeader( 115, "Level" );
            AddColumnHeader(  50, "Guild" );
            AddColumnHeader( 115, "Name" );
            AddColumnHeader(  60, "Wins" );
            AddColumnHeader(  60, "Losses" );

            for ( int i = start; i < end && i < lc; ++i )
            {
                LadderEntry entry = (LadderEntry)list[i];

                int y = 32 + ((i - start) * 20);
                int x = 12;

                AddBorderedText( x, y, 75, Center( Rank( i+1 ) ), 0xFFFFFF, 0 );
                x += 75;

                /*AddImage( 20, y + 5, 0x2616, 0x96C );
                AddImage( 22, y + 5, 0x2616, 0x96C );
                AddImage( 20, y + 7, 0x2616, 0x96C );
                AddImage( 22, y + 7, 0x2616, 0x96C );

                AddImage( 21, y + 6, 0x2616, 0x454 );*/

                AddImage( x + 3, y + 4, 0x805 );

                int xp = entry.Experience;
                int level = Ladder.GetLevel( xp );

                int xpBase, xpAdvance;
                Ladder.GetLevelInfo( level, out xpBase, out xpAdvance );

                int width;

                int xpOffset = xp - xpBase;

                if ( xpOffset >= xpAdvance )
                    width = 109; // level 50
                else
                    width = ((109 * xpOffset) + (xpAdvance / 2)) / (xpAdvance - 1);

                //AddImageTiled( 21, y + 6, width, 8, 0x2617 );
                AddImageTiled( x + 3, y + 4, width, 11, 0x806 );
                AddBorderedText( x, y, 115, Center( level.ToString() ), 0xFFFFFF, 0 );
                x += 115;

                Mobile mob = entry.Mobile;

                if ( mob.Guild != null )
                    AddBorderedText( x, y, 50, Center( mob.Guild.Abbreviation ), 0xFFFFFF, 0 );

                x += 50;

                AddBorderedText( x + 5, y, 115 - 5, ( mob.Name ), 0xFFFFFF, 0 );
                x += 115;

                AddBorderedText( x, y, 60, Center( entry.Wins.ToString() ), 0xFFFFFF, 0 );
                x += 60;

                AddBorderedText( x, y, 60, Center( entry.Losses.ToString() ), 0xFFFFFF, 0 );
                x += 60;

                //AddBorderedText( 292 + 15, y, 115 - 30, String.Format( "{0} <DIV ALIGN=CENTER>/</DIV> <DIV ALIGN=RIGHT>{1}</DIV>", entry.Wins, entry.Losses ), 0xFFC000, 0 );
            }
        }
Beispiel #7
0
 public LadderGump( Ladder ladder )
     : this(ladder, 0)
 {
 }
Beispiel #8
0
        public LadderGump(Ladder ladder, int page)
            : base(50, 50)
        {
            m_Ladder = ladder;
            m_Page   = page;

            AddPage(0);

            ArrayList list = ladder.ToArrayList();

            m_List = list;

            int lc = Math.Min(list.Count, 150);

            int start = page * 15;
            int end   = start + 15;

            if (end > lc)
            {
                end = lc;
            }

            int ct = end - start;

            int height = 12 + 20 + (ct * 20) + 23 + 12;

            AddBackground(0, 0, 499, height, 0x2436);

            for (int i = start + 1; i < end; i += 2)
            {
                AddImageTiled(12, 32 + ((i - start) * 20), 475, 20, 0x2430);
            }

            AddAlphaRegion(10, 10, 479, height - 20);

            if (page > 0)
            {
                AddButton(446, height - 12 - 2 - 16, 0x15E3, 0x15E7, 1, GumpButtonType.Reply, 0);
            }
            else
            {
                AddImage(446, height - 12 - 2 - 16, 0x2626);
            }

            if (((page + 1) * 15) < lc)
            {
                AddButton(466, height - 12 - 2 - 16, 0x15E1, 0x15E5, 2, GumpButtonType.Reply, 0);
            }
            else
            {
                AddImage(466, height - 12 - 2 - 16, 0x2622);
            }

            AddHtml(16, height - 12 - 2 - 18, 400, 20, Color(String.Format("Top {3} of {0:N0} duelists, page {1} of {2}", list.Count, page + 1, (lc + 14) / 15, lc), 0xFFC000), false, false);

            AddColumnHeader(75, "Rank");
            AddColumnHeader(115, "Level");
            AddColumnHeader(50, "Guild");
            AddColumnHeader(115, "Name");
            AddColumnHeader(60, "Wins");
            AddColumnHeader(60, "Losses");

            for (int i = start; i < end && i < lc; ++i)
            {
                LadderEntry entry = (LadderEntry)list[i];

                int y = 32 + ((i - start) * 20);
                int x = 12;

                AddBorderedText(x, y, 75, Center(Rank(i + 1)), 0xFFFFFF, 0);
                x += 75;

                /*AddImage( 20, y + 5, 0x2616, 0x96C );
                *  AddImage( 22, y + 5, 0x2616, 0x96C );
                *  AddImage( 20, y + 7, 0x2616, 0x96C );
                *  AddImage( 22, y + 7, 0x2616, 0x96C );
                *
                *  AddImage( 21, y + 6, 0x2616, 0x454 );*/

                AddImage(x + 3, y + 4, 0x805);

                int xp    = entry.Experience;
                int level = Ladder.GetLevel(xp);

                int xpBase, xpAdvance;
                Ladder.GetLevelInfo(level, out xpBase, out xpAdvance);

                int width;

                int xpOffset = xp - xpBase;

                if (xpOffset >= xpAdvance)
                {
                    width = 109; // level 50
                }
                else
                {
                    width = ((109 * xpOffset) + (xpAdvance / 2)) / (xpAdvance - 1);
                }

                //AddImageTiled( 21, y + 6, width, 8, 0x2617 );
                AddImageTiled(x + 3, y + 4, width, 11, 0x806);
                AddBorderedText(x, y, 115, Center(level.ToString()), 0xFFFFFF, 0);
                x += 115;

                Mobile mob = entry.Mobile;

                if (mob.Guild != null)
                {
                    AddBorderedText(x, y, 50, Center(mob.Guild.Abbreviation), 0xFFFFFF, 0);
                }

                x += 50;

                AddBorderedText(x + 5, y, 115 - 5, (mob.Name), 0xFFFFFF, 0);
                x += 115;

                AddBorderedText(x, y, 60, Center(entry.Wins.ToString()), 0xFFFFFF, 0);
                x += 60;

                AddBorderedText(x, y, 60, Center(entry.Losses.ToString()), 0xFFFFFF, 0);
                x += 60;

                //AddBorderedText( 292 + 15, y, 115 - 30, String.Format( "{0} <DIV ALIGN=CENTER>/</DIV> <DIV ALIGN=RIGHT>{1}</DIV>", entry.Wins, entry.Losses ), 0xFFC000, 0 );
            }
        }
Beispiel #9
0
 public LadderGump(Ladder ladder)
     : this(ladder, 0)
 {
 }
Beispiel #10
0
 public LadderEntry(Mobile mob, Ladder ladder)
 {
     m_Ladder = ladder;
     m_Mobile = mob;
 }
Beispiel #11
0
        public ArenaGump(Mobile from, ArenasMoongate gate)
            : base(50, 50)
        {
            this.m_From   = from;
            this.m_Gate   = gate;
            this.m_Arenas = Arena.Arenas;

            this.AddPage(0);

            int height = 12 + 20 + (this.m_Arenas.Count * 31) + 24 + 12;

            this.AddBackground(0, 0, 499 + 40, height, 0x2436);

            List <Arena> list = this.m_Arenas;

            for (int i = 1; i < list.Count; i += 2)
            {
                this.AddImageTiled(12, 32 + (i * 31), 475 + 40, 30, 0x2430);
            }

            this.AddAlphaRegion(10, 10, 479 + 40, height - 20);

            this.AddColumnHeader(35, null);
            this.AddColumnHeader(115, "Arena");
            this.AddColumnHeader(325, "Participants");
            this.AddColumnHeader(40, "Obs");

            this.AddButton(499 + 40 - 12 - 63 - 4 - 63, height - 12 - 24, 247, 248, 1, GumpButtonType.Reply, 0);
            this.AddButton(499 + 40 - 12 - 63, height - 12 - 24, 241, 242, 2, GumpButtonType.Reply, 0);

            for (int i = 0; i < list.Count; ++i)
            {
                Arena ar = list[i];

                string name = ar.Name;

                if (name == null)
                {
                    name = "(no name)";
                }

                int x = 12;
                int y = 32 + (i * 31);

                int color = (ar.Players.Count > 0 ? 0xCCFFCC : 0xCCCCCC);

                this.AddRadio(x + 3, y + 1, 9727, 9730, false, i);
                x += 35;

                this.AddBorderedText(x + 5, y + 5, 115 - 5, name, color, 0);
                x += 115;

                StringBuilder sb = new StringBuilder();

                if (ar.Players.Count > 0)
                {
                    Ladder ladder = Ladder.Instance;

                    if (ladder == null)
                    {
                        continue;
                    }

                    LadderEntry p1 = null, p2 = null, p3 = null, p4 = null;

                    for (int j = 0; j < ar.Players.Count; ++j)
                    {
                        Mobile      mob = (Mobile)ar.Players[j];
                        LadderEntry c   = ladder.Find(mob);

                        if (p1 == null || c.Index < p1.Index)
                        {
                            p4 = p3;
                            p3 = p2;
                            p2 = p1;
                            p1 = c;
                        }
                        else if (p2 == null || c.Index < p2.Index)
                        {
                            p4 = p3;
                            p3 = p2;
                            p2 = c;
                        }
                        else if (p3 == null || c.Index < p3.Index)
                        {
                            p4 = p3;
                            p3 = c;
                        }
                        else if (p4 == null || c.Index < p4.Index)
                        {
                            p4 = c;
                        }
                    }

                    this.Append(sb, p1);
                    this.Append(sb, p2);
                    this.Append(sb, p3);
                    this.Append(sb, p4);

                    if (ar.Players.Count > 4)
                    {
                        sb.Append(", ...");
                    }
                }
                else
                {
                    sb.Append("Empty");
                }

                this.AddBorderedText(x + 5, y + 5, 325 - 5, sb.ToString(), color, 0);
                x += 325;

                this.AddBorderedText(x, y + 5, 40, this.Center(ar.Spectators.ToString()), color, 0);
            }
        }
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (info.ButtonID == 1 && info.IsSwitched(1))
            {
                var tourney = m_Tournament;
                var 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;
                    }

                    var ladder = Ladder.Instance;

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

                        var 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;
                        var    minutesUntil = (int)Math.Round(
                            (tourney.SignupStart + tourney.SignupPeriod - Core.Now)
                            .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
                            );
                    }

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

                    tourney.Participants.Add(part);

                    break;
                }
                }
            }
            else if (info.ButtonID > 1)
            {
                var 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));
                }
            }
        }
Beispiel #13
0
 public LadderEntry(Mobile mob, Ladder ladder)
 {
     this.m_Ladder = ladder;
     this.m_Mobile = mob;
 }
Beispiel #14
0
 public LadderEntry(Mobile mob, Ladder ladder)
 {
     this.m_Ladder = ladder;
     this.m_Mobile = mob;
 }
Beispiel #15
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;
            }