feat: the rebuild gamemode of "Gauntlet"
This commit is contained in:
@@ -72,11 +72,11 @@ func show_panel() -> void:
|
||||
status_label.text = "Syncing scores..."
|
||||
# Bulk-sync all users' storage stats to native leaderboard (server-side operation)
|
||||
if NakamaManager.session:
|
||||
var sync_result = await NakamaManager.client.rpc_async(NakamaManager.session, "sync_leaderboard", "{}")
|
||||
if sync_result.is_exception():
|
||||
push_error("[Leaderboard] sync_leaderboard RPC failed: ", sync_result.get_exception().message)
|
||||
var sync_result = await BackendService.sync_leaderboard()
|
||||
if sync_result.get("success", false) == false:
|
||||
push_error("[Leaderboard] sync_leaderboard RPC failed: " + str(sync_result.get("error", "")))
|
||||
else:
|
||||
print("[Leaderboard] Server sync finished: ", sync_result.payload)
|
||||
print("[Leaderboard] Server sync finished: ", sync_result.get("data", {}))
|
||||
_fetch_leaderboard_data()
|
||||
|
||||
func _on_close_pressed() -> void:
|
||||
@@ -150,29 +150,25 @@ func _fetch_native_leaderboard() -> Array:
|
||||
|
||||
func _fetch_via_rpc() -> void:
|
||||
"""Fallback: call server RPC which reads the same native leaderboard."""
|
||||
var result = await NakamaManager.client.rpc_async(NakamaManager.session, "get_leaderboard_stats", "{}")
|
||||
var result = await BackendService.get_leaderboard_stats()
|
||||
|
||||
if result.is_exception():
|
||||
if result.get("success", false) == false:
|
||||
status_label.text = "Failed to load leaderboard"
|
||||
push_error("[Leaderboard] RPC failed: ", result.get_exception().message)
|
||||
push_error("[Leaderboard] RPC failed: " + str(result.get("error", "")))
|
||||
return
|
||||
|
||||
var json := JSON.new()
|
||||
if json.parse(result.payload) == OK:
|
||||
var data = json.get_data()
|
||||
if data.has("leaderboard") and data.leaderboard.size() > 0:
|
||||
_apply_local_overrides(data.leaderboard)
|
||||
leaderboard_data = data.leaderboard
|
||||
_calculate_win_rates()
|
||||
status_label.text = ""
|
||||
_sort_by(current_sort_key)
|
||||
if leaderboard_data.size() > 0:
|
||||
_show_entry_preview(0)
|
||||
else:
|
||||
# No records exist yet — show a helpful hint
|
||||
status_label.text = "No scores recorded yet.\nPlay a match to appear here!"
|
||||
var data = result.get("data", {})
|
||||
if data.has("leaderboard") and data.leaderboard.size() > 0:
|
||||
_apply_local_overrides(data.leaderboard)
|
||||
leaderboard_data = data.leaderboard
|
||||
_calculate_win_rates()
|
||||
status_label.text = ""
|
||||
_sort_by(current_sort_key)
|
||||
if leaderboard_data.size() > 0:
|
||||
_show_entry_preview(0)
|
||||
else:
|
||||
status_label.text = "Error parsing server data"
|
||||
# No records exist yet — show a helpful hint
|
||||
status_label.text = "No scores recorded yet.\nPlay a match to appear here!"
|
||||
|
||||
func _calculate_win_rates() -> void:
|
||||
for entry in leaderboard_data:
|
||||
|
||||
Reference in New Issue
Block a user