local D = {}

function D.show (index)

	DialogManager.CurrentDialogIndex = index

	if index == 1 then
		DialogManager.showDialog({key = "ask_provisioner_text_1", options = {{key = "option_1"}}})

	elseif index == 2 then
		DialogManager.showDialog({key = "ask_provisioner_text_2", options = {{key = "option_2"}}})

	elseif index == 3 then
		DialogManager.showDialog({key = "ask_provisioner_text_3", options = {{key = "option_3"}}})

	else
		DialogManager.showDialog({key = "ask_provisioner_text_4", options = {{key = "continue", id = ConstEndDialog}}})
	end

end

-- Called when choosing an reply option from the list
function D.dismiss (index, identifier)

	if DialogManager.CurrentDialogIndex == 4 then
		gVarStore.setBool("learned_missing_provisioner", true)
	end

	-- Reply that indicates to end the dialog tree
	if identifier == ConstEndDialog then
		DialogManager.endCurrentDialogTree()
		return
	end

	D.show(DialogManager.CurrentDialogIndex + 1)
end

-- Called when dialog tree is initialized
function D.started ()
	D.show(1)
end

-- Called when dialog tree is terminated
function D.ended()

end

-- Register globally
DialogManager.Dialogs["tavernkeeper1"].DialogTrees["ask_provisioner"] = D
