Skip to content

Commit c59dd49

Browse files
authored
Merge pull request #974 from Debilski/feature/no-food-shadow-outside-homezone
BF: Do not draw food shadow outside of own homezone
2 parents f5e293d + fec6ce5 commit c59dd49

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

pelita/ui/tk_canvas.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
from .. import layout
2121
from ..game import next_round_turn
22+
from ..gamestate_filters import in_homezone
2223
from ..team import _ensure_list_tuples
2324
from .tk_sprites import (
2425
BLUE,
@@ -683,10 +684,11 @@ def draw_bot_shadow(self, game_state):
683684
if not self._grid_enabled:
684685
return
685686

686-
bot = game_state.get('turn')
687-
if bot is None:
687+
turn = game_state.get('turn')
688+
if turn is None:
688689
# game has not started yet or we are in layout-only mode
689690
return
691+
team_id = turn % 2
690692

691693
# border_col = "#000"
692694
fill_col = LIGHT_GREY
@@ -698,17 +700,11 @@ def draw_box(pos):
698700
self.ui_game_canvas.create_rectangle(*ul, *lr, width=2, outline='#111', tags=("bot_shadow",))
699701

700702
try:
701-
old_pos = tuple(game_state['requested_moves'][bot]['previous_position'])
703+
old_pos = tuple(game_state['requested_moves'][turn]['previous_position'])
702704
except TypeError:
703-
old_pos = game_state['bots'][bot]
705+
old_pos = game_state['bots'][turn]
704706

705-
boundary = game_state['shape'][0] / 2
706-
if bot % 2 == 0:
707-
in_homezone = old_pos[0] < boundary
708-
else:
709-
in_homezone = old_pos[0] >= boundary
710-
711-
if not in_homezone:
707+
if not in_homezone(old_pos, team_id, game_state['shape']):
712708
# We are a pacman. No shadow
713709
return
714710

@@ -754,6 +750,10 @@ def draw_box(pos, fill_col):
754750
if not in_maze(pos[0], pos[1]):
755751
continue
756752

753+
if not in_homezone(pos, team_id, game_state['shape']):
754+
# Only draw food shadow when in homezone
755+
continue
756+
757757
draw_box(pos, fill_col=fill_col)
758758

759759
# Border around the shadow removed for now

0 commit comments

Comments
 (0)