> cat /wizhelp/wizadvanced1
> _
======================================================================== Advanced: Doors and Exits ======================================================================== Creating complex exit systems with doors, locks, and conditions. DOOR BASICS: ```python from lib.models.entity import Exit, Door from lib.models.enums import ExitType # Simple door exit = Exit("north", "hallway", ExitType.DOOR) # Door with properties door = Door( is_open=False, is_locked=True, key_name="iron_key" ) exit.door = door ``` CONDITIONAL EXITS: ```python def can_traverse(player): """Check if player can use this exit""" # Check for key if player.has_item("golden_key"): return True, "" # Check for puzzle completion puzzle_room = player.game_state.rooms.get("puzzle_room") if puzzle_room and puzzle_room.puzzle_complete: return True, "" # Check player level if player.level >= 20: return True, "" return False, "The door won't budge. You need a golden key." exit.can_traverse = can_traverse ``` ONE-WAY EXITS: ```python # Room A to Room B (one way) room_a.exits.append(Exit("jump", "room_b")) # Don't add reverse exit in room_b ``` HIDDEN EXITS: ```python hidden = Exit("panel", "secret_room", ExitType.HIDDEN) hidden.search_difficulty = 15 # Higher = harder to find hidden.search_message = "You discover a hidden panel!" ``` DYNAMIC EXITS: ```python class TimedExit(Exit): def can_traverse(self, player): hour = datetime.now().hour if 22 <= hour or hour < 6: return True, "" return False, "The portal only opens at night." ``` LOCKED DOOR PATTERNS: Simple Key Lock: ```python exit.can_traverse = lambda p: ( p.has_item("red_key"), "You need a red key." ) ``` Multi-Key Lock: ```python def check_keys(player): keys = ["red_key", "blue_key", "green_key"] for key in keys: if not player.has_item(key): return False, f"You need the {key}." return True, "" exit.can_traverse = check_keys ``` Puzzle Lock: ```python def puzzle_door(player): room = player.game_state.rooms.get(player._location) if hasattr(room, 'puzzle_solved') and room.puzzle_solved: return True, "" return False, "Solve the puzzle first." ``` DOOR DESCRIPTIONS: ```python # Add to description items DescriptionItem( name="door", aliases=["north door", "wooden door"], description="A sturdy oak door with iron hinges." ) ``` ========================================================================
> _