Exemple #1
0
 public int GetRank(PvPSeason season = null)
 {
     return(AutoPvP.GetProfileRank(Owner, AutoPvP.CMOptions.Advanced.Profiles.RankingOrder, season));
 }
Exemple #2
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);
        }
Exemple #3
0
        public static List <PvPProfile> GetSortedProfiles(
            PvPProfileRankOrder order, List <PvPProfile> profiles, PvPSeason season = null)
        {
            if (profiles == null || profiles.Count == 0)
            {
                profiles = new List <PvPProfile>(Profiles.Values);
            }

            switch (order)
            {
            case PvPProfileRankOrder.Points:
            {
                profiles.Sort(
                    (a, b) =>
                    {
                        if (a == b)
                        {
                            return(0);
                        }

                        if (b == null)
                        {
                            return(-1);
                        }

                        if (a == null)
                        {
                            return(1);
                        }

                        if (a.Deleted && b.Deleted)
                        {
                            return(0);
                        }

                        if (b.Deleted)
                        {
                            return(-1);
                        }

                        if (a.Deleted)
                        {
                            return(1);
                        }

                        long aTotal;
                        long bTotal;

                        if (season == null)
                        {
                            aTotal = a.TotalPointsGained - a.TotalPointsLost;
                            bTotal = b.TotalPointsGained - b.TotalPointsLost;
                        }
                        else
                        {
                            aTotal = a.History.EnsureEntry(season).PointsGained - a.History.EnsureEntry(season).PointsLost;
                            bTotal = b.History.EnsureEntry(season).PointsGained - b.History.EnsureEntry(season).PointsLost;
                        }

                        if (aTotal > bTotal)
                        {
                            return(-1);
                        }

                        if (aTotal < bTotal)
                        {
                            return(1);
                        }

                        return(0);
                    });
            }
            break;

            case PvPProfileRankOrder.Wins:
            {
                profiles.Sort(
                    (a, b) =>
                    {
                        if (a == b)
                        {
                            return(0);
                        }

                        if (b == null)
                        {
                            return(-1);
                        }

                        if (a == null)
                        {
                            return(1);
                        }

                        if (a.Deleted && b.Deleted)
                        {
                            return(0);
                        }

                        if (b.Deleted)
                        {
                            return(-1);
                        }

                        if (a.Deleted)
                        {
                            return(1);
                        }

                        long aTotal;
                        long bTotal;

                        if (season == null)
                        {
                            aTotal = a.TotalWins;
                            bTotal = b.TotalWins;
                        }
                        else
                        {
                            aTotal = a.History.EnsureEntry(season).Wins;
                            bTotal = b.History.EnsureEntry(season).Wins;
                        }

                        if (aTotal > bTotal)
                        {
                            return(-1);
                        }

                        if (aTotal < bTotal)
                        {
                            return(1);
                        }

                        return(0);
                    });
            }
            break;

            case PvPProfileRankOrder.Kills:
            {
                profiles.Sort(
                    (a, b) =>
                    {
                        if (a == b)
                        {
                            return(0);
                        }

                        if (b == null)
                        {
                            return(-1);
                        }

                        if (a == null)
                        {
                            return(1);
                        }

                        if (a.Deleted && b.Deleted)
                        {
                            return(0);
                        }

                        if (b.Deleted)
                        {
                            return(-1);
                        }

                        if (a.Deleted)
                        {
                            return(1);
                        }

                        long aTotal;
                        long bTotal;

                        if (season == null)
                        {
                            aTotal = a.TotalKills;
                            bTotal = b.TotalKills;
                        }
                        else
                        {
                            aTotal = a.History.EnsureEntry(season).Kills;
                            bTotal = b.History.EnsureEntry(season).Kills;
                        }

                        if (aTotal > bTotal)
                        {
                            return(-1);
                        }

                        if (aTotal < bTotal)
                        {
                            return(1);
                        }

                        return(0);
                    });
            }
            break;
            }

            return(profiles);
        }
Exemple #4
0
 public static List <PvPProfile> GetSortedProfiles(PvPProfileRankOrder order, PvPSeason season = null)
 {
     return(GetSortedProfiles(order, null, season));
 }
Exemple #5
0
 public static List <PvPProfile> GetSortedProfiles(List <PvPProfile> profiles, PvPSeason season = null)
 {
     return(GetSortedProfiles(CMOptions.Advanced.Profiles.RankingOrder, profiles, season));
 }
Exemple #6
0
        public static long GetSortedValue(PvPProfileRankOrder order, PvPProfile profile, PvPSeason season = null)
        {
            switch (order)
            {
            case PvPProfileRankOrder.Points:
            {
                if (season == null)
                {
                    return(profile.TotalPointsGained - profile.TotalPointsLost);
                }

                var e = profile.History.EnsureEntry(season);

                return(e.PointsGained - e.PointsLost);
            }

            case PvPProfileRankOrder.Wins:
            {
                if (season == null)
                {
                    return(profile.TotalWins - profile.TotalLosses);
                }

                var e = profile.History.EnsureEntry(season);

                return(e.Wins - e.Losses);
            }

            case PvPProfileRankOrder.Kills:
            {
                if (season == null)
                {
                    return(profile.TotalKills - profile.TotalDeaths);
                }

                var e = profile.History.EnsureEntry(season);

                return(e.Kills - e.Deaths);
            }

            default:
                return(0);
            }
        }
Exemple #7
0
 public static IEnumerable <PvPProfile> GetSortedProfiles(PvPSeason season = null)
 {
     return(GetSortedProfiles(CMOptions.Advanced.Profiles.RankingOrder, season));
 }