예제 #1
0
        protected virtual void OnResetStatistics(GumpButton button)
        {
            if (Selected == null || Selected.Deleted)
            {
                Selected = AutoPvP.EnsureProfile(User as PlayerMobile);
            }

            if (UseConfirmDialog)
            {
                Send(
                    new ConfirmDialogGump(
                        User,
                        Refresh(),
                        title: "Reset Profile Statistics?",
                        html:
                        "All data associated with the profile statistics will be lost.\n" +
                        "This action can not be reversed!\nDo you want to continue?",
                        onAccept: OnConfirmResetStatistics));
            }
            else
            {
                Selected.History.Entries.Clear();
                Refresh(true);
            }
        }
예제 #2
0
 public virtual IEnumerable <PlayerMobile> GetWorldBroadcastList()
 {
     return(NetState.Instances.Where(state => state != null)
            .Select(state => state.Mobile as PlayerMobile)
            .Where(pm => pm != null && !pm.Deleted)
            .Where(pm => IsOnline(pm) && AutoPvP.EnsureProfile(pm).IsSubscribed(this)));
 }
예제 #3
0
        private void TransferStatistics(PlayerMobile pm, PvPProfileHistoryEntry e)
        {
            var profile = AutoPvP.EnsureProfile(pm);

            OnTransferStatistics(profile, e);
            OnTransferPoints(profile, e.Points);
        }
예제 #4
0
        public void Eject(PlayerMobile pm, bool teleport)
        {
            if (pm == null || pm.Deleted)
            {
                return;
            }

            PvPTeam team;

            if (IsParticipant(pm, out team))
            {
                if (State == PvPBattleState.Running || State == PvPBattleState.Ended)
                {
                    var h = EnsureStatistics(pm);

                    h.Battles = 1;

                    if (State == PvPBattleState.Running)
                    {
                        h.Losses = 1;

                        var points = GetAwardPoints(team, pm);

                        h.PointsLost += points;

                        var p = AutoPvP.EnsureProfile(pm);

                        if (p != null)
                        {
                            p.Points -= points;
                        }
                    }
                }

                team.RemoveMember(pm, false);
            }
            else if (IsSpectator(pm))
            {
                RemoveSpectator(pm, false);
            }

            if (teleport)
            {
                var bounce = BounceInfo.GetValue(pm);

                if (bounce != null && !bounce.InternalOrZero)
                {
                    Teleport(pm, bounce, bounce);

                    BounceInfo.Remove(pm);
                }
                else
                {
                    Teleport(pm, Options.Locations.Eject, Options.Locations.Eject.Map);
                }
            }
        }
예제 #5
0
        public virtual void RevokePoints(PlayerMobile pm, int points)
        {
            if (!IsParticipant(pm))
            {
                return;
            }

            EnsureStatistics(pm).PointsLost  += points;
            AutoPvP.EnsureProfile(pm).Points -= points;
        }
예제 #6
0
        public virtual void AwardPoints(PlayerMobile pm, int points)
        {
            if (!IsParticipant(pm))
            {
                return;
            }

            EnsureStatistics(pm).PointsGained += points;
            AutoPvP.EnsureProfile(pm).Points  += points;
        }
예제 #7
0
        protected override void Compile()
        {
            base.Compile();

            if (Selected == null || Selected.Deleted)
            {
                Selected = AutoPvP.EnsureProfile(User as PlayerMobile, true);
            }

            Html = Selected.ToHtmlString(User);
        }
예제 #8
0
 public virtual void AwardTeamPoints(PvPTeam team, int points)
 {
     if (team != null)
     {
         team.ForEachMember(
             pm =>
         {
             EnsureStatistics(pm).PointsGained += points;
             AutoPvP.EnsureProfile(pm).Points  += points;
         });
     }
 }
예제 #9
0
 public virtual void RevokeTeamPoints(PvPTeam team, int points)
 {
     if (team != null)
     {
         team.ForEachMember(
             pm =>
         {
             EnsureStatistics(pm).PointsLost  += points;
             AutoPvP.EnsureProfile(pm).Points -= points;
         });
     }
 }
예제 #10
0
        public void TransferStatistics(PlayerMobile pm)
        {
            if (!Ranked)
            {
                Statistics.Remove(pm);
                return;
            }

            var profile = AutoPvP.EnsureProfile(pm);
            var entry   = EnsureStatistics(pm);

            OnTransferStatistics(pm, profile.Statistics, entry);

            Statistics.Remove(pm);
        }
