public void Assert_that_a_checker_cannot_jump_empty_square() { var p1Checker = new Checker(Player.PlayerOne); var p2Checker = new Checker(Player.PlayerTwo); var move = new Move { Player = Player.PlayerOne, From = new Square(5, 2), To = new Square(3, 4), }; var gameLogic = new GameLogic { Board = GetEmptyBoard() }; gameLogic.Board[5][2] = p1Checker; gameLogic.Board[0][7] = p2Checker; var validation = gameLogic.IsValidMove(move); Assert.That(validation.IsValid, Is.False, "P1 attempted to jump over an empty square"); }
public void Assert_that_a_player_must_jump_when_another_checker_is_able_to_jump() { // If a player attempts to simply move when another checker has a jump, then the move is not valid var p1Checker = new Checker(Player.PlayerOne); var p1Jumper = new Checker(Player.PlayerOne); var p2Checker = new Checker(Player.PlayerTwo); var move = new Move { Player = Player.PlayerOne, From = new Square(7, 2), To = new Square(6, 3), }; var gameLogic = new GameLogic { Board = GetEmptyBoard() }; gameLogic.Board[7][2] = p1Checker; gameLogic.Board[5][2] = p1Jumper; gameLogic.Board[4][3] = p2Checker; var isSuccessful = gameLogic.SendMove(move); Assert.That(isSuccessful, Is.False, "P1 cannot move a checker when another cheker has a jump available"); }
public void Assert_that_a_player_must_jump_when_possible() { // If a player attempts to simply move when a jump is possible, then the move is not valid var p1Checker = new Checker(Player.PlayerOne); var p2Checker = new Checker(Player.PlayerTwo); var move = new Move { Player = Player.PlayerOne, From = new Square(5, 2), To = new Square(4, 3), }; var gameLogic = new GameLogic { Board = GetEmptyBoard() }; gameLogic.Board[5][2] = p1Checker; gameLogic.Board[3][4] = p2Checker; var isSuccessful = gameLogic.SendMove(move); Assert.That(isSuccessful, Is.True, "P1 is allowed to commit suicide"); var boardState = gameLogic.GetBoardState(); Assert.That(boardState.IsPlayerOnesTurn, Is.False, "Should be P2's turn after P1's suicide"); }
public void Assert_that_when_a_double_jump_is_possible_that_the_players_turn_does_not_end() { // If a player attempts to simply move when another checker has a jump, then the move is not valid var p1Checker = new Checker(Player.PlayerOne); var p2Jumpee1 = new Checker(Player.PlayerTwo); var p2Jumpee2 = new Checker(Player.PlayerTwo); var p2LastMove = new Checker(Player.PlayerTwo); var move = new Move { Player = Player.PlayerOne, From = new Square(5, 2), To = new Square(3, 4), }; var gameLogic = new GameLogic { Board = GetEmptyBoard() }; gameLogic.Board[5][2] = p1Checker; gameLogic.Board[4][3] = p2Jumpee1; gameLogic.Board[4][5] = p2Jumpee2; gameLogic.Board[0][1] = p2LastMove; var isSuccessful = gameLogic.SendMove(move); Assert.That(isSuccessful, Is.True, "P1 has a double jump opportunity"); var boardState = gameLogic.GetBoardState(); Assert.That(boardState.IsPlayerOnesTurn, Is.True, "It should still be P1's turn"); //Make double jump move = new Move { Player = Player.PlayerOne, From = new Square(3, 4), To = new Square(5, 6), }; isSuccessful = gameLogic.SendMove(move); Assert.That(isSuccessful, Is.True, "P1 should have been alowed to make a double jump"); boardState = gameLogic.GetBoardState(); Assert.That(boardState.IsPlayerOnesTurn, Is.False, "It should be P2's turn after the double jump"); }
public void Assert_that_unkinged_p2_checker_cannot_jump_backwards() { var p1Checker = new Checker(Player.PlayerOne); var p2Checker = new Checker(Player.PlayerTwo); var move = new Move { Player = Player.PlayerTwo, From = new Square(2, 5), To = new Square(3, 6), }; var gameLogic = new GameLogic { Board = GetEmptyBoard() }; gameLogic.Board[2][5] = p1Checker; gameLogic.Board[7][0] = p2Checker; var validation = gameLogic.IsValidMove(move); Assert.That(validation.IsValid, Is.False, "Cannot jump backwards!"); }
public void Assert_that_suicidal_move_yields_turn_to_other_player_to_make_jump() { // If a player attempts to simply move when a jump is possible, then the move is not valid var p1Checker = new Checker(Player.PlayerOne); var p2Checker = new Checker(Player.PlayerTwo); var move = new Move { Player = Player.PlayerOne, From = new Square(5, 2), To = new Square(6, 3), }; var gameLogic = new GameLogic { Board = GetEmptyBoard() }; gameLogic.Board[5][2] = p1Checker; gameLogic.Board[4][3] = p2Checker; var isSuccessful = gameLogic.SendMove(move); Assert.That(isSuccessful, Is.False, "P1 cannot avoid a jump when available"); }
public void Assert_that_p2_king_can_jump_p1_baseline_test() { var p1Checker = new Checker(Player.PlayerOne); var p2Checker = new Checker(Player.PlayerTwo) { IsKinged = true, }; var move = new Move { Player = Player.PlayerTwo, From = new Square(5, 2), To = new Square(3, 4), }; var gameLogic = new GameLogic { Board = GetEmptyBoard() }; gameLogic.Board[5][2] = p2Checker; gameLogic.Board[4][3] = p1Checker; var validation = gameLogic.IsValidMove(move); Assert.That(validation.IsValid, Is.True, "P2 is jumping P1"); }
public void Assert_that_p2_is_kinged_upon_reaching_top_row() { var p1Checker = new Checker(Player.PlayerOne); var p2Checker = new Checker(Player.PlayerTwo); var move = new Move { Player = Player.PlayerTwo, From = new Square(6, 1), To = new Square(7, 0), }; var gameLogic = new GameLogic { Board = GetEmptyBoard(), IsPlayerOnesTurn = false,}; gameLogic.Board[3][2] = p1Checker; gameLogic.Board[6][1] = p2Checker; var success = gameLogic.SendMove(move); Assert.That(success, Is.True, "Send move succeeded"); Assert.That(p2Checker.IsKinged, Is.True, "YOU DIDN'T KING ME!"); }
public void Assert_that_p1_is_kinged_upon_reaching_bottom_row() { var p1Checker = new Checker(Player.PlayerOne); var p2Checker = new Checker(Player.PlayerTwo); var move = new Move { Player = Player.PlayerOne, From = new Square(1, 6), To = new Square(0, 7), }; var gameLogic = new GameLogic { Board = GetEmptyBoard() }; gameLogic.Board[1][6] = p1Checker; gameLogic.Board[3][2] = p2Checker; var success = gameLogic.SendMove(move); Assert.That(success, Is.True, "Send move succeeded"); Assert.That(p1Checker.IsKinged, Is.True, "YOU DIDN'T KING ME!"); }
public void Assert_that_logjam_forces_game_over() { var p1Checker = new Checker(Player.PlayerOne); var p2Checker1 = new Checker(Player.PlayerTwo); var p2Checker2 = new Checker(Player.PlayerTwo); var move = new Move { Player = Player.PlayerTwo, }; var gameLogic = new GameLogic {Board = GetEmptyBoard()}; gameLogic.Board[0][7] = p1Checker; gameLogic.Board[1][6] = p2Checker1; gameLogic.Board[2][5] = p2Checker2; var isGameOver = gameLogic.IsGameOver(move); Assert.That(isGameOver, Is.True); }
public void Assert_that_kinged_p1_checker_can_jump_backwards() { var p1Checker = new Checker(Player.PlayerOne) { IsKinged = true, }; var p2Checker = new Checker(Player.PlayerTwo); var move = new Move { Player = Player.PlayerOne, From = new Square(3, 2), To = new Square(2, 1), }; var gameLogic = new GameLogic { Board = GetEmptyBoard() }; gameLogic.Board[3][2] = p1Checker; gameLogic.Board[0][7] = p2Checker; var validation = gameLogic.IsValidMove(move); Assert.That(validation.IsValid, Is.True, "Kings can jump backwards!"); }
public void Assert_that_jump_removes_checker() { var p1Checker = new Checker(Player.PlayerOne); var p2Checker = new Checker(Player.PlayerTwo); var move = new Move { Player = Player.PlayerOne, From = new Square(5, 2), To = new Square(3, 4), }; var gameLogic = new GameLogic { Board = GetEmptyBoard() }; gameLogic.Board[5][2] = p1Checker; gameLogic.Board[4][3] = p2Checker; var isSuccessful = gameLogic.SendMove(move); Assert.That(isSuccessful, Is.True, "P1 is jumping P2"); var oldP2Checker = gameLogic.Board[4][3]; Assert.That(oldP2Checker, Is.Null, "Player Two's checker was not removed."); }
public void Assert_that_jumping_last_checker_results_in_game_over() { var p1Checker = new Checker(Player.PlayerOne); var move = new Move { Player = Player.PlayerOne, }; var gameLogic = new GameLogic {Board = GetEmptyBoard()}; gameLogic.Board[2][5] = p1Checker; var isGameOver = gameLogic.IsGameOver(move); Assert.That(isGameOver, Is.True); }
public void Assert_that_checker_cannot_jump_2_squares_at_once() { var p1Checker = new Checker(Player.PlayerOne); var p2Checker = new Checker(Player.PlayerTwo); var move = new Move { Player = Player.PlayerOne, From = new Square(5, 2), To = new Square(2, 5), }; var gameLogic = new GameLogic { Board = GetEmptyBoard() }; gameLogic.Board[5][2] = p1Checker; gameLogic.Board[4][3] = p2Checker; var validation = gameLogic.IsValidMove(move); Assert.That(validation.IsValid, Is.False, "P1 is jumping too far"); }
public void StartGame() { Board = new[] { new Checker[8], new Checker[8], new Checker[8], new Checker[8], new Checker[8], new Checker[8], new Checker[8], new Checker[8], }; for (var y = 0; y < 3; y++) { for (var x = 0; x < 8; x++) { if (new Square {X = x, Y = y}.IsValidSquare()) { Board[x][y] = new Checker(Player.PlayerOne); } } } for (var y = 5; y < 8; y++) { for (var x = 0; x < 8; x++) { if (new Square {X = x, Y = y}.IsValidSquare()) { Board[x][y] = new Checker(Player.PlayerTwo); } } } IsPlayerOnesTurn = true; }