public static MvcHtmlString GameResults(this HtmlHelper htmlHelper, GameResultViewModel playerGameResultDetails, WinnerTypes? winnerType) { Validate(playerGameResultDetails); string cssPlace; string gameRankText; if (winnerType == WinnerTypes.TeamWin) { cssPlace = CSS_CLASS_TEAM_WIN; gameRankText = PLACE_TEAM_WIN; } else if (winnerType == WinnerTypes.TeamLoss) { cssPlace = CSS_CLASS_TEAM_LOSS; gameRankText = PLACE_EVERYONE_LOST; } else { switch (playerGameResultDetails.GameRank) { case 1: cssPlace = CSS_CLASS_FIRST_PLACE; gameRankText = PLACE_FIRST; break; case 2: cssPlace = CSS_CLASS_SECOND_PLACE; gameRankText = PLACE_SECOND; break; case 3: cssPlace = CSS_CLASS_THIRD_PLACE; gameRankText = PLACE_THIRD; break; case 4: cssPlace = CSS_CLASS_FOURTH_PLACE; gameRankText = PLACE_FOURTH; break; default: cssPlace = CSS_CLASS_LOSER_PLACE; gameRankText = PLACE_BIG_LOSER; break; } } string nemeStatsPointsComponent = string.Format(HTML_NEME_POINTS_TEMPLATE, playerGameResultDetails.NemePointsSummary.TotalNemePoints, htmlHelper.NemePointsIco(showTooltip: true, tooltip: NEMEPOINTICO_TOOLTIP, tooltipPosition: NEMEPOINTSICO_TOOLTIP_POSITION)); return MvcHtmlString.Create(string.Format(HTML_TEMPLATE, CSS_CLASS_GAME_RANK, cssPlace, gameRankText, nemeStatsPointsComponent)); }
private void TestRenderingForGivenRank(int gameRank, WinnerTypes winnerType, string expectedCssClass, string expectedRankText) { HtmlHelper helper = new HtmlHelper(new ViewContext(), new ViewPage()); GameResultViewModel playerGameResultDetails = new GameResultViewModel() { GameRank = gameRank, NemePointsSummary = new NemePointsSummaryViewModel(0, 0, 0) }; XElement result = helper.GameResults(playerGameResultDetails, winnerType).ToXElement(); string firstAttribute = result.FirstAttribute.ToString(); StringAssert.Contains("class=\"", firstAttribute); StringAssert.Contains(expectedCssClass, firstAttribute); string firstNodeText = result.FirstNode.ToString(); StringAssert.StartsWith(expectedRankText, firstNodeText); }
private void TestRenderingForGivenRank(int gameRank, WinnerTypes winnerType, string expectedCssClass, string expectedRankText) { HtmlHelper helper = new HtmlHelper(new ViewContext(), new ViewPage()); GameResultViewModel playerGameResultDetails = new GameResultViewModel() { GameRank = gameRank }; XElement result = helper.GameResults(playerGameResultDetails, winnerType).ToXElement(); string firstAttribute = result.FirstAttribute.ToString(); StringAssert.Contains("class=\"", firstAttribute); StringAssert.Contains(expectedCssClass, firstAttribute); string firstNodeText = result.FirstNode.ToString(); StringAssert.StartsWith(expectedRankText, firstNodeText); }
public static void Prefix(EndGameManager __instance) { switch (TempData.EndReason) { case GameOverReason.HumansByTask: case GameOverReason.HumansByVote: WinnerType = WinnerTypes.Crewmates; SetValues("", RoleInfo.CrewmateColor, RoleInfo.CrewmateColor, StingerTypes.Crew); if (PlayerControl.LocalPlayer.Data.IsImpostor || RoleInfo.IsRole(PlayerControl.LocalPlayer, Roles.Jester)) { WinnerText = "Defeat"; } else { WinnerText = "Victory"; } break; case GameOverReason.ImpostorByKill: case GameOverReason.ImpostorBySabotage: case GameOverReason.ImpostorByVote: WinnerType = WinnerTypes.Impostors; SetValues("", RoleInfo.ImpostorColor, RoleInfo.ImpostorColor, StingerTypes.Impostor); if (PlayerControl.LocalPlayer.Data.IsImpostor) { WinnerText = "Victory"; } else { WinnerText = "Defeat"; } break; } SetWinners(); OverrideScreen(__instance, false); }
private void SetItAllUp(WinnerTypes winnerType) { Stack <int> gameRankStack = new Stack <int>(); if (winnerType == WinnerTypes.PlayerWin) { gameRankStack.Push(1); gameRankStack.Push(2); gameRankStack.Push(3); } else if (winnerType == WinnerTypes.TeamLoss) { gameRankStack.Push(2); gameRankStack.Push(2); gameRankStack.Push(2); } else if (winnerType == WinnerTypes.TeamWin) { gameRankStack.Push(1); gameRankStack.Push(1); gameRankStack.Push(1); } this.gamingGroup = new GamingGroup { Id = this.gamingGroupId, Name = "gaming group name" }; this.playedGame = new PlayedGame { Id = 11111, GameDefinition = new GameDefinition(), GamingGroup = this.gamingGroup, GameDefinitionId = 2222, PlayerGameResults = new List <PlayerGameResult>(), GamingGroupId = this.gamingGroupId, Notes = "some notes" + Environment.NewLine + "some notes on a separate line" }; this.playedGame.PlayerGameResults.Add(new PlayerGameResult() { GameRank = gameRankStack.Pop(), NemeStatsPointsAwarded = 3, Id = 1, PlayedGameId = this.playedGame.Id, PlayerId = 1 }); this.playedGame.PlayerGameResults.Add(new PlayerGameResult() { GameRank = gameRankStack.Pop(), NemeStatsPointsAwarded = 2, Id = 2, PlayedGameId = this.playedGame.Id, PlayerId = 2 }); this.playedGame.PlayerGameResults.Add(new PlayerGameResult() { GameRank = gameRankStack.Pop(), NemeStatsPointsAwarded = 1, Id = 3, PlayedGameId = this.playedGame.Id, PlayerId = 3, PlayedGame = new PlayedGame() { GameDefinition = new GameDefinition() { Id = 135, Name = "Test game name" } } }); this.detailsBuilder = MockRepository.GenerateMock <IGameResultViewModelBuilder>(); this.builder = new PlayedGameDetailsViewModelBuilder(this.detailsBuilder); int totalPlayerGameResults = this.playedGame.PlayerGameResults.Count; for (int i = 0; i < totalPlayerGameResults; i++) { this.detailsBuilder.Expect( x => x.Build(this.playedGame.PlayerGameResults[i])) .Repeat .Once() .Return(new GameResultViewModel() { PlayerId = this.playedGame.PlayerGameResults[i].PlayerId }); } this.currentUser = new ApplicationUser() { CurrentGamingGroupId = this.gamingGroupId }; this.actualViewModel = this.builder.Build(this.playedGame, this.currentUser); }
private void SetItAllUp(WinnerTypes winnerType) { Stack<int> gameRankStack = new Stack<int>(); if (winnerType == WinnerTypes.PlayerWin) { gameRankStack.Push(1); gameRankStack.Push(2); gameRankStack.Push(3); }else if (winnerType == WinnerTypes.TeamLoss) { gameRankStack.Push(2); gameRankStack.Push(2); gameRankStack.Push(2); }else if (winnerType == WinnerTypes.TeamWin) { gameRankStack.Push(1); gameRankStack.Push(1); gameRankStack.Push(1); } _gamingGroup = new GamingGroup { Id = _gamingGroupId, Name = "gaming group name" }; _playedGame = new PlayedGame { Id = 11111, GameDefinition = new GameDefinition(), GamingGroup = _gamingGroup, GameDefinitionId = 2222, PlayerGameResults = new List<PlayerGameResult>(), GamingGroupId = _gamingGroupId, Notes = "some notes" + Environment.NewLine + "some notes on a separate line", WinnerType = winnerType }; _playedGame.PlayerGameResults.Add(new PlayerGameResult() { GameRank = gameRankStack.Pop(), NemeStatsPointsAwarded = 3, Id = 1, PlayedGameId = _playedGame.Id, PlayerId = 1 }); _playedGame.PlayerGameResults.Add(new PlayerGameResult() { GameRank = gameRankStack.Pop(), NemeStatsPointsAwarded = 2, Id = 2, PlayedGameId = _playedGame.Id, PlayerId = 2 }); _playedGame.PlayerGameResults.Add(new PlayerGameResult() { GameRank = gameRankStack.Pop(), NemeStatsPointsAwarded = 1, Id = 3, PlayedGameId = _playedGame.Id, PlayerId = 3, PlayedGame = new PlayedGame() { GameDefinition = new GameDefinition() { Id = 135, Name = "Test game name" } } }); _detailsBuilder = MockRepository.GenerateMock<IGameResultViewModelBuilder>(); _builder = new PlayedGameDetailsViewModelBuilder(_detailsBuilder); int totalPlayerGameResults = _playedGame.PlayerGameResults.Count; for (int i = 0; i < totalPlayerGameResults; i++) { _detailsBuilder.Expect( x => x.Build(_playedGame.PlayerGameResults[i])) .Repeat .Once() .Return(new GameResultViewModel() { PlayerId = _playedGame.PlayerGameResults[i].PlayerId }); } _currentUser = new ApplicationUser() { CurrentGamingGroupId = _gamingGroupId }; _actualViewModel = _builder.Build(_playedGame, _currentUser, false); }