示例#1
0
        public async Task <ActionResult> VoteOnNomination(VoteViewModel voteViewModel)
        {
            if (voteViewModel.Vote.Id != 0)
            {
                VoteAPI.Update(voteViewModel.Vote);
            }
            else if (voteViewModel.Vote.Id == 0)
            {
                VoteAPI.Create(voteViewModel.Vote);
            }
            ;
            Nomination nomination = await NominationAPI.GetById(voteViewModel.Vote.NominationId);

            YearCategoryModel returnParameters   = new YearCategoryModel(nomination.Year, nomination.AwardCategory);
            Nomination        nominationVotedFor = await NominationAPI.GetById(voteViewModel.Vote.NominationId);

            RecommendationViewModel recommendationViewModel = new RecommendationViewModel()
            {
                Year     = nominationVotedFor.Year,
                Category = nominationVotedFor.AwardCategory
            };

            recommendationViewModel.Movie = await MovieAPI.GetById(nominationVotedFor.MovieId);

            recommendationViewModel.MovieId = recommendationViewModel.Movie.Id;
            return(RedirectToAction(nameof(MovieRecommendation), recommendationViewModel));
        }
示例#2
0
        public async Task <ActionResult> DisplayNominations(string year, string category)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("DisplayNominations", "Home", new YearCategoryModel(year, category)));
            }
            string    userId    = this.User.FindFirstValue(ClaimTypes.NameIdentifier);
            Moviegoer moviegoer = await MoviegoerAPI.GetByUserId(userId);

            List <Vote> myVotes = await VoteAPI.GetByIdentityUserIdYearOfNominationAndCategory(userId, year, category);

            bool hasVotedThisYear = myVotes.Where(v => v.Date.Year == DateTime.Now.Year).FirstOrDefault() != null;

            if (!hasVotedThisYear)
            {
                return(RedirectToAction(nameof(VoteOnNomination), new YearCategoryModel(year, category)));
            }
            NominationViewModel nominationViewModel = await CreateNominationViewModel(year, category);

            nominationViewModel.JsonVotes        = JsonDataBuilder.CreateJsonVoteCollection(nominationViewModel);
            nominationViewModel.JsonNomineeNames = JsonDataBuilder.CreateJsonStringFromStringList(nominationViewModel.Nominations.Select(n => n.Nominee).ToList());
            nominationViewModel.MyVotes          = await VoteAPI.GetByIdentityUserIdYearOfNominationAndCategory(userId, year, category);

            nominationViewModel.AllYearCategoryCombinations = await NominationAPI.GetAllYearCategoryCombinations();

            return(View(nominationViewModel));
        }
