# If it's the player's turn and they press on a square that hasn't been pressed before: take a shot elif player_turn and event.type == pygame.MOUSEBUTTONDOWN: if event.button == 1 and event.pos[0] < 660: coordinates = convert_pixel_coordinates( event.pos[0], event.pos[1]) # Take a shot last_player_attack = AI.suffer_attack(coordinates) # Check for sunken ships: AI.check_sunken_ships() # Update display board_array = AI.get_board() update_player_grid(board_array) wait_for(800) # Check if player wins: if AI.check_loss(): player_win = True carryOn = False # Update turn: If last turn was a hit or sink, go again if last_player_attack == Cell.HIT or last_player_attack == Cell.SUNK: player_turn = True AI_turn = False else: player_turn = False AI_turn = True # --- Game logic should go here # If user presses start - make sure that all the board pieces are in the correct place, then start game if not setup: if AI_turn: