fix: describe enemy loot rewards in HUD

This commit is contained in:
goose
2026-10-09 10:25:24 -04:00
parent 4cc2bd4272
commit 0090753675
4 changed files with 116 additions and 4 deletions
+29 -2
View File
@@ -23,7 +23,7 @@ func test_hud_localizes_current_structured_journal_events_without_using_the_engl
GameEvent.new(10, 0, &"damage_dealt", {"damage": 3}, "You deal 3 damage.", &"player", &"goblin"),
GameEvent.new(11, 0, &"actor_died", {}, "The goblin is defeated.", &"goblin", &"player"),
GameEvent.new(12, 0, &"xp_granted", {"xp": 12}, "You gain experience.", &"player", &"goblin"),
GameEvent.new(13, 0, &"loot_dropped", {}, "Loot dropped.", &"goblin", &"player"),
GameEvent.new(13, 0, &"loot_dropped", {"items": [{"item_id": &"consumable_bandage", "quantity": 2}, {"item_id": &"weapon_hunting_knife", "quantity": 1}], "gold": 12, "empty": false}, "Loot dropped.", &"goblin", &"player"),
GameEvent.new(14, 0, &"companion_intercepted", {}, "Your companion intercepts the attack.", &"goblin", &"companion"),
GameEvent.new(15, 0, &"companion_died", {}, "Your companion falls, but your run continues.", &"companion", &"player"),
GameEvent.new(16, 0, &"companion_moved", {}, "Your companion follows.", &"companion", &"player"),
@@ -46,7 +46,7 @@ func test_hud_localizes_current_structured_journal_events_without_using_the_engl
"Vous infligez 3 dégâts au gobelin.",
"Le gobelin succombe.",
"Vous gagnez 12 points d’expérience.",
"Le gobelin laisse tomber du butin.",
"Butin au sol : Bandage x2, Couteau de chasse x1, 12 or.",
"Votre familier intercepte l’attaque du gobelin.",
"Votre familier tombe, mais votre aventure continue.",
"Votre familier vous suit.",
@@ -55,6 +55,33 @@ func test_hud_localizes_current_structured_journal_events_without_using_the_engl
assert_string_contains(journal_text, expected)
for english_source: String in ["Ariane begins a new run.", "You move to (6, 8).", "The goblin moves.", "Your way is blocked.", "You strike the goblin with a short sword for 3.", "The goblin hits you with claws for 2.", "The goblin is defeated.", "You attack.", "You hit.", "You deal 3 damage.", "You gain experience.", "Loot dropped.", "Your companion intercepts the attack.", "Your companion falls, but your run continues.", "Your companion follows.", "Episode 7 published."]:
assert_eq(journal_text.find(english_source), -1, "GameHud must localize %s from structured event data, not reuse its source message" % english_source)
for technical_id: String in ["consumable_bandage", "weapon_hunting_knife"]:
assert_eq(journal_text.find(technical_id), -1, "GameHud must resolve %s through the content catalog" % technical_id)
func test_hud_describes_empty_loot_and_pickup_outcomes_in_french() -> void:
var game := GameScene.instantiate() as Game
add_child_autofree(game)
await get_tree().process_frame
var hud := game.get_node("HUD") as GameHud
var state := game.get_game_state()
var events: Array[GameEvent] = [
GameEvent.new(1, 0, &"loot_dropped", {"items": [], "gold": 0, "empty": true}, "Loot dropped.", &"goblin", &"player"),
GameEvent.new(2, 0, &"item_picked_up", {"item_id": &"consumable_bandage", "quantity": 2}, "Picked up consumable_bandage x2.", &"player"),
GameEvent.new(3, 0, &"pickup_refused", {"item_id": &"consumable_bandage", "quantity": 2, "reason": "inventory_full"}, "Inventory is full.", &"player"),
GameEvent.new(4, 0, &"loot_taken", {"items": [{"item_id": &"consumable_bandage", "quantity": 1}], "gold": 4, "ammunition": 3, "refused_items": [{"item_id": &"weapon_hunting_knife", "quantity": 1, "reason": "inventory_full"}]}, "Loot taken.", &"player"),
]
hud.refresh(state, events, game.get_run_state())
var journal_text := hud.event_log.get_parsed_text()
assert_string_contains(journal_text, "Aucun butin")
assert_eq(journal_text.find("laisse tomber du butin"), -1)
assert_string_contains(journal_text, "Ramassé : Bandage x2.")
assert_string_contains(journal_text, "Inventaire plein")
assert_string_contains(journal_text, "Butin récupéré : Bandage x1, 4 or, 3 munitions")
assert_string_contains(journal_text, "Couteau de chasse x1 non ramassé (inventaire plein)")
for technical_id: String in ["consumable_bandage", "weapon_hunting_knife"]:
assert_eq(journal_text.find(technical_id), -1, "GameHud must never expose known item IDs")
func test_hud_localizes_generated_enemy_ids_from_live_state_and_catalog_after_removal() -> void:
var game := GameScene.instantiate() as Game