def undo_all_moves(self, annotation=''): while self.undo_list: move = self.undo_list.pop() rev_move = Move([[idx, dest, src] for idx, src, dest in move.affected_squares]) rev_move.annotation = move.annotation self.make_move(rev_move, True, False) move.annotation = annotation self.redo_list.append(move) annotation = rev_move.annotation
def undo_move(self, move=None, notify=True, redo=True, annotation=''): if move is None: if not self.undo_list: return if redo: move = self.undo_list.pop() rev_move = Move([[idx, dest, src] for idx, src, dest in move.affected_squares]) rev_move.annotation = move.annotation self.make_move(rev_move, notify, False) if redo: move.annotation = annotation self.redo_list.append(move)