def show_playing_screen(screen: pygame.Surface, cell_size: tuple, angel_icon, devil_icon, game_logic: GameLogic): """ Show the playing screen Return (new game logic which is changed,whether a move is made) """ move_made = False board_size = game_logic.get_board().get_size() board_width = board_size[0] board_height = board_size[1] #width/column index for column_index in range(board_width): #height/row index for row_index in range(board_height): if not (column_index < board_width and row_index < board_height): continue rect = get_rect(row_index, column_index, cell_size) #If the position is angel position if game_logic.get_board().get_position( row_index, column_index) == ANGLE_SPACE: screen.blit(angel_icon, rect) #If the position is devil position elif game_logic.get_board().get_position( row_index, column_index) == BLOCK_SPACE: screen.blit(devil_icon, rect) else: pygame.draw.rect(screen, BLACK, rect) positions = list() is_angel_turn = game_logic.is_angel_turn() avaliable_moves = set() if is_angel_turn: avaliable_moves = game_logic.get_avaliable_angel_moves() else: avaliable_moves = game_logic.get_avaliable_devil_moves() for (i, j) in avaliable_moves: rect = get_rect(i, j, cell_size) pygame.draw.rect(screen, BLUE, rect) positions.append(Position(i, j, rect)) left_clicked, _, _ = pygame.mouse.get_pressed() #if left clicked if left_clicked == 1: mouse = pygame.mouse.get_pos() for position in positions: #if the avaliable position is clicked if position.rect.collidepoint(mouse): move_made = True #if it is an angel turn,move the angel if is_angel_turn: game_logic.angel_move(position.row_index, position.column_index) else: game_logic.devil_move(position.row_index, position.column_index) return game_logic, move_made