mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-13 22:32:09 +00:00
feat(multiplayer): explain allocation lifecycle
This commit is contained in:
@@ -190,7 +190,9 @@ func _render(snapshot: Dictionary) -> void:
|
||||
elif phase == MatchmakingState.PROPOSED:
|
||||
detail_label.text = proposal_countdown_text(int(snapshot.get("expires_at_unix", 0)), int(Time.get_unix_time_from_system()))
|
||||
elif phase == MatchmakingState.ACCEPTED:
|
||||
detail_label.text = "All players accepted; preparing the match server"
|
||||
detail_label.text = phase_detail_label(phase)
|
||||
elif phase in [MatchmakingState.ALLOCATING, MatchmakingState.PROCESS_READY, MatchmakingState.ASSIGNMENT_READY, MatchmakingState.ASSIGNED, MatchmakingState.CONNECTING, MatchmakingState.LIVE]:
|
||||
detail_label.text = phase_detail_label(phase)
|
||||
elif phase == MatchmakingState.RESULT_PENDING:
|
||||
detail_label.text = "The server is confirming the final result"
|
||||
elif phase == MatchmakingState.COMPLETED:
|
||||
@@ -210,6 +212,26 @@ static func _is_terminal(phase: String) -> bool:
|
||||
return phase in [MatchmakingState.CANCELLED, MatchmakingState.EXPIRED, MatchmakingState.FAILED, MatchmakingState.LIVE, MatchmakingState.COMPLETED]
|
||||
|
||||
|
||||
static func phase_detail_label(phase: String) -> String:
|
||||
match phase:
|
||||
MatchmakingState.ACCEPTED:
|
||||
return "All players accepted; preparing the match server"
|
||||
MatchmakingState.ALLOCATING:
|
||||
return "Finding a dedicated match server"
|
||||
MatchmakingState.PROCESS_READY:
|
||||
return "Match server started; preparing player assignments"
|
||||
MatchmakingState.ASSIGNMENT_READY:
|
||||
return "Player assignments are ready"
|
||||
MatchmakingState.ASSIGNED:
|
||||
return "Your match server is ready"
|
||||
MatchmakingState.CONNECTING:
|
||||
return "Connecting to the match server"
|
||||
MatchmakingState.LIVE:
|
||||
return "Match in progress"
|
||||
_:
|
||||
return ""
|
||||
|
||||
|
||||
static func proposal_countdown_text(expires_at_unix: int, now_unix: int) -> String:
|
||||
if expires_at_unix <= 0:
|
||||
return "Review the proposal before the countdown expires"
|
||||
|
||||
@@ -23,3 +23,10 @@ func test_proposal_countdown_uses_authoritative_expiry_and_clamps_after_expiry()
|
||||
assert_eq(Matchmaking.proposal_countdown_text(1100, 1000), "Review proposal · 100s remaining", "proposal countdown uses server expiry")
|
||||
assert_eq(Matchmaking.proposal_countdown_text(1000, 1001), "Review proposal · 0s remaining", "expired proposal countdown clamps to zero")
|
||||
assert_eq(Matchmaking.proposal_countdown_text(0, 1000), "Review the proposal before the countdown expires", "missing expiry retains compatible copy")
|
||||
|
||||
|
||||
func test_allocation_lifecycle_phases_have_specific_detail_copy() -> void:
|
||||
for phase in [MatchmakingState.ACCEPTED, MatchmakingState.ALLOCATING, MatchmakingState.PROCESS_READY, MatchmakingState.ASSIGNMENT_READY, MatchmakingState.ASSIGNED, MatchmakingState.CONNECTING, MatchmakingState.LIVE]:
|
||||
assert_true(not Matchmaking.phase_detail_label(phase).is_empty(), "phase %s has lifecycle detail copy" % phase)
|
||||
assert_true(Matchmaking.phase_detail_label(MatchmakingState.ALLOCATING).contains("dedicated"), "allocation explains dedicated server provisioning")
|
||||
assert_true(Matchmaking.phase_detail_label(MatchmakingState.CONNECTING).contains("Connecting"), "connecting explains the active transport step")
|
||||
|
||||
Reference in New Issue
Block a user