feat: overhaul the nakama user management, leaderboard, prep for 2.1
This commit is contained in:
@@ -2182,6 +2182,25 @@ func _show_game_over_panel():
|
||||
var local_peer_id = multiplayer.get_unique_id()
|
||||
panel.setup(all_player_scores, local_peer_id)
|
||||
|
||||
# --- REPORT NAKAMA MATCH STATS ---
|
||||
var local_player_won = false
|
||||
var local_player_score = 0
|
||||
|
||||
if all_player_scores.size() > 0:
|
||||
# all_player_scores is sorted descending by score or winner ID, so index 0 is the winner
|
||||
if all_player_scores[0].peer_id == local_peer_id:
|
||||
local_player_won = true
|
||||
|
||||
for data in all_player_scores:
|
||||
if data.peer_id == local_peer_id:
|
||||
local_player_score = data.score
|
||||
break
|
||||
|
||||
# Send match result to Nakama storage via UserProfileManager (runs async)
|
||||
if get_node_or_null("/root/UserProfileManager"):
|
||||
UserProfileManager.record_game_result(local_player_won, local_player_score)
|
||||
# ---------------------------------
|
||||
|
||||
# Connect signals
|
||||
panel.back_pressed.connect(_on_back_to_menu_pressed)
|
||||
panel.rematch_pressed.connect(func():
|
||||
|
||||
Reference in New Issue
Block a user