예제 #11
0
        protected override void CompileMenuOptions(MenuGumpOptions list)
        {
            if (Selected == null || Selected.Deleted)
            {
                Selected = AutoPvP.EnsureProfile(User as PlayerMobile, true);
            }

            if ((Selected.Owner == User && AutoPvP.CMOptions.Advanced.Profiles.AllowPlayerDelete) ||
                User.AccessLevel >= AutoPvP.Access)
            {
                list.AppendEntry(new ListGumpEntry("Clear Statistics", OnResetStatistics, HighlightHue));
                list.AppendEntry(new ListGumpEntry("Delete Profile", OnDeleteProfile, HighlightHue));
            }

            base.CompileMenuOptions(list);
        }
예제 #12
0
        public void Sync()
        {
            GetParticipants()
            .Where(pm => pm != null && !pm.Deleted)
            .Select(pm => AutoPvP.EnsureProfile(pm))
            .ForEach(p => p.Sync());

            Teams.Where(team => team != null && !team.Deleted).ForEach(team => team.Sync());

            if (Schedule != null && Schedule.Enabled)
            {
                Schedule.InvalidateNextTick(DateTime.UtcNow);
            }

            OnSync();
        }
예제 #13
0
        protected virtual void OnConfirmSubscribe(GumpButton button)
        {
            if (Selected == null || Selected.Deleted)
            {
                Close();
                return;
            }

            PvPProfile profile = AutoPvP.EnsureProfile(User);

            if (profile != null && !profile.Deleted)
            {
                profile.Subscribe(Selected);
                User.SendMessage("You have subscribed to {0} notifications.", Selected.Name);
                Refresh(true);
            }
        }
예제 #14
0
        public void Eject(PlayerMobile pm, bool teleport)
        {
            if (pm == null || pm.Deleted)
            {
                return;
            }

            PvPTeam team;

            if (IsParticipant(pm, out team))
            {
                if (State == PvPBattleState.Running || State == PvPBattleState.Ended)
                {
                    EnsureStatistics(pm).Battles = 1;

                    if (State == PvPBattleState.Running)
                    {
                        EnsureStatistics(pm).Losses = 1;

                        int points = GetAwardPoints(team, pm);

                        EnsureStatistics(pm).PointsLost  += points;
                        AutoPvP.EnsureProfile(pm).Points -= points;
                    }
                }

                team.RemoveMember(pm, false);
            }
            else if (IsSpectator(pm))
            {
                RemoveSpectator(pm, false);
            }

            if (teleport)
            {
                Teleport(pm, Options.Locations.Eject, Options.Locations.Eject.Map);
            }
        }
예제 #15
0
        protected virtual void OnDeleteProfile(GumpButton button)
        {
            if (Selected == null || Selected.Deleted)
            {
                Selected = AutoPvP.EnsureProfile(User as PlayerMobile);
            }

            if (UseConfirmDialog)
            {
                new ConfirmDialogGump(User, Refresh())
                {
                    Title = "Delete Profile?",
                    Html  = "All data associated with this profile will be deleted.\n" +
                            "This action can not be reversed!\nDo you want to continue?",
                    AcceptHandler = OnConfirmDeleteProfile,
                    CancelHandler = Refresh
                }.Send();
            }
            else
            {
                OnConfirmDeleteProfile(button);
            }
        }
예제 #16
0
        protected virtual void OnDeleteProfile(GumpButton button)
        {
            if (Selected == null || Selected.Deleted)
            {
                Selected = AutoPvP.EnsureProfile(User);
            }

            if (UseConfirmDialog)
            {
                Send(
                    new ConfirmDialogGump(
                        User,
                        Refresh(),
                        title: "Delete Profile?",
                        html:
                        "All data associated with this profile will be deleted.\nThis action can not be reversed!\nDo you want to continue?",
                        onAccept: OnConfirmDeleteProfile));
            }
            else
            {
                Selected.Delete();
                Close();
            }
        }
