File size: 4,293 Bytes
87532e2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/usr/bin/env python3
"""

MMORPG Application - HuggingFace Space Version

Simplified version for HuggingFace deployment with fallback imports

"""

import gradio as gr
import asyncio
import os
import sys
from typing import Optional

# Add current directory to Python path for HF Spaces
current_dir = os.path.dirname(os.path.abspath(__file__))
if current_dir not in sys.path:
    sys.path.insert(0, current_dir)

def create_fallback_interface():
    """Create a fallback interface if main components fail to load."""
    with gr.Blocks(title="MMORPG - Limited Mode") as interface:
        gr.Markdown("""

        # 🎮 MMORPG Application - Limited Mode

        

        **Note:** Running in limited mode due to import issues.

        

        This is a simplified version that focuses on core functionality.

        """)
        
        with gr.Tab("🔍 SearchHF Oracle"):
            gr.Markdown("""

            ## 🔍 SearchHF Oracle

            

            Advanced Hugging Face search using MCP integration.

            """)
            
            query_input = gr.Textbox(
                label="Search Query", 
                placeholder="e.g., 'text-generation models'"
            )
            search_btn = gr.Button("🔍 Search", variant="primary")
            search_output = gr.Textbox(
                label="Search Results",
                lines=10,
                interactive=False
            )
            
            def simple_search(query):
                if not query.strip():
                    return "❌ Please enter a search query"
                return f"🔍 **Search Results for:** {query}\n\n⚠️ Full MCP integration not available in this environment.\n\nTo use full functionality, please run locally."
            
            search_btn.click(
                simple_search,
                inputs=[query_input],
                outputs=[search_output]
            )
        
        with gr.Tab("ℹ️ About"):
            gr.Markdown("""

            # About MMORPG Application

            

            This is an AI-powered MMORPG with:

            - **MCP Integration** - Model Context Protocol for AI agents

            - **Dynamic NPCs** - AI-powered non-player characters  

            - **Plugin System** - Extensible addon architecture

            - **Real-time Chat** - Multi-channel communication

            - **Trading System** - Virtual economy

            

            ## 🚀 Full Version

            

            For the complete experience with all features, please run the application locally.

            

            ## 🔧 Technical Details

            

            - **Framework:** Gradio + Python

            - **AI Integration:** MCP (Model Context Protocol)

            - **Architecture:** Clean architecture with dependency injection

            """)
    
    return interface

def main():
    """Main application entry point for HuggingFace Spaces."""
    try:
        # Try to import the full application
        from src.core.game_engine import GameEngine
        from src.facades.game_facade import GameFacade
        from src.ui.huggingface_ui import HuggingFaceUI
        from src.ui.improved_interface_manager import ImprovedInterfaceManager
        from src.mcp.mcp_tools import GradioMCPTools
        
        # Initialize full application
        game_engine = GameEngine()
        game_facade = GameFacade()
        ui = HuggingFaceUI(game_facade)
        interface_manager = ImprovedInterfaceManager(game_facade, ui)
        
        # Create the complete interface
        interface = interface_manager.create_interface()
        
        print("✅ Full MMORPG application loaded successfully!")
        
    except Exception as e:
        print(f"⚠️ Failed to load full application: {e}")
        print("🔄 Falling back to limited mode...")
        
        # Create fallback interface
        interface = create_fallback_interface()
    
    # Launch the interface
    interface.launch(
        server_name="0.0.0.0",
        server_port=7860,  # Standard HF port
        share=False,
        show_error=True,
        quiet=False
    )

if __name__ == "__main__":
    main()