示例#3
0
文件: Hooks.cs 项目: tung362/RoR2PVP
        public static void Init()
        {
            /*Assets*/
            RegisterAssets();

            /*Options menu for lobby*/
            //Header
            RuleCategoryDef PVPHeader = VoteAPI.AddVoteHeader("PVP", new Color(1.0f, 0.0f, 0.0f, 1.0f), false);

            //Selection
            RuleDef PVPSelection = VoteAPI.AddVoteSelection(PVPHeader, "PVP", new ChoiceMenu("Free For All PVP On", new Color(0.0f, 1.0f, 0.0f, 0.4f), "Enables free for all game mode", Color.black, "@TeamPVP:Assets/Resources/UI/FreeForAllPVPSelected.png", "artifact_teampvp", Settings.FreeForAllPVPToggle.Item2));

            VoteAPI.AddVoteChoice(PVPSelection, new ChoiceMenu("Team PVP On", new Color(0.0f, 1.0f, 0.0f, 0.4f), "Enables team pvp game mode", Color.black, "@TeamPVP:Assets/Resources/UI/TeamPVPSelected.png", "artifact_teampvp", Settings.TeamPVPToggle.Item2));
            VoteAPI.AddVoteChoice(PVPSelection, new ChoiceMenu("PVP Off", new Color(1.0f, 0.0f, 0.0f, 0.4f), "Disables Mod", Color.black, "@TeamPVP:Assets/Resources/UI/TeamPVPDeselected.png", "artifact_teampvp", -1));
            PVPSelection.defaultChoiceIndex = 2;

            RuleDef randomTeamsSelection = VoteAPI.AddVoteSelection(PVPHeader, "Random Teams", new ChoiceMenu("Random Teams On", new Color(0.0f, 0.58f, 1.0f, 0.4f), "Teams will be shuffled every round (only for team pvp game mode)", Color.black, "@TeamPVP:Assets/Resources/UI/RandomTeamsSelected.png", "artifact_teampvp", Settings.RandomTeams.Item2));

            VoteAPI.AddVoteChoice(randomTeamsSelection, new ChoiceMenu("Random Teams Off", new Color(1.0f, 0.0f, 0.0f, 0.4f), "Teams will stay the same every round (only for team pvp game mode)", Color.black, "@TeamPVP:Assets/Resources/UI/RandomTeamsDeselected.png", "artifact_teampvp", -1));
            randomTeamsSelection.defaultChoiceIndex = Settings.RandomTeams.Item1 ? 0 : 1;

            RuleDef mobSpawnSelection = VoteAPI.AddVoteSelection(PVPHeader, "Mob Spawn", new ChoiceMenu("Mob Spawn On", new Color(0.0f, 0.58f, 1.0f, 0.4f), "Mobs will spawn", Color.black, "@TeamPVP:Assets/Resources/UI/MobSpawnSelected.png", "artifact_teampvp", Settings.MobSpawn.Item2));

            VoteAPI.AddVoteChoice(mobSpawnSelection, new ChoiceMenu("Mob Spawn Off", new Color(1.0f, 0.0f, 0.0f, 0.4f), "Mobs will not spawn", Color.black, "@TeamPVP:Assets/Resources/UI/MobSpawnDeselected.png", "artifact_teampvp", -1));
            mobSpawnSelection.defaultChoiceIndex = Settings.MobSpawn.Item1 ? 0 : 1;

            RuleDef banItemsSelection = VoteAPI.AddVoteSelection(PVPHeader, "Ban Items", new ChoiceMenu("Ban Items On", new Color(0.0f, 0.58f, 1.0f, 0.4f), "Banned items configured in the config will be blacklisted", Color.black, "@TeamPVP:Assets/Resources/UI/BanItemsSelected.png", "artifact_teampvp", Settings.BanItems.Item2));

            VoteAPI.AddVoteChoice(banItemsSelection, new ChoiceMenu("Ban Items Off", new Color(1.0f, 0.0f, 0.0f, 0.4f), "Banned Items will not be blacklisted", Color.black, "@TeamPVP:Assets/Resources/UI/BanItemsDeselected.png", "artifact_teampvp", -1));
            banItemsSelection.defaultChoiceIndex = Settings.BanItems.Item1 ? 0 : 1;

            RuleDef companionsShareItemsSelection = VoteAPI.AddVoteSelection(PVPHeader, "Companions Share Items", new ChoiceMenu("Companions Share Items On", new Color(0.0f, 0.58f, 1.0f, 0.4f), "Items picked up by the player will be shared with their drones etc", Color.black, "@TeamPVP:Assets/Resources/UI/CompanionsShareItemsSelected.png", "artifact_teampvp", Settings.CompanionsShareItems.Item2));

            VoteAPI.AddVoteChoice(companionsShareItemsSelection, new ChoiceMenu("Companions Share Items Off", new Color(1.0f, 0.0f, 0.0f, 0.4f), "Items will not be shared with drones etc", Color.black, "@TeamPVP:Assets/Resources/UI/CompanionsShareItemsDeselected.png", "artifact_teampvp", -1));
            companionsShareItemsSelection.defaultChoiceIndex = Settings.CompanionsShareItems.Item1 ? 0 : 1;

            RuleDef customPlayableCharactersSelection = VoteAPI.AddVoteSelection(PVPHeader, "Custom Playable Characters", new ChoiceMenu("Custom Playable Characters On", new Color(0.0f, 0.58f, 1.0f, 0.4f), "Play custom characters configured in the config", Color.black, "@TeamPVP:Assets/Resources/UI/CustomPlayableCharactersSelected.png", "artifact_teampvp", Settings.CustomPlayableCharacters.Item2));

            VoteAPI.AddVoteChoice(customPlayableCharactersSelection, new ChoiceMenu("Custom Playable Characters Off", new Color(1.0f, 0.0f, 0.0f, 0.4f), "Play the default vanilla characters (unbalanced)", Color.black, "@TeamPVP:Assets/Resources/UI/CustomPlayableCharactersDeselected.png", "artifact_teampvp", -1));
            customPlayableCharactersSelection.defaultChoiceIndex = Settings.CustomPlayableCharacters.Item1 ? 0 : 1;

            RuleDef customInteractablesSpawnerSelection = VoteAPI.AddVoteSelection(PVPHeader, "Custom Interactables Spawner", new ChoiceMenu("Custom Interactables Spawner On", new Color(0.0f, 0.58f, 1.0f, 0.4f), "Spawn custom objects (chests, drones, etc) at custom rates configured in the config", Color.black, "@TeamPVP:Assets/Resources/UI/CustomInteractablesSpawnerSelected.png", "artifact_teampvp", Settings.CustomInteractablesSpawner.Item2));

            VoteAPI.AddVoteChoice(customInteractablesSpawnerSelection, new ChoiceMenu("Custom Interactables Spawner Off", new Color(1.0f, 0.0f, 0.0f, 0.4f), "Spawn objects (chests, drones, etc) normally as vanilla", Color.black, "@TeamPVP:Assets/Resources/UI/CustomInteractablesSpawnerDeselected.png", "artifact_teampvp", -1));
            customInteractablesSpawnerSelection.defaultChoiceIndex = Settings.CustomInteractablesSpawner.Item1 ? 0 : 1;

            RuleDef useDeathPlaneFailsafeSelection = VoteAPI.AddVoteSelection(PVPHeader, "Use Death Plane Failsafe", new ChoiceMenu("Use Death Plane Failsafe On", new Color(0.0f, 0.58f, 1.0f, 0.4f), "Force players to die should they fall off the map to prevent softlock", Color.black, "@TeamPVP:Assets/Resources/UI/UseDeathPlaneFailsafeSelected.png", "artifact_teampvp", Settings.UseDeathPlaneFailsafe.Item2));

            VoteAPI.AddVoteChoice(useDeathPlaneFailsafeSelection, new ChoiceMenu("Use Death Plane Failsafe Off", new Color(1.0f, 0.0f, 0.0f, 0.4f), "Disables the death plane. Only turn off if your using a custom map!", Color.black, "@TeamPVP:Assets/Resources/UI/UseDeathPlaneFailsafeDeselected.png", "artifact_teampvp", -1));
            useDeathPlaneFailsafeSelection.defaultChoiceIndex = Settings.UseDeathPlaneFailsafe.Item1 ? 0 : 1;

            RuleDef widerStageTransitionsSelection = VoteAPI.AddVoteSelection(PVPHeader, "Wider Stage Transitions", new ChoiceMenu("Wider Stage Transitions On", new Color(0.0f, 0.58f, 1.0f, 0.4f), "Transitions through a wider selection of stages when using the teleporter", Color.black, "@TeamPVP:Assets/Resources/UI/WiderStageTransitionsSelected.png", "artifact_teampvp", Settings.WiderStageTransitions.Item2));

            VoteAPI.AddVoteChoice(widerStageTransitionsSelection, new ChoiceMenu("Wider Stage Transitions Off", new Color(1.0f, 0.0f, 0.0f, 0.4f), "Vanilla stage transitions. Also turn off when using custom stages", Color.black, "@TeamPVP:Assets/Resources/UI/WiderStageTransitionsDeselected.png", "artifact_teampvp", -1));
            widerStageTransitionsSelection.defaultChoiceIndex = Settings.WiderStageTransitions.Item1 ? 0 : 1;
        }
