feat: update the rematch, lobby, leaderboard

This commit is contained in:
2026-03-30 16:56:35 +08:00
parent 3035a221ba
commit fb20af1ae5
5 changed files with 140 additions and 121 deletions
+7 -5
View File
@@ -846,23 +846,25 @@ func _on_server_disconnected() -> void:
func reset_rematch_votes() -> void:
rematch_votes.clear()
emit_signal("rematch_votes_updated", 0, 2)
var required = max(1, ceili(players_in_room.size() / 2.0))
emit_signal("rematch_votes_updated", 0, required)
@rpc("any_peer", "call_local", "reliable")
func request_rematch(player_id: int) -> void:
"""Client requests a rematch. Only 2 votes needed to trigger."""
"""Client requests a rematch. Votes needed depend on connected real players."""
if not multiplayer.is_server():
return
if player_id not in rematch_votes:
rematch_votes.append(player_id)
print("[LobbyManager] Rematch vote from %d. Total: %d/2" % [player_id, rematch_votes.size()])
var required = max(1, ceili(players_in_room.size() / 2.0))
print("[LobbyManager] Rematch vote from %d. Total: %d/%d" % [player_id, rematch_votes.size(), required])
# Sync vote count to all clients
rpc("sync_rematch_votes", rematch_votes.size(), 2)
rpc("sync_rematch_votes", rematch_votes.size(), required)
# Check if we have enough votes
if rematch_votes.size() >= 2:
if rematch_votes.size() >= required:
print("[LobbyManager] Rematch threshold met! Starting game...")
start_rematch()