Update
This commit is contained in:
@@ -35,6 +35,8 @@ class Interactable:
|
||||
name: Union[str, Dict[str, str]]
|
||||
image_path: str = ""
|
||||
actions: List[Action] = field(default_factory=list)
|
||||
unlocked_by: str = ""
|
||||
locked: bool = False
|
||||
|
||||
def add_action(self, action: Action):
|
||||
self.actions.append(action)
|
||||
@@ -63,6 +65,8 @@ class Location:
|
||||
x: float = 0.0 # X coordinate for distance calculations
|
||||
y: float = 0.0 # Y coordinate for distance calculations
|
||||
danger_level: int = 0 # Danger level (0-5)
|
||||
unlocked_by: str = ""
|
||||
locked: bool = False
|
||||
|
||||
def add_exit(self, direction: str, destination: str, stamina_cost: int = 5):
|
||||
self.exits[direction] = destination
|
||||
@@ -114,9 +118,14 @@ class WorldLoader:
|
||||
interactable = Interactable(
|
||||
id=template_id,
|
||||
name=template_data.get('name', 'Unknown'),
|
||||
image_path=template_data.get('image_path', '')
|
||||
image_path=template_data.get('image_path', ''),
|
||||
unlocked_by=instance_data.get('unlocked_by', template_data.get('unlocked_by', '')),
|
||||
)
|
||||
|
||||
# Set locked status if unlocked_by is present
|
||||
if interactable.unlocked_by:
|
||||
interactable.locked = True
|
||||
|
||||
# Get actions from template
|
||||
template_actions = template_data.get('actions', {})
|
||||
|
||||
@@ -211,9 +220,14 @@ class WorldLoader:
|
||||
y=float(loc_data.get('y', 0.0)),
|
||||
danger_level=danger_level,
|
||||
tags=loc_data.get('tags', []),
|
||||
npcs=loc_data.get('npcs', [])
|
||||
npcs=loc_data.get('npcs', []),
|
||||
unlocked_by=loc_data.get('unlocked_by', '')
|
||||
)
|
||||
|
||||
# Set locked status if unlocked_by is present
|
||||
if location.unlocked_by:
|
||||
location.locked = True
|
||||
|
||||
# Add exits
|
||||
for direction, destination in loc_data.get('exits', {}).items():
|
||||
location.add_exit(direction, destination)
|
||||
|
||||
Reference in New Issue
Block a user