fix: hide movement events from HUD journal
This commit is contained in:
@@ -10,7 +10,9 @@ func test_hud_replaces_its_log_with_the_supplied_journal_events() -> void:
|
||||
var hud := game.get_node("HUD") as GameHud
|
||||
var state := game.get_game_state()
|
||||
|
||||
hud.refresh(state, [GameEvent.new(1, 0, &"moved", {}, "obsolete transient message")])
|
||||
hud.refresh(state, [GameEvent.new(2, 0, &"blocked", {}, "authoritative journal message")])
|
||||
hud.refresh(state, [
|
||||
GameEvent.new(1, 0, &"moved", {}, "obsolete transient message"),
|
||||
GameEvent.new(2, 0, &"blocked", {}, "authoritative journal message"),
|
||||
])
|
||||
|
||||
assert_eq(hud.event_log.get_parsed_text(), "Votre chemin est bloqué.\n")
|
||||
|
||||
@@ -27,7 +27,8 @@ func test_hud_localizes_current_structured_journal_events_without_using_the_engl
|
||||
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"),
|
||||
GameEvent.new(17, 0, &"episode_published", {"number": 7}, "Episode 7 published."),
|
||||
GameEvent.new(17, 0, &"party_moved", {}, "The party moves.", &"player"),
|
||||
GameEvent.new(18, 0, &"episode_published", {"number": 7}, "Episode 7 published."),
|
||||
]
|
||||
|
||||
hud.refresh(state, events, game.get_run_state())
|
||||
@@ -35,8 +36,6 @@ func test_hud_localizes_current_structured_journal_events_without_using_the_engl
|
||||
var journal_text := hud.event_log.get_parsed_text()
|
||||
for expected: String in [
|
||||
"Ariane commence une nouvelle aventure.",
|
||||
"Vous vous déplacez vers (6, 8).",
|
||||
"Le gobelin se déplace.",
|
||||
"Votre chemin est bloqué.",
|
||||
"Vous frappez le gobelin avec épée courte et lui infligez 3 dégâts.",
|
||||
"Le gobelin vous frappe avec griffes et vous inflige 2 dégâts.",
|
||||
@@ -49,15 +48,37 @@ func test_hud_localizes_current_structured_journal_events_without_using_the_engl
|
||||
"Butin — au sol : Bandage x2, Couteau de chasse x1 ; or récupéré : 12.",
|
||||
"Votre familier intercepte l’attaque du gobelin.",
|
||||
"Votre familier tombe, mais votre aventure continue.",
|
||||
"Votre familier vous suit.",
|
||||
"Épisode 7 publié.",
|
||||
]:
|
||||
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."]:
|
||||
for hidden_movement: String in ["You move to (6, 8).", "The goblin moves.", "Your companion follows.", "The party moves.", "Vous vous déplacez vers (6, 8).", "Le gobelin se déplace.", "Votre familier vous suit."]:
|
||||
assert_eq(journal_text.find(hidden_movement), -1, "GameHud must omit movement events from the journal even when they provide source messages")
|
||||
for english_source: String in ["Ariane begins a new run.", "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.", "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_shows_only_non_movement_events_in_a_mixed_batch() -> 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, &"moved", {"to_cell": Vector2i(5, 7)}, "You move.", &"player"),
|
||||
GameEvent.new(1, 0, &"enemy_moved", {}, "The goblin moves.", &"goblin", &"player"),
|
||||
GameEvent.new(1, 0, &"companion_moved", {}, "Your companion follows.", &"companion", &"player"),
|
||||
GameEvent.new(1, 0, &"party_moved", {}, "The party moves.", &"player"),
|
||||
GameEvent.new(1, 0, &"blocked", {}, "Your way is blocked.", &"player"),
|
||||
GameEvent.new(1, 0, &"loot_dropped", {"items": [], "gold": 4}, "Loot dropped.", &"goblin", &"player"),
|
||||
GameEvent.new(1, 0, &"melee", {"damage": 3, "attack_method": "épée courte"}, "You strike.", &"player", &"goblin"),
|
||||
]
|
||||
|
||||
hud.refresh(state, events, game.get_run_state())
|
||||
|
||||
assert_eq(hud.event_log.get_parsed_text(), "Votre chemin est bloqué.\nOr récupéré : 4.\nVous frappez le gobelin avec épée courte et lui infligez 3 dégâts.\n")
|
||||
|
||||
func test_hud_distinguishes_dropped_enemy_items_from_immediately_collected_gold() -> void:
|
||||
var game := GameScene.instantiate() as Game
|
||||
add_child_autofree(game)
|
||||
@@ -107,11 +128,9 @@ func test_hud_localizes_generated_enemy_ids_from_live_state_and_catalog_after_re
|
||||
var generated_id := &"enemy_scavenger_07"
|
||||
state.enemies[generated_id] = ActorState.new(generated_id, Vector2i(5, 8), 22, 5, &"enemy_scavenger")
|
||||
|
||||
# Movement events are deliberately not journal entries, including generated enemies.
|
||||
hud.refresh(state, [GameEvent.new(1, 0, &"enemy_moved", {}, "The scavenger moves.", generated_id, &"player")], game.get_run_state())
|
||||
var live_text := hud.event_log.get_parsed_text()
|
||||
assert_string_contains(live_text, "Le pillard efflanque se déplace.")
|
||||
assert_eq(live_text.find("enemy_scavenger_07"), -1)
|
||||
assert_eq(live_text.find("_"), -1)
|
||||
assert_eq(hud.event_log.get_parsed_text(), "")
|
||||
|
||||
state.enemies.erase(generated_id)
|
||||
hud.refresh(state, [GameEvent.new(2, 0, &"enemy_melee", {"damage": 2, "attack_method": "griffes"}, "The scavenger hits you.", generated_id, &"player")], game.get_run_state())
|
||||
|
||||
Reference in New Issue
Block a user