fix: show only actionable HUD status information

This commit is contained in:
goose
2026-10-09 17:09:44 -04:00
parent a2d5918b36
commit 70aa27d232
5 changed files with 180 additions and 27 deletions
+95
View File
@@ -1,6 +1,7 @@
extends GutTest
const GameScene = preload("res://scenes/Game.tscn")
const StatusEffectType = preload("res://scripts/domain/combat/status_effect.gd")
const HEADER_VALUES_GROUP := &"hud_header_values"
const CHARACTER_VALUES_GROUP := &"hud_character_values"
const COMMAND_HINTS_GROUP := &"hud_command_hints"
@@ -365,6 +366,84 @@ func test_non_sixteen_by_nine_viewports_center_the_artboard_and_mask_every_outsi
assert_eq(top.size.y, 0.0)
assert_eq(bottom.size.y, 0.0)
func test_status_section_only_shows_actionable_information_without_a_floor_zero_placeholder() -> void:
var hud := game.get_node_or_null("HUD") as GameHud
assert_not_null(hud, "Game scene requires HUD")
if hud == null:
return
var state := game.get_game_state()
var run := game.get_run_state()
state.enemies.clear()
run.current_floor = 0
hud.refresh(state, [], run)
var status := hud.get_node_or_null("ResponsiveLayout/StatusSection") as Control
var status_title := hud.get_node_or_null("ResponsiveLayout/StatusSectionTitle") as Label
assert_not_null(status)
assert_not_null(status_title)
if status_title != null:
assert_true(status_title.visible)
assert_eq(status_title.text, "ÉTAT")
for label_name: String in ["CharacterStatusLabel", "EnemyHealthLabel", "CombatSummaryLabel", "SpellLabel", "DeadlineLabel"]:
var label := hud.get_node_or_null(label_name) as Label
assert_not_null(label, "HUD requires %s" % label_name)
if label != null:
assert_eq(label.text, "", "%s must be cleared in the neutral state" % label_name)
assert_false(label.visible, "%s must be hidden in the neutral state" % label_name)
assert_eq(hud.combat_summary, "")
assert_eq(_visible_text_occurrences(hud, "Aucune cible active"), 0)
assert_eq(_visible_text_occurrences(hud, "prêt à explorer"), 0)
func test_status_section_formats_active_player_effects_in_french() -> void:
var hud := game.get_node_or_null("HUD") as GameHud
assert_not_null(hud, "Game scene requires HUD")
if hud == null:
return
var state := game.get_game_state()
state.enemies.clear()
state.player.apply_status(StatusEffectType.new(&"poison", 3))
state.player.apply_status(StatusEffectType.new(&"strengthened", 2))
hud.refresh(state, [], game.get_run_state())
var effects := hud.get_node_or_null("CharacterStatusLabel") as Label
assert_not_null(effects)
if effects == null:
return
assert_true(effects.visible)
assert_eq(effects.text, "Effets : Empoisonnement (3 tours), Renforcé (2 tours)")
assert_eq(effects.text.findn("prêt à explorer"), -1)
func test_visible_status_labels_are_contained_separated_and_non_overlapping_at_reference_and_compact_sizes() -> void:
var hud := game.get_node_or_null("HUD") as GameHud
assert_not_null(hud, "Game scene requires HUD")
if hud == null:
return
var state := game.get_game_state()
var run := game.get_run_state()
state.enemies.clear()
state.enemies[&"goblin"] = ActorState.new(&"goblin", state.player.cell + Vector2i.RIGHT, 6, 2)
state.player.apply_status(StatusEffectType.new(&"poison", 3))
run.current_floor = 1
run.ensure_floor_deadline(1).turns_remaining = 15 * FloorDeadline.TURNS_PER_DAY
for viewport_size: Vector2 in [Vector2(1920, 1080), Vector2(1280, 720)]:
hud.apply_viewport_layout(viewport_size)
hud.refresh(state, [], run)
await get_tree().process_frame
var status := hud.get_node_or_null("ResponsiveLayout/StatusSection") as Control
assert_not_null(status)
if status == null:
continue
var visible_labels := _visible_status_labels(hud)
assert_gte(visible_labels.size(), 3, "The configured actionable state must expose effects, target, and deadline")
for label: Label in visible_labels:
assert_true(status.get_global_rect().encloses(label.get_global_rect()), "%s must stay inside StatusSection at %s" % [label.name, viewport_size])
for index in visible_labels.size():
for other_index in range(index + 1, visible_labels.size()):
var first := visible_labels[index].get_global_rect()
var second := visible_labels[other_index].get_global_rect()
assert_false(first.intersects(second), "%s must not overlap %s at %s" % [visible_labels[index].name, visible_labels[other_index].name, viewport_size])
var upper := first if first.position.y <= second.position.y else second
var lower := second if upper == first else first
assert_gte(lower.position.y - upper.end.y, 8.0, "Visible status labels need at least 8px vertical separation at %s" % viewport_size)
func test_deadline_label_is_hidden_on_floor_zero_and_uses_only_the_live_collapse_countdown_afterward() -> void:
var hud := game.get_node_or_null("HUD") as GameHud
assert_not_null(hud, "Game scene requires HUD")
@@ -642,6 +721,22 @@ func test_command_bar_subzones_are_distinct_and_contain_their_text() -> void:
if help_panel != null and help_text != null:
assert_true(help_panel.get_global_rect().encloses(help_text.get_global_rect()), "HelpPanel must contain its text")
func _visible_status_labels(hud: GameHud) -> Array[Label]:
var labels: Array[Label] = []
for label_name: String in ["CharacterStatusLabel", "SpellLabel", "EnemyHealthLabel", "CombatSummaryLabel", "DeadlineLabel"]:
var label := hud.get_node_or_null(label_name) as Label
if label != null and label.visible:
labels.append(label)
return labels
func _visible_text_occurrences(hud: GameHud, needle: String) -> int:
var occurrences := 0
for node in hud.find_children("*", "Label", true, false):
var label := node as Label
if label != null and label.visible and label.text.contains(needle):
occurrences += 1
return occurrences
func _assert_play_area_is_centered_and_inside_effective_viewport(play_area_frame: Control) -> void:
var viewport_rect := get_viewport().get_visible_rect()
var expected_viewport := Vector2(Game.REFERENCE_VIEWPORT)