def makeMove(a: gameLogic.gameState, turn: str): """ Asks the user to enter a space on the board in row,col format. Then checks if its valid and places it on the board. If invalid, it remprompts. """ count = 0 while True: temp = [18, 18] # Initializing move = [] while len(move) != 2 or gameLogic.inBoard(a, turn, temp) == False: # Checks if move is in the board try: move = input( "Please select a space on the board by entering (row #,col #) like 3,4 or q to quit: " ) # Asks for the move from the user if move.upper() == "Q": os._exit(0) move = move.split(",") move[0] = int(move[0]) move[1] = int(move[1]) temp = [move[0], move[1]] except: print("Please enter a valid move") # Prints when invalid characters are used. if count > 0 and gameLogic.inBoard(a, turn, temp) == False: print("Enter a move on the board please") # Prints if not on board count += 1 legal = gameLogic.validateMove(a, turn, temp) # Validates whether the move is legal flipPieces = legal[1] # Gets the list of pieces that were to be flipped. if turn == gameLogic.BLACK: # Checks if black's turn if a.getBoard()[int(move[1]) - 1][int(move[0]) - 1] == "-" and legal[0]: # Checks if move is valid a.flipPiece(flipPieces) # Flips pieces a.makeBlack(int(move[1]), int(move[0])) # Makes new piece black break else: if ( a.getBoard()[int(move[1]) - 1][int(move[0]) - 1] == "-" ): # Checks if space is blank which means invalid move would have to been entered print("Please enter a valid move.") else: print("Please enter an unfilled space.") # Otherwise the space is taken already. else: if a.getBoard()[int(move[1] - 1)][int(move[0]) - 1] == "-" and legal[0]: # Checks if move is valid a.flipPiece(flipPieces) # Flips Pieces a.makeWhite(int(move[1]), int(move[0])) # Places new white piece break else: if ( a.getBoard()[int(move[1]) - 1][int(move[0]) - 1] == "-" ): # Checks if space is blank which means invalid move would have to been entered print("Please enter a valid move.") else: print("Please enter an unfilled space.") # Otherwise the space is taken already.