feat: add responsive HUD prompts
This commit is contained in:
@@ -1,13 +1,20 @@
|
||||
class_name GameHud
|
||||
extends CanvasLayer
|
||||
|
||||
const DOOR_PROMPT := "Espace — Ouvrir la porte"
|
||||
const STAIRS_PROMPT := "Espace — Descendre l’escalier"
|
||||
const EXIT_REACHED_PROMPT := "Sortie atteinte — prochain étage bientôt disponible"
|
||||
|
||||
@onready var player_health_label: Label = $PlayerHealthLabel
|
||||
@onready var enemy_health_label: Label = $EnemyHealthLabel
|
||||
@onready var combat_summary_label: Label = $CombatSummaryLabel
|
||||
@onready var event_log: RichTextLabel = $EventLog
|
||||
@onready var context_prompt_label: Label = $ContextPromptLabel
|
||||
var combat_summary := ""
|
||||
var _state: GameState
|
||||
|
||||
func refresh(state: GameState, results: Array[TurnResult] = []) -> void:
|
||||
_state = state
|
||||
player_health_label.text = "Player HP: %d/%d" % [state.player.hit_points, state.player.max_hit_points]
|
||||
if state.enemies.has(&"goblin"):
|
||||
var goblin: ActorState = state.enemies[&"goblin"]
|
||||
@@ -17,5 +24,19 @@ func refresh(state: GameState, results: Array[TurnResult] = []) -> void:
|
||||
enemy_health_label.text = "No active target"
|
||||
combat_summary = "No active target"
|
||||
combat_summary_label.text = combat_summary
|
||||
context_prompt_label.text = get_context_prompt()
|
||||
for result in results:
|
||||
event_log.append_text(result.message + "\n")
|
||||
|
||||
func get_context_prompt() -> String:
|
||||
if _state == null:
|
||||
return ""
|
||||
match _state.get_context_target():
|
||||
&"closed_door":
|
||||
return DOOR_PROMPT
|
||||
&"stairs":
|
||||
return STAIRS_PROMPT
|
||||
&"exit_reached":
|
||||
return EXIT_REACHED_PROMPT
|
||||
_:
|
||||
return ""
|
||||
|
||||
Reference in New Issue
Block a user