Highlight tiles that are legal moves.
authorJeremy Thurgood <firxen@gmail.com>
Wed, 14 May 2014 20:00:22 +0000 (22:00 +0200)
committerJeremy Thurgood <firxen@gmail.com>
Wed, 14 May 2014 20:00:22 +0000 (22:00 +0200)
naja/widgets/tile.py

index 01efdac4ff8a16a5f029864254d72253a760d1eb..f71cda9b3609e8f2b1a2163159136ec29563ee50 100644 (file)
@@ -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: