From c410f830e3b0a823c9acd600bbebdfb744d1e6a3 Mon Sep 17 00:00:00 2001 From: goose Date: Fri, 9 Oct 2026 12:21:45 -0400 Subject: [PATCH] test: define final character HUD contracts --- tests/e2e/test_achievement_reward_e2e.gd | 20 +- ...tributes_current_game_nonregression_e2e.gd | 2 +- tests/e2e/test_level_up_e2e.gd | 22 +- tests/e2e/test_shop_rest_e2e.gd | 2 +- tests/unit/test_action_router.gd | 10 + tests/unit/test_hud_journal_localization.gd | 2 +- tests/unit/test_hud_layout.gd | 226 +++++++++++------- 7 files changed, 193 insertions(+), 91 deletions(-) diff --git a/tests/e2e/test_achievement_reward_e2e.gd b/tests/e2e/test_achievement_reward_e2e.gd index 5fb07d5..8ac1d72 100644 --- a/tests/e2e/test_achievement_reward_e2e.gd +++ b/tests/e2e/test_achievement_reward_e2e.gd @@ -36,7 +36,25 @@ func test_real_hit_unlocks_reward_toast_journal_claim_and_title_refresh() -> voi assert_string_contains((game.get_node("HUD/AchievementToast") as Label).text, "Premier coup") assert_true(game.get_run_state().recent_events(game.get_run_state().log.size()).any(func(event: GameEvent) -> bool: return event.kind == &"achievement_unlocked")) assert_eq(game.get_run_state().current_title_id, &"striker") - assert_string_contains((game.get_node("HUD/TitleLabel") as Label).text, "Frappeur") + var permanent_title := game.get_node_or_null("HUD/TitleLabel") as Label + var notification := game.get_node_or_null("HUD/TitleNotificationLabel") as Label + var notification_timer := game.get_node_or_null("HUD/TitleNotificationTimer") as Timer + assert_not_null(permanent_title) + assert_not_null(notification, "HUD requires a separate temporary TitleNotificationLabel") + assert_not_null(notification_timer, "HUD requires TitleNotificationTimer") + if permanent_title != null: + assert_eq(permanent_title.text, "Étage 0", "The permanent TopBar title remains the current floor") + if notification == null or notification_timer == null: + return + assert_true(notification.visible, "A newly earned title needs a temporary notification") + assert_eq(notification.text, "Frappeur") + assert_true(notification_timer.one_shot) + assert_eq(notification_timer.wait_time, 5.0) + notification_timer.timeout.emit() + await get_tree().process_frame + assert_false(notification.visible, "The title notification disappears at timeout") + if permanent_title != null: + assert_eq(permanent_title.text, "Étage 0") await _dispatch_key(KEY_L) assert_true(panel.visible) diff --git a/tests/e2e/test_attributes_current_game_nonregression_e2e.gd b/tests/e2e/test_attributes_current_game_nonregression_e2e.gd index 1777350..462b396 100644 --- a/tests/e2e/test_attributes_current_game_nonregression_e2e.gd +++ b/tests/e2e/test_attributes_current_game_nonregression_e2e.gd @@ -15,5 +15,5 @@ func test_current_game_event_and_hud_remain_available_with_attributes_domain_loa var hud := game.get_node("HUD") as GameHud assert_eq(state.enemies[&"goblin"].hit_points, 3) assert_true(game.get_run_state().recent_events(2).any(func(event: GameEvent) -> bool: return event.kind == &"melee")) - assert_true(hud.player_health_label.text.contains("PV du joueur :")) + assert_eq(hud.player_health_label.text, "PV : %d/%d" % [state.player.hit_points, state.player.max_hit_points]) assert_true(hud.event_log.get_parsed_text().contains("Vous frappez le gobelin")) diff --git a/tests/e2e/test_level_up_e2e.gd b/tests/e2e/test_level_up_e2e.gd index 6091fe4..911a94c 100644 --- a/tests/e2e/test_level_up_e2e.gd +++ b/tests/e2e/test_level_up_e2e.gd @@ -30,10 +30,26 @@ func test_real_character_input_opens_panel_and_allocates_level_up_points_without assert_eq(xp_bar.max_value, 200.0) assert_eq(xp_label.text, "Niveau 2 — XP 0/200") - await _dispatch_key(KEY_P) var panel := game.get_node("HUD/CharacterPanel") as PanelContainer - assert_true(panel.visible) - assert_string_contains((panel.get_node("Body") as RichTextLabel).get_parsed_text(), "Level 2") + game.get_run_state().player_name = "Dame Ysabel" + await _dispatch_key(KEY_P) + assert_false(panel.visible, "P must no longer open the character sheet") + await _dispatch_key(KEY_C) + assert_true(panel.visible, "The physical C key opens the character sheet") + var sheet_text := (panel.get_node("Body") as RichTextLabel).get_parsed_text() + assert_string_contains(sheet_text, "Nom : Dame Ysabel") + assert_string_contains(sheet_text, "Titre : Bleu du Donjon") + assert_string_contains(sheet_text, "Vous n'avez encore rien prouve.") + assert_string_contains(sheet_text, "Niveau 2") + assert_string_contains(sheet_text, "XP") + assert_string_contains(sheet_text, "Points d’attribut") + assert_string_contains(sheet_text, "Points de compétence") + for attribute_name: String in ["Force", "Agilité", "Endurance", "Perception", "Intelligence", "Volonté", "Charisme", "Chance"]: + assert_string_contains(sheet_text, attribute_name, "The sheet must list %s" % attribute_name) + for skill_name: String in ["Compétences principales", "Corps à corps", "Distance", "Esquive"]: + assert_string_contains(sheet_text, skill_name, "The sheet must list %s" % skill_name) + assert_string_contains(sheet_text, "A / S") + assert_string_contains(sheet_text, "Échap") await _dispatch_key(KEY_A) assert_eq(state.player.progression.attribute_points, 0) assert_eq(game.get_dialogue_player().attributes.get_attribute(&"str_"), 5) diff --git a/tests/e2e/test_shop_rest_e2e.gd b/tests/e2e/test_shop_rest_e2e.gd index 334482f..d104b7e 100644 --- a/tests/e2e/test_shop_rest_e2e.gd +++ b/tests/e2e/test_shop_rest_e2e.gd @@ -20,7 +20,7 @@ func test_real_merchant_interaction_opens_shop_and_purchase_updates_inventory_an game.get_run_state().gold = 100 var no_events: Array[GameEvent] = [] game.get_node("HUD").refresh(state, no_events, game.get_run_state()) - assert_eq((game.get_node("HUD/GoldLabel") as Label).text, "Or : 100") + assert_eq((game.get_node("HUD/GoldLabel") as Label).text, "100") await _dispatch_key(KEY_E) var dialogue_entries := game.get_node("HUD/DialoguePanel/Layout/Entries") as RichTextLabel diff --git a/tests/unit/test_action_router.gd b/tests/unit/test_action_router.gd index ced7ba8..22fef66 100644 --- a/tests/unit/test_action_router.gd +++ b/tests/unit/test_action_router.gd @@ -30,6 +30,16 @@ func test_f_starts_ranged_targeting_and_ctrl_s_or_v_requests_a_manual_save() -> assert_eq(router.action_from_input(_action_event(&"ranged")).kind, &"ranged") assert_eq(router.action_from_input(_action_event(&"save")).kind, &"save") +func test_character_opens_with_physical_c_while_p_is_free_and_southeast_uses_keypad_3() -> void: + var character_c := _key_event(KEY_C) + var legacy_character_p := _key_event(KEY_P) + var southeast_keypad_3 := _key_event(KEY_KP_3) + + assert_true(InputMap.action_has_event(&"character", character_c), "C is the physical character-sheet binding") + assert_false(InputMap.action_has_event(&"character", legacy_character_p), "P must no longer open the character sheet") + assert_true(InputMap.action_has_event(&"move_southeast", southeast_keypad_3), "South-east is bound to keypad 3") + assert_false(InputMap.action_has_event(&"move_southeast", character_c), "C must no longer move south-east") + func test_action_from_input_maps_the_complete_command_vocabulary() -> void: var router := ActionRouter.new(null) var expected := { diff --git a/tests/unit/test_hud_journal_localization.gd b/tests/unit/test_hud_journal_localization.gd index f5ee91a..56a856f 100644 --- a/tests/unit/test_hud_journal_localization.gd +++ b/tests/unit/test_hud_journal_localization.gd @@ -182,7 +182,7 @@ func test_hud_uses_french_spacing_for_focus_and_gold_labels() -> void: game.get_run_state().gold = 42 hud.refresh(state, [], game.get_run_state()) assert_eq(hud.player_focus_label.text, "Focus : %d/%d" % [state.player.focus, state.player.max_focus]) - assert_eq(hud.gold_label.text, "Or : 42") + assert_eq(hud.gold_label.text, "42") func test_hud_keeps_the_domain_message_for_unknown_journal_event_kinds() -> void: var game := GameScene.instantiate() as Game diff --git a/tests/unit/test_hud_layout.gd b/tests/unit/test_hud_layout.gd index b6d9006..4d164e7 100644 --- a/tests/unit/test_hud_layout.gd +++ b/tests/unit/test_hud_layout.gd @@ -157,7 +157,7 @@ func test_live_hud_content_is_enclosed_by_its_intended_shell_region() -> void: _assert_controls_enclosed(right_rail, [hud.get_node_or_null("EventLog") as Control], "RightRail") _assert_controls_enclosed(command_bar, _controls_in_group(hud, COMMAND_HINTS_GROUP), "CommandBar") -func test_dynamic_hud_groups_refresh_from_live_game_values() -> void: +func test_dynamic_hud_groups_refresh_live_character_and_command_values_without_a_redundant_header() -> void: var hud := game.get_node_or_null("HUD") as GameHud assert_not_null(hud, "Game scene requires HUD") if hud == null: @@ -166,13 +166,13 @@ func test_dynamic_hud_groups_refresh_from_live_game_values() -> void: assert_not_null(layout, "HUD requires ResponsiveLayout") if layout == null: return - var top_bar := layout.get_node_or_null("TopBar") as Control var left_rail := layout.get_node_or_null("LeftRail") as Control var command_bar := layout.get_node_or_null("CommandBar") as Control - assert_not_null(top_bar, "ResponsiveLayout requires a TopBar") - assert_not_null(left_rail, "ResponsiveLayout requires a LeftRail") - assert_not_null(command_bar, "ResponsiveLayout requires a CommandBar") - if top_bar == null or left_rail == null or command_bar == null: + var header_values := hud.get_node_or_null("HeaderValuesLabel") as Label + assert_not_null(left_rail) + assert_not_null(command_bar) + assert_not_null(header_values, "Legacy HeaderValuesLabel remains an explicitly hidden empty compatibility control") + if left_rail == null or command_bar == null or header_values == null: return var state := game.get_game_state() @@ -182,29 +182,15 @@ func test_dynamic_hud_groups_refresh_from_live_game_values() -> void: state.player.cell = state.floor_state.entrance hud.refresh(state, [], run) - var header_values := _labels_in_group(hud, HEADER_VALUES_GROUP) var character_values := _labels_in_group(hud, CHARACTER_VALUES_GROUP) var command_hints := _labels_in_group(hud, COMMAND_HINTS_GROUP) - assert_gte(header_values.size(), 1, "TopBar exposes dynamic header values through the hud_header_values group") assert_gte(character_values.size(), 1, "LeftRail exposes dynamic character values through the hud_character_values group") assert_gte(command_hints.size(), 1, "CommandBar exposes dynamic hints through the hud_command_hints group") - if header_values.is_empty() or character_values.is_empty() or command_hints.is_empty(): + assert_false(header_values.visible, "HeaderValuesLabel must not duplicate top-bar information") + assert_eq(header_values.text, "", "HeaderValuesLabel must be empty when hidden") + if character_values.is_empty() or command_hints.is_empty(): return - - var header_text := _combined_label_text(header_values) - var character_text := _combined_label_text(character_values) - var expected_room_id := "" - for room: RoomState in state.floor_state.rooms: - if room.bounds.has_point(state.player.cell): - expected_room_id = String(room.id) - break - assert_ne(expected_room_id, "", "The player's authored room must be discoverable from its bounds") - assert_string_contains(header_text, run.player_name) - assert_string_contains(header_text, str(state.floor_state.floor_number)) - assert_string_contains(header_text, expected_room_id) - assert_string_contains(header_text, str(state.explored_cells.size())) - assert_string_contains(character_text, str(state.player.hit_points)) - _assert_controls_enclosed(top_bar, header_values, "TopBar") + assert_string_contains(_combined_label_text(character_values), str(state.player.hit_points)) _assert_controls_enclosed(left_rail, character_values, "LeftRail") state.player.cell = Vector2i(35, 7) @@ -213,23 +199,19 @@ func test_dynamic_hud_groups_refresh_from_live_game_values() -> void: assert_string_contains(_combined_label_text(command_hints), "Ouvrir la porte") _assert_controls_enclosed(command_bar, command_hints, "CommandBar") -func test_compact_1280_layout_scales_header_text_and_keeps_it_inside_the_top_bar() -> void: +func test_compact_1280_layout_keeps_the_hidden_legacy_header_out_of_the_top_bar_content() -> void: var hud := game.get_node_or_null("HUD") as GameHud assert_not_null(hud, "Game scene requires HUD") if hud == null: return hud.apply_viewport_layout(Vector2(1280, 720)) - var top_bar := hud.get_node_or_null("ResponsiveLayout/TopBar") as Control var header := hud.get_node_or_null("HeaderValuesLabel") as Label - assert_not_null(top_bar, "ResponsiveLayout requires a TopBar") - assert_not_null(header, "HUD requires HeaderValuesLabel") - if top_bar == null or header == null: + assert_not_null(header, "HUD retains HeaderValuesLabel as a compatibility node") + if header == null: return - - assert_eq(header.get_theme_font_size(&"font_size"), 11, "The compact shell scales the 16px header value font to the 1280x720 artboard") - assert_true(top_bar.get_global_rect().encloses(header.get_global_rect()), "The compact header remains inside its TopBar") - assert_lte(header.get_minimum_size().y, header.size.y, "The compact header has enough height for its scaled text") + assert_false(header.visible, "The compact TopBar must not revive the removed header values") + assert_eq(header.text, "") func test_compact_1280_layout_contains_live_hud_regions_without_covering_the_play_area() -> void: var hud := game.get_node_or_null("HUD") as GameHud @@ -371,27 +353,35 @@ 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_long_deadline_text_wraps_and_stays_inside_the_left_rail() -> void: +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") if hud == null: return var state := game.get_game_state() var run := game.get_run_state() - run.current_floor = 1 - run.ensure_floor_deadline(1) - hud.refresh(state, [], run) - await get_tree().process_frame - - var left_rail := hud.get_node_or_null("ResponsiveLayout/LeftRail") as Control var deadline := hud.get_node_or_null("DeadlineLabel") as Label - assert_not_null(left_rail, "ResponsiveLayout requires a LeftRail") assert_not_null(deadline, "HUD requires DeadlineLabel") - if left_rail == null or deadline == null: + if deadline == null: return - assert_true(left_rail.get_global_rect().encloses(deadline.get_global_rect())) - assert_lte(deadline.get_minimum_size().x, deadline.size.x) - assert_gt(deadline.size.y, deadline.get_line_height()) + + run.current_floor = 0 + hud.refresh(state, [], run) + assert_eq(deadline.text, "", "Floor zero has no collapse deadline") + assert_false(deadline.visible, "Floor zero must not show an empty deadline slot") + + run.current_floor = 1 + var floor_deadline := run.ensure_floor_deadline(1) + floor_deadline.turns_remaining = 15 * floor_deadline.TURNS_PER_DAY + hud.refresh(state, [], run) + assert_true(deadline.visible) + assert_eq(deadline.text, "Effondrement du niveau dans 15 jours") + assert_eq(deadline.text.findn("escalier"), -1, "DeadlineLabel must not mention stairs") + assert_eq(deadline.text.findn("Étage"), -1, "DeadlineLabel must not repeat the floor") + + floor_deadline.rest() + hud.refresh(state, [], run) + assert_eq(deadline.text, "Effondrement du niveau dans 14 jours", "The displayed count must follow the live deadline") func test_event_log_and_log_panel_never_intersect_the_hud_minimap_at_reference_and_compact_sizes() -> void: var hud := game.get_node_or_null("HUD") as GameHud @@ -483,20 +473,21 @@ func _assert_named_non_overlapping_sections(layout: Control, rail_name: String, for other_index in range(index + 1, sections.size()): assert_false(sections[index].get_global_rect().intersects(sections[other_index].get_global_rect()), "%s must not overlap %s" % [sections[index].name, sections[other_index].name]) -func test_character_section_exposes_live_name_and_level_labels() -> void: +func test_character_section_title_shows_the_real_run_name_without_a_redundant_name_label() -> void: var hud := game.get_node_or_null("HUD") as GameHud assert_not_null(hud, "Game scene requires HUD") if hud == null: return var layout := hud.get_node_or_null("ResponsiveLayout") as Control var character_section := layout.get_node_or_null("CharacterSection") as Control if layout != null else null + var section_title := layout.get_node_or_null("CharacterSectionTitle") as Label if layout != null else null var name_label := layout.get_node_or_null("CharacterNameLabel") as Label if layout != null else null var level_label := layout.get_node_or_null("CharacterLevelLabel") as Label if layout != null else null assert_not_null(layout, "HUD requires ResponsiveLayout") assert_not_null(character_section, "ResponsiveLayout requires CharacterSection") - assert_not_null(name_label, "CharacterSection requires CharacterNameLabel") + assert_not_null(section_title, "CharacterSection requires CharacterSectionTitle") assert_not_null(level_label, "CharacterSection requires CharacterLevelLabel") - if layout == null or character_section == null or name_label == null or level_label == null: + if layout == null or character_section == null or section_title == null or level_label == null: return var state := game.get_game_state() @@ -505,12 +496,16 @@ func test_character_section_exposes_live_name_and_level_labels() -> void: state.player.progression.set_total_xp(125) hud.refresh(state, [], run) - assert_true(name_label.visible, "CharacterNameLabel must be visible") - assert_true(level_label.visible, "CharacterLevelLabel must be visible") - assert_true(character_section.get_global_rect().encloses(name_label.get_global_rect()), "CharacterSection must contain CharacterNameLabel") - assert_true(character_section.get_global_rect().encloses(level_label.get_global_rect()), "CharacterSection must contain CharacterLevelLabel") - assert_string_contains(name_label.text, run.player_name, "CharacterNameLabel must show the real player name") - assert_string_contains(level_label.text, str(state.player.progression.level), "CharacterLevelLabel must show the real player level") + assert_true(section_title.visible) + assert_eq(section_title.text, run.player_name, "The card heading is the run's real name, not PERSONNAGE") + assert_ne(section_title.text, "PERSONNAGE") + assert_true(name_label == null or not name_label.visible, "CharacterNameLabel must be absent or invisible because the title already names the run") + if name_label != null: + assert_eq(name_label.text, "", "The hidden duplicate must not retain a second visible identity") + assert_true(level_label.visible) + assert_true(character_section.get_global_rect().encloses(section_title.get_global_rect())) + assert_true(character_section.get_global_rect().encloses(level_label.get_global_rect())) + assert_string_contains(level_label.text, str(state.player.progression.level)) func test_character_portrait_uses_mockup_width_and_preserves_its_aspect_ratio_at_reference_size() -> void: var hud := game.get_node_or_null("HUD") as GameHud @@ -558,7 +553,7 @@ func test_section_titles_are_visible_contained_and_readable_at_reference_size() assert_true(section.get_global_rect().encloses(title.get_global_rect()), "%s must contain %s" % [section_names[index], title_names[index]]) assert_gte(title.get_theme_font_size(&"font_size"), 16, "%s must use at least a 16px font at 1920x1080" % title_names[index]) -func test_top_bar_contains_readable_non_overlapping_title_and_header_values() -> void: +func test_top_bar_defaults_to_a_single_floor_title_without_legacy_values_or_notifications() -> void: var hud := game.get_node_or_null("HUD") as GameHud assert_not_null(hud, "Game scene requires HUD") if hud == null: @@ -569,16 +564,23 @@ func test_top_bar_contains_readable_non_overlapping_title_and_header_values() -> var top_bar := layout.get_node_or_null("TopBar") as Control if layout != null else null var title := hud.get_node_or_null("TitleLabel") as Label var header_values := hud.get_node_or_null("HeaderValuesLabel") as Label + var achievement_toast := hud.get_node_or_null("AchievementToast") as Label + var title_notification := hud.get_node_or_null("TitleNotificationLabel") as Label assert_not_null(top_bar, "ResponsiveLayout requires TopBar") assert_not_null(title, "TopBar requires TitleLabel") - assert_not_null(header_values, "TopBar requires HeaderValuesLabel") - if top_bar == null or title == null or header_values == null: + assert_not_null(header_values, "Legacy HeaderValuesLabel must be explicitly hidden") + assert_not_null(achievement_toast, "HUD retains AchievementToast") + assert_not_null(title_notification, "HUD requires a separate temporary TitleNotificationLabel") + if top_bar == null or title == null or header_values == null or achievement_toast == null or title_notification == null: return - assert_true(top_bar.get_global_rect().encloses(title.get_global_rect()), "TopBar must contain TitleLabel") - assert_true(top_bar.get_global_rect().encloses(header_values.get_global_rect()), "TopBar must contain HeaderValuesLabel") - assert_false(title.get_global_rect().intersects(header_values.get_global_rect()), "TitleLabel and HeaderValuesLabel must not intersect") - assert_gte(title.get_theme_font_size(&"font_size"), 20, "TitleLabel must use at least a 20px font at 1920x1080") - assert_gte(header_values.get_theme_font_size(&"font_size"), 15, "HeaderValuesLabel must use at least a 15px font at 1920x1080") + assert_true(title.visible, "TitleLabel is the sole default visible TopBar value") + assert_eq(title.text, "Étage 0") + assert_false(header_values.visible) + assert_eq(header_values.text, "") + assert_false(achievement_toast.visible) + assert_false(title_notification.visible) + assert_true(top_bar.get_global_rect().encloses(title.get_global_rect())) + assert_gte(title.get_theme_font_size(&"font_size"), 20) func test_command_bar_subzones_are_distinct_and_contain_their_text() -> void: var hud := game.get_node_or_null("HUD") as GameHud @@ -721,26 +723,73 @@ func test_decorative_equipment_and_header_art_are_absent_or_hidden() -> void: var decorative := layout.get_node_or_null(decorative_name) as Control assert_true(decorative == null or not decorative.visible, "%s must be absent or invisible rather than adding decorative visual noise" % decorative_name) -func test_objectives_and_status_keep_the_requested_vertical_breathing_room() -> void: +func test_objectives_and_status_keep_separate_titles_and_content_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 - hud.apply_viewport_layout(Vector2(1920, 1080)) - await get_tree().process_frame - var layout := hud.get_node_or_null("ResponsiveLayout") as Control - var objectives := layout.get_node_or_null("ObjectivesSection") as Control if layout != null else null - var status := layout.get_node_or_null("StatusSection") as Control if layout != null else null - var status_title := layout.get_node_or_null("StatusSectionTitle") as Label if layout != null else null - assert_not_null(objectives) - assert_not_null(status) - assert_not_null(status_title) - if objectives == null or status == null or status_title == null: - return - assert_gte(status.get_global_rect().position.y - objectives.get_global_rect().end.y, 24.0, "Objectives and Status need at least 24px of vertical separation at 1920x1080") - assert_gte(status_title.get_global_rect().position.y - status.get_global_rect().position.y, 14.0, "ÉTAT title needs at least 14px top inset") + for viewport_size: Vector2 in [Vector2(1920, 1080), Vector2(1280, 720)]: + hud.apply_viewport_layout(viewport_size) + await get_tree().process_frame + var layout := hud.get_node_or_null("ResponsiveLayout") as Control + var objectives := layout.get_node_or_null("ObjectivesSection") as Control if layout != null else null + var status := layout.get_node_or_null("StatusSection") as Control if layout != null else null + var objectives_title := layout.get_node_or_null("ObjectivesSectionTitle") as Label if layout != null else null + var status_title := layout.get_node_or_null("StatusSectionTitle") as Label if layout != null else null + var quest_content := hud.get_node_or_null("QuestTrackerLabel") as Control + var status_content := hud.get_node_or_null("CharacterStatusLabel") as Control + assert_not_null(objectives, "ObjectivesSection is required at %s" % viewport_size) + assert_not_null(status, "StatusSection is required at %s" % viewport_size) + assert_not_null(objectives_title) + assert_not_null(status_title) + assert_not_null(quest_content) + assert_not_null(status_content) + if objectives == null or status == null or objectives_title == null or status_title == null or quest_content == null or status_content == null: + continue + assert_true(status.get_global_rect().encloses(status_content.get_global_rect()), "CharacterStatusLabel belongs inside StatusSection at %s" % viewport_size) + assert_true(objectives.get_global_rect().encloses(objectives_title.get_global_rect())) + assert_true(objectives.get_global_rect().encloses(quest_content.get_global_rect())) + assert_true(status.get_global_rect().encloses(status_title.get_global_rect())) + assert_false(status_content.get_global_rect().intersects(objectives.get_global_rect()), "CharacterStatusLabel must not touch ObjectivesSection at %s" % viewport_size) + assert_false(objectives_title.get_global_rect().intersects(quest_content.get_global_rect()), "Objectives title and content must be distinct at %s" % viewport_size) + assert_false(status_title.get_global_rect().intersects(status_content.get_global_rect()), "Status title and content must be distinct at %s" % viewport_size) + assert_false(objectives.get_global_rect().intersects(status.get_global_rect()), "Objectives and status frames must remain separate at %s" % viewport_size) + if viewport_size == Vector2(1920, 1080): + assert_gte(status.get_global_rect().position.y - objectives.get_global_rect().end.y, 24.0) + assert_gte(status_title.get_global_rect().position.y - status.get_global_rect().position.y, 14.0) -func test_character_and_journal_titles_are_outlined_light_and_readable() -> void: +func test_player_health_and_gold_use_the_final_compact_character_section_contract() -> 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() + run.gold = 15 + hud.refresh(state, [], run) + var layout := hud.get_node_or_null("ResponsiveLayout") as Control + var character_section := layout.get_node_or_null("CharacterSection") as Control if layout != null else null + var health := hud.get_node_or_null("PlayerHealthLabel") as Label + var gold_icon := hud.get_node_or_null("GoldIcon") as TextureRect + var gold_label := hud.get_node_or_null("GoldLabel") as Label + assert_not_null(character_section) + assert_not_null(health) + assert_not_null(gold_icon, "CharacterSection requires GoldIcon") + assert_not_null(gold_label) + if character_section == null or health == null or gold_icon == null or gold_label == null: + return + assert_eq(health.text, "PV : %d/%d" % [state.player.hit_points, state.player.max_hit_points]) + assert_true(gold_icon.visible) + assert_not_null(gold_icon.texture) + if gold_icon.texture != null: + assert_true(_texture_has_gold_coin_path(gold_icon.texture), "GoldIcon must use the gold_coin SVG or PNG asset") + assert_eq(gold_label.text, "15", "GoldLabel contains the numeric value only") + assert_true(character_section.get_global_rect().encloses(gold_icon.get_global_rect())) + assert_true(character_section.get_global_rect().encloses(gold_label.get_global_rect())) + var currency_bottom := maxf(gold_icon.get_global_rect().end.y, gold_label.get_global_rect().end.y) + assert_gte(character_section.get_global_rect().end.y - currency_bottom, 16.0, "The currency icon/value union needs a >=16px bottom margin") + +func test_character_and_journal_titles_use_the_final_large_outlined_light_style() -> void: var hud := game.get_node_or_null("HUD") as GameHud assert_not_null(hud, "Game scene requires HUD") if hud == null: @@ -751,14 +800,20 @@ func test_character_and_journal_titles_are_outlined_light_and_readable() -> void assert_not_null(layout) if layout == null: return - for title_name: String in ["CharacterSectionTitle", "JournalSectionTitle"]: - var title := layout.get_node_or_null(title_name) as Label - assert_not_null(title, "ResponsiveLayout requires %s" % title_name) - if title == null: + for specification: Dictionary in [ + {"section": "CharacterSection", "title": "CharacterSectionTitle"}, + {"section": "JournalSection", "title": "JournalSectionTitle"}, + ]: + var section := layout.get_node_or_null(String(specification.section)) as Control + var title := layout.get_node_or_null(String(specification.title)) as Label + assert_not_null(section) + assert_not_null(title, "ResponsiveLayout requires %s" % specification.title) + if section == null or title == null: continue - assert_gte(title.get_theme_font_size(&"font_size"), 16, "%s needs at least a 16px font at 1920x1080" % title_name) - assert_gte(title.get_theme_constant(&"outline_size"), 2, "%s needs a >=2px contour" % title_name) - assert_gte(title.get_theme_color(&"font_color").get_luminance(), 0.60, "%s needs a light font color" % title_name) + assert_gte(title.get_theme_font_size(&"font_size"), 20, "%s needs a >=20px font at 1920x1080" % title.name) + assert_gte(title.get_theme_constant(&"outline_size"), 3, "%s needs a >=3px contour" % title.name) + assert_gte(title.get_theme_color(&"font_color").get_luminance(), 0.75, "%s needs a >=0.75 luminance" % title.name) + assert_gte(title.get_global_rect().position.y - section.get_global_rect().position.y, 16.0, "%s needs a >=16px vertical inset" % title.name) func test_command_bar_keeps_all_three_zones_readable_at_reference_and_compact_sizes() -> void: var hud := game.get_node_or_null("HUD") as GameHud @@ -798,6 +853,9 @@ func test_command_bar_keeps_all_three_zones_readable_at_reference_and_compact_si assert_lte(help.get_minimum_size().x, help.size.x, "The right help zone must fit its complete label at %s" % viewport_size) assert_eq(prompt.text, "F : Distance • X : Magie • K : Familier", "The center zone must contain exactly the three requested command notions") +func _texture_has_gold_coin_path(texture: Texture2D) -> bool: + return _texture_uses_path(texture, "res://assets/ui/dark_fantasy/gold_coin.svg") or _texture_uses_path(texture, "res://assets/ui/dark_fantasy/gold_coin.png") + func _texture_uses_path(texture: Texture2D, expected_path: String) -> bool: if texture == null: return false