Legal docs draft and Client refactor
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
class_name GameOverOverlay
|
||||
extends Node
|
||||
|
||||
## Manages the end-of-game Victory/Defeat overlay.
|
||||
## Node refs are set by game_screen after scene is ready.
|
||||
|
||||
var go_overlay: PanelContainer = null
|
||||
var go_result_lbl: Label = null
|
||||
var go_rank_lbl: Label = null
|
||||
var go_menu_btn: Button = null
|
||||
|
||||
func show_result(winner_id: String, win_condition: String,
|
||||
winner_delta: int, loser_delta: int,
|
||||
player_outcomes: Array = []) -> void:
|
||||
var i_won: bool
|
||||
if not player_outcomes.is_empty():
|
||||
var my_outcome: String = ""
|
||||
for po: Dictionary in player_outcomes:
|
||||
if str(po.get("accountId", "")) == Auth.user_id:
|
||||
my_outcome = str(po.get("outcome", ""))
|
||||
break
|
||||
i_won = (my_outcome == "Winner")
|
||||
else:
|
||||
i_won = (winner_id == Auth.user_id)
|
||||
|
||||
go_result_lbl.text = "Victory!" if i_won else "Defeat"
|
||||
go_result_lbl.modulate = Color(0.4, 1.0, 0.5) if i_won else Color(1.0, 0.4, 0.4)
|
||||
|
||||
if not player_outcomes.is_empty():
|
||||
var outcome_lines: Array = []
|
||||
for po: Dictionary in player_outcomes:
|
||||
var pid: String = str(po.get("accountId", ""))
|
||||
var oc: String = str(po.get("outcome", "?"))
|
||||
var rd: int = int(po.get("rankDelta", 0))
|
||||
var sign: String = "+" if rd >= 0 else ""
|
||||
var label: String = "You" if pid == Auth.user_id else Game.get_display_name(pid)
|
||||
outcome_lines.append("%s: %s (%s%d)" % [label, oc, sign, rd])
|
||||
go_rank_lbl.text = "[%s]\n" % win_condition + "\n".join(outcome_lines)
|
||||
else:
|
||||
var my_delta: int = winner_delta if i_won else loser_delta
|
||||
go_rank_lbl.text = "Win by %s | Rank %s%d" % [
|
||||
win_condition, "+" if my_delta >= 0 else "", my_delta]
|
||||
go_overlay.visible = true
|
||||
|
||||
|
||||
func on_session_abandoned(_reason: String) -> void:
|
||||
get_tree().change_scene_to_file("res://scenes/main/MainScreen.tscn")
|
||||
@@ -0,0 +1 @@
|
||||
uid://c1acrobstx4i5
|
||||
@@ -0,0 +1,72 @@
|
||||
class_name InactiveDialogs
|
||||
extends Node
|
||||
|
||||
## Creates inactivity and player-elimination dialogs dynamically.
|
||||
## Dialogs are added as children of this node (which is a child of game_screen).
|
||||
|
||||
signal spectator_mode_requested() # emitted when local player is eliminated
|
||||
|
||||
func on_opponent_inactive(_sid: String) -> void:
|
||||
var dialog: ConfirmationDialog = ConfirmationDialog.new()
|
||||
dialog.title = "Opponent Inactive"
|
||||
dialog.dialog_text = (
|
||||
"Your opponent has not acted for 5 minutes.\n"
|
||||
+ "Do you want to claim their forfeit?"
|
||||
)
|
||||
dialog.ok_button_text = "Accept Forfeit"
|
||||
dialog.cancel_button_text = "Wait"
|
||||
add_child(dialog)
|
||||
dialog.confirmed.connect(func() -> void:
|
||||
dialog.queue_free()
|
||||
Game.send_force_concede()
|
||||
)
|
||||
dialog.canceled.connect(func() -> void:
|
||||
dialog.queue_free()
|
||||
)
|
||||
dialog.popup_centered()
|
||||
|
||||
|
||||
func on_inactive_warning(_sid: String) -> void:
|
||||
var dialog: AcceptDialog = AcceptDialog.new()
|
||||
dialog.title = "Inactivity Warning"
|
||||
dialog.dialog_text = (
|
||||
"You have been inactive for 5 minutes.\n"
|
||||
+ "Your opponent may claim a forfeit."
|
||||
)
|
||||
add_child(dialog)
|
||||
dialog.confirmed.connect(func() -> void: dialog.queue_free())
|
||||
dialog.popup_centered()
|
||||
|
||||
|
||||
func on_both_idle_warning(_sid: String) -> void:
|
||||
for child: Node in get_children():
|
||||
if child is ConfirmationDialog or child is AcceptDialog:
|
||||
child.queue_free()
|
||||
var dialog: AcceptDialog = AcceptDialog.new()
|
||||
dialog.title = "Both Players Idle"
|
||||
dialog.dialog_text = (
|
||||
"Both players have been idle for 10 minutes.\n"
|
||||
+ "Please return to continue the game."
|
||||
)
|
||||
dialog.ok_button_text = "Wait"
|
||||
add_child(dialog)
|
||||
dialog.confirmed.connect(func() -> void: dialog.queue_free())
|
||||
dialog.popup_centered()
|
||||
|
||||
|
||||
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!\nYou can continue watching the game as a spectator."
|
||||
if is_me
|
||||
else "Player %s has been eliminated from the game!" % Game.get_display_name(elim_id))
|
||||
var dlg: AcceptDialog = 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 is_me:
|
||||
emit_signal("spectator_mode_requested")
|
||||
@@ -0,0 +1 @@
|
||||
uid://cq32begww8vf5
|
||||
Reference in New Issue
Block a user