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