summaryrefslogtreecommitdiff
path: root/UI/Start.gd
diff options
context:
space:
mode:
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")