22
33from engine .ability_effects import ABILITY_LOGIC
44from .incident_effects import INCIDENT_EFFECTS
5- from .models import Action , Character , Location , ActionType , ALL_LOCATIONS , RoleType , TurnData
5+ from .models import Action , Character , Location , ActionType , ALL_LOCATIONS , LocationType , RoleType , TurnData
66from .role_effects import ROLE_EFFECTS
77from .state import GameState
88from collections import defaultdict
99
1010# Define the layout as a 2x2 grid
1111LOCATION_GRID = [
12- [Location .HOSPITAL , Location .SHRINE ], # Top row
13- [Location .CITY , Location .SCHOOL ] # Bottom row
12+ [LocationType .HOSPITAL , LocationType .SHRINE ], # Top row
13+ [LocationType .CITY , LocationType .SCHOOL ] # Bottom row
1414]
1515
16- def find_location_coords (location : Location ) -> tuple [int , int ]:
16+ def find_location_coords (location : LocationType ) -> tuple [int , int ]:
1717 for row_idx , row in enumerate (LOCATION_GRID ):
1818 for col_idx , loc in enumerate (row ):
1919 if loc == location :
@@ -80,7 +80,7 @@ def resolve_actions(game_state: GameState, turn_data: TurnData):
8080 # Resolve actions targeting characters
8181 for char , action_list in char_to_actions .items ():
8282 for action in action_list :
83- resolve_action (char , action .type ) # type: ignore
83+ resolve_action (char , action .type )
8484
8585 # TODO: Resolve location-based actions (not yet implemented)
8686 # for loc, action_list in loc_to_actions.items():
@@ -98,18 +98,22 @@ def resolve_abilities(game_state: GameState, turn_data: TurnData):
9898
9999 for choice in turn_data .ability_actions :
100100 source_char = next ((c for c in game_state .characters if c .role == choice .source ), None )
101- target_char = next ((c for c in game_state .characters if c .name == choice .target ), None )
101+ if choice .target .lower () in {l .value for l in LocationType }:
102+ target_loc_enum = LocationType (choice .target .lower ())
103+ target_obj = game_state .location_states [target_loc_enum ]
104+ else :
105+ target_obj = next ((c for c in game_state .characters if c .name == choice .target ), None )
102106
103- if not source_char or not target_char :
104- print (f"Warning: Invalid character in ability choice, skipping." )
107+ if not source_char or not target_obj :
108+ print (f"Warning: Invalid character or location in ability choice, skipping." )
105109 continue
106110
107111 ability_fn = ABILITY_LOGIC .get (source_char .role )
108112 if not ability_fn :
109113 print (f"Warning: { source_char .name } ({ source_char .role .name } ) has no defined ability, skipping." )
110114 continue
111115
112- ability_fn (source_char , target_char , game_state )
116+ ability_fn (source_char , target_obj )
113117
114118
115119def resolve_roles (game_state : GameState ):
0 commit comments