Ejemplo n.º 1
0
        public ActionResult Guild(int id = -1, int d = -1, int g = -1)
        {
            #region Validation
            if (id == -1)
            {
                return(View("InvalidResource", model: "bossfight"));
            }

            var difficulty = _difficultyRepository.GetDefaultDifficulty();
            if (difficulty == null)
            {
                return(View("InvalidResource", model: "encounter difficulty"));
            }

            if (d != -1)
            {
                var overrideDifficulty = _difficultyRepository.Get(d);
                if (overrideDifficulty != null)
                {
                    difficulty = overrideDifficulty;
                }
            }

            var bossFight = _bossFightRepository.Get(id);
            if (bossFight == null)
            {
                return(View("InvalidResource", model: "bossfight"));
            }

            var guild = _guildRepository.Get(g);
            if (guild == null)
            {
                return(View("InvalidResource", model: "guild"));
            }

            // Privacy
            if (!Request.IsAuthenticated && guild.HideFromRankings)
            {
                return(View("GuildPrivate"));
            }
            if (guild.HideFromRankings)
            {
                bool sameGuild = false;
                // Check we have a valid user
                var user = _authRepository.GetUserAccount(User.Identity.GetUserId());
                if (user == null)
                {
                    HttpContext.GetOwinContext().Authentication.SignOut();
                    return(RedirectToAction("Index", "Home"));
                }

                // Get the characters for this user
                var userCharacters = _authUserCharacterRepository.GetCharacters(user.Email);
                if (userCharacters.Any(c => c.GuildId == guild.Id) || User.IsInRole(UserGroups.Admin))
                {
                    sameGuild = true;
                }

                if (!sameGuild)
                {
                    return(View("GuildPrivate"));
                }
            }

            #endregion

            var model = new GuildRecords()
            {
                GuildName = guild.Name,
                // Fight related
                BossFight  = bossFight,
                Difficulty = difficulty,
                // General, not guild related
                SingleFastestKill = _encounterRepository.GetFastestKills(id, difficulty.Id).FirstOrDefault(), // Fix this later - use the method that only returns one

                // Player-based
                SingleTopAps = _recordsRepository.GetSingleTopAps(id, difficulty.Id),
                SingleTopDps = _recordsRepository.GetSingleTopDps(id, difficulty.Id),
                SingleTopHps = _recordsRepository.GetSingleTopHps(id, difficulty.Id),
                // Guild-based
                SingleTopApsGuild = _recordsRepository.GetSingleTopApsGuild(id, difficulty.Id),
                SingleTopDpsGuild = _recordsRepository.GetSingleTopDpsGuild(id, difficulty.Id),
                SingleTopHpsGuild = _recordsRepository.GetSingleTopHpsGuild(id, difficulty.Id),
                // This guild-related
                GuildHybridXpsOverTimeChart = _recordCharts.GuildHybridXpsOverTime(id, difficulty.Id, g, guild.Name, bossFight.Name),
                GuildDurationOverTimeChart  = _recordCharts.GetEncounterDurationOverTime(id, difficulty.Id, g, guild.Name, bossFight.Name),
                GuildTopDps            = _recordsRepository.GetTopGuildDps(id, g, difficulty.Id),
                GuildTopHps            = _recordsRepository.GetTopGuildHps(id, g, difficulty.Id),
                GuildTopAps            = _recordsRepository.GetTopGuildAps(id, g, difficulty.Id),
                PlayerDpsOverTimeChart = _recordCharts.GuildPlayerXpsOverTime(id, difficulty.Id, guild.Id, guild.Name, bossFight.Name, "DPS", 20),
                PlayerHpsOverTimeChart = _recordCharts.GuildPlayerXpsOverTime(id, difficulty.Id, guild.Id, guild.Name, bossFight.Name, "HPS", 20),
                PlayerApsOverTimeChart = _recordCharts.GuildPlayerXpsOverTime(id, difficulty.Id, guild.Id, guild.Name, bossFight.Name, "APS", 20),
            };

            if (System.IO.File.Exists(Server.MapPath(string.Format("~/Content/images/portrait/{0}.png", bossFight.PortraitFilename))))
            {
                model.LoadImage = true;
            }

            return(View(model));
        }
