extends Window

@onready var nameLabel : Label = %NameLabel
@onready var difficultyLabel : Label = %DifficultyLabel
@onready var locationLabel : Label = %LocationLabel
@onready var advRewardList : GridContainer = %AdventurerRewardList
@onready var guildRewardList : GridContainer = %GuildRewardList
var quest : Quest

func setup(qst : Quest) -> void:
	quest = qst
	quest.status_changed.connect(_on_quest_changed)
	update()
	#TODO: Show quest rewards

func update() -> void:
	nameLabel.text = quest.name
	difficultyLabel.text = quest.difficulty_name()
	locationLabel.text = quest.location_name()
	#TODO: Show the current status of the quest
	
func close() -> void:
	hide()
	queue_free()

func _on_quest_changed(status : Quest.Status) -> void:
	if status == Quest.Status.CLOSED:
		close()
	else:
		update()

func _on_remove_quest_confirm() -> void:
	Guild.remove_quest(quest)
	close()

func _on_remove_quest_cancel() -> void:
	%ConfirmDialog.hide()


func _on_remove_button_pressed() -> void:
	pass


func _on_back_button_pressed() -> void:
	close()
