File size: 2,582 Bytes
4c75d73
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env python3
"""

Test script to check plugin service status

"""

from src.core.game_engine import GameEngine

def test_plugin_status():
    """Test the plugin service status."""
    print("=== Plugin Service Status Test ===")
    
    # Get the game engine instance
    engine = GameEngine()
    
    # Start the engine if not already started
    if not engine._running:
        engine.start()
    
    # Get the plugin service
    plugin_service = engine.get_service('plugin')
    
    if not plugin_service:
        print("❌ Plugin service not found!")
        return
    
    # Check status
    status = plugin_service.get_all_plugin_status()
    print(f"📊 Plugin Status: {status}")
    
    # Check loaded plugins
    loaded_plugins = plugin_service.get_loaded_plugins()
    print(f"🔌 Loaded Plugins ({len(loaded_plugins)}): {loaded_plugins}")
    
    # Check individual plugin statuses
    for plugin_id in loaded_plugins:
        plugin = plugin_service.get_plugin(plugin_id)
        if plugin:
            try:
                if hasattr(plugin, 'get_status'):
                    plugin_status = plugin.get_status()
                    print(f"  🔧 {plugin_id}: {plugin_status}")
                else:
                    print(f"  🔧 {plugin_id}: No status method")
            except Exception as e:
                print(f"  ❌ {plugin_id}: Error getting status - {e}")

def test_npc_purchase():
    """Test the merchant NPC purchase functionality."""
    print("\n=== NPC Purchase Test ===")
    
    # Get the game engine instance
    engine = GameEngine()
    world = engine.get_world()
    
    # Check if addon_npcs exist
    if hasattr(world, 'addon_npcs'):
        print(f"🏪 Available addon NPCs: {list(world.addon_npcs.keys())}")
        
        # Test example merchant if available
        if 'example_merchant' in world.addon_npcs:
            merchant = world.addon_npcs['example_merchant']
            print(f"🛒 Example Merchant found: {merchant}")
            
            # Test a command
            try:
                response = merchant.handle_command("test_player", "shop")
                print(f"📝 Shop response: {response}")
            except Exception as e:
                print(f"❌ Error testing merchant: {e}")
        else:
            print("🚫 Example merchant not found in addon_npcs")
    else:
        print("🚫 No addon_npcs found in world")

if __name__ == "__main__":
    test_plugin_status()
    test_npc_purchase()