summaryrefslogtreecommitdiff
path: root/UI/Start.gd
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2024-11-27 14:36:20 +0100
committerDaniel Weipert <git@mail.dweipert.de>2024-11-27 14:36:20 +0100
commita854a1862a30632e49520f6e1e11333d5c8ff241 (patch)
tree2b10c4d19bb66b270a7726d660ed85d7fcf9482e /UI/Start.gd
parentcb9bb9d1c757b53707c741a3c8c218b513ffb5ec (diff)
next commit
Diffstat (limited to 'UI/Start.gd')
-rw-r--r--UI/Start.gd13
1 files changed, 4 insertions, 9 deletions
diff --git a/UI/Start.gd b/UI/Start.gd
index b078d65..85a7946 100644
--- a/UI/Start.gd
+++ b/UI/Start.gd
@@ -22,7 +22,7 @@ func get_ip() -> String:
func get_port() -> int:
- var port := 1234
+ var port: int = Client.get_config().get_value("general", "host_default_port")
if %Port.text:
port = int(%Port.text)
@@ -38,17 +38,12 @@ func _on_peer_disconnected(id):
func _on_host_pressed() -> void:
Client.player.username = %Username.text
- var response = await Client.request(
- "%s" % [Client.game_lobby_url],
- [],
- HTTPClient.METHOD_POST,
- JSON.stringify({"host": true, "port": get_port(), "name" : %GameName.text})
- )
-
+ var response = await GameLobby.request_post("/host", {"port": get_port(), "name" : %GameName.text})
if response.result_code == HTTPRequest.RESULT_SUCCESS:
var result = response.parse_json()
if result["success"]:
- Client.current_game_id = result["data"]
+ GameLobby.current_game_id = result["data"]["id"]
+ GameLobby.current_secret = result["data"]["secret"]
Network.host_game(get_port())
get_tree().change_scene_to_file("res://UI/PlayerLobby/Lobby.tscn")