--[[

    MonkeyQuest:
    Quest tracker.
    
    Website:	www.toctastic.net
	Author:		Trentin
	Email:		monkeymods@gmail.com

--]]


function MonkeyQuest_FindRelevantQuest(strInfo)
	
	local key, value, questKey, questValue, objKey, objValue;
	local i, j;


	for key, value in pairs(MonkeyQuestTable) do

		if (value.quests ~= nil) then
			for questKey, questValue in pairs(value.quests) do
				
				if (questValue.objectives ~= nil) then
					for objKey, objValue in pairs(questValue.objectives) do
						
						i, j = string.find(objKey, strInfo);
						
						--MonkeyAPI_DebugMsg(objKey .. " == " .. strInfo)-- .. " i= " .. i .. " j= " .. j);
						
						if (j ~= nil and i == 1) then
							-- found something
							if (objValue.numNeeded ~= nil) then
								return questValue.questTitle, tostring(objKey) .. " " .. objValue.numItems .. "/" .. objValue.numNeeded;
							else
								return questValue.questTitle, tostring(objKey);
							end
						end
					end
				end
				-- search the quest descriptions here
			end
		end
	end
end


function MonkeyQuest_AddQuestInfoToTooltip(strQuestTitle, strObjective)

	-- TODO: add colour options
	if (strQuestTitle ~= nil) then
		GameTooltip:AddLine(MONKEYQUEST_QUEST_STR .. strQuestTitle);
	end
	
	if (strObjective ~= nil) then
		GameTooltip:AddLine(strObjective);
	end
	
	GameTooltip:Show();
end
