fix: distinguish dropped and collected enemy loot
This commit is contained in:
@@ -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.",
|
||||
"Butin au sol : Bandage x2, Couteau de chasse x1, 12 or.",
|
||||
"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.",
|
||||
@@ -58,27 +58,40 @@ func test_hud_localizes_current_structured_journal_events_without_using_the_engl
|
||||
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:
|
||||
func test_hud_distinguishes_dropped_enemy_items_from_immediately_collected_gold() -> 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 cases: Array[Dictionary] = [
|
||||
{"payload": {"items": [{"item_id": &"consumable_bandage", "quantity": 1}], "gold": 26}, "expected": "Butin — au sol : Bandage x1 ; or récupéré : 26."},
|
||||
{"payload": {"items": [{"item_id": &"consumable_bandage", "quantity": 2}], "gold": 0}, "expected": "Butin au sol : Bandage x2."},
|
||||
{"payload": {"items": [], "gold": 8}, "expected": "Or récupéré : 8."},
|
||||
{"payload": {"items": [], "gold": 0, "empty": true}, "expected": "Aucun butin."},
|
||||
]
|
||||
for test_case: Dictionary in cases:
|
||||
hud.refresh(state, [GameEvent.new(1, 0, &"loot_dropped", test_case.payload, "Loot dropped.", &"goblin", &"player")], game.get_run_state())
|
||||
assert_eq(hud.event_log.get_parsed_text(), "%s\n" % test_case.expected)
|
||||
|
||||
func test_hud_describes_pickup_and_loot_take_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"),
|
||||
GameEvent.new(1, 0, &"item_picked_up", {"item_id": &"consumable_bandage", "quantity": 2}, "Picked up consumable_bandage x2.", &"player"),
|
||||
GameEvent.new(2, 0, &"pickup_refused", {"item_id": &"consumable_bandage", "quantity": 2, "reason": "inventory_full"}, "Inventory is full.", &"player"),
|
||||
GameEvent.new(3, 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, "Butin récupéré : Bandage x1, 4 or, 3 munitions récupérées")
|
||||
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")
|
||||
|
||||
Reference in New Issue
Block a user