File size: 2,179 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
#!/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()