예제 #17
0
        protected override void CompileMenuOptions(MenuGumpOptions list)
        {
            list.Clear();

            if (Selected != null && !Selected.Deleted)
            {
                if (User.AccessLevel >= AutoPvP.Access)
                {
                    list.AppendEntry(
                        new ListGumpEntry(
                            "Edit Options",
                            b =>
                    {
                        Minimize();
                        User.SendGump(
                            new PropertiesGump(User, Selected)
                        {
                            X = b.X,
                            Y = b.Y
                        });
                    },
                            HighlightHue));

                    list.AppendEntry(
                        new ListGumpEntry(
                            "Edit Advanced Options",
                            b =>
                    {
                        Minimize();
                        User.SendGump(
                            new PropertiesGump(User, Selected.Options)
                        {
                            X = b.X,
                            Y = b.Y
                        });
                    },
                            HighlightHue));

                    if (Selected.State == PvPBattleState.Internal)
                    {
                        list.AppendEntry(
                            new ListGumpEntry(
                                "Edit Spectate Region",
                                b =>
                        {
                            if (Selected.SpectateRegion == null)
                            {
                                Selected.SpectateRegion = RegionExtUtility.Create <PvPSpectateRegion>(Selected);
                            }

                            Send(new PvPSpectateBoundsGump(User, Selected, Hide(true)));
                        },
                                HighlightHue));

                        list.AppendEntry(
                            new ListGumpEntry(
                                "Edit Battle Region",
                                b =>
                        {
                            if (Selected.BattleRegion == null)
                            {
                                Selected.BattleRegion = RegionExtUtility.Create <PvPBattleRegion>(Selected);
                            }

                            Send(new PvPBattleBoundsGump(User, Selected, Hide(true)));
                        },
                                HighlightHue));
                    }

                    list.AppendEntry(
                        new ListGumpEntry(
                            "Edit Doors", b => Send(new PvPDoorListGump(User, Selected, Hide(true), UseConfirmDialog)), HighlightHue));

                    list.AppendEntry(
                        new ListGumpEntry(
                            "Edit Description",
                            b =>
                            Send(
                                new TextInputPanelGump <PvPBattle>(
                                    User,
                                    Hide(true),
                                    title: "Battle Description (HTML/BBC Supported)",
                                    input: Selected.Description,
                                    limit: 1000,
                                    callback: s =>
                    {
                        s = s.ParseBBCode();

                        if (!String.IsNullOrWhiteSpace(s))
                        {
                            Selected.Description = s;
                        }

                        Refresh(true);
                    })),
                            HighlightHue));
                }

                list.AppendEntry(
                    new ListGumpEntry(
                        "View Schedule",
                        b => Send(new ScheduleOverviewGump(User, Selected.Schedule, Hide(true))),
                        (User.AccessLevel >= AutoPvP.Access) ? HighlightHue : TextHue));

                list.AppendEntry(
                    new ListGumpEntry(
                        "View Teams",
                        b => Send(new PvPTeamListGump(User, Selected, Hide(true))),
                        (User.AccessLevel >= AutoPvP.Access) ? HighlightHue : TextHue));

                if (User.AccessLevel >= AutoPvP.Access)
                {
                    list.AppendEntry(
                        new ListGumpEntry(
                            "View Rules/Restrictions",
                            b =>
                    {
                        MenuGumpOptions opts = new MenuGumpOptions();

                        opts.AppendEntry(
                            new ListGumpEntry(
                                "Inherit Rules/Restrictions",
                                b2 =>
                        {
                            MenuGumpOptions opts2 = new MenuGumpOptions();

                            AutoPvP.Battles.Values.Where(ba => ba != Selected)
                            .ForEach(
                                ba => opts2.AppendEntry(
                                    new ListGumpEntry(
                                        ba.Name,
                                        () =>
                            {
                                var rulesA = Selected.Options.Rules;
                                var rulesB = ba.Options.Rules;

                                rulesA.AllowBeneficial    = rulesB.AllowBeneficial;
                                rulesA.AllowHarmful       = rulesB.AllowHarmful;
                                rulesA.AllowHousing       = rulesB.AllowHousing;
                                rulesA.AllowPets          = rulesB.AllowPets;
                                rulesA.AllowSpawn         = rulesB.AllowSpawn;
                                rulesA.AllowSpeech        = rulesB.AllowSpeech;
                                rulesA.CanBeDamaged       = rulesB.CanBeDamaged;
                                rulesA.CanDamageEnemyTeam = rulesB.CanDamageEnemyTeam;
                                rulesA.CanDamageOwnTeam   = rulesB.CanDamageOwnTeam;
                                rulesA.CanDie             = rulesB.CanDie;
                                rulesA.CanHeal            = rulesB.CanHeal;
                                rulesA.CanHealEnemyTeam   = rulesB.CanHealEnemyTeam;
                                rulesA.CanHealOwnTeam     = rulesB.CanHealOwnTeam;
                                rulesA.CanMount           = rulesB.CanMount;
                                rulesA.CanMoveThrough     = rulesB.CanMoveThrough;
                                rulesA.CanMountEthereal   = rulesB.CanMountEthereal;
                                rulesA.CanResurrect       = rulesB.CanResurrect;
                                rulesA.CanUseStuckMenu    = rulesB.CanUseStuckMenu;

                                Selected.Options.Restrictions.Items.List =
                                    new Dictionary <Type, bool>(ba.Options.Restrictions.Items.List);

                                Selected.Options.Restrictions.Pets.List =
                                    new Dictionary <Type, bool>(ba.Options.Restrictions.Pets.List);

                                Selected.Options.Restrictions.Spells.List =
                                    new Dictionary <Type, bool>(ba.Options.Restrictions.Spells.List);

                                Selected.Options.Restrictions.Skills.List =
                                    new Dictionary <int, bool>(ba.Options.Restrictions.Skills.List);

                                Refresh(true);
                            })));

                            Send(new MenuGump(User, this, opts2, b));
                        }));

                        opts.AppendEntry(
                            new ListGumpEntry(
                                "Rules",
                                mb =>
                        {
                            Refresh();

                            PropertiesGump g = new PropertiesGump(User, Selected.Options.Rules)
                            {
                                X = mb.X,
                                Y = mb.Y
                            };
                            User.SendGump(g);
                        }));

                        opts.AppendEntry(
                            new ListGumpEntry(
                                "Items", mb => Send(new PvPRestrictItemsListGump(User, Selected.Options.Restrictions.Items, Hide(true)))));

                        opts.AppendEntry(
                            new ListGumpEntry(
                                "Pets", mb => Send(new PvPRestrictPetsListGump(User, Selected.Options.Restrictions.Pets, Hide(true)))));

                        opts.AppendEntry(
                            new ListGumpEntry(
                                "Skills", mb => Send(new PvPRestrictSkillsListGump(User, Selected.Options.Restrictions.Skills, Hide(true)))));

                        opts.AppendEntry(
                            new ListGumpEntry(
                                "Spells", mb => Send(new PvPRestrictSpellsListGump(User, Selected.Options.Restrictions.Spells, Hide(true)))));

                        Send(new MenuGump(User, this, opts, b));
                    },
                            (User.AccessLevel >= AutoPvP.Access) ? HighlightHue : TextHue));

                    list.AppendEntry(
                        new ListGumpEntry(
                            "Reset Statistics",
                            b =>
                    {
                        if (UseConfirmDialog)
                        {
                            Send(
                                new ConfirmDialogGump(
                                    User,
                                    this,
                                    title: "Reset Battle Statistics?",
                                    html:
                                    "All data associated with the battle statistics will be transferred to player profiles then cleared.\nThis action can not be reversed!\nDo you want to continue?",
                                    onAccept: OnConfirmResetStatistics));
                        }
                        else
                        {
                            OnConfirmResetStatistics(b);
                        }
                    },
                            HighlightHue));

                    if (Selected.State == PvPBattleState.Internal)
                    {
                        if (Selected.Validate(User))
                        {
                            list.AppendEntry(
                                new ListGumpEntry(
                                    "Publish",
                                    b =>
                            {
                                Selected.State = PvPBattleState.Queueing;
                                Refresh(true);
                            },
                                    HighlightHue));
                        }
                    }
                    else
                    {
                        list.AppendEntry(
                            new ListGumpEntry(
                                "Internalize",
                                b =>
                        {
                            Selected.State = PvPBattleState.Internal;
                            Refresh(true);
                        },
                                HighlightHue));

                        if (!Selected.Hidden)
                        {
                            if (Selected.Validate(User))
                            {
                                list.AppendEntry(
                                    new ListGumpEntry(
                                        "Hide",
                                        b =>
                                {
                                    Selected.Hidden = true;
                                    Refresh(true);
                                },
                                        HighlightHue));
                            }
                        }
                        else
                        {
                            list.AppendEntry(
                                new ListGumpEntry(
                                    "Unhide",
                                    b =>
                            {
                                Selected.Hidden = false;
                                Refresh(true);
                            },
                                    HighlightHue));
                        }
                    }

                    list.AppendEntry(
                        new ListGumpEntry(
                            "Delete",
                            b =>
                    {
                        if (UseConfirmDialog)
                        {
                            Send(
                                new ConfirmDialogGump(
                                    User,
                                    this,
                                    title: "Delete Battle?",
                                    html:
                                    "All data associated with this battle will be deleted.\nThis action can not be reversed!\nDo you want to continue?",
                                    onAccept: OnConfirmDeleteBattle));
                        }
                        else
                        {
                            OnConfirmDeleteBattle(b);
                        }
                    },
                            HighlightHue));
                }

                list.AppendEntry(
                    new ListGumpEntry(
                        "Command List",
                        b =>
                {
                    StringBuilder html = new StringBuilder();
                    Selected.GetHtmlCommandList(User, html);
                    new HtmlPanelGump <PvPBattle>(User, this, title: "Command List", html: html.ToString(), selected: Selected).Send();
                }));

                PvPProfile profile = AutoPvP.EnsureProfile(User);

                if (profile != null && !profile.Deleted)
                {
                    if (profile.IsSubscribed(Selected))
                    {
                        list.AppendEntry(
                            new ListGumpEntry(
                                "Unsubscribe",
                                b =>
                        {
                            profile.Unsubscribe(Selected);
                            User.SendMessage("You have unsubscribed from {0} notifications.", Selected.Name);
                            Refresh(true);
                        }));
                    }
                    else
                    {
                        list.AppendEntry(
                            new ListGumpEntry(
                                "Subscribe",
                                b =>
                        {
                            if (UseConfirmDialog)
                            {
                                Send(
                                    new ConfirmDialogGump(
                                        User,
                                        this,
                                        title: "Subscriptions",
                                        html:
                                        "Subscribing to a battle allows you to see its world broadcast notifications.\n\nDo you want to subscribe to " +
                                        Selected.Name + "?",
                                        onAccept: OnConfirmSubscribe));
                            }
                            else
                            {
                                OnConfirmSubscribe(b);
                            }
                        }));
                    }
                }

                if (Selected.IsParticipant(User))
                {
                    list.AppendEntry(new ListGumpEntry("Quit & Leave", b => Selected.Eject(User, true)));
                }
                else
                {
                    if (Selected.IsQueued(User))
                    {
                        list.AppendEntry(new ListGumpEntry("Leave Queue", b => Selected.Dequeue(User)));
                    }
                    else if (Selected.CanQueue(User))
                    {
                        list.AppendEntry(new ListGumpEntry("Join Queue", b => Selected.Enqueue(User)));
                    }

                    if (Selected.IsSpectator(User))
                    {
                        list.AppendEntry(new ListGumpEntry("Leave Spectators", b => Selected.RemoveSpectator(User, true)));
                    }
                    else if (Selected.CanSpectate(User))
                    {
                        list.AppendEntry(new ListGumpEntry("Join Spectators", b => Selected.AddSpectator(User, true)));
                    }
                }
            }

            base.CompileMenuOptions(list);
        }
