Beispiel #1
0
 def test_pawn_illegal_double_move_black(self):
     board, teams = setup_game()
     black = teams[1]
     board, black, piece_to_move, legal = run_game_test(
         board, black, 'c7', 'c6')
     board, black, piece_to_move, legal = run_game_test(
         board, black, 'c6', 'c4')
     assert legal == False
Beispiel #2
0
 def test_knight_good_move2_black(self):
     board, teams = setup_game()
     black = teams[1]
     board, black, piece_to_move, legal = run_game_test(
         board, black, 'b8', 'a6')
     board, black, piece_to_move, legal = run_game_test(
         board, black, 'a6', 'c5')
     assert legal == True
Beispiel #3
0
 def test_pawn_lateral_black(self):
     board, teams = setup_game()
     black = teams[1]
     board, black, piece_to_move, legal = run_game_test(
         board, black, 'a7', 'a6')
     board, black, piece_to_move, legal = run_game_test(
         board, black, 'a6', 'c6')
     assert legal == False
Beispiel #4
0
 def test_bishop_lateral_move_black(self):
     board, teams = setup_game()
     black = teams[1]
     board, black, piece_to_move, legal = run_game_test(
         board, black, 'g8', 'h6')
     board, black, piece_to_move, legal = run_game_test(
         board, black, 'f8', 'g8')
     assert legal == False
Beispiel #5
0
 def test_pawn_take_same_team_pawn_black(self):
     board, teams = setup_game()
     black = teams[0]
     board, black, piece_to_move, legal = run_game_test(
         board, black, 'c7', 'c6')
     board, black, piece_to_move, legal = run_game_test(
         board, black, 'b7', 'c6')
     assert legal == False
Beispiel #6
0
 def test_knight_good_move2_white(self):
     board, teams = setup_game()
     white = teams[0]
     board, white, piece_to_move, legal = run_game_test(
         board, white, 'b1', 'c3')
     board, white, piece_to_move, legal = run_game_test(
         board, white, 'c3', 'e4')
     assert legal == True
Beispiel #7
0
 def test_bishop_good_move_white(self):
     board, teams = setup_game()
     white = teams[0]
     board, white, piece_to_move, legal = run_game_test(
         board, white, 'd2', 'd3')
     board, white, piece_to_move, legal = run_game_test(
         board, white, 'c1', 'f4')
     assert legal == True
Beispiel #8
0
 def test_bishop_good_move_black(self):
     board, teams = setup_game()
     black = teams[1]
     board, black, piece_to_move, legal = run_game_test(
         board, black, 'd7', 'd6')
     board, black, piece_to_move, legal = run_game_test(
         board, black, 'c8', 'h3')
     assert legal == True
Beispiel #9
0
 def test_pawn_take_same_team_pawn_white(self):
     board, teams = setup_game()
     white = teams[0]
     board, white, piece_to_move, legal = run_game_test(
         board, white, 'c2', 'c3')
     board, white, piece_to_move, legal = run_game_test(
         board, white, 'b2', 'c3')
     assert legal == False
Beispiel #10
0
 def test_pawn_illegal_double_move_white(self):
     board, teams = setup_game()
     white = teams[0]
     board, white, piece_to_move, legal = run_game_test(
         board, white, 'c2', 'c3')
     board, white, piece_to_move, legal = run_game_test(
         board, white, 'c3', 'c5')
     assert legal == False
Beispiel #11
0
 def test_pawn_lateral_white(self):
     board, teams = setup_game()
     white = teams[0]
     board, white, piece_to_move, legal = run_game_test(
         board, white, 'a2', 'a3')
     board, white, piece_to_move, legal = run_game_test(
         board, white, 'a3', 'c3')
     assert legal == False
Beispiel #12
0
 def test_bishop_straight_move_black(self):
     board, teams = setup_game()
     black = teams[1]
     board, black, piece_to_move, legal = run_game_test(
         board, black, 'c7', 'c5')
     board, black, piece_to_move, legal = run_game_test(
         board, black, 'c8', 'c6')
     assert legal == False
Beispiel #13
0
 def test_bishop_straight_move_white(self):
     board, teams = setup_game()
     white = teams[0]
     board, white, piece_to_move, legal = run_game_test(
         board, white, 'c2', 'c4')
     board, white, piece_to_move, legal = run_game_test(
         board, white, 'c1', 'c3')
     assert legal == False
Beispiel #14
0
 def test_bishop_lateral_move_white(self):
     board, teams = setup_game()
     white = teams[0]
     board, white, piece_to_move, legal = run_game_test(
         board, white, 'b1', 'a3')
     board, white, piece_to_move, legal = run_game_test(
         board, white, 'c1', 'b1')
     assert legal == False