Ejemplo n.º 2
0
        public ActionResult BossFight(int id = -1, int o = 0, int d = -1)
        {
            if (id == -1)
            {
                return(View("InvalidResource", model: "bossfight"));
            }

            var difficulty = _difficultyRepository.GetDefaultDifficulty();

            if (difficulty == null)
            {
                return(View("InvalidResource", model: "encounter difficulty"));
            }

            if (d != -1)
            {
                var overrideDifficulty = _difficultyRepository.Get(d);
                if (overrideDifficulty != null)
                {
                    difficulty = overrideDifficulty;
                }
            }

            var bossFight = _bossFightRepository.Get(id);

            if (bossFight == null)
            {
                return(View("InvalidResource", model: "bossfight"));
            }
            bool returnAll = false;

            if (Request.IsAuthenticated)
            {
                if (User.IsInRole(UserGroups.Admin))
                {
                    returnAll = true;
                }
            }

            var dbSessions = returnAll
                ? _sessionRepository.GetAllBossFightSessions(id, difficulty.Id)
                : _sessionRepository.GetBossFightSessions(id, User.Identity.GetUserId(), difficulty.Id);

            if (o == 0)
            {
                dbSessions = dbSessions.Where(s => s.Date >= DateTime.Today.Date.Subtract(new TimeSpan(14, 0, 0, 0))).Take(10).ToList();
            }

            var leaderboards = _leaderboardRepository.GetLeaderboards_v2(id, 10, difficulty.Id);
            var model        = new SessionBossFightVM
            {
                BossFight                     = bossFight,
                Sessions                      = dbSessions,
                Difficulty                    = difficulty,
                TopSingleTargetDps            = leaderboards.TopSingleTargetDps,
                Top10WarriorAps               = leaderboards.WarriorTopAps,
                Top10WarriorDps               = leaderboards.WarriorTopDps,
                Top10WarriorHps               = leaderboards.WarriorTopHps,
                Top10MageAps                  = leaderboards.MageTopAps,
                Top10MageDps                  = leaderboards.MageTopDps,
                Top10MageHps                  = leaderboards.MageTopHps,
                Top10ClericAps                = leaderboards.ClericTopAps,
                Top10ClericDps                = leaderboards.ClericTopDps,
                Top10ClericHps                = leaderboards.ClericTopHps,
                Top10RogueAps                 = leaderboards.RogueTopAps,
                Top10RogueDps                 = leaderboards.RogueTopDps,
                Top10RogueHps                 = leaderboards.RogueTopHps,
                Top10PrimalistAps             = leaderboards.PrimalistTopAps,
                Top10PrimalistDps             = leaderboards.PrimalistTopDps,
                Top10PrimalistHps             = leaderboards.PrimalistTopHps,
                FastestKills                  = leaderboards.FastestKills,
                Top10SingleTargetWarriorDps   = leaderboards.WarriorTopSingleTarget,
                Top10SingleTargetMageDps      = leaderboards.MageTopSingleTarget,
                Top10SingleTargetClericDps    = leaderboards.ClericTopSingleTarget,
                Top10SingleTargetRogueDps     = leaderboards.RogueTopSingleTarget,
                Top10SingleTargetPrimalistDps = leaderboards.PrimalistTopSingleTarget,
                TopAps                 = leaderboards.TopAps,
                TopDps                 = leaderboards.TopDps,
                TopHps                 = leaderboards.TopHps,
                TopSupportDps          = leaderboards.TopSupportDps,
                WarriorTopSupportDps   = leaderboards.WarriorTopSupportDps,
                MageTopSupportDps      = leaderboards.MageTopSupportDps,
                ClericTopSupportDps    = leaderboards.ClericTopSupportDps,
                RogueTopSupportDps     = leaderboards.RogueTopSupportDps,
                PrimalistTopSupportDps = leaderboards.PrimalistTopSupportDps,
                TopBurstDamage1S       = leaderboards.TopBurstDamage1S
            };

            model.SingleFastestKill = model.FastestKills.FirstOrDefault();
            model.SingleTopDps      = model.Top10Dps.FirstOrDefault();
            model.SingleTopHps      = model.Top10Hps.FirstOrDefault();
            model.SingleTopAps      = model.Top10Aps.FirstOrDefault();

            foreach (var guildSession in model.Sessions)
            {
                guildSession.BossesSeen          = _sessionRepository.GetBossesKilled(guildSession.Id);
                guildSession.BossesSeenNotKilled = _sessionRepository.GetBossesSeenButNotKilled(guildSession.Id);
            }

            if (System.IO.File.Exists(Server.MapPath(string.Format("~/Content/images/portrait/{0}.png", bossFight.PortraitFilename))))
            {
                model.LoadImage = true;
            }
            return(View(model));
        }