From b53ebac2dd925bd58a435dbe8841841c6df82765 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20N=C3=B6llemeyer?= Date: Mon, 19 Aug 2024 20:43:30 +0200 Subject: [PATCH] clarification --- game/screens/game_screens.py | 14 +++++++------- game/tags.py | 2 +- game/world_tools.py | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/game/screens/game_screens.py b/game/screens/game_screens.py index 159dede..f5a46ce 100644 --- a/game/screens/game_screens.py +++ b/game/screens/game_screens.py @@ -15,7 +15,7 @@ import g from game.components import Action, Gold, Graphic, Position from game.constants import DIRECTION_KEYS, ACTION_KEYS, FLOOR_CHAR from game.screens import Push, Screen, ScreenResult -from game.tags import IsDoor, IsItem, IsPlayer, IsActor +from game.tags import IsWalllike, IsItem, IsPlayer, IsActor from game.constants import WALL_CHAR, VERTICAL_WALL_CHAR from game.screens import menu_screens from game.world_tools import world_pos_to_map_pos, map_pos_to_world_pos @@ -28,11 +28,11 @@ def _handle_movement(player, map, dir): pos = player.components[Position] new_pos = pos + dir 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) + if action_entities := g.world.Q.all_of(components=[Action], tags=[new_pos]): + for entity in action_entities: + entity.components[Action](entity) map_pos = world_pos_to_map_pos(pos) - map.compute_fov(map_pos.x, map_pos.y, 100) + _recalc_fov(map_pos) return None if not map.walkable[map_pos.y, map_pos.x]: return None @@ -62,7 +62,7 @@ def _draw_entity(entity: tcod.ecs.Entity, camera_pos, camera_radius_x, camera_ra map_pos = world_pos_to_map_pos(pos) if g.world[None].components[Map].fov[map_pos.y, map_pos.x]: graphic = entity.components[Graphic] - r,gg,b,a = graphic.fg + r,gg,b,_ = graphic.fg fg = (r,gg,b,255) g.foreground.rgba[["ch", "fg"]][screen_pos.y + camera_radius_y, screen_pos.x + camera_radius_x] = graphic.ch, fg @@ -98,7 +98,7 @@ class MainScreen(Screen): map: Map = g.world[None].components[Map] # Draw walls and floors - doors = [ d.components[Position] for d in g.world.Q.all_of(tags=[IsDoor]) ] + doors = [ d.components[Position] for d in g.world.Q.all_of(tags=[IsWalllike]) ] for i in range(console.width): for j in range(console.height): world_pos = Position(i-w,j-h)+camera_pos diff --git a/game/tags.py b/game/tags.py index 69017e0..feed0fd 100644 --- a/game/tags.py +++ b/game/tags.py @@ -13,5 +13,5 @@ IsActor: Final = "IsActor" IsItem: Final = "IsItem" """Entity is an item.""" -IsDoor: Final = "IsDoor" +IsWalllike: Final = "IsDoor" """Entity is a door.""" diff --git a/game/world_tools.py b/game/world_tools.py index d493862..911f2b1 100644 --- a/game/world_tools.py +++ b/game/world_tools.py @@ -10,7 +10,7 @@ from tcod.map import Map import g from game.components import Action, Gold, Graphic, Position -from game.tags import IsActor, IsItem, IsPlayer, IsDoor +from game.tags import IsActor, IsItem, IsPlayer, IsWalllike world_center: Final = Position(50, 50) @@ -33,7 +33,7 @@ def add_door(world, pos): Graphic: Graphic(ord('\\')), Action: unlock_door }, - tags=[IsDoor] + tags=[IsWalllike] ) add_wall(world, pos)