local D = {}

function D.show (index)

	DialogManager.CurrentDialogIndex = index

	if index == 1 then
		DialogManager.showDialog({key = "goods_text_1", options = {{key = "goods_reply_1"}}})
	elseif index == 2 then
		DialogManager.showDialog({key = "goods_text_2", 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
		if DialogManager.CurrentDialogIndex == 2 then
			gTownState.unlockLocation(TownLocation.Store)
		end
		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["merchant0"].DialogTrees["ask_about_goods"] = D
