Collecting a list of the moves that need to be highlighted

We also called the update_highlight_list(position) method from the on_square_clicked method. The purpose of this method is to collect all the possible moves for a given chess piece in a list named all_squares_to_be_highlighted.

The actual focusing of the available moves takes place in the draw_board method of the GUI class. The code for this is as follows (see 4.06view.py):

def update_highlight_list(self, position):
self.all_squares_to_be_highlighted = None
try:
piece = self.controller.get_piece_at(position)
except:
piece = None
if piece and (piece.color == self.controller.player_turn()):
self.selected_piece_position = position
self.all_squares_to_be_highlighted = list(map(self.controller.get_numeric_notation,
self.controller.get_piece_at(position).moves_available(position)))
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.39.60