class_name QuestBoardWindow extends Popup

const entry_template = preload("res://templates/quest_board_entry.tscn")

@onready var entry_list : VBoxContainer = %Entries


func populate(quests : Array[Quest]) -> void:
	for entry : QuestBoardEntry in entry_list.get_children():
		entry.queue_free()
	for quest in quests:
		if !quest.is_taken():
			add_entry(quest)

func add_entry(quest : Quest) -> void:
	var qle : QuestBoardEntry = entry_template.instantiate()
	entry_list.add_child(qle)
	qle.setup(quest)
	qle.board_window = self

func _on_quest_accepted() -> void:
	hide()

func _on_close_requested() -> void:
	hide()
