1919
2020from .. import layout
2121from ..game import next_round_turn
22+ from ..gamestate_filters import in_homezone
2223from ..team import _ensure_list_tuples
2324from .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,12 +750,7 @@ def draw_box(pos, fill_col):
754750 if not in_maze (pos [0 ], pos [1 ]):
755751 continue
756752
757- if bot % 2 == 0 :
758- in_homezone = pos [0 ] < boundary
759- else :
760- in_homezone = pos [0 ] >= boundary
761-
762- if not in_homezone :
753+ if not in_homezone (pos , team_id , game_state ['shape' ]):
763754 # Only draw food shadow when in homezone
764755 continue
765756
0 commit comments