|
|
|
"""
|
|
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 ===")
|
|
|
|
|
|
engine = GameEngine()
|
|
|
|
|
|
if not engine._running:
|
|
engine.start()
|
|
|
|
|
|
plugin_service = engine.get_service('plugin')
|
|
|
|
if not plugin_service:
|
|
print("❌ Plugin service not found!")
|
|
return
|
|
|
|
|
|
status = plugin_service.get_all_plugin_status()
|
|
print(f"📊 Plugin Status: {status}")
|
|
|
|
|
|
loaded_plugins = plugin_service.get_loaded_plugins()
|
|
print(f"🔌 Loaded Plugins ({len(loaded_plugins)}): {loaded_plugins}")
|
|
|
|
|
|
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 ===")
|
|
|
|
|
|
engine = GameEngine()
|
|
world = engine.get_world()
|
|
|
|
|
|
if hasattr(world, 'addon_npcs'):
|
|
print(f"🏪 Available addon NPCs: {list(world.addon_npcs.keys())}")
|
|
|
|
|
|
if 'example_merchant' in world.addon_npcs:
|
|
merchant = world.addon_npcs['example_merchant']
|
|
print(f"🛒 Example Merchant found: {merchant}")
|
|
|
|
|
|
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()
|
|
|