public void NoDahan_NoDefend() { var fxt = new GameFixture() .WithSpirit(new StonesUnyieldingDefiance()) .Start(); // Given: a space to ravage on. var space = fxt.board[5]; var tokens = fxt.gameState.Tokens[space]; fxt.gameState.InvaderDeck.Ravage.Add(InvaderCardEx.For(space)); // And: no dahan tokens.InitDefault(TokenType.Dahan, 0); // And: enough explorers to cause blight tokens.InitDefault(Invader.Explorer, 2); // When: Card Played (grow,select card,play card) // And: Invader actions proceed Stone_Grows(fxt); BuysAndUses(fxt, StubbornSolidity.Name); // Then: Blight tokens.Blight.Count.ShouldBe(1); }
public void DoNotRunGame_IfNotStartGameFirst() { var gameFixture = new GameFixture(); var game = new GameFixture().CreateGame(); Assert.Throws <GameNotStartedException>(() => game.Run(gameFixture.GetUsersInGame())); }
public void LotsOfInvaders_DahanUnchanged() { var fxt = new GameFixture() .WithSpirit(new StonesUnyieldingDefiance()) .Start(); // Given: a space to ravage on. var space = fxt.board[5]; // a5 var tokens = fxt.gameState.Tokens[space]; fxt.gameState.InvaderDeck.Ravage.Add(InvaderCardEx.For(space)); // And: dahan in space const int startingDahanCount = 10; tokens.InitDefault(TokenType.Dahan, startingDahanCount); // And: will cause 9 points of damage tokens.InitDefault(Invader.Explorer, 19); // 19 = 10 defend from dahan + 9 points of damage // When: Card Played (grow,select card,play card) // And: Invader actions proceed Stone_Grows(fxt); BuysAndUses(fxt, StubbornSolidity.Name); // Then: all dahan still there tokens[Tokens.Dahan].ShouldBe(startingDahanCount); }
public void WhenUserGuessNo_ThenItShouldBeTheWinner() { const int expectedGuessNo = 5; const int expectedWinnerUserId = 2; var gameFixture = new GameFixture(); const int noOfRounds = 3; var game = gameFixture.CreateGame(expectedGuessNo); var usersForGame = new List <int> { 1, expectedWinnerUserId, 3 }; game.Start(noOfRounds, 100, usersForGame); var expectedNonWinner = new UserInGame(1, expectedGuessNo); var expectedWinner = new UserInGame(expectedWinnerUserId, expectedGuessNo - 4); var usersInGame = new List <UserInGame>() { expectedNonWinner, expectedWinner, new UserInGame(3, expectedGuessNo + 44) }; game.Run(usersInGame); expectedNonWinner.Number = expectedGuessNo + 22; expectedWinner.Number = expectedGuessNo; game.Run(usersInGame); game.Run(usersInGame); var actualGameWinner = game.GameWinnerId; Assert.Equal(expectedWinner.UserId, actualGameWinner); }
internal static Task <LeagueOverview> ExtractStandingsAndFixturesAsync(DomResultItem item, bool areStandingRequired, CancellationToken ct) { return(Task.Run(() => { var html = new HtmlDocument(); html.LoadHtml(item.Content); var standings = GetStandings(html, areStandingRequired, ct); var fixturesTable = html.DocumentNode.SelectSingleNode("//table[@id='mbt-v2-schedule-table']"); GameFixture[] fixtures; // when there are no fixtures, pages shows only results if (IsFixturesTabActive(html)) { fixtures = ExtractFixturesOrResults <GameFixture>(fixturesTable, includeResults: false, ct); } else { fixtures = new GameFixture[0]; } return new LeagueOverview( standings: standings, fixtures: fixtures.Where(f => f != null).ToArray(), results: null ); })); }
public void WhenStartingNewGame_ThenDoNotAllowZeroRounds() { var game = new GameFixture().CreateGame(); var guessMaxAnonymous = 1; var rounds = 0; Assert.Throws <ArgumentException>(() => game.Start(rounds, guessMaxAnonymous, new List <int>())); }
public void WhenStartingNewGame_ThenShouldAcceptNoOfRounds() { var expectedRounds = 5; var guessMaxAnonymous = 10; var game = new GameFixture().CreateGame(); game.Start(expectedRounds, guessMaxAnonymous, new List <int>()); Assert.Equal(expectedRounds, game.TotalRounds); }
public void WhenRunTheGame_ThenCurrentRoundShouldIncrease() { var gameFixture = new GameFixture(); var game = gameFixture.CreateGame(); gameFixture.StartAnyGame(); game.Run(gameFixture.GetUsersInGame()); Assert.Equal(1, game.CurrentRound); }
public void WhenLastRoundOfGame_ShouldLastPropertyFalse() { var gameFixture = new GameFixture(); var game = gameFixture.CreateGame(); gameFixture.StartAnyGame(2); var round1 = game.Run(gameFixture.GetUsersInGame()); Assert.False(round1.LastRound); var round2 = game.Run(gameFixture.GetUsersInGame()); Assert.True(round2.LastRound); }
public void WhenGameFinish_ThenRunShouldThrowGameOver() { var gameFixture = new GameFixture(); var game = gameFixture.CreateGame(); gameFixture.StartAnyGame(1); var anonymousUsersInGame = new List <UserInGame> { new UserInGame(1, 1) }; game.Run(anonymousUsersInGame); Assert.Throws <GameOverException>(() => game.Run(anonymousUsersInGame)); }
public void WhenUserGuessesNumberInOneRound_ThenItShouldWinTheGame() { var gameFixture = new GameFixture(); const int expectedGuessNo = 5; const int expectedWinnerUserId = 1; var usersForGame = new List <int> { expectedWinnerUserId, 2 }; var game = gameFixture.CreateGame(); game.Start(1, 100, usersForGame); var usersInGame = new List <UserInGame> { new UserInGame(expectedWinnerUserId, expectedGuessNo), new UserInGame(2, expectedGuessNo + 50) }; game.Run(usersInGame); Assert.Equal(expectedWinnerUserId, game.GameWinnerId); }
static void BuysAndUses(GameFixture fxt, string cardName) { fxt.user.PlaysCard(cardName); fxt.user.SelectsFastAction(cardName); fxt.user.TargetsLand(cardName, "A1,A2,A3,A4,(A5),A6"); }
static void Stone_Grows(GameFixture fxt) { fxt.user.Growth_SelectsOption("PlacePresence(2) / GainEnergy(3)"); fxt.user.Growth_PlacesPresence("energy>A1;A2;A3;A4;(A5);A6;A7;A8"); // fxt.user.Growth_GainsEnergy(); }