def validate_and_move_piece(from_coordiantes, to_coordinates): """imports validation at the top and validates """ #validate if from_coordiantes == None: return False # to_coordinates = None: # return False if not special_move_manager.check_and_move(from_coordinates, to_coordinates): try: validate_move(chess_board, from_coordiantes, to_coordinates) move_piece(from_coordiantes, to_coordinates) # except IndexError("Please enter a coordinate using, once character and one number from the grid") except ValidationException as e: tb.print_exc() print(e)
def testKingMove(self): # pass #self.assertEqual(True, False) # self.assertEqual(True, False) validate.validate_move(self.chess_board, "D1", "D3") with self.assertRaises(validate.ValidationException): validate.validate_move(self.chess_board, "C3", "D4") validate.validate_move(self.chess_board, "C3", "D7") validate.validate_move(self.chess_board, "C3", "H3")
def testBishopMove(self): validate.validate_move(self.chess_board, "H4", "F2") validate.validate_move(self.chess_board, "H4", "F6") with self.assertRaises(validate.ValidationException): validate.validate_move(self.chess_board, "H4", "E6")
def testRookMove(self): with self.assertRaises(validate.ValidationException): validate._validate_rook_move(self.chess_board, "A8", "B3", 0, 1) validate._validate_rook_move(self.chess_board, "A8", "A3", 0, 0) validate._validate_rook_move(self.chess_board, "A8", "C8", 0, 2) validate._validate_rook_move(self.chess_board, "A8", "A5", 0, 0) validate._validate_rook_move(self.chess_board, "A6", "E6", 0, 4) validate._validate_rook_move(self.chess_board, "A6", "B6", 0, 1) validate._validate_rook_move(self.chess_board, "A8", "A6", 0, 0) validate.validate_move(self.chess_board, "A8", "A6") validate.validate_move(self.chess_board, "A8", "C8") validate.validate_move(self.chess_board, "A8", "A5") validate.validate_move(self.chess_board, "A6", "E6")
def testQueenMove(self): # self.assertEqual(True, validate.validate_move(self.chess_board, "D1", "D2")) # self.assertEqual(True,True) # with self.assertRaises(validate.ValidationException): validate.validate_move(self.chess_board, "D1", "D2")
def testPawnMove(self): #self.assertEqual(True, validate.validate_move(self.chess_board, "A2", "A3")) with self.assertRaises(validate.ValidationException): validate.validate_move(self.chess_board, "A2", "A4") validate.validate_move(self.chess_board, "A2", "A3") validate.validate_move(self.chess_board, "A2", "A7") validate.validate_move(self.chess_board, "A2", "A4") validate.validate_move(self.chess_board, "A2", "A1") validate.validate_move(self.chess_board, "C7", "C5")
def testValidate_move(self): validate.validate_move(self.chess_board, "A2", "A3") validate.validate_move(self.chess_board, "C3", "D4") """needs fix test in validate.py, """ with self.assertRaises(validate.ValidationException): validate.validate_move(self.chess_board, "H9", "cheese") with self.assertRaises(validate.ValidationException): validate.validate_move(self.chess_board, "E1", "E3") with self.assertRaises(validate.ValidationException): validate.validate_move(self.chess_board, "C3", "D7") with self.assertRaises(validate.ValidationException): validate.validate_move(self.chess_board, "C3", "H3")
def testKnightMove(self): validate.validate_move(self.chess_board, "B1", "D2") with self.assertRaises(validate.ValidationException): validate.validate_move(self.chess_board, "B1", "C3")
print(specialMove.en_passant) chess_board["H5"] = chess_board["H7"] del chess_board["H7"] print("Validate en_passant BLACK! G5 to H6 is True", specialMove.check_and_move(chess_board, "G5", "H6")) print(chess_board) print("====" * 30) print(undoMoves.undo_moves) undoMoves.undo_last_move(chess_board) print(chess_board) print(undoMoves.undo_moves) print("====" * 30) print("====" * 30 + "validate") print("A2", validate.validate_move(chess_board, "A2", "A3")) print("====" * 30) print(validate.validate_move(chess_board, "H9", "cheese")) print("====" * 30) print(validate.validate_move(chess_board, "E1", "E3")) print("====" * 30) print("True validate move king", validate.validate_move(chess_board, "C3", "D4")) print("False validate move king", validate.validate_move(chess_board, "C3", "D7")) print("False validate move king", validate.validate_move(chess_board, "C3", "H3")) print("====" * 30) print("Validate C is 3", validate.coordinate_to_column_number("C3"))