From 78d16685c9b2707b0908f7c0b2e357216347466d Mon Sep 17 00:00:00 2001 From: Gonzalo Odiard Date: Fri, 08 Aug 2014 20:20:46 +0000 Subject: Draw the pieces for the automatic player flipped --- diff --git a/dominoactivity.py b/dominoactivity.py index 28f5978..b417ee9 100644 --- a/dominoactivity.py +++ b/dominoactivity.py @@ -258,6 +258,8 @@ class Domino(activity.Activity): for player in self.game.players: pieces = player.get_pieces() + # the first player have the pieces flipped + flipped = player == self.game.players[0] # TODO: replace for m (m is needed below) for m in range(0, len(pieces)): piece = pieces[m] @@ -265,12 +267,12 @@ class Domino(activity.Activity): if self.game.game_state != \ DominoGame.GAME_STATE_LOCATE_PIECE \ or (m != self.game.ui_player.order_piece_selected): - piece.draw(surf_ctx, False) + piece.draw(surf_ctx, False, flipped) # to debug - self.game.table.show_values(surf_ctx, self.game.values) - self.game.table.mark_tile(surf_ctx, self.game.start) - self.game.table.mark_tile(surf_ctx, self.game.end) + #self.game.table.show_values(surf_ctx, self.game.values) + #self.game.table.mark_tile(surf_ctx, self.game.start) + #self.game.table.mark_tile(surf_ctx, self.game.end) def _start_game(self, button): if self.show_scores: diff --git a/dominopiece.py b/dominopiece.py index 02f94f8..d9db237 100644 --- a/dominopiece.py +++ b/dominopiece.py @@ -42,7 +42,7 @@ class DominoPiece: height = dominoview.SIZE return (self.x < x < self.x + width) and (self.y < y < self.y + height) - def draw(self, ctx, selected): + def draw(self, ctx, selected, fipped=False): SIZE = dominoview.SIZE # if self.vertical: # width = SIZE + SIZE/8 + 2 @@ -101,12 +101,13 @@ class DominoPiece: ctx.set_source_rgb(stroke_r, stroke_g, stroke_b) ctx.stroke() - if not self.reversed: - self._draw_label_a(ctx, 0, 0) - self._draw_label_b(ctx, 0, SIZE) - else: - self._draw_label_b(ctx, 0, 0) - self._draw_label_a(ctx, 0, SIZE) + if not fipped: + if not self.reversed: + self._draw_label_a(ctx, 0, 0) + self._draw_label_b(ctx, 0, SIZE) + else: + self._draw_label_b(ctx, 0, 0) + self._draw_label_a(ctx, 0, SIZE) else: cairoutils.draw_round_rect(ctx, -1, -1, SIZE * 2 + 2, SIZE + 2, r) @@ -141,12 +142,13 @@ class DominoPiece: ctx.set_source_rgb(stroke_r, stroke_g, stroke_b) ctx.stroke() - if not self.reversed: - self._draw_label_a(ctx, 0, 0) - self._draw_label_b(ctx, SIZE, 0) - else: - self._draw_label_b(ctx, 0, 0) - self._draw_label_a(ctx, SIZE, 0) + if not fipped: + if not self.reversed: + self._draw_label_a(ctx, 0, 0) + self._draw_label_b(ctx, SIZE, 0) + else: + self._draw_label_b(ctx, 0, 0) + self._draw_label_a(ctx, SIZE, 0) ctx.restore() -- cgit v0.9.1