diff --git a/game/screens/game_screens.py b/game/screens/game_screens.py index 2633fff..bbbfde1 100644 --- a/game/screens/game_screens.py +++ b/game/screens/game_screens.py @@ -38,8 +38,15 @@ class MainScreen(Screen): case tcod.event.Quit(): raise SystemExit() case tcod.event.KeyDown(sym=sym) if sym in DIRECTION_KEYS: - new_pos = player.components[Position] + DIRECTION_KEYS[sym] + pos = player.components[Position] + new_pos = pos + DIRECTION_KEYS[sym] map_pos = world_pos_to_map_pos(new_pos) + if a := g.world.Q.all_of(components=[Action], tags=[new_pos]): + for aa in a: + aa.components[Action](aa) + map_pos = world_pos_to_map_pos(pos) + map.compute_fov(map_pos.x, map_pos.y, 100) + return None if not map.walkable[map_pos.y, map_pos.x]: return None player.components[Position] = new_pos