Beispiel #1
0
        public KHBoardGump(Mobile mob, KHGame game)
            : base(60, 60)
        {
            m_Game = game;

            KHTeamInfo ourTeam = game.GetTeamInfo(mob);

            ArrayList entries = new ArrayList();

            for (int i = 0; i < game.Context.Participants.Count; ++i)
            {
                KHTeamInfo teamInfo = game.Controller.TeamInfo[i % game.Controller.TeamInfo.Length];

                if (teamInfo == null)
                {
                    continue;
                }

                entries.Add(teamInfo);
            }

            entries.Sort();

            /*
             *  delegate( IRankedCTF a, IRankedCTF b )
             * {
             *  return b.Score - a.Score;
             * } );*/

            int height = 73 + (entries.Count * 75) + 28;

            Closable = false;

            AddPage(0);

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

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

            for (int i = 0; i < entries.Count; i += 1)
            {
                AddImageTiled(22, 58 + (i * 75), 357, 70, 0x2430);
            }

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

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

            AddBorderedText(22, 22, 294, 20, Center("King of the Hill Scoreboard"), LabelColor32, BlackColor32);

            AddImageTiled(32, 50, 264, 1, 9107);
            AddImageTiled(42, 52, 264, 1, 9157);

            for (int i = 0; i < entries.Count; ++i)
            {
                KHTeamInfo teamInfo = entries[i] as KHTeamInfo;

                AddImage(30, 70 + (i * 75), 10152);
                AddImage(30, 85 + (i * 75), 10151);
                AddImage(30, 100 + (i * 75), 10151);
                AddImage(30, 106 + (i * 75), 10154);

                AddImage(24, 60 + (i * 75), teamInfo == ourTeam ? 9730 : 9727, teamInfo.Color - 1);

                int nameColor   = LabelColor32;
                int borderColor = BlackColor32;

                switch (teamInfo.Color)
                {
                case 0x47E:
                    nameColor = 0xFFFFFF;
                    break;

                case 0x4F2:
                    nameColor = 0x3399FF;
                    break;

                case 0x4F7:
                    nameColor = 0x33FF33;
                    break;

                case 0x4FC:
                    nameColor = 0xFF00FF;
                    break;

                case 0x021:
                    nameColor = 0xFF3333;
                    break;

                case 0x01A:
                    nameColor = 0xFF66FF;
                    break;

                case 0x455:
                    nameColor   = 0x333333;
                    borderColor = 0xFFFFFF;
                    break;
                }

                AddBorderedText(60, 65 + (i * 75), 250, 20, String.Format("{0}: {1}", LadderGump.Rank(1 + i), teamInfo.Name), nameColor, borderColor);

                AddBorderedText(50 + 10, 85 + (i * 75), 100, 20, "Score:", 0xFFC000, BlackColor32);
                AddBorderedText(50 + 15, 105 + (i * 75), 100, 20, teamInfo.Score.ToString("N0"), 0xFFC000, BlackColor32);

                AddBorderedText(110 + 10, 85 + (i * 75), 100, 20, "Kills:", 0xFFC000, BlackColor32);
                AddBorderedText(110 + 15, 105 + (i * 75), 100, 20, teamInfo.Kills.ToString("N0"), 0xFFC000, BlackColor32);

                AddBorderedText(160 + 10, 85 + (i * 75), 100, 20, "Captures:", 0xFFC000, BlackColor32);
                AddBorderedText(160 + 15, 105 + (i * 75), 100, 20, teamInfo.Captures.ToString("N0"), 0xFFC000, BlackColor32);

                string leader = null;
                if (teamInfo.Leader != null)
                {
                    leader = teamInfo.Leader.Name;
                }
                if (leader == null)
                {
                    leader = "(none)";
                }

                AddBorderedText(235 + 10, 85 + (i * 75), 250, 20, "Leader:", 0xFFC000, BlackColor32);
                AddBorderedText(235 + 15, 105 + (i * 75), 250, 20, leader, 0xFFC000, BlackColor32);
            }

            AddButton(314, height - 42, 247, 248, 1, GumpButtonType.Reply, 0);
        }
