Refactor game HUD scenes and harden attack checks

This commit is contained in:
dingo
2026-05-07 13:38:19 -04:00
parent 3be1099d93
commit 11c1fcb13a
9 changed files with 688 additions and 775 deletions
@@ -165,8 +165,10 @@ func valid_attack_target_coords(unit: Dictionary) -> Array:
return results
var ux: int = pos.get("x", 0)
var uy: int = pos.get("y", 0)
var min_r: int = int(unit.get("minAttackRange") or 1)
var max_r: int = int(unit.get("maxAttackRange") or 1)
var raw_min_r: Variant = unit.get("minAttackRange")
var raw_max_r: Variant = unit.get("maxAttackRange")
var min_r: int = 1 if raw_min_r == null else int(raw_min_r)
var max_r: int = 1 if raw_max_r == null else int(raw_max_r)
var needs_los: bool = bool(unit.get("attackRequiresLos", false))
if unit.get("isExhausted", false) and unit.get("extraAttacksRemaining", 0) == 0:
return results
@@ -200,8 +202,10 @@ func valid_attack_target_ids(unit: Dictionary) -> Array:
return results
var ux: int = pos.get("x", 0)
var uy: int = pos.get("y", 0)
var min_r: int = int(unit.get("minAttackRange") or 1)
var max_r: int = int(unit.get("maxAttackRange") or 1)
var raw_min_r: Variant = unit.get("minAttackRange")
var raw_max_r: Variant = unit.get("maxAttackRange")
var min_r: int = 1 if raw_min_r == null else int(raw_min_r)
var max_r: int = 1 if raw_max_r == null else int(raw_max_r)
var needs_los: bool = bool(unit.get("attackRequiresLos", false))
if unit.get("isExhausted", false) and unit.get("extraAttacksRemaining", 0) == 0:
return results
@@ -9,8 +9,15 @@ signal zoom_btn_toggled(pressed: bool)
var cam_yaw: float = 0.0
var cam_pitch: float = 40.0
var cam_distance: float = 14.0
var cam_target_distance: float = 14.0
var cam_pivot: Vector3 = Vector3.ZERO
var cam_tween: Tween = null
var cam_zoom_tween: Tween = null
const CAM_MIN_DISTANCE: float = 4.0
const CAM_MAX_DISTANCE: float = 22.0
const CAM_ZOOM_SENSITIVITY: float = 0.4
const CAM_ZOOM_TWEEN_SECONDS: float = 0.12
# Set by parent
var camera_rig: Node3D = null
@@ -32,7 +39,25 @@ func apply_camera() -> void:
func zoom(delta: float) -> void:
cam_distance = clampf(cam_distance - delta, 4.0, 22.0)
if cam_zoom_tween == null or not cam_zoom_tween.is_running():
cam_target_distance = cam_distance
cam_target_distance = clampf(
cam_target_distance - (delta * CAM_ZOOM_SENSITIVITY),
CAM_MIN_DISTANCE,
CAM_MAX_DISTANCE)
if cam_zoom_tween != null:
cam_zoom_tween.kill()
cam_zoom_tween = create_tween()
cam_zoom_tween.tween_method(
_set_distance,
cam_distance,
cam_target_distance,
CAM_ZOOM_TWEEN_SECONDS
).set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_OUT)
func _set_distance(distance: float) -> void:
cam_distance = distance
apply_camera()
@@ -90,7 +115,7 @@ func apply_orbit(delta: Vector2) -> void:
func apply_pan(delta: Vector2, cam_dist: float) -> void:
var ps: float = cam_dist * 0.0015
var right: Vector3 = camera_rig.global_basis.x * delta.x * ps
var fwd: Vector3 = Vector3(camera_rig.global_basis.z.x, 0.0, camera_rig.global_basis.z.z).normalized()
var fwd: Vector3 = Vector3(camera_rig.global_basis.z.x, 0.0, -camera_rig.global_basis.z.z).normalized()
cam_pivot += right + fwd * -delta.y * ps
var pan_lim: float = clampf(max(float(Game.board_width()), float(Game.board_height())) * GameConstants.TILE_SPACING * 0.5, 6.0, 20.0)
cam_pivot.x = clampf(cam_pivot.x, -pan_lim, pan_lim)
@@ -1,106 +1,139 @@
class_name HudController
extends Node
extends Control
# ── Node refs (set from game_screen) ─────────────────────────────────────────
## Owns all permanent HUD elements: TopBar, SP-ST panel, ActionRail, DiscardViewer,
## SpectatorPanel. Emits signals for actions that GameScreen must handle.
signal draw_requested
signal end_turn_requested
signal settings_requested
signal spectator_leave_requested
# ── Scene node refs ───────────────────────────────────────────────────────────
@onready var _phase_lbl : Label = %PhaseLabel
@onready var _turn_lbl : Label = %TurnLabel
@onready var _turn_order_strip : HBoxContainer = %TurnOrderStrip
@onready var _opp_panel : HBoxContainer = %OpponentPanel
@onready var _opp_name_lbl : Label = %OppNameLabel
@onready var _opp_hand_lbl : Label = %OppHandLabel
@onready var _opp_deck_lbl : Label = %OppDeckLabel
@onready var _opp_discard_btn : Button = %OppDiscardBtn
@onready var _sp_lbl : Label = %SpLabel
@onready var _st_lbl : Label = %StLabel
@onready var _deck_lbl : Label = %DeckLabel
@onready var _discard_btn : Button = %DiscardBtn
@onready var _discard_lbl : Label = %DiscardLabel
@onready var _draw_btn : Button = %DrawBtn
@onready var _end_turn_btn : Button = %EndTurnBtn
@onready var _settings_btn : Button = %SettingsBtn
@onready var _spectator_leave_btn : Button = %SpectatorLeaveBtn
@onready var _dv_overlay : PanelContainer = %DiscardViewer
@onready var _dv_title : Label = %DVTitle
@onready var _dv_list : VBoxContainer = %DVList
@onready var _dv_close_btn : Button = %DVCloseBtn
@onready var _spectator_panel : PanelContainer = %SpectatorPlayersPanel
@onready var _spectator_list : VBoxContainer = %SpectatorPlayerList
@onready var _sp_st_panel : PanelContainer = $"SP-ST Panel Container"
@onready var _deck_discard_panel: Control = $"ActionRail/RailMargin/RailHBox/Deck-Discard Panel Container"
## Exposed so GameScreen can hand it to the Chat system.
@onready var chat_bubble_host : Control = %ChatBubbleHost
var phase_lbl: Label = null
var turn_lbl: Label = null
var turn_order_strip: HBoxContainer = null
var opp_panel: HBoxContainer = null
var opp_name_lbl: Label = null
var opp_hand_lbl: Label = null
var opp_deck_lbl: Label = null
var opp_discard_btn: Button = null
var sp_lbl: Label = null
var st_lbl: Label = null
var deck_lbl: Label = null
var discard_btn: Button = null
var discard_lbl: Label = null
var draw_btn: Button = null
var end_turn_btn: Button = null
var dv_overlay: PanelContainer = null
var dv_title: Label = null
var dv_list: VBoxContainer = null
var dv_close_btn: Button = null
var spectator_panel: PanelContainer = null
var spectator_list: VBoxContainer = null
var is_spectating: bool = false
# ── Lifecycle ─────────────────────────────────────────────────────────────────
func _ready() -> void:
_draw_btn.pressed.connect(func() -> void: draw_requested.emit())
_end_turn_btn.pressed.connect(func() -> void: end_turn_requested.emit())
_settings_btn.pressed.connect(func() -> void: settings_requested.emit())
_discard_btn.pressed.connect(func() -> void: show_own_discard(Game.state))
_opp_discard_btn.pressed.connect(func() -> void: show_opp_discard(Game.state))
_dv_close_btn.pressed.connect(func() -> void: _dv_overlay.visible = false)
_spectator_leave_btn.pressed.connect(func() -> void: spectator_leave_requested.emit())
# ── Public API ────────────────────────────────────────────────────────────────
func enter_spectator_mode() -> void:
is_spectating = true
_sp_st_panel.visible = false
_deck_discard_panel.visible = false
_draw_btn.visible = false
_end_turn_btn.visible = false
_spectator_panel.visible = true
_spectator_leave_btn.visible = true
func update_hud(state: Dictionary) -> void:
var phase: String = state.get("phase", "")
var turn: int = state.get("turnNumber", 1)
phase_lbl.text = "Phase: %s" % phase
_phase_lbl.text = "Phase: %s" % phase
if is_spectating:
update_hud_spectator(state)
return
# ── Player path ───────────────────────────────────────────────────────────
var is_mine: bool = Game.is_my_turn()
var my: Dictionary = Game.get_my_player()
var opp: Dictionary = Game.get_opponent()
turn_lbl.text = "Turn %d — %s" % [turn, "Your turn" if is_mine else "Opponent's turn"]
turn_lbl.modulate = Color(0.4, 1.0, 0.5) if is_mine else Color(1.0, 0.6, 0.6)
_turn_lbl.text = "Turn %d — %s" % [turn, "Your turn" if is_mine else "Opponent's turn"]
_turn_lbl.modulate = Color(0.4, 1.0, 0.5) if is_mine else Color(1.0, 0.6, 0.6)
sp_lbl.text = "%d" % int(my.get("currentSp", 0))
st_lbl.text = "%d" % int(my.get("currentSt", 0))
deck_lbl.text = "%d" % int(my.get("deckCount", 0))
_sp_lbl.text = "%d" % int(my.get("currentSp", 0))
_st_lbl.text = "%d" % int(my.get("currentSt", 0))
_deck_lbl.text = "%d" % int(my.get("deckCount", 0))
var discard: Array = my.get("discard", [])
discard_lbl.text = "%d" % max(0, discard.size())
_discard_lbl.text = "%d" % max(0, discard.size())
opp_name_lbl.text = Game.get_display_name(str(opp.get("accountId", "")))
opp_hand_lbl.text = "Hand: %d" % int(opp.get("handCount", 0))
opp_deck_lbl.text = "Deck: %d" % int(opp.get("deckCount", 0))
_opp_name_lbl.text = Game.get_display_name(str(opp.get("accountId", "")))
_opp_hand_lbl.text = "Hand: %d" % int(opp.get("handCount", 0))
_opp_deck_lbl.text = "Deck: %d" % int(opp.get("deckCount", 0))
var all_players: Array = state.get("players", [])
if all_players.size() > 2:
opp_panel.visible = false
turn_order_strip.visible = true
_opp_panel.visible = false
_turn_order_strip.visible = true
rebuild_turn_order_strip(state)
else:
opp_panel.visible = true
turn_order_strip.visible = false
_opp_panel.visible = true
_turn_order_strip.visible = false
draw_btn.visible = (phase == "Draw" and is_mine)
end_turn_btn.visible = (phase == "Main" and is_mine)
end_turn_btn.disabled = not is_mine
_draw_btn.visible = (phase == "Draw" and is_mine)
_end_turn_btn.visible = (phase == "Main" and is_mine)
_end_turn_btn.disabled = not is_mine
if phase == "Placement":
var my_arch: Dictionary = my.get("archSpirit", {})
var i_have_placed: bool = not my_arch.is_empty() and my_arch.get("position") != null
if not i_have_placed:
phase_lbl.text = "Phase: Placement — click a tile to place your ArchSpirit"
_phase_lbl.text = "Phase: Placement — click a tile to place your ArchSpirit"
else:
phase_lbl.text = "Phase: Placement — waiting for opponent…"
_phase_lbl.text = "Phase: Placement — waiting for opponent…"
func update_hud_spectator(state: Dictionary) -> void:
var turn: int = state.get("turnNumber", 1)
var active_id: String = str(state.get("activePlayerAccountId", ""))
var active_name: String = Game.get_display_name(active_id)
turn_lbl.text = "Turn %d — %s is acting" % [turn, active_name]
turn_lbl.modulate = Color(1.0, 0.76, 0.2)
_turn_lbl.text = "Turn %d — %s is acting" % [turn, active_name]
_turn_lbl.modulate = Color(1.0, 0.76, 0.2)
# Always hide the 2-player opponent panel; show turn strip for all player counts.
opp_panel.visible = false
_opp_panel.visible = false
var all_players: Array = state.get("players", [])
turn_order_strip.visible = all_players.size() > 1
if turn_order_strip.visible:
_turn_order_strip.visible = all_players.size() > 1
if _turn_order_strip.visible:
rebuild_turn_order_strip(state)
draw_btn.visible = false
end_turn_btn.visible = false
_draw_btn.visible = false
_end_turn_btn.visible = false
rebuild_spectator_panel(state)
## Rebuild the spectator player-summary list. One row per player sorted by seatIndex.
## Shows name (with active-turn highlight), SP, ST, deck count, and a Discard button.
func rebuild_spectator_panel(state: Dictionary) -> void:
for c in spectator_list.get_children():
for c in _spectator_list.get_children():
c.queue_free()
var active_id: String = str(state.get("activePlayerAccountId", ""))
@@ -187,21 +220,17 @@ func rebuild_spectator_panel(state: Dictionary) -> void:
disc_btn.disabled = true
hbox.add_child(disc_btn)
spectator_list.add_child(row)
_spectator_list.add_child(row)
## Rebuild the turn-order chip strip for N-player games.
## One chip per player sorted by seatIndex; highlights the active player,
## dims eliminated players, and marks the local player as "You".
func rebuild_turn_order_strip(state: Dictionary) -> void:
for c in turn_order_strip.get_children():
for c in _turn_order_strip.get_children():
c.queue_free()
var active_id: String = str(state.get("activePlayerAccountId", ""))
var players: Array = state.get("players", []).duplicate()
var team_colors: Dictionary = state.get("teamColors", {})
# Sort by seatIndex so chips appear in turn order.
players.sort_custom(func(a: Dictionary, b: Dictionary) -> bool:
return int(a.get("seatIndex", 0)) < int(b.get("seatIndex", 0)))
@@ -219,7 +248,6 @@ func rebuild_turn_order_strip(state: Dictionary) -> void:
chip.self_modulate = Color(1, 1, 1, 0.3 if eliminated else (0.95 if is_active else 0.6))
chip.mouse_filter = Control.MOUSE_FILTER_STOP
# Team-color left border via StyleBoxFlat.
var style: StyleBoxFlat = StyleBoxFlat.new()
style.bg_color = Color(0.12, 0.12, 0.14, 0.85)
style.border_width_left = 3
@@ -242,7 +270,6 @@ func rebuild_turn_order_strip(state: Dictionary) -> void:
elif is_me:
lbl.add_theme_color_override("font_color", Color(0.5, 1.0, 0.5))
# Hover tooltip showing player specs (opponents only).
if not is_me:
var sp: int = int(p.get("currentSp", 0))
var st: int = int(p.get("currentSt", 0))
@@ -252,7 +279,7 @@ func rebuild_turn_order_strip(state: Dictionary) -> void:
display, sp, st, hand, deck]
chip.add_child(lbl)
turn_order_strip.add_child(chip)
_turn_order_strip.add_child(chip)
func show_own_discard(state: Dictionary) -> void:
@@ -264,18 +291,18 @@ func show_opp_discard(state: Dictionary) -> void:
func show_discard_for(title: String, cards: Array) -> void:
dv_title.text = "%s (%d)" % [title, cards.size()]
for c in dv_list.get_children():
_dv_title.text = "%s (%d)" % [title, cards.size()]
for c in _dv_list.get_children():
c.queue_free()
if cards.is_empty():
var lbl: Label = Label.new()
lbl.text = "(empty)"
lbl.add_theme_color_override("font_color", Color(0.55, 0.55, 0.6))
dv_list.add_child(lbl)
_dv_list.add_child(lbl)
else:
for card: Dictionary in cards:
dv_list.add_child(make_discard_row(card))
dv_overlay.visible = true
_dv_list.add_child(make_discard_row(card))
_dv_overlay.visible = true
func make_discard_row(card: Dictionary) -> Control:
@@ -0,0 +1,407 @@
[gd_scene load_steps=15 format=3 uid="uid://doy6e5sb5bk48"]
[ext_resource type="Script" uid="uid://c0cr5qgneoab1" path="res://scenes/game/components/hud/hud_controller.gd" id="1_script"]
[ext_resource type="Texture2D" uid="uid://dvmripj4jux0b" path="res://icons/SP-Symbol-White.png" id="2_sp"]
[ext_resource type="Texture2D" uid="uid://csvmdo2kwnh7c" path="res://icons/ST-Symbol-White.png" id="3_st"]
[ext_resource type="Texture2D" uid="uid://beyeu0y34m3v4" path="res://ui/icons/Deck Icon.png" id="4_deck"]
[ext_resource type="Texture2D" uid="uid://c65s8sn4p7s37" path="res://ui/icons/Discard Icon.png" id="5_discard"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_spst"]
[sub_resource type="Theme" id="Theme_tex"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_action"]
bg_color = Color(0.38039216, 0.38039216, 0.38039216, 0.58431375)
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_disc_normal"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_disc_pressed"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_disc_hover"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_disc_hovpressed"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_disc_disabled"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_disc_focus"]
[node name="HudController" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
mouse_filter = 2
script = ExtResource("1_script")
[node name="TopBar" type="HBoxContainer" parent="."]
layout_mode = 0
anchor_right = 1.0
offset_bottom = 48.0
theme_override_constants/separation = 0
[node name="PhaseLabel" type="Label" parent="TopBar"]
unique_name_in_owner = true
custom_minimum_size = Vector2(140, 48)
layout_mode = 2
theme_override_font_sizes/font_size = 13
text = "Phase: —"
vertical_alignment = 1
[node name="TurnLabel" type="Label" parent="TopBar"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
theme_override_font_sizes/font_size = 13
text = "Turn 1 — Your turn"
horizontal_alignment = 1
vertical_alignment = 1
[node name="TurnOrderStrip" type="HBoxContainer" parent="TopBar"]
unique_name_in_owner = true
visible = false
layout_mode = 2
size_flags_horizontal = 3
theme_override_constants/separation = 4
[node name="OpponentPanel" type="HBoxContainer" parent="TopBar"]
unique_name_in_owner = true
custom_minimum_size = Vector2(240, 48)
layout_mode = 2
theme_override_constants/separation = 8
[node name="OppNameLabel" type="Label" parent="TopBar/OpponentPanel"]
unique_name_in_owner = true
modulate = Color(1, 0.5, 0.5, 1)
layout_mode = 2
theme_override_font_sizes/font_size = 12
text = "Opponent"
vertical_alignment = 1
[node name="OppHandLabel" type="Label" parent="TopBar/OpponentPanel"]
unique_name_in_owner = true
layout_mode = 2
theme_override_font_sizes/font_size = 12
text = "Hand: 0"
vertical_alignment = 1
[node name="OppDeckLabel" type="Label" parent="TopBar/OpponentPanel"]
unique_name_in_owner = true
layout_mode = 2
theme_override_font_sizes/font_size = 12
text = "Deck: 0"
vertical_alignment = 1
[node name="OppDiscardBtn" type="Button" parent="TopBar/OpponentPanel"]
unique_name_in_owner = true
layout_mode = 2
theme_override_font_sizes/font_size = 11
text = "Discard"
[node name="SP-ST Panel Container" type="PanelContainer" parent="."]
layout_mode = 0
anchor_top = 0.675
anchor_bottom = 0.675
offset_top = -156.40002
offset_right = 76.0
offset_bottom = -0.4000244
theme_override_styles/panel = SubResource("StyleBoxEmpty_spst")
[node name="VBoxContainer" type="VBoxContainer" parent="SP-ST Panel Container"]
layout_mode = 2
alignment = 2
[node name="TextureRect" type="TextureRect" parent="SP-ST Panel Container/VBoxContainer"]
self_modulate = Color(0, 0.8117647, 0.77254903, 0.38039216)
texture_filter = 5
custom_minimum_size = Vector2(1.78, 76)
layout_mode = 2
theme = SubResource("Theme_tex")
texture = ExtResource("2_sp")
expand_mode = 1
[node name="SpLabel" type="Label" parent="SP-ST Panel Container/VBoxContainer/TextureRect"]
unique_name_in_owner = true
layout_mode = 1
anchors_preset = -1
anchor_left = 0.513
anchor_top = 0.36800003
anchor_right = 0.513
anchor_bottom = 0.36800003
offset_left = -18.987999
offset_top = -22.968002
offset_right = 19.012001
offset_bottom = 23.031998
tooltip_text = "Spirit Points"
mouse_filter = 1
theme_override_colors/font_color = Color(0.012617188, 0.012617188, 0.012617188, 1)
theme_override_font_sizes/font_size = 33
text = "88"
horizontal_alignment = 1
vertical_alignment = 1
metadata/_edit_use_anchors_ = true
[node name="TextureRect2" type="TextureRect" parent="SP-ST Panel Container/VBoxContainer"]
self_modulate = Color(0, 0.8117647, 0.77254903, 0.38039216)
texture_filter = 5
custom_minimum_size = Vector2(1.78, 76)
layout_mode = 2
theme = SubResource("Theme_tex")
texture = ExtResource("3_st")
expand_mode = 1
[node name="StLabel" type="Label" parent="SP-ST Panel Container/VBoxContainer/TextureRect2"]
unique_name_in_owner = true
layout_mode = 1
anchors_preset = -1
anchor_left = 0.5
anchor_top = 0.32200003
anchor_right = 0.5
anchor_bottom = 0.32200003
offset_left = -20.0
offset_top = -20.472002
offset_right = 22.0
offset_bottom = 25.527998
tooltip_text = "Sacrifice Tokens"
mouse_filter = 1
theme_override_colors/font_color = Color(0.06469653, 0.06469653, 0.06469653, 1)
theme_override_font_sizes/font_size = 33
text = "88"
horizontal_alignment = 1
vertical_alignment = 1
[node name="ActionRail" type="PanelContainer" parent="."]
layout_mode = 0
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = -262.0
offset_top = -220.0
offset_right = -70.0
offset_bottom = -56.0
grow_horizontal = 0
grow_vertical = 0
theme_override_styles/panel = SubResource("StyleBoxFlat_action")
[node name="RailMargin" type="MarginContainer" parent="ActionRail"]
layout_mode = 2
theme_override_constants/margin_left = 10
theme_override_constants/margin_top = 8
theme_override_constants/margin_right = 10
theme_override_constants/margin_bottom = 8
[node name="RailHBox" type="HBoxContainer" parent="ActionRail/RailMargin"]
layout_mode = 2
theme_override_constants/separation = 12
[node name="Deck-Discard Panel Container" type="Control" parent="ActionRail/RailMargin/RailHBox"]
custom_minimum_size = Vector2(76, 0)
layout_mode = 2
[node name="VBoxContainer" type="VBoxContainer" parent="ActionRail/RailMargin/RailHBox/Deck-Discard Panel Container"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
alignment = 2
[node name="TextureRect" type="TextureRect" parent="ActionRail/RailMargin/RailHBox/Deck-Discard Panel Container/VBoxContainer"]
self_modulate = Color(0, 0.8117647, 0.77254903, 0.38039216)
texture_filter = 5
custom_minimum_size = Vector2(1.78, 76)
layout_mode = 2
theme = SubResource("Theme_tex")
texture = ExtResource("4_deck")
expand_mode = 1
[node name="DeckLabel" type="Label" parent="ActionRail/RailMargin/RailHBox/Deck-Discard Panel Container/VBoxContainer/TextureRect"]
unique_name_in_owner = true
layout_mode = 1
anchors_preset = -1
anchor_left = 0.507
anchor_top = 0.40789473
anchor_right = 0.507
anchor_bottom = 0.40789473
offset_left = -22.532001
offset_top = -36.0
offset_right = 22.467999
offset_bottom = 10.0
grow_horizontal = 2
grow_vertical = 2
tooltip_text = "Cards in Deck"
mouse_filter = 1
theme_override_colors/font_color = Color(0, 0, 0, 1)
theme_override_font_sizes/font_size = 33
text = "88"
horizontal_alignment = 1
vertical_alignment = 1
metadata/_edit_use_anchors_ = true
[node name="TextureRect2" type="TextureRect" parent="ActionRail/RailMargin/RailHBox/Deck-Discard Panel Container/VBoxContainer"]
self_modulate = Color(0, 0.8117647, 0.77254903, 0.38039216)
texture_filter = 5
custom_minimum_size = Vector2(1.78, 76)
layout_mode = 2
theme = SubResource("Theme_tex")
expand_mode = 1
[node name="DiscardBtn" type="Button" parent="ActionRail/RailMargin/RailHBox/Deck-Discard Panel Container/VBoxContainer/TextureRect2"]
unique_name_in_owner = true
layout_mode = 0
offset_left = -4.000001
offset_top = -5.000001
offset_right = 568.0
offset_bottom = 275.0
scale = Vector2(0.14754085, 0.23068035)
tooltip_text = "View Discard"
theme_override_colors/icon_normal_color = Color(0.18431373, 0.49411765, 0.47843137, 1)
theme_override_colors/icon_focus_color = Color(0.18431373, 0.49411765, 0.47843137, 1)
theme_override_colors/icon_pressed_color = Color(0.35976923, 0.7944459, 0.77106035, 1)
theme_override_colors/icon_hover_color = Color(0.18431373, 0.49411765, 0.47843137, 1)
theme_override_colors/icon_hover_pressed_color = Color(0.18431373, 0.49411765, 0.47843137, 1)
theme_override_font_sizes/font_size = 12
theme_override_icons/icon = ExtResource("5_discard")
theme_override_styles/normal = SubResource("StyleBoxEmpty_disc_normal")
theme_override_styles/pressed = SubResource("StyleBoxEmpty_disc_pressed")
theme_override_styles/hover = SubResource("StyleBoxEmpty_disc_hover")
theme_override_styles/hover_pressed = SubResource("StyleBoxEmpty_disc_hovpressed")
theme_override_styles/disabled = SubResource("StyleBoxEmpty_disc_disabled")
theme_override_styles/focus = SubResource("StyleBoxEmpty_disc_focus")
[node name="DiscardLabel" type="Label" parent="ActionRail/RailMargin/RailHBox/Deck-Discard Panel Container/VBoxContainer/TextureRect2"]
unique_name_in_owner = true
layout_mode = 1
anchors_preset = -1
anchor_left = 0.5
anchor_top = 0.32200003
anchor_right = 0.5
anchor_bottom = 0.32200003
offset_left = -20.0
offset_top = -31.472002
offset_right = 22.0
offset_bottom = 14.527998
theme_override_colors/font_color = Color(0.06469653, 0.06469653, 0.06469653, 1)
theme_override_font_sizes/font_size = 33
text = "88"
horizontal_alignment = 1
vertical_alignment = 1
[node name="Controls" type="Control" parent="ActionRail/RailMargin/RailHBox"]
layout_mode = 2
size_flags_horizontal = 3
[node name="RightVBox" type="VBoxContainer" parent="ActionRail/RailMargin/RailHBox/Controls"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/separation = 6
[node name="EndTurnBtn" type="Button" parent="ActionRail/RailMargin/RailHBox/Controls/RightVBox"]
unique_name_in_owner = true
custom_minimum_size = Vector2(0, 36)
layout_mode = 2
theme_override_font_sizes/font_size = 13
text = "End Turn"
[node name="DrawBtn" type="Button" parent="ActionRail/RailMargin/RailHBox/Controls/RightVBox"]
unique_name_in_owner = true
custom_minimum_size = Vector2(0, 36)
layout_mode = 2
theme_override_font_sizes/font_size = 13
text = "Draw Card"
[node name="SettingsBtn" type="Button" parent="ActionRail/RailMargin/RailHBox/Controls/RightVBox"]
unique_name_in_owner = true
custom_minimum_size = Vector2(0, 36)
layout_mode = 2
theme_override_font_sizes/font_size = 12
text = "Settings"
[node name="ChatBubbleHost" type="Control" parent="ActionRail/RailMargin/RailHBox/Controls/RightVBox"]
unique_name_in_owner = true
custom_minimum_size = Vector2(0, 36)
layout_mode = 2
[node name="SpectatorLeaveBtn" type="Button" parent="ActionRail/RailMargin/RailHBox/Controls/RightVBox"]
unique_name_in_owner = true
visible = false
custom_minimum_size = Vector2(0, 36)
layout_mode = 2
theme_override_font_sizes/font_size = 12
text = "Leave Spectator"
[node name="DiscardViewer" type="PanelContainer" parent="."]
unique_name_in_owner = true
visible = false
layout_mode = 0
anchor_left = 0.1
anchor_top = 0.05
anchor_right = 0.9
anchor_bottom = 0.95
[node name="DVMargin" type="MarginContainer" parent="DiscardViewer"]
layout_mode = 2
theme_override_constants/margin_left = 16
theme_override_constants/margin_top = 12
theme_override_constants/margin_right = 16
theme_override_constants/margin_bottom = 12
[node name="DVVBox" type="VBoxContainer" parent="DiscardViewer/DVMargin"]
layout_mode = 2
theme_override_constants/separation = 8
[node name="DVTitle" type="Label" parent="DiscardViewer/DVMargin/DVVBox"]
unique_name_in_owner = true
layout_mode = 2
theme_override_font_sizes/font_size = 16
text = "Discard Pile"
[node name="DVScroll" type="ScrollContainer" parent="DiscardViewer/DVMargin/DVVBox"]
layout_mode = 2
size_flags_vertical = 3
horizontal_scroll_mode = 0
[node name="DVList" type="VBoxContainer" parent="DiscardViewer/DVMargin/DVVBox/DVScroll"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
theme_override_constants/separation = 4
[node name="DVCloseBtn" type="Button" parent="DiscardViewer/DVMargin/DVVBox"]
unique_name_in_owner = true
custom_minimum_size = Vector2(0, 36)
layout_mode = 2
theme_override_font_sizes/font_size = 13
text = "Close"
[node name="SpectatorPlayersPanel" type="PanelContainer" parent="."]
unique_name_in_owner = true
visible = false
layout_mode = 0
anchor_top = 1.0
anchor_right = 0.75
anchor_bottom = 1.0
offset_top = -200.0
[node name="SpectatorMargin" type="MarginContainer" parent="SpectatorPlayersPanel"]
layout_mode = 2
theme_override_constants/margin_left = 8
theme_override_constants/margin_top = 8
theme_override_constants/margin_right = 8
theme_override_constants/margin_bottom = 8
[node name="SpectatorScroll" type="ScrollContainer" parent="SpectatorPlayersPanel/SpectatorMargin"]
layout_mode = 2
size_flags_vertical = 3
horizontal_scroll_mode = 0
[node name="SpectatorPlayerList" type="VBoxContainer" parent="SpectatorPlayersPanel/SpectatorMargin/SpectatorScroll"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
theme_override_constants/separation = 4
@@ -1,13 +1,17 @@
class_name GameOverOverlay
extends Node
extends PanelContainer
## Manages the end-of-game Victory/Defeat overlay.
## Node refs are set by game_screen after scene is ready.
## End-of-game Victory/Defeat overlay.
## Self-contained: wires its own button and handles scene transitions internally.
@onready var _result_lbl : Label = %GOResultLabel
@onready var _rank_lbl : Label = %GORankLabel
@onready var _menu_btn : Button = %GOMainMenuBtn
func _ready() -> void:
_menu_btn.pressed.connect(func() -> void:
get_tree().change_scene_to_file("res://scenes/main/MainScreen.tscn"))
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,
@@ -23,8 +27,8 @@ func show_result(winner_id: String, win_condition: String,
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)
_result_lbl.text = "Victory!" if i_won else "Defeat"
_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 = []
@@ -35,12 +39,12 @@ func show_result(winner_id: String, win_condition: String,
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)
_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" % [
_rank_lbl.text = "Win by %s | Rank %s%d" % [
win_condition, "+" if my_delta >= 0 else "", my_delta]
go_overlay.visible = true
visible = true
func on_session_abandoned(_reason: String) -> void:
@@ -0,0 +1,43 @@
[gd_scene load_steps=2 format=3 uid="uid://game_over_overlay"]
[ext_resource type="Script" path="res://scenes/game/components/overlays/game_over_overlay.gd" id="1_script"]
[node name="GameOverOverlay" type="PanelContainer"]
visible = false
anchors_preset = -1
anchor_left = 0.25
anchor_top = 0.25
anchor_right = 0.75
anchor_bottom = 0.75
script = ExtResource("1_script")
[node name="GOMargin" type="MarginContainer" parent="."]
layout_mode = 2
theme_override_constants/margin_left = 24
theme_override_constants/margin_top = 24
theme_override_constants/margin_right = 24
theme_override_constants/margin_bottom = 24
[node name="GOVBox" type="VBoxContainer" parent="GOMargin"]
layout_mode = 2
theme_override_constants/separation = 16
[node name="GOResultLabel" type="Label" parent="GOMargin/GOVBox"]
unique_name_in_owner = true
layout_mode = 2
theme_override_font_sizes/font_size = 28
text = "Game Over"
horizontal_alignment = 1
[node name="GORankLabel" type="Label" parent="GOMargin/GOVBox"]
unique_name_in_owner = true
layout_mode = 2
theme_override_font_sizes/font_size = 15
horizontal_alignment = 1
[node name="GOMainMenuBtn" type="Button" parent="GOMargin/GOVBox"]
unique_name_in_owner = true
custom_minimum_size = Vector2(0, 44)
layout_mode = 2
theme_override_font_sizes/font_size = 15
text = "Return to Main Menu"