fix: localize active HUD journal events
This commit is contained in:
@@ -11,17 +11,59 @@ func test_hud_localizes_current_structured_journal_events_without_using_the_engl
|
||||
var state := game.get_game_state()
|
||||
var events: Array[GameEvent] = [
|
||||
GameEvent.new(1, 0, &"game_started", {"player_name": "Ariane"}, "Ariane begins a new run."),
|
||||
GameEvent.new(2, 0, &"moved", {"to": Vector2i(6, 8)}, "You move to (6, 8)."),
|
||||
GameEvent.new(3, 0, &"companion_moved", {}, "Your companion follows."),
|
||||
GameEvent.new(4, 0, &"episode_published", {"number": 7}, "Episode 7 published."),
|
||||
# Production events carry their destination as `to_cell`, not the legacy `to` key.
|
||||
GameEvent.new(2, 0, &"moved", {"to_cell": Vector2i(6, 8)}, "You move to (6, 8).", &"player"),
|
||||
GameEvent.new(3, 0, &"enemy_moved", {"to_cell": Vector2i(5, 8)}, "The goblin moves.", &"goblin", &"player"),
|
||||
GameEvent.new(4, 0, &"blocked", {"to_cell": Vector2i(5, 7)}, "Your way is blocked.", &"player"),
|
||||
GameEvent.new(5, 0, &"melee", {"damage": 3, "attack_method": "épée courte"}, "You strike the goblin with a short sword for 3.", &"player", &"goblin"),
|
||||
GameEvent.new(6, 0, &"enemy_melee", {"damage": 2, "attack_method": "griffes"}, "The goblin hits you with claws for 2.", &"goblin", &"player"),
|
||||
GameEvent.new(7, 0, &"enemy_defeated", {}, "The goblin is defeated.", &"goblin", &"player"),
|
||||
GameEvent.new(8, 0, &"attack_started", {"attack_method": "épée courte"}, "You attack.", &"player", &"goblin"),
|
||||
GameEvent.new(9, 0, &"attack_hit", {}, "You hit.", &"player", &"goblin"),
|
||||
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(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."),
|
||||
]
|
||||
|
||||
hud.refresh(state, events, game.get_run_state())
|
||||
|
||||
var journal_text := hud.event_log.get_parsed_text()
|
||||
assert_string_contains(journal_text, "Ariane commence une nouvelle aventure.")
|
||||
assert_string_contains(journal_text, "Vous vous déplacez vers (6, 8).")
|
||||
assert_string_contains(journal_text, "Votre familier vous suit.")
|
||||
assert_string_contains(journal_text, "Épisode 7 publié.")
|
||||
for english_source: String in ["Ariane begins a new run.", "You move to (6, 8).", "Your companion follows.", "Episode 7 published."]:
|
||||
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.",
|
||||
"Le gobelin est vaincu.",
|
||||
"Vous attaquez le gobelin avec épée courte.",
|
||||
"Vous touchez le gobelin.",
|
||||
"Vous infligez 3 dégâts au gobelin.",
|
||||
"Le gobelin succombe.",
|
||||
"Vous gagnez 12 points d’expérience.",
|
||||
"Le gobelin laisse tomber du butin.",
|
||||
"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."]:
|
||||
assert_eq(journal_text.find(english_source), -1, "GameHud must localize %s from structured event data, not reuse its source message" % english_source)
|
||||
|
||||
func test_hud_keeps_the_domain_message_for_unknown_journal_event_kinds() -> 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 source_message := "An unknown event remains readable."
|
||||
|
||||
hud.refresh(state, [GameEvent.new(1, 0, &"unknown_event", {}, source_message)], game.get_run_state())
|
||||
|
||||
assert_string_contains(hud.event_log.get_parsed_text(), source_message)
|
||||
|
||||
Reference in New Issue
Block a user