summaryrefslogtreecommitdiff
path: root/UI/GameLobby/lobby_game.gd
blob: 39f9076aff6e16493125b0ed045a148dee272df1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
extends HBoxContainer

@export var game_id := ""
@export var game_name := "":
	set = set_game_name


func set_game_name(value):
	game_name = value
	%Name.text = value


func _on_join_pressed() -> void:
	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"]
		
		print(game_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)