feat: Implement core multiplayer features including user authentication, profile management, lobby, game mode managers, and leaderboard.

This commit is contained in:
2026-03-12 03:55:20 +08:00
parent 650d241a72
commit 4f6783b468
13 changed files with 1151 additions and 31 deletions
+7 -10
View File
@@ -9,10 +9,6 @@ signal player_penalized(player_id: int)
enum Phase {GO, STOP}
const GO_DURATION: float = 15.0
const STOP_DURATION: float = 4.0
const REQUIRED_GOALS: int = 8
# Dynamic Safe Zone
const SAFE_ZONE_PRE_TIME: float = 5.0 # Seconds before STOP to spawn safe zone
const SAFE_ZONE_RADIUS: int = 2 # 5x5 area (radius 2 from center)
@@ -34,7 +30,7 @@ const PERMANENT_POWERUP_LOCATIONS: Array[Vector2i] = [
]
var current_phase: Phase = Phase.GO
var phase_timer: float = GO_DURATION
var phase_timer: float = 15.0 # Initialized dynamically later
var is_active: bool = false
var player_missions: Dictionary = {} # player_id -> {target_tile: int, required: int, current: int}
@@ -134,10 +130,11 @@ func _update_hud_visuals():
# Get count from GoalsCycleManager (Source of truth for PlayerBoardLabel)
var completed_count = goals_cycle_manager.player_goal_counts.get(my_id, 0) if goals_cycle_manager else 0
var required_goals = LobbyManager.sng_required_goals
mission_label.text = "GOALS (%d/%d)" % [completed_count, REQUIRED_GOALS]
mission_label.text = "GOALS (%d/%d)" % [completed_count, required_goals]
if completed_count >= REQUIRED_GOALS:
if completed_count >= required_goals:
mission_label.text = "ALL GOALS COMPLETE!\nREACH THE FINISH!"
mission_label.add_theme_color_override("font_color", Color.GOLD)
@@ -235,7 +232,7 @@ func start_game_mode():
func _start_phase(phase: Phase):
current_phase = phase
phase_timer = GO_DURATION if phase == Phase.GO else STOP_DURATION
phase_timer = float(LobbyManager.sng_go_duration) if phase == Phase.GO else float(LobbyManager.sng_stop_duration)
var phase_name = "GO" if phase == Phase.GO else "STOP"
if can_rpc():
@@ -436,7 +433,7 @@ func is_mission_complete(player_id: int) -> bool:
if not goals_cycle_manager: return false
var completed_count = goals_cycle_manager.player_goal_counts.get(player_id, 0)
return completed_count >= REQUIRED_GOALS
return completed_count >= LobbyManager.sng_required_goals
func check_win_condition(player_id: int, position: Vector2i) -> bool:
# 1. Must reach the finish line (Column 21)
@@ -452,7 +449,7 @@ func check_win_condition(player_id: int, position: Vector2i) -> bool:
var main = get_node_or_null("/root/Main")
var player_node = main.get_node_or_null(str(player_id)) if main else null
if player_node:
NotificationManager.send_message(player_node, "Incomplete! Achieve %d goals to win!" % REQUIRED_GOALS, NotificationManager.MessageType.WARNING)
NotificationManager.send_message(player_node, "Incomplete! Achieve %d goals to win!" % LobbyManager.sng_required_goals, NotificationManager.MessageType.WARNING)
print("[StopNGo] Player %d reached finish but goals incomplete." % player_id)
return false