| |
|
| | """
|
| | Test script to verify keyboard controls integration in the running MMORPG application.
|
| | """
|
| |
|
| | import requests
|
| | import time
|
| | from src.core.game_engine import GameEngine
|
| | from src.facades.game_facade import GameFacade
|
| |
|
| | def test_keyboard_integration():
|
| | """Test that keyboard controls are properly integrated."""
|
| | print("🎮 Testing Keyboard Controls Integration")
|
| | print("=" * 50)
|
| |
|
| | try:
|
| |
|
| | engine = GameEngine()
|
| | facade = GameFacade(engine)
|
| |
|
| |
|
| | player_id = facade.join_game("KeyboardTester")
|
| | print(f"✅ Player created: {player_id}")
|
| |
|
| |
|
| | movements = [
|
| | ("up", "🔼"),
|
| | ("down", "🔽"),
|
| | ("left", "◀️"),
|
| | ("right", "▶️")
|
| | ]
|
| |
|
| | print("\n🎯 Testing movement commands (keyboard backend):")
|
| | for direction, icon in movements:
|
| | try:
|
| | result = facade.move_player(player_id, direction)
|
| | print(f" {icon} Move {direction}: {'✅' if result else '❌'}")
|
| | except Exception as e:
|
| | print(f" {icon} Move {direction}: ❌ ({str(e)})")
|
| |
|
| |
|
| | try:
|
| | result = facade.action_command(player_id, "special")
|
| | print(f" ⚡ Special action: {'✅' if result else '❌'}")
|
| | except Exception as e:
|
| | print(f" ⚡ Special action: ❌ ({str(e)})")
|
| |
|
| |
|
| | print(f"\n🌐 Testing server connectivity:")
|
| | try:
|
| | response = requests.get("http://localhost:7865", timeout=5)
|
| | print(f" Server status: {'✅ Online' if response.status_code == 200 else '❌ Error'}")
|
| | print(f" Response time: {response.elapsed.total_seconds():.2f}s")
|
| | except Exception as e:
|
| | print(f" Server status: ❌ ({str(e)})")
|
| |
|
| |
|
| | facade.leave_game(player_id)
|
| | print(f"\n🧹 Cleanup: Player {player_id} removed")
|
| |
|
| | except Exception as e:
|
| | print(f"❌ Test failed: {str(e)}")
|
| | return False
|
| |
|
| | print("\n" + "=" * 50)
|
| | print("🎉 Keyboard Integration Test Complete!")
|
| | print("✅ Backend movement commands working")
|
| | print("✅ Server responding")
|
| | print("✅ Ready for frontend keyboard controls")
|
| | print("\n💡 To test keyboard controls:")
|
| | print(" 1. Open http://localhost:7865 in browser")
|
| | print(" 2. Join the game with a player name")
|
| | print(" 3. Try WASD or Arrow keys for movement")
|
| | print(" 4. Try Spacebar for special action")
|
| | return True
|
| |
|
| | if __name__ == "__main__":
|
| | test_keyboard_integration()
|
| |
|