From a854a1862a30632e49520f6e1e11333d5c8ff241 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Wed, 27 Nov 2024 14:36:20 +0100 Subject: next commit --- UI/GameLobby/game_lobby.gd | 6 +++--- UI/GameLobby/lobby_game.gd | 15 +++++++++------ 2 files changed, 12 insertions(+), 9 deletions(-) (limited to 'UI/GameLobby') diff --git a/UI/GameLobby/game_lobby.gd b/UI/GameLobby/game_lobby.gd index 9f13882..85a8a91 100644 --- a/UI/GameLobby/game_lobby.gd +++ b/UI/GameLobby/game_lobby.gd @@ -16,11 +16,11 @@ func _ready() -> void: $RefreshTimer.wait_time = refresh_interval $RefreshTimer.start() else: - %ServerNotReachable.text = %ServerNotReachable.text.replace("%SERVER%", Client.game_lobby_url) + %ServerNotReachable.text = %ServerNotReachable.text.replace("%SERVER%", GameLobby.server_base_url) func check_game_lobby_available(): - var is_available = await Client.check_game_lobby_available() + var is_available = await GameLobby.check_available() %ServerNotReachable.visible = !is_available @@ -28,7 +28,7 @@ func check_game_lobby_available(): func get_server_list(): - var response = await Client.request("%s/?get-list" % [Client.game_lobby_url], [], HTTPClient.METHOD_GET) + var response = await GameLobby.request_get("/get-list") var result = response.parse_json() print(result) diff --git a/UI/GameLobby/lobby_game.gd b/UI/GameLobby/lobby_game.gd index 4736d44..2433dfd 100644 --- a/UI/GameLobby/lobby_game.gd +++ b/UI/GameLobby/lobby_game.gd @@ -11,9 +11,12 @@ func set_game_name(value): func _on_join_pressed() -> void: - var response = await Network.request("%s/?join=%s" % [Client.game_lobby_url, game_id]) - var result = response.parse_json() - var game_data = result["data"] - - Network.join_game(game_data["ip"], game_data["port"]) - get_tree().change_scene_to_file("res://UI/PlayerLobby/Lobby.tscn") + var response = await GameLobby.request_get("/join?id=%s" % [game_id]) + if response.response_code == 200: + var result = response.parse_json() + var game_data = result["data"] + + Network.join_game(game_data["ip"], game_data["port"]) + get_tree().change_scene_to_file("res://UI/PlayerLobby/Lobby.tscn") + else: + print(response.response_code) -- cgit v1.2.3