示例#4
0
        public void Awake()
        {
            //Get root path
            ConfigRootPath = Config.ConfigFilePath;
            ConfigRootPath = ConfigRootPath.Remove(Config.ConfigFilePath.Count() - "PVP.cfg".Length);

            /*Compatibility*/

            /*API Extenstions*/
            VoteAPI.SetHook();
            /*Mod menu options*/
            Hooks.Init();
        }
示例#5
0
        public async Task <ActionResult> VoteOnNomination(string year, string category)
        {
            VoteViewModel voteViewModel = new VoteViewModel();
            string        userId        = this.User.FindFirstValue(ClaimTypes.NameIdentifier);
            List <Vote>   myVotes       = await VoteAPI.GetByIdentityUserIdYearOfNominationAndCategory(userId, year, category);

            voteViewModel.Vote = myVotes.Where(v => v.Date.Year == DateTime.Now.Year).FirstOrDefault();
            if (voteViewModel.Vote == null)
            {
                voteViewModel.Vote = await CreateNewVote(userId);
            }
            voteViewModel.Nominations = await NominationAPI.GetNominationsByYearAndCategoryIncludeMovie(year, category);

            return(View(voteViewModel));
        }
示例#6
0
        private async Task <NominationViewModel> CreateNominationViewModel(string year, string category)
        {
            NominationViewModel nominationViewModel;

            try
            {
                int yearInt = int.Parse(year);
                nominationViewModel = new NominationViewModel()
                {
                    Nominations = await NominationAPI.GetNominationsByYearAndCategoryIncludeMovie(year, category),
                    Votes       = await VoteAPI.GetVotesByYearOfNominationAndCategory(year, category),
                    Year        = yearInt,
                    Category    = category
                };
            }
            catch
            {
                nominationViewModel = null;
            }
            return(nominationViewModel);
        }