From: Jeremy Thurgood Date: Wed, 14 May 2014 20:00:22 +0000 (+0200) Subject: Highlight tiles that are legal moves. X-Git-Tag: 0.1~301 X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;h=72a347097e53a92bedda692da7cdb34f8b370437;p=naja.git Highlight tiles that are legal moves. --- diff --git a/naja/widgets/tile.py b/naja/widgets/tile.py index 01efdac..f71cda9 100644 --- a/naja/widgets/tile.py +++ b/naja/widgets/tile.py @@ -2,7 +2,7 @@ import pygame import pygame.locals as pgl -from naja.constants import TILE_SIZE, BITS, LOCK_HEIGHT +from naja.constants import TILE_SIZE, BITS, LOCK_HEIGHT, MOVE from naja.resources import resources from naja.resources.mutators import EIGHT_BIT from naja.widgets.base import Widget @@ -29,7 +29,11 @@ class TileWidget(Widget): def prepare(self): # Draw background x, y = abs(self.board_pos[0] - 2), abs(self.board_pos[1] - 2) - if (x + y) % 2 == 0: + legal_move = (self.board_pos in self.state.player.legal_moves()) + if self.state.gameboard.player_mode == MOVE and legal_move: + bg = resources.get_image('board/tile_available.png', + transforms=(EIGHT_BIT,)) + elif (x + y) % 2 == 0: bg = resources.get_image('board/tile_2.png', transforms=(EIGHT_BIT,)) else: