Recording a move in the data structure

The shift method defined in view.py is responsible for the actual moving of a chess piece on the chessboard. However, this brings about a change in the underlying data structure. The move method of the Model class is then responsible for updating the data structure. This move method is called from the previously defined pre_move_validation() method if and only if no errors are raised, as follows (4.06model.py):

def move(self, start_pos, final_pos):
self[final_pos] = self.pop(start_pos, None)

Note that as soon as this update is complete, the control returns to the on_square_clicked() method in view.py. The method then calls the draw_all_pieces() method, which updates the view.

..................Content has been hidden....................

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