예제 #18
0
파일: Battle.cs 프로젝트: AllanNisbet/runuo
        public void Sync()
        {
            foreach (var p in GetParticipants().Where(pm => pm != null && !pm.Deleted).Select(pm => AutoPvP.EnsureProfile(pm)))
            {
                p.Sync();
            }

            foreach (var team in Teams.Where(team => team != null && !team.Deleted))
            {
                team.Sync();
            }

            if (Schedule != null && Schedule.Enabled)
            {
                Schedule.InvalidateNextTick(DateTime.UtcNow);
            }

            OnSync();
        }
예제 #19
0
        protected override void CompileMenuOptions(MenuGumpOptions list)
        {
            list.Clear();

            if (Selected != null && !Selected.Deleted)
            {
                if (User.AccessLevel >= AutoPvP.Access)
                {
                    list.AppendEntry(
                        "Edit Options",
                        b =>
                    {
                        Minimize();

                        var pg = new PropertiesGump(User, Selected)
                        {
                            X = b.X,
                            Y = b.Y
                        };

                        User.SendGump(pg);
                    },
                        HighlightHue);

                    list.AppendEntry(
                        "Edit Advanced Options",
                        b =>
                    {
                        Minimize();

                        var pg = new PropertiesGump(User, Selected.Options)
                        {
                            X = b.X,
                            Y = b.Y
                        };

                        User.SendGump(pg);
                    },
                        HighlightHue);

                    if (Selected.State == PvPBattleState.Internal)
                    {
                        list.AppendEntry(
                            "Edit Spectate Region",
                            b =>
                        {
                            if (Selected.SpectateRegion == null)
                            {
                                Selected.SpectateRegion = RegionExtUtility.Create <PvPSpectateRegion>(Selected);
                            }

                            new PvPSpectateBoundsGump(User, Selected, Hide(true)).Send();
                        },
                            HighlightHue);

                        list.AppendEntry(
                            "Edit Battle Region",
                            b =>
                        {
                            if (Selected.BattleRegion == null)
                            {
                                Selected.BattleRegion = RegionExtUtility.Create <PvPBattleRegion>(Selected);
                            }

                            new PvPBattleBoundsGump(User, Selected, Hide(true)).Send();
                        },
                            HighlightHue);
                    }

                    list.AppendEntry(
                        "Edit Doors",
                        b => new PvPDoorsUI(User, Selected, Hide(true), UseConfirmDialog).Send(),
                        HighlightHue);

                    list.AppendEntry(
                        "Edit Description",
                        b => new TextInputPanelGump <PvPBattle>(User, Hide(true))
                    {
                        Title    = "Battle Description (HTML/BBC Supported)",
                        Input    = Selected.Description,
                        Limit    = 1000,
                        Callback = s =>
                        {
                            s = s.ParseBBCode();

                            if (!String.IsNullOrWhiteSpace(s))
                            {
                                Selected.Description = s;
                            }

                            Refresh(true);
                        }
                    }.Send(),
                        HighlightHue);
                }

                list.AppendEntry(
                    "View Schedule",
                    b => new ScheduleOverviewGump(User, Selected.Schedule, Hide(true)).Send(),
                    User.AccessLevel >= AutoPvP.Access ? HighlightHue : TextHue);

                if (User.AccessLevel >= AutoPvP.Access)
                {
                    list.AppendEntry(
                        "View Rules/Restrictions",
                        b =>
                    {
                        var opts = new MenuGumpOptions();

                        opts.AppendEntry(
                            "Inherit Rules/Restrictions",
                            b2 =>
                        {
                            var opts2 = new MenuGumpOptions();

                            foreach (var ba in AutoPvP.Battles.Values.Where(ba => ba != Selected))
                            {
                                opts2.AppendEntry(
                                    ba.Name,
                                    () =>
                                {
                                    Selected.Options.Rules.CopyFrom(ba.Options.Rules);

                                    Selected.Options.Restrictions.Items.List =                                                             //
                                                                               new Dictionary <Type, bool>(ba.Options.Restrictions.Items.List);

                                    Selected.Options.Restrictions.Pets.List =                                                             //
                                                                              new Dictionary <Type, bool>(ba.Options.Restrictions.Pets.List);

                                    Selected.Options.Restrictions.Spells.List =                                                             //
                                                                                new Dictionary <Type, bool>(ba.Options.Restrictions.Spells.List);

                                    Selected.Options.Restrictions.Skills.List =                                                             //
                                                                                new Dictionary <int, bool>(ba.Options.Restrictions.Skills.List);

                                    Refresh(true);
                                });
                            }

                            new MenuGump(User, this, opts2, b).Send();
                        });

                        opts.AppendEntry(
                            new ListGumpEntry(
                                "Rules",
                                mb =>
                        {
                            Refresh();

                            var g = new PropertiesGump(User, Selected.Options.Rules)
                            {
                                X = mb.X,
                                Y = mb.Y
                            };

                            User.SendGump(g);
                        }));

                        opts.AppendEntry(
                            "Items",
                            mb => new PvPRestrictItemsListGump(User, Selected.Options.Restrictions.Items, Hide(true)).Send());

                        opts.AppendEntry(
                            "Pets",
                            mb => new PvPRestrictPetsListGump(User, Selected.Options.Restrictions.Pets, Hide(true)).Send());

                        opts.AppendEntry(
                            "Skills",
                            mb => new PvPRestrictSkillsListGump(User, Selected.Options.Restrictions.Skills, Hide(true)).Send());

                        opts.AppendEntry(
                            "Spells",
                            mb => new PvPRestrictSpellsListGump(User, Selected.Options.Restrictions.Spells, Hide(true)).Send());

                        new MenuGump(User, this, opts, b).Send();
                    },
                        User.AccessLevel >= AutoPvP.Access ? HighlightHue : TextHue);

                    list.AppendEntry(
                        "Reset Statistics",
                        b =>
                    {
                        if (UseConfirmDialog)
                        {
                            new ConfirmDialogGump(User, this)
                            {
                                Title = "Reset Battle Statistics?",
                                Html  = "All data associated with the battle statistics will " +
                                        "be transferred to player profiles then cleared.\nThis action can not be reversed!\n" +
                                        "Do you want to continue?",
                                AcceptHandler = OnConfirmResetStatistics,
                                CancelHandler = Refresh
                            }.Send();
                        }
                        else
                        {
                            OnConfirmResetStatistics(b);
                        }
                    },
                        HighlightHue);

                    if (Selected.State == PvPBattleState.Internal)
                    {
                        if (Selected.Validate(User))
                        {
                            list.AppendEntry(
                                "Publish",
                                b =>
                            {
                                Selected.State = PvPBattleState.Queueing;

                                Refresh(true);
                            },
                                HighlightHue);
                        }
                    }
                    else
                    {
                        list.AppendEntry(
                            "Internalize",
                            b =>
                        {
                            Selected.State = PvPBattleState.Internal;

                            Refresh(true);
                        },
                            HighlightHue);

                        if (!Selected.Hidden)
                        {
                            if (Selected.Validate(User))
                            {
                                list.AppendEntry(
                                    "Hide",
                                    b =>
                                {
                                    Selected.Hidden = true;

                                    Refresh(true);
                                },
                                    HighlightHue);
                            }
                        }
                        else
                        {
                            list.AppendEntry(
                                "Unhide",
                                b =>
                            {
                                Selected.Hidden = false;

                                Refresh(true);
                            },
                                HighlightHue);
                        }
                    }

                    list.AppendEntry(
                        "Delete",
                        b =>
                    {
                        if (UseConfirmDialog)
                        {
                            new ConfirmDialogGump(User, this)
                            {
                                Title = "Delete Battle?",
                                Html  = "All data associated with this battle will be deleted.\n" +
                                        "This action can not be reversed!\nDo you want to continue?",
                                AcceptHandler = OnConfirmDeleteBattle,
                                CancelHandler = Refresh
                            }.Send();
                        }
                        else
                        {
                            OnConfirmDeleteBattle(b);
                        }
                    },
                        HighlightHue);
                }

                list.AppendEntry(
                    "Command List",
                    b =>
                {
                    var html = new StringBuilder();

                    Selected.GetHtmlCommandList(User, html);

                    new HtmlPanelGump <PvPBattle>(User, this)
                    {
                        Title    = "Command List",
                        Html     = html.ToString(),
                        Selected = Selected
                    }.Send();
                });

                var profile = AutoPvP.EnsureProfile(User as PlayerMobile);

                if (profile != null && !profile.Deleted)
                {
                    if (profile.IsSubscribed(Selected))
                    {
                        list.AppendEntry(
                            "Unsubscribe",
                            b =>
                        {
                            profile.Unsubscribe(Selected);

                            User.SendMessage("You have unsubscribed from {0} notifications.", Selected.Name);

                            Refresh(true);
                        });
                    }
                    else
                    {
                        list.AppendEntry(
                            "Subscribe",
                            b =>
                        {
                            if (UseConfirmDialog)
                            {
                                new ConfirmDialogGump(User, this)
                                {
                                    Title = "Subscriptions",
                                    Html  = "Subscribing to a battle allows you to see its world broadcast notifications.\n\n" +
                                            "Do you want to subscribe to " + Selected.Name + "?",
                                    AcceptHandler = OnConfirmSubscribe,
                                    CancelHandler = Refresh
                                }.Send();
                            }
                            else
                            {
                                OnConfirmSubscribe(b);
                            }
                        });
                    }
                }

                if (User is PlayerMobile)
                {
                    var user = (PlayerMobile)User;

                    if (Selected.IsParticipant(user))
                    {
                        list.AppendEntry("Quit & Leave", b => Selected.Quit(user, true));
                    }
                    else
                    {
                        if (Selected.IsQueued(user))
                        {
                            list.AppendEntry("Leave Queue", b => Selected.Dequeue(user));
                        }
                        else if (Selected.CanQueue(user))
                        {
                            list.AppendEntry("Join Queue", b => Selected.Enqueue(user));
                        }

                        if (Selected.IsSpectator(user))
                        {
                            list.AppendEntry("Leave Spectators", b => Selected.RemoveSpectator(user, true));
                        }
                        else if (Selected.CanSpectate(user))
                        {
                            list.AppendEntry("Join Spectators", b => Selected.AddSpectator(user, true));
                        }
                    }
                }
            }

            base.CompileMenuOptions(list);
        }
