Phase 5: N-player ELO, spectator-for-eliminated, turn-limit/concede N-player paths
- GameEngine: GetNPlayerTurnLimitWinners() ranks surviving players by ArchSpirit HP; highest-HP player(s) win, rest lose - GameConcedeHandler: N-player path — conceder is loser, remaining non-eliminated players are winners; delegates to FinalizeMultiPlayerGameAsync - GameForceConcedeHandler: same N-player/1v1 branch split for inactivity forfeit - GameEndTurnHandler: N-player path uses GetNPlayerTurnLimitWinners + FinalizeMultiPlayerGameAsync on turn-limit game-over - GameTurnTimerService: same N-player/1v1 branch on timer-expiry game-over - Game.gd: player_eliminated signal + game.player_eliminated push handler - game_screen.gd: _on_player_eliminated shows AcceptDialog; sets _is_spectating=true for the local player so they can watch the rest of the game Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
@@ -37,6 +37,9 @@ signal inactive_warning(session_id: String)
|
||||
## Both players must wait — no concede or force-concede is allowed.
|
||||
signal both_idle_warning(session_id: String)
|
||||
|
||||
## Emitted when a player is knocked out mid-game (game continues for others).
|
||||
signal player_eliminated(session_id: String, eliminated_account_id: String, seat_index: int, team_index: int)
|
||||
|
||||
## Emitted when a game session starts or ends (from game.activity pushes).
|
||||
## Used by game_screen.gd to drive the live-star skybox.
|
||||
## event_type: "started" | "ended"
|
||||
@@ -576,6 +579,14 @@ func _on_server_push(type: String, payload: Variant) -> void:
|
||||
print("[Game] PUSH both_idle_warning session=", sid)
|
||||
both_idle_warning.emit(sid)
|
||||
|
||||
"game.player_eliminated":
|
||||
var d := payload as Dictionary
|
||||
player_eliminated.emit(
|
||||
str(d.get("sessionId", "")),
|
||||
str(d.get("eliminatedAccountId", "")),
|
||||
int(d.get("seatIndex", -1)),
|
||||
int(d.get("teamIndex", -1)))
|
||||
|
||||
"game.activity":
|
||||
var d := payload as Dictionary
|
||||
var ev_type : String = str(d.get("eventType", ""))
|
||||
|
||||
@@ -250,6 +250,7 @@ func _ready() -> void:
|
||||
Game.opponent_inactive.connect(_on_opponent_inactive)
|
||||
Game.inactive_warning.connect(_on_inactive_warning)
|
||||
Game.both_idle_warning.connect(_on_both_idle_warning)
|
||||
Game.player_eliminated.connect(_on_player_eliminated)
|
||||
|
||||
if Game.is_spectating:
|
||||
_is_spectating = true
|
||||
@@ -286,6 +287,8 @@ func _exit_tree() -> void:
|
||||
Game.inactive_warning.disconnect(_on_inactive_warning)
|
||||
if Game.both_idle_warning.is_connected(_on_both_idle_warning):
|
||||
Game.both_idle_warning.disconnect(_on_both_idle_warning)
|
||||
if Game.player_eliminated.is_connected(_on_player_eliminated):
|
||||
Game.player_eliminated.disconnect(_on_player_eliminated)
|
||||
if Game.game_activity.is_connected(_on_game_activity):
|
||||
Game.game_activity.disconnect(_on_game_activity)
|
||||
if Settings.settings_changed.is_connected(_on_skybox_setting_changed):
|
||||
@@ -3460,6 +3463,26 @@ func _on_both_idle_warning(_sid: String) -> void:
|
||||
|
||||
# ── State → scene ─────────────────────────────────────────────────────────────
|
||||
|
||||
|
||||
## Pushed when a player is knocked out mid-game (FFA / team game continues).
|
||||
func _on_player_eliminated(session_id: String, elim_id: String, _seat_idx: int, _team_idx: int) -> void:
|
||||
if session_id != Game.session_id: return
|
||||
var is_me : bool = elim_id == Auth.user_id
|
||||
var msg : String = (
|
||||
"You have been eliminated!
|
||||
You can continue watching the game as a spectator."
|
||||
if is_me
|
||||
else "Player %s has been eliminated from the game!" % elim_id.substr(0, 8))
|
||||
var dlg := AcceptDialog.new()
|
||||
dlg.title = "Player Eliminated"
|
||||
dlg.dialog_text = msg
|
||||
add_child(dlg)
|
||||
dlg.confirmed.connect(func() -> void: dlg.queue_free())
|
||||
dlg.popup_centered()
|
||||
# If the local player was eliminated, switch to read-only spectator view.
|
||||
if is_me:
|
||||
_is_spectating = true
|
||||
|
||||
func _on_state_updated(state: Dictionary) -> void:
|
||||
print("[StateUpdate] phase=", state.get("phase","?"),
|
||||
" mode=", _mode, " sel_card=",
|
||||
|
||||
Reference in New Issue
Block a user