File size: 4,230 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/usr/bin/env python3
"""

Verification script to demonstrate the private chat dropdown fix.

Shows that dropdown now displays human-readable names instead of entity IDs.

"""

import sys
import os
sys.path.append(os.path.dirname(os.path.abspath(__file__)))

def verify_dropdown_fix():
    """Verify that the dropdown fix is working correctly."""
    try:        
        print("🔧 Verifying Private Chat Dropdown Fix...")
        print("="*50)
        
        from src.core.game_engine import GameEngine
        from src.ui.interface_manager import InterfaceManager
        from src.ui.huggingface_ui import HuggingFaceUI
        from src.facades.game_facade import GameFacade
        from src.core.player import Player
        
        # Initialize system
        game_engine = GameEngine()
        game_facade = GameFacade(game_engine)
        ui = HuggingFaceUI(game_facade)
        interface_manager = InterfaceManager(game_facade, ui)
        
        # Create test players
        player1 = Player("FixTestPlayer1")
        player2 = Player("FixTestPlayer2")
        
        game_engine.get_world().add_player(player1)
        game_engine.get_world().add_player(player2)
        
        # Position them together for proximity
        player1.x, player1.y = 100, 100
        player2.x, player2.y = 110, 110
        
        print(f"✅ Created test players:")
        print(f"   - {player1.name}: {player1.id}")
        print(f"   - {player2.name}: {player2.id}")
        
        # Test proximity detection and dropdown choices
        proximity_html, choices, has_entities = interface_manager._get_proximity_info(player1.id)
        
        print(f"\n📡 Proximity Detection Results:")
        print(f"   - Has nearby entities: {has_entities}")
        print(f"   - Number of choices: {len(choices)}")
        print(f"   - Raw choices: {choices}")
        
        print(f"\n🎯 Dropdown Display Analysis:")
        for i, choice in enumerate(choices, 1):
            # Check if it looks like an entity ID (long alphanumeric string)
            is_entity_id = len(choice) > 20 and '-' in choice
            # Check if it's a human-readable name
            is_readable_name = not is_entity_id and len(choice) < 30
            
            print(f"   Choice {i}: '{choice}'")
            if is_entity_id:
                print(f"     ❌ ISSUE: Shows entity ID instead of name")
            elif is_readable_name:
                print(f"     ✅ GOOD: Shows human-readable name")
            else:
                print(f"     ⚠️  UNKNOWN: Format unclear")
        
        # Verify entity name mapping
        print(f"\n🗺️  Entity Name-to-ID Mapping:")
        if hasattr(interface_manager, 'entity_name_to_id'):
            for name, entity_id in interface_manager.entity_name_to_id.items():
                print(f"   - '{name}' -> {entity_id}")
        else:
            print("   ❌ No entity name mapping found")
        
        # Test specific entity name resolution
        print(f"\n🔍 Entity Name Resolution Test:")
        # Test NPC
        npc_name = interface_manager._get_entity_name('scholar')
        print(f"   - NPC ID 'scholar' resolves to: '{npc_name}'")
        
        # Test Player
        player_name = interface_manager._get_entity_name(player2.id)
        print(f"   - Player ID '{player2.id}' resolves to: '{player_name}'")
        
        # Final assessment
        print(f"\n🏆 Fix Assessment:")
        all_readable = all(not (len(choice) > 20 and '-' in choice) for choice in choices)
        if all_readable:
            print("   ✅ SUCCESS: All dropdown choices show human-readable names!")
            print("   ✅ The private chat dropdown fix is working correctly.")
        else:
            print("   ❌ ISSUE: Some dropdown choices still show entity IDs.")
        
        return all_readable
        
    except Exception as e:
        print(f"❌ Verification failed: {e}")
        import traceback
        traceback.print_exc()
        return False

if __name__ == "__main__":
    success = verify_dropdown_fix()
    sys.exit(0 if success else 1)