fix: finish French HUD event presentation

This commit is contained in:
goose
2026-10-09 09:53:41 -04:00
parent dbc53aab71
commit 4cc2bd4272
4 changed files with 174 additions and 7 deletions
+94 -4
View File
@@ -192,7 +192,7 @@ func refresh(state: GameState, events: Array[GameEvent] = [], run_state: RunStat
if run_state != null:
_run_state = run_state
player_health_label.text = "PV du joueur : %d/%d" % [state.player.hit_points, state.player.max_hit_points]
player_focus_label.text = "Focus: %d/%d" % [state.player.focus, state.player.max_focus]
player_focus_label.text = "Focus : %d/%d" % [state.player.focus, state.player.max_focus]
_refresh_live_gauge(health_bar, state.player.hit_points, state.player.max_hit_points)
_refresh_live_gauge(focus_bar, state.player.focus, state.player.max_focus)
_refresh_experience(state.player.progression)
@@ -210,7 +210,7 @@ func refresh(state: GameState, events: Array[GameEvent] = [], run_state: RunStat
enemy_health_label.text = combat_summary
combat_summary_label.text = ""
deadline_label.text = _deadline_status()
gold_label.text = "Or: %d" % (_run_state.gold if _run_state != null else 0)
gold_label.text = "Or : %d" % (_run_state.gold if _run_state != null else 0)
quest_tracker_label.text = _quest_tracker()
action_hint_label.text = "F : Distance • X : Magie • K : Familier"
context_prompt_label.text = get_context_prompt()
@@ -263,9 +263,74 @@ func _localized_event_message(event: GameEvent) -> String:
return "Votre familier vous suit."
&"episode_published":
return "Épisode %d publié." % int(event.payload.get("number", 0))
&"ranged":
return "Vous tirez sur %s avec %s et infligez %d dégâts." % [target, _localized_weapon(event.payload), damage]
&"cast":
return "Vous lancez %s sur %s et infligez %d dégâts." % [_localized_spell(event.payload), target, damage]
&"ranged_attack_started":
return "Vous préparez un tir avec %s sur %s." % [_localized_weapon(event.payload), target]
&"projectile_fired":
return "Vous tirez avec %s sur %s." % [_localized_weapon(event.payload), target]
&"ranged_attack_hit":
return "Votre tir atteint %s." % target
&"invalid_ranged_target":
return "Tir impossible : %s." % _localized_failure_reason(event.payload.get("reason", ""))
&"spell_targeting_started":
return "Choisissez la cible de votre sort."
&"spell_targeting_cancelled":
return "Ciblage du sort annulé."
&"invalid_spell_target":
return "Sort impossible : %s." % _localized_failure_reason(event.payload.get("reason", ""))
&"spell_cast_started":
return "Vous lancez %s sur %s." % [_localized_spell(event.payload), target]
&"spell_damage_dealt":
return "%s inflige %d dégâts %s." % [_sentence_case(_localized_spell(event.payload)), damage, _with_preposition("à", target)]
&"spell_effect_applied":
return "%s applique l’état %s %s." % [_sentence_case(_localized_spell(event.payload)), _localized_status(event.payload.get("status", "")), _with_preposition("à", target)]
_:
return event.message
func _localized_weapon(payload: Dictionary) -> String:
var weapon_id := StringName(payload.get("weapon_id", ""))
if _run_state != null and _run_state.content_catalog != null and not weapon_id.is_empty():
var weapon := _run_state.content_catalog.get_item(weapon_id)
if not weapon.is_empty():
return String(weapon.get("name", weapon_id))
return "votre arme à distance"
func _localized_spell(payload: Dictionary) -> String:
var spell_name := String(payload.get("spell_name", ""))
if not spell_name.is_empty():
return spell_name
var spell_id := StringName(payload.get("spell_id", ""))
if _run_state != null and _run_state.content_catalog != null and not spell_id.is_empty():
var spell := _run_state.content_catalog.get_spell(spell_id)
if not spell.is_empty():
return String(spell.get("name", spell_id))
return "votre sort"
func _localized_failure_reason(reason: Variant) -> String:
match StringName(reason):
&"cooldown": return "le sort est en recharge"
&"insufficient_focus": return "Focus insuffisant"
&"out_of_range": return "la cible est hors de portée"
&"line_of_sight_blocked": return "la ligne de vue est bloquée"
&"no_ammunition": return "vous n’avez plus de munitions"
&"no_ranged_weapon": return "aucune arme à distance n’est équipée"
&"invalid_target": return "cible invalide"
&"no_valid_spell_target": return "aucune cible valide pour ce sort"
_: return "action impossible"
func _localized_status(status: Variant) -> String:
match StringName(status):
&"poison": return "empoisonnement"
&"burning": return "brûlure"
&"bleeding": return "saignement"
&"feared": return "peur"
&"stunned": return "étourdissement"
&"wounded": return "blessure"
_: return "effet"
func _sentence_case(text: String) -> String:
return text.left(1).to_upper() + text.substr(1)
@@ -286,8 +351,33 @@ func _localized_actor(actor_id: StringName) -> String:
return "le gobelin"
&"":
return "l’adversaire"
_:
return String(actor_id).replace("_", " ")
var content_id := actor_id
if _state != null and _state.enemies.has(actor_id):
var enemy: ActorState = _state.enemies[actor_id]
content_id = enemy.content_id
else:
content_id = _content_id_from_generated_actor(actor_id)
if _run_state != null and _run_state.content_catalog != null:
var enemy_definition := _run_state.content_catalog.get_enemy(content_id)
if not enemy_definition.is_empty():
return _with_definite_article(String(enemy_definition.get("name", "adversaire")))
return "l’adversaire"
func _content_id_from_generated_actor(actor_id: StringName) -> StringName:
var id := String(actor_id)
var suffix_start := id.rfind("_")
if suffix_start >= 0 and id.substr(suffix_start + 1).is_valid_int():
return StringName(id.left(suffix_start))
return actor_id
func _with_definite_article(name: String) -> String:
var normalized := name.strip_edges()
if normalized.is_empty():
return "l’adversaire"
var lower := normalized.to_lower()
if lower.begins_with("le ") or lower.begins_with("la ") or lower.begins_with("les ") or lower.begins_with("l’") or lower.begins_with("l'"):
return normalized
return "l’%s" % normalized if lower.begins_with("a") or lower.begins_with("e") or lower.begins_with("i") or lower.begins_with("o") or lower.begins_with("u") or lower.begins_with("h") else "le %s" % lower
func _refresh_live_gauge(gauge: ProgressBar, current: int, maximum: int) -> void:
gauge.min_value = 0