diff options
author | Gonzalo Odiard <godiard@gmail.com> | 2014-08-09 00:51:11 (GMT) |
---|---|---|
committer | Gonzalo Odiard <godiard@gmail.com> | 2014-08-09 00:51:11 (GMT) |
commit | 2246982f77352f948d08b8aaa670b03849983667 (patch) | |
tree | e207ab3d528fb1b7e5696509d8fe7c7fa8969e74 | |
parent | 0b087a9c83105640214eb38778d92f8c1aa5b47b (diff) |
Place piece on user click over piece
-rw-r--r-- | dominoactivity.py | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/dominoactivity.py b/dominoactivity.py index c84da86..166c4e7 100644 --- a/dominoactivity.py +++ b/dominoactivity.py @@ -218,13 +218,18 @@ class Domino(activity.Activity): y = int(event.get_coords()[2]) if self.game.game_state == DominoGame.GAME_STATE_SELECT_PIECE: - for player in self.game.players: - i = 0 - for piece in player.get_pieces(): - if piece.visible and piece.check_touched(x, y): - player.order_piece_selected = i - self.drawingarea.queue_draw() - i += 1 + player = self.game.ui_player + i = 0 + for piece in player.get_pieces(): + if piece.visible and piece.check_touched(x, y): + player.order_piece_selected = i + + if player.place_piece(piece): + player.end_play() + self.draw_pieces() + + self.drawingarea.queue_draw() + i += 1 def draw_pieces(self): self.surface = cairo.ImageSurface( |