local D = {}

function D.show (index)

	DialogManager.CurrentDialogIndex = index

	if index == 1 then
		DialogManager.showDialog({key = "greet_text_2", options = {{key = "option_2"} }})
	elseif index == 2 then
		DialogManager.showDialog({key = "greet_text_3", options = {{key = "option_3"} }})
	elseif index == 3 then
		DialogManager.showDialog({key = "greet_text_4", options = {{key = "option_4"} }})
	elseif index == 4 then
		DialogManager.showDialog({key = "greet_text_5", options = {{key = "continue", id = ConstEndDialog}}})
	end

end

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

	-- 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["tavernkeeper2"].DialogTrees["what_happened"] = D