Beispiel #1
0
 def _update_after_animation(self, anim, *args):
     if hasattr(anim, 'fen'):
         self.set_position(anim.fen)
         self._draw_board()
         self._draw_pieces()
     elif hasattr(anim, 'move'):
         print('ANIMMOVE : ' + anim.move)
         self.fen = sf.get_fen(self._game.start_position, self._game.moves+[anim.move])
         self._game.moves.append(anim.move)
         self.set_position(self.fen)
         self._draw_board()
         self._draw_pieces()
     else:
         self._moving_piece_from = -1
         self._moving_piece = '.'
Beispiel #2
0
 def _update_position(self, g, value):
     #print "UPDATING WITH MOVE" + str(value)
     if self.fen == g.current_fen():
         return
     if self.fen == sf.get_fen(g.start_position,g.moves[:-1]):  # Animate if this is a new move on current fen
         self._moving_piece_from = self.square_number(g.moves[-1][:2])
         self._moving_piece = self.position[self._moving_piece_from]
         self._moving_piece_pos[0], self._moving_piece_pos[1] = self._to_coordinates(self._moving_piece_from)
         animation = Animation(_moving_piece_pos=self._to_coordinates(self.square_number(g.moves[-1][2:4])), duration=0.1, t='in_out_sine')
         animation.fen=g.current_fen()
         animation.bind(on_complete=self._update_after_animation)
         animation.start(self)
     else:
         self.set_position(g.current_fen())
         self._draw_board()
         self._draw_pieces()
Beispiel #3
0
 def current_fen(self):
     return sf.get_fen(self.start_position, self.moves)