public void TestEnterPieceStrategyTwoDice() { var player = this.app.GetGameFactory().CreatePlayer("Player 1"); var enemy = this.app.GetGameFactory().CreatePlayer("Player 2"); var dice = new[] { new DefaultDie(false, 6), new DefaultDie(false, 5), new DefaultDie(false, 4), new DefaultDie(true, 3) }; var turn = new DefaultTurn(player, dice); var context = new DefaultGameRuleStrategyContext(); var board = this.CreateDefaultBoard(); board.Bar.Add(new DefaultPiece(player)); board.Lanes[4].Add(new DefaultPiece(enemy)); board.Lanes[3].Add(new DefaultPiece(enemy)); board.Lanes[3].Add(new DefaultPiece(enemy)); var strategy = new EnterPieceStrategy(); var moves = this.CallGetStrategyValidMoves(strategy, board, turn, context); context.IsDone.Should().BeTrue("the strategy should short-circuit the chain if there are pieces to enter"); moves.Count.Should().Be(2, "there should be two available moves"); moves[0].Die.Should().BeSameAs(dice[0], "die with value 6 is unused"); moves[0].Lane.Should().BeSameAs(board.Bar, "the piece on the bar needs to be entered"); moves[0].LaneIndex.Should().Be(-1, "the bar's index should be -1"); moves[1].Die.Should().BeSameAs(dice[1], "die with value 5 is unused and the target has only 1 enemy piece"); moves[1].Lane.Should().BeSameAs(board.Bar, "the piece on the bar needs to be entered"); moves[1].LaneIndex.Should().Be(-1, "the bar's index should be -1"); var piece = board.Bar[0]; var enemyPiece = board.Lanes[4][0]; strategy.MovePiece(player, board, moves[1]); board.Bar.Should().ContainSingle("the enemy piece should have been moved to the bar"); board.Bar[0].Should().BeSameAs(enemyPiece, "the enemy piece should be the same as the moved one"); board.Lanes[4].Should().ContainSingle("the piece should have been moved to lane 5"); board.Lanes[4][0].Should().BeSameAs(piece, "the moved piece should be the same as the removed one"); }
public void TestEnterPieceStrategyZeroDice() { var player = this.app.GetGameFactory().CreatePlayer("Player 1"); var enemy = this.app.GetGameFactory().CreatePlayer("Player 2"); var dice = new[] { new DefaultDie(false, 6), new DefaultDie(true, 5) }; var turn = new DefaultTurn(player, dice); var context = new DefaultGameRuleStrategyContext(); var board = this.CreateDefaultBoard(); board.Bar.Add(new DefaultPiece(player)); board.Lanes[5].Add(new DefaultPiece(enemy)); board.Lanes[5].Add(new DefaultPiece(enemy)); var strategy = new EnterPieceStrategy(); var moves = this.CallGetStrategyValidMoves(strategy, board, turn, context); context.IsDone.Should().BeTrue("the strategy should short-circuit the chain if there are pieces to enter"); moves.Should().BeEmpty("there should be no available moves because one dice is used and other position is taken"); }
public void TestEnterPieceStrategyOneDie() { var player = this.app.GetGameFactory().CreatePlayer("Player 1"); var dice = new[] { new DefaultDie(false, 6), new DefaultDie(true, 5) }; var turn = new DefaultTurn(player, dice); var context = new DefaultGameRuleStrategyContext(); var board = this.CreateDefaultBoard(); board.Bar.Add(new DefaultPiece(player)); var strategy = new EnterPieceStrategy(); var moves = this.CallGetStrategyValidMoves(strategy, board, turn, context); context.IsDone.Should().BeTrue("the strategy should short-circuit the chain if there are pieces to enter"); moves.Should().ContainSingle("there should be one available move because only one dice is unused"); moves[0].Die.Should().BeSameAs(dice[0], "die with value 6 is unused"); moves[0].Lane.Should().BeSameAs(board.Bar, "the piece on the bar needs to be entered"); moves[0].LaneIndex.Should().Be(-1, "the bar's index should be -1"); var piece = board.Bar[0]; strategy.MovePiece(player, board, moves[0]); board.Bar.Should().BeEmpty("the piece should have been moved from the bar"); board.Lanes[5].Should().ContainSingle("the piece should have been moved to lane 5"); board.Lanes[5][0].Should().BeSameAs(piece, "the moved piece should be the same as the removed one"); }