extends Control


var quest : Quest


func generate_quest() -> void:
	quest = Quest.new()
	quest.name = "A Test Quest"
	quest.location = Quest.Locations.NESTORS_WOODS
	quest.difficulty = 1
	quest.length = 60
	quest.rewards = {"exp":100,"gold":1}

func update_quest_window() -> void:
	if quest:
		%NameField.text = quest.name
		%DifficultyField.text = quest.difficulty_name()
		%LocationField.text = quest.location_name()
	#for reward in quest.rewards.:

func reset() -> void:
	quest = null
	%DifficultyOptions.select(0)
	%LocationOptions.select(0)
	#TODO: Clear bonus rewards

func _on_generate_button_pressed() -> void:
	generate_quest()
	update_quest_window()
	%GenerateQuest.hide()
	%PostQuest.show()

func _on_post_button_pressed() -> void:
	Guild.add_quest(quest)
	quest = null
	%GenerateQuest.show()
	%PostQuest.hide()
	hide()

func _on_post_back_button_pressed() -> void:
	%GenerateQuest.show()
	%PostQuest.hide()

func _on_generate_back_button_pressed() -> void:
	hide()
	reset()