예제 #20
0
 protected virtual void OnMyProfile(GumpButton button)
 {
     new PvPProfileUI(User, AutoPvP.EnsureProfile(User as PlayerMobile), Hide(true)).Send();
 }
예제 #21
0
 protected virtual void OnMyProfile(GumpButton button)
 {
     Send(new PvPProfileOverviewGump(User, AutoPvP.EnsureProfile(User), Hide(true)));
 }
예제 #22
0
        protected override void CompileMenuOptions(MenuGumpOptions list)
        {
            list.Clear();

            if (User.AccessLevel >= AutoPvP.Access)
            {
                list.AppendEntry(
                    new ListGumpEntry(
                        "Delete All",
                        button =>
                        Send(
                            new ConfirmDialogGump(
                                User,
                                this,
                                title: "Delete All Profiles?",
                                html:
                                "All profiles in the database will be deleted, erasing all data associated with them.\nThis action can not be reversed.\n\nDo you want to continue?",
                                onAccept: subButton =>
                {
                    var profiles = new List <PvPProfile>(AutoPvP.Profiles.Values);

                    foreach (PvPProfile p in profiles.Where(p => p != null && !p.Deleted))
                    {
                        p.Delete();
                    }

                    Refresh(true);
                })),
                        HighlightHue));
            }

            list.AppendEntry(new ListGumpEntry("My Profile", OnMyProfile));

            list.AppendEntry(
                new ListGumpEntry("Sort By (" + RankSortOrder + ")", b => Send(new PvPProfileListSortGump(User, this, this, b))));

            if (Season != null)
            {
                list.AppendEntry(
                    new ListGumpEntry(
                        "Overall Ranks",
                        b =>
                {
                    Season = null;
                    Refresh(true);
                }));

                if (!Season.Active && User.AccessLevel >= AutoPvP.Access)
                {
                    list.AppendEntry(
                        new ListGumpEntry(
                            "Issue Winner Rewards",
                            b => Season.Winners.Keys.Select(m => AutoPvP.EnsureProfile(m)).ForEach(
                                p =>
                    {
                        Season.IssueWinnerRewards(p);
                        Refresh();
                    })));

                    list.AppendEntry(
                        new ListGumpEntry(
                            "Issue Loser Rewards",
                            b => Season.Losers.Keys.Select(m => AutoPvP.EnsureProfile(m)).ForEach(
                                p =>
                    {
                        Season.IssueLoserRewards(p);
                        Refresh();
                    })));
                }
            }

            PvPSeason season = AutoPvP.CurrentSeason;

            if (Season != season)
            {
                list.AppendEntry(
                    new ListGumpEntry(
                        "Season " + season.Number + " Ranks",
                        b =>
                {
                    Season = season;
                    Refresh(true);
                }));
            }

            if (season.Number > 1)
            {
                list.AppendEntry(
                    new ListGumpEntry(
                        "Select Season",
                        b =>
                        Send(
                            new InputDialogGump(
                                User,
                                this,
                                title: "Select Season",
                                html: "Enter the number for the season you wish to view rankings for.\nSeasons 1 to " + season.Number,
                                input: Season == null ? "" : Season.Number.ToString(CultureInfo.InvariantCulture),
                                callback: (ib, text) =>
                {
                    int num;

                    if (Int32.TryParse(text, out num))
                    {
                        if ((Season = (AutoPvP.Seasons.ContainsKey(num) ? AutoPvP.Seasons[num] : null)) == null)
                        {
                            User.SendMessage(ErrorHue, "Invalid Season selection.");
                        }
                    }

                    Refresh(true);
                }))));
            }

            base.CompileMenuOptions(list);
        }