Beispiel #15
0
 def test_board_team_piece_update_black(self):
     board, teams = setup_game()
     black = teams[1]
     board, black, piece_to_move, legal = run_game_test(
         board, black, 'b8', 'a6')
     assert board.squares['a6'] is not None and board.squares[
         'b8'] is None and piece_to_move.pos == 'a6' and [
             piece for piece in black.pieces if piece.pos == 'a6'
         ]
Beispiel #16
0
 def test_board_team_piece_update_white(self):
     board, teams = setup_game()
     white = teams[0]
     board, white, piece_to_move, legal = run_game_test(
         board, white, 'a2', 'a4')
     assert board.squares[
         'a4'] is not None and piece_to_move.pos == 'a4' and board.squares[
             'a2'] is None and [
                 piece for piece in white.pieces if piece.pos == 'a4'
             ]
Beispiel #17
0
 def test_rook_diagonal_white(self):
     board, teams = setup_game()
     white = teams[0]
     board, white, piece_to_move, legal = run_game_test(
         board, white, 'a2', 'a4')
     board, white, piece_to_move, legal = run_game_test(
         board, white, 'a1', 'a3')
     board, white, piece_to_move, legal = run_game_test(
         board, white, 'a3', 'd6')
     assert legal == False
Beispiel #18
0
 def test_rook_lateral_black(self):
     board, teams = setup_game()
     black = teams[1]
     board, black, piece_to_move, legal = run_game_test(
         board, black, 'h7', 'h5')
     board, black, piece_to_move, legal = run_game_test(
         board, black, 'h8', 'h6')
     board, black, piece_to_move, legal = run_game_test(
         board, black, 'h6', 'c6')
     assert legal == True
Beispiel #19
0
 def test_rook_diagonal_black(self):
     board, teams = setup_game()
     black = teams[1]
     board, black, piece_to_move, legal = run_game_test(
         board, black, 'h7', 'h5')
     board, black, piece_to_move, legal = run_game_test(
         board, black, 'h8', 'h6')
     board, black, piece_to_move, legal = run_game_test(
         board, black, 'h6', 'g5')
     assert legal == False
Beispiel #20
0
 def test_pawn_take_pawn_black(self):
     board, teams = setup_game()
     white = teams[0]
     black = teams[1]
     board, black, piece_to_move, legal = run_game_test(
         board, black, 'c7', 'c5')
     board, white, piece_to_move, legal = run_game_test(
         board, white, 'b2', 'c4')
     board, black, piece_to_move, legal = run_game_test(
         board, black, 'c5', 'c4')
     assert legal == True
Beispiel #21
0
 def test_pawn_take_straight_ahead_white(self):
     board, teams = setup_game()
     white = teams[0]
     black = teams[1]
     board, white, piece_to_move, legal = run_game_test(
         board, white, 'c2', 'c4')
     board, black, piece_to_move, legal = run_game_test(
         board, black, 'c7', 'c5')
     board, white, piece_to_move, legal = run_game_test(
         board, white, 'c4', 'c5')
     assert legal == False
Beispiel #22
0
def run_game():
    board, teams = setup_game()
    win = False
    i = 0
    while win is False:
        team = teams[i % 2]
        oppo_team = teams[(i + 1) % 2]
        print('\n{}\'s turn\n'.format(team.colour))

        # Get input
        piece_to_move = get_piece_to_move(piece_to_move_prompt(), team)
        target = target_square_prompt()
        # Check input
        legal = check_move_legality(board, piece_to_move, target)
        # Act on input
        if legal is True:
            move_or_take = move_or_take(board, piece_to_move, target)
            board.move_piece(piece_to_move, target)
            i += 1
        else:
            print('Illegal move. Try again.')
Beispiel #23
0
 def test_knight_bad_move_black(self):
     board, teams = setup_game()
     black = teams[1]
     board, black, piece_to_move, legal = run_game_test(
         board, black, 'b8', 'c5')
     assert legal == False
Beispiel #24
0
 def test_select_empty_square_white(self):
     board, teams = setup_game()
     white = teams[0]
     board, white, piece_to_move, legal = run_game_test(
         board, white, 'a3', 'a4')
     assert legal == False
Beispiel #25
0
 def test_knight_bad_move_white(self):
     board, teams = setup_game()
     white = teams[0]
     board, white, piece_to_move, legal = run_game_test(
         board, white, 'b1', 'b3')
     assert legal == False
Beispiel #26
0
 def test_select_empty_square_black(self):
     board, teams = setup_game()
     black = teams[1]
     board, black, piece_to_move, legal = run_game_test(
         board, black, 'b6', 'b4')
     assert legal == False