MMORPG_AI_NPC_MCP_CLIENT_SERVER / tests /test_enhanced_chat.py
Chris4K's picture
Upload 195 files
4c75d73 verified
#!/usr/bin/env python3
"""
Test script for enhanced chat features (emotes, commands)
"""
import sys
import os
# Add the src directory to Python path
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src'))
def test_enhanced_chat():
try:
from src.core.game_engine import get_game_engine
from src.facades.game_facade import GameFacade
print("🧪 Testing Enhanced Chat Features...")
# Get game instances
facade = GameFacade()
# Add test player
player_id = facade.join_game('ChatTester')
print(f"✅ Created player: {player_id}")
print("\n🎭 Testing Emotes...")
# Test emote processing
emote_messages = [
"Hello :smile: everyone!",
"This is :fire: amazing!",
"Good job :thumbsup: team!",
":wave: Hey there :heart:"
]
for msg in emote_messages:
success = facade.send_chat_message(player_id, msg)
print(f"📤 Emote message '{msg}' sent: {success}")
print("\n🔧 Testing Chat Commands...")
# Test chat commands
commands = [
"/help",
"/emotes",
"/channels",
"/time",
"/invalid_command"
]
for cmd in commands:
success = facade.send_chat_message(player_id, cmd)
print(f"⚡ Command '{cmd}' sent: {success}")
print("\n📜 Recent Chat History:")
chat_history = facade.get_chat_history(10)
for i, msg in enumerate(chat_history[-10:], 1):
sender = msg.get('sender', 'Unknown')
message = msg.get('message', '')
msg_type = msg.get('type', 'unknown')
print(f" {i}. [{msg_type}] {sender}: {message}")
print("\n✅ Enhanced chat test completed successfully!")
except Exception as e:
print(f"❌ Test failed: {e}")
import traceback
traceback.print_exc()
if __name__ == "__main__":
test_enhanced_chat()