mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-10 16:04:04 +00:00
feat: add player-scoped assignment recovery
This commit is contained in:
@@ -19,6 +19,7 @@ var player_id := ""
|
||||
var session_expires_at := ""
|
||||
var state: MatchmakingState
|
||||
var ranked_profile: RankedProfileState
|
||||
var assignment: AssignmentState
|
||||
|
||||
var _request: HTTPRequest
|
||||
var _operation := ""
|
||||
@@ -28,6 +29,7 @@ var _last_queue_create: Dictionary = {}
|
||||
func _ready() -> void:
|
||||
state = MatchmakingState.new()
|
||||
ranked_profile = RankedProfileState.new()
|
||||
assignment = AssignmentState.new()
|
||||
_load_persisted_state()
|
||||
state.changed.connect(_persist_state)
|
||||
_request = HTTPRequest.new()
|
||||
@@ -99,6 +101,12 @@ func fetch_ranked_profile() -> Error:
|
||||
return _start_request("ranked_profile", HTTPClient.METHOD_GET, "/v1/profile/ranked", {}, "")
|
||||
|
||||
|
||||
func fetch_assignment(match_id: String) -> Error:
|
||||
if match_id.is_empty():
|
||||
return ERR_INVALID_PARAMETER
|
||||
return _start_request("assignment", HTTPClient.METHOD_GET, "/v1/assignments/" + match_id, {}, "")
|
||||
|
||||
|
||||
func heartbeat(ticket_id: String, expected_revision: int) -> Error:
|
||||
if ticket_id.is_empty() or expected_revision < 0:
|
||||
return ERR_INVALID_PARAMETER
|
||||
@@ -227,6 +235,10 @@ func _on_request_completed(result: HTTPRequest.Result, response_code: int, _head
|
||||
if not ranked_profile.apply(payload):
|
||||
request_failed.emit(operation, response_code, ranked_profile.error_message)
|
||||
return
|
||||
elif operation == "assignment":
|
||||
if not assignment.apply(payload):
|
||||
request_failed.emit(operation, response_code, assignment.error_message)
|
||||
return
|
||||
request_succeeded.emit(operation, payload)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user