Spaces:
Runtime error
Runtime error
| #!/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() | |