Add ready lobby and reconnect support

This commit is contained in:
Emporex committed 2026-10-04 04:31:52 +02:00
1 parent 19b1a67773
commit 32594c7f81
8 files changed
+215 -36

No files matched your search

+18 -2
View File
@@ -32,9 +32,9 @@ func _run() -> void:
assert(not info.is_exception(), "Die Godot-Anbindung muss Server-RPCs erreichen.")
var info_data = JSON.parse_string(info.payload)
assert(info_data is Dictionary and info_data.get("status") == "online", "Der Server muss seinen Onlinestatus melden.")
assert(info_data.get("version") == "0.20", "Der Server muss die aktuelle Runtime 0.20 geladen haben: %s" % info_data)
assert(info_data.get("version") == "0.21", "Der Server muss die aktuelle Runtime 0.21 geladen haben: %s" % info_data)
var run_payload := JSON.stringify({"map": 1, "difficulty": 1, "mode": "mission", "wave": 4, "score": 4700, "client_version": "0.20-integration"})
var run_payload := JSON.stringify({"map": 1, "difficulty": 1, "mode": "mission", "wave": 4, "score": 4700, "client_version": "0.21-integration"})
var submitted = await client_a.rpc_async(session_a, "submit_run", run_payload)
assert(not submitted.is_exception(), "Ein plausibles Ergebnis muss serverseitig angenommen werden.")
var records = await client_a.list_leaderboard_records_async(session_a, "mission_map1_difficulty1", null, null, 10)
@@ -62,6 +62,10 @@ func _run() -> void:
var match_b = await socket_b.join_matched_async(matched_b)
assert(not match_a.is_exception() and not match_b.is_exception(), "Beide Spieler müssen der autoritativen Koop-Partie beitreten können.")
assert(match_a.match_id == match_b.match_id, "Beide Spieler müssen dieselbe Koop-Partie erhalten.")
await create_timer(0.2).timeout
assert(not bool(snapshot_a.get("started", false)), "Die Partie darf vor der Bereitschaft beider Spieler nicht starten.")
await socket_a.send_match_state_async(match_a.match_id, 14, JSON.stringify({"ready": true, "name": "TESTPILOT ALPHA"}))
await socket_b.send_match_state_async(match_b.match_id, 14, JSON.stringify({"ready": true, "name": "TESTPILOT BETA"}))
for attempt in 100:
if bool(snapshot_a.get("started", false)) and bool(snapshot_b.get("started", false)):
break
@@ -103,6 +107,18 @@ func _run() -> void:
assert(found_data is Dictionary and String(found_data.get("match_id", "")) == private_match_id, "Der Raumcode muss genau zur erstellten Partie führen: %s" % found_data)
var private_match_b = await socket_b.join_match_async(private_match_id)
assert(not private_match_b.is_exception(), "Der Mitspieler muss dem privaten Raum beitreten können.")
await create_timer(0.2).timeout
assert(not bool(snapshot_a.get("started", false)), "Auch private Räume müssen auf die Bereitschaft beider Spieler warten.")
var lobby_players: Array = snapshot_a.get("players", [])
assert(lobby_players.size() == 2 and lobby_players[0] is Dictionary and lobby_players[1] is Dictionary, "Die Lobby muss beide Spielerplätze anzeigen.")
assert(not (await socket_b.leave_match_async(private_match_id)).is_exception(), "Ein Mitspieler muss die Lobby verlassen können.")
await create_timer(0.2).timeout
lobby_players = snapshot_a.get("players", [])
assert(lobby_players.size() == 2 and not bool(lobby_players[1].get("connected", true)), "Die Lobby muss einen getrennten Mitspieler erkennen.")
private_match_b = await socket_b.join_match_async(private_match_id)
assert(not private_match_b.is_exception(), "Der reservierte Spieler muss demselben Raum wieder beitreten können.")
await socket_a.send_match_state_async(private_match_id, 14, JSON.stringify({"ready": true, "name": "TESTPILOT ALPHA"}))
await socket_b.send_match_state_async(private_match_id, 14, JSON.stringify({"ready": true, "name": "TESTPILOT BETA"}))
for attempt in 100:
if bool(snapshot_a.get("started", false)) and bool(snapshot_b.get("started", false)):
break