Beispiel #2
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);

                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.RedVsBlue)
                {
                    sb.Append("Red v Blue");
                }
                else if (tourney.TourneyType == TourneyType.Faction)
                {
                    sb.Append(tourney.ParticipantsPerMatch);
                    sb.Append("-Team Faction");
                }
                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 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)
                {
                    var    until = m_Tournament.SignupStart + m_Tournament.SignupPeriod - DateTime.UtcNow;
                    string text;
                    var    secs = (int)until.TotalSeconds;

                    if (secs > 0)
                    {
                        var 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:
            {
                var ruleset = tourney.Ruleset;
                var basedef = ruleset.Base;

                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);
                    }
                }
                else
                {
                    defs = basedef.Options;
                }

                var changes = 0;

                var opts = ruleset.Options;

                for (var 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"));

                var 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;

                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)";
                    }
                }

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

                y += 8;

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

                for (var 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 (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);
                                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);

                var 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 var index, out var count, out var y, 12);

                for (var i = 0; i < count; ++i, y += 18)
                {
                    var part = pList[index + i];
                    var 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"));

                var y = 53;

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

                for (var i = 0; i < part.Players.Count; ++i)
                {
                    var mob  = part.Players[i];
                    var 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;

                var sb = new StringBuilder();

                for (var 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;
                }

                var ladder = Ladder.Instance;
                var 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;
            }
Beispiel #3
0
        public CTFBoardGump(Mobile mob, CTFGame game, CTFTeamInfo section)
            : base(60, 60)
        {
            m_Game = game;

            CTFTeamInfo ourTeam = game.GetTeamInfo(mob);

            List <IRankedCTF> entries = new List <IRankedCTF>();

            if (section == null)
            {
                for (int i = 0; i < game.Context.Participants.Count; ++i)
                {
                    CTFTeamInfo teamInfo = game.Controller.TeamInfo[i % 8];

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

                    entries.Add(teamInfo);
                }
            }
            else
            {
                foreach (CTFPlayerInfo player in section.Players.Values)
                {
                    if (player.Score > 0)
                    {
                        entries.Add(player);
                    }
                }
            }

            entries.Sort(delegate(IRankedCTF a, IRankedCTF b)
            {
                return(b.Score - a.Score);
            });

            int height = 0;

            if (section == null)
            {
                height = 73 + (entries.Count * 75) + 28;
            }

            Closable = false;

            AddPage(0);

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

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

            for (int i = 0; i < entries.Count; i += 1)
            {
                AddImageTiled(22, 58 + (i * 75), 357, 70, 0x2430);
            }

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

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

            AddBorderedText(22, 22, 294, 20, Center("CTF Scoreboard"), LabelColor32, BlackColor32);

            AddImageTiled(32, 50, 264, 1, 9107);
            AddImageTiled(42, 52, 264, 1, 9157);

            if (section == null)
            {
                for (int i = 0; i < entries.Count; ++i)
                {
                    CTFTeamInfo teamInfo = entries[i] as CTFTeamInfo;

                    AddImage(30, 70 + (i * 75), 10152);
                    AddImage(30, 85 + (i * 75), 10151);
                    AddImage(30, 100 + (i * 75), 10151);
                    AddImage(30, 106 + (i * 75), 10154);

                    AddImage(24, 60 + (i * 75), teamInfo == ourTeam ? 9730 : 9727, teamInfo.Color - 1);

                    int nameColor   = LabelColor32;
                    int borderColor = BlackColor32;

                    switch (teamInfo.Color)
                    {
                    case 0x47E:
                        nameColor = 0xFFFFFF;
                        break;

                    case 0x4F2:
                        nameColor = 0x3399FF;
                        break;

                    case 0x4F7:
                        nameColor = 0x33FF33;
                        break;

                    case 0x4FC:
                        nameColor = 0xFF00FF;
                        break;

                    case 0x021:
                        nameColor = 0xFF3333;
                        break;

                    case 0x01A:
                        nameColor = 0xFF66FF;
                        break;

                    case 0x455:
                        nameColor   = 0x333333;
                        borderColor = 0xFFFFFF;
                        break;
                    }

                    AddBorderedText(60, 65 + (i * 75), 250, 20, String.Format("{0}: {1} Team", LadderGump.Rank(1 + i), teamInfo.Name), nameColor, borderColor);

                    AddBorderedText(50 + 10, 85 + (i * 75), 100, 20, "Score:", 0xFFC000, BlackColor32);
                    AddBorderedText(50 + 15, 105 + (i * 75), 100, 20, teamInfo.Score.ToString("N0"), 0xFFC000, BlackColor32);

                    AddBorderedText(110 + 10, 85 + (i * 75), 100, 20, "Kills:", 0xFFC000, BlackColor32);
                    AddBorderedText(110 + 15, 105 + (i * 75), 100, 20, teamInfo.Kills.ToString("N0"), 0xFFC000, BlackColor32);

                    AddBorderedText(160 + 10, 85 + (i * 75), 100, 20, "Captures:", 0xFFC000, BlackColor32);
                    AddBorderedText(160 + 15, 105 + (i * 75), 100, 20, teamInfo.Captures.ToString("N0"), 0xFFC000, BlackColor32);

                    CTFPlayerInfo pl = teamInfo.Leader;

                    AddBorderedText(235 + 10, 85 + (i * 75), 250, 20, "Leader:", 0xFFC000, BlackColor32);

                    if (pl != null)
                    {
                        AddBorderedText(235 + 15, 105 + (i * 75), 250, 20, pl.Player.Name, 0xFFC000, BlackColor32);
                    }
                }
            }
            else
            {
            }

            AddButton(314, height - 42, 247, 248, 1, GumpButtonType.Reply, 0);
        }