fix: show only actionable HUD status information
This commit is contained in:
@@ -19,10 +19,13 @@ func test_combat_routes_damage_feedback_and_exposes_current_target_summary() ->
|
||||
var enemy_view := game.get_node("World/Enemies/Goblin") as ActorView
|
||||
hud.refresh(state, [], game.get_run_state())
|
||||
|
||||
assert_string_contains(hud.combat_summary, "Gobelin")
|
||||
assert_string_contains(hud.combat_summary, "PV")
|
||||
assert_eq(hud.combat_summary.find("Target"), -1)
|
||||
assert_eq(hud.combat_summary.find("HP"), -1)
|
||||
assert_eq(hud.combat_summary, "Gobelin — PV : 6/6")
|
||||
assert_true((hud.get_node("EnemyHealthLabel") as Label).visible)
|
||||
assert_eq((hud.get_node("EnemyHealthLabel") as Label).text, "Gobelin — PV : 6/6")
|
||||
for label_name: String in ["CharacterStatusLabel", "SpellLabel", "CombatSummaryLabel", "DeadlineLabel"]:
|
||||
var label := hud.get_node(label_name) as Label
|
||||
assert_false(label.visible, "%s must stay hidden while only the target is actionable" % label_name)
|
||||
assert_eq(label.text, "")
|
||||
game.submit_test_action(Vector2i.RIGHT)
|
||||
await _wait_for_feedback()
|
||||
assert_eq(player_view.last_damage, 2)
|
||||
@@ -36,9 +39,10 @@ func test_combat_routes_damage_feedback_and_exposes_current_target_summary() ->
|
||||
game.submit_test_action(Vector2i.RIGHT)
|
||||
await _wait_for_feedback()
|
||||
assert_false(is_instance_valid(enemy_view))
|
||||
assert_eq(hud.combat_summary, "Aucune cible active")
|
||||
assert_eq(hud.get_node("EnemyHealthLabel").text, "Aucune cible active")
|
||||
assert_eq(_visible_text_occurrences(hud, "Aucune cible active"), 1, "The no-target state must have one visible string, never a duplicate")
|
||||
assert_eq(hud.combat_summary, "")
|
||||
assert_eq((hud.get_node("EnemyHealthLabel") as Label).text, "")
|
||||
assert_false((hud.get_node("EnemyHealthLabel") as Label).visible)
|
||||
assert_eq(_visible_text_occurrences(hud, "Aucune cible active"), 0, "The no-target state must never expose a no-target placeholder")
|
||||
assert_eq(_visible_text_occurrences(hud, "No active target"), 0, "The no-target state must never expose the English fallback")
|
||||
assert_string_contains(hud.event_log.get_parsed_text(), "Vous frappez le gobelin avec mains nues")
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user