> cat /wizhelp/wizadvanced7

========================================================================
                  Advanced: Debugging Tips
========================================================================

How to debug your wizard creations effectively.

DEBUG LOG:
Check debug.log in your wizard directory:
/lib/wizrooms/<yourname>/debug.log

COMMON ERRORS:

1. Import Errors:
```python
# WRONG - missing import
room = Room(...)  # NameError

# RIGHT - import first
from lib.models.entity import Room
room = Room(...)
```

2. No load() function:
```python
# WRONG - won't load
room = Room(name="test")

# RIGHT - use load()
def load():
    return Room(name="test")
```

3. Invalid room names:
```python
# WRONG - spaces break goto
name="my cool room"

# RIGHT - use underscores
name="my_cool_room"
```

4. Missing destinations:
```python
# Check if destination exists
exit = Exit("north", "fake_room")  # Error!

# Better - verify first
if "target_room" in game_state.rooms:
    exit = Exit("north", "target_room")
```

TESTING COMMANDS:
Add debug messages to test:
```python
def my_command(player, params):
    player.message(f"DEBUG: params = {params}")
    player.message(f"DEBUG: location = {player._location}")
    
    # Your code here
    
    player.message("DEBUG: command completed")
```

ROOM TESTING:
```python
def load():
    room = Room(name="test_room")
    
    # Add test command
    def test(player, params):
        player.message(f"Room name: {room.name}")
        player.message(f"Exits: {len(room.exits)}")
        player.message(f"Items: {room.inventory.count()}")
    
    room.custom_commands = {"test": test}
    return room
```

OBJECT TESTING:
```python
# Test cloning
clone battle_sword
examine battle_sword
wield battle_sword

# Test values
clone 100 coins
inv
```

PLUGIN DEBUGGING:
```python
import logging
log = logging.getLogger(__name__)

def my_plugin_function(player, params):
    log.info(f"Plugin called by {player.name} with {params}")
    try:
        # Your code
        pass
    except Exception as e:
        log.error(f"Plugin error: {e}")
        player.message("Plugin error - check logs")
```

COMBAT TESTING:
```python
# Create test weapon with debug
weapon = Weapon(
    name="debug_sword",
    damage=50
)

# Add debug flag
weapon.debug = True

# In combat hook
if hasattr(weapon, 'debug'):
    attacker.message(f"DEBUG: Base damage = {damage}")
```

TIPS:
- Start simple, add complexity
- Test each feature separately
- Use goto to verify rooms load
- Check player messages for errors
- Review working examples
- Ask other wizards for help

========================================================================    

> _