local mod	= DBM:NewMod(1207, "DBM-Party-WoD", 5, 556)
local L		= mod:GetLocalizedStrings()
local wowToc = DBM:GetTOC()

mod.statTypes = "normal,heroic,mythic,challenge,timewalker"

if (wowToc >= 100200) then
	mod.upgradedMPlus = true
end

mod:SetRevision("20231020041658")
mod:SetCreatureID(83894, 83892, 83893)--Dulhu 83894, Gola 83892, Telu
mod:SetEncounterID(1757)
mod:SetBossHPInfoToHighest()

mod:RegisterCombat("combat")

if (wowToc >= 100200) then
	--Patch 10.2 or later
	mod:RegisterEventsInCombat(
	--	"SPELL_CAST_START",
	--	"SPELL_CAST_SUCCESS",
	--	"SPELL_AURA_APPLIED",
	--	"SPELL_AURA_APPLIED_DOSE",
	--	"SPELL_AURA_REMOVED",
	--	"SPELL_AURA_REMOVED_DOSE",
	--	"SPELL_PERIODIC_DAMAGE",
	--	"SPELL_PERIODIC_MISSED",
	--	"UNIT_DIED",
	--	"UNIT_SPELLCAST_SUCCEEDED boss1"
	)

	--local warnSpreadshot								= mod:NewSpellAnnounce(334404, 3)

	--local specWarnSinseeker							= mod:NewSpecialWarningYou(335114, nil, nil, nil, 3, 2)
	--local yellSinseeker								= mod:NewShortYell(335114)
	--local specWarnPyroBlast							= mod:NewSpecialWarningInterrupt(396040, "HasInterrupt", nil, nil, 1, 2)
	--local specWarnGTFO								= mod:NewSpecialWarningGTFO(409058, nil, nil, nil, 1, 8)

	--local timerSinseekerCD							= mod:NewAITimer(49, 335114, nil, nil, nil, 3)
	--local timerSpreadshotCD							= mod:NewAITimer(11.8, 334404, nil, nil, nil, 2, nil, DBM_COMMON_L.TANK_ICON)

	--mod:AddRangeFrameOption("5/6/10")
	--mod:AddInfoFrameOption(407919, true)
	--mod:AddSetIconOption("SetIconOnSinSeeker", 335114, true, false, {1, 2, 3})

	function mod:OnCombatStart(delay)

	end

	--function mod:OnCombatEnd()
	--	if self.Options.RangeFrame then
	--		DBM.RangeCheck:Hide()
	--	end
	--end

	--[[
	function mod:SPELL_CAST_START(args)
		local spellId = args.spellId
		if spellId == 335114 then
	--		if self:CheckInterruptFilter(args.sourceGUID, false, true) then
	--
	--		end
		end
	end
	--]]

	--[[
	function mod:SPELL_CAST_SUCCESS(args)
		local spellId = args.spellId
		if spellId == 334945 then

		end
	end
	--]]

	--[[
	function mod:SPELL_AURA_APPLIED(args)
		local spellId = args.spellId
		if spellId == 334971 then

		end
	end
	--mod.SPELL_AURA_APPLIED_DOSE = mod.SPELL_AURA_APPLIED
	--]]

	--[[
	function mod:SPELL_AURA_REMOVED(args)
		local spellId = args.spellId
		if spellId == 334945 then

		end
	end
	--mod.SPELL_AURA_REMOVED_DOSE = mod.SPELL_AURA_REMOVED
	--]]

	--[[
	function mod:SPELL_PERIODIC_DAMAGE(_, _, _, _, destGUID, _, _, _, spellId, spellName)
		if spellId == 409058 and destGUID == UnitGUID("player") and self:AntiSpam(2, 4) then
			specWarnGTFO:Show(spellName)
			specWarnGTFO:Play("watchfeet")
		end
	end
	mod.SPELL_PERIODIC_MISSED = mod.SPELL_PERIODIC_DAMAGE

	function mod:UNIT_DIED(args)
		local cid = self:GetCIDFromGUID(args.destGUID)
		if cid == 165067 then

		end
	end

	function mod:UNIT_SPELLCAST_SUCCEEDED(uId, _, spellId)
		if spellId == 405814 then

		end
	end
	--]]
else
	--10.1.7 on retail, and classic if it happens (if it doesn't happen old version of mod will be retired)
	mod:RegisterEventsInCombat(
		"SPELL_CAST_START 168082 168041 168105 168383 175997",
		"SPELL_CAST_SUCCESS 168375",
		"SPELL_AURA_APPLIED 168105 168041 168520",
		"SPELL_AURA_REMOVED 168520",
		"SPELL_PERIODIC_DAMAGE 167977",
		"SPELL_ABSORBED 167977",
		"UNIT_DIED"
	)

	--Timers are too difficult to do, rapidTides messes up any chance of ever having decent timers.
	--TODO, check if timers more stable in DF version, probably not
	--General
	local warnShapersFortitude			= mod:NewTargetNoFilterAnnounce(168520, 3)

	local timerShapersFortitude			= mod:NewTargetTimer(8, 168520, nil, false, 2, 5)

	mod:AddNamePlateOption("NPAuraOnFort", 168520)
	--Life Warden Gola
	mod:AddTimerLine(DBM:EJ_GetSectionInfo(10409))
	local specWarnRevitalizingWaters	= mod:NewSpecialWarningInterrupt(168082, "HasInterrupt", nil, 2, 1, 2)
	local specWarnRapidTidesDispel		= mod:NewSpecialWarningDispel(168105, "MagicDispeller", nil, nil, 3, 2)
	--Earthshaper Telu
	mod:AddTimerLine(DBM:EJ_GetSectionInfo(10413))
	local specWarnBramble				= mod:NewSpecialWarningGTFO(167977, nil, nil, nil, 1, 8)
	local specWarnBriarskin				= mod:NewSpecialWarningInterrupt(168041, false, nil, nil, 1, 2)--if you have more than one interruptor, great. but off by default because we can't assume you can interrupt every bosses abilities. and heal takes priority
	local specWarnBriarskinDispel		= mod:NewSpecialWarningDispel(168041, false, nil, nil, 1, 2)--Not as important as rapid Tides and to assume you have at least two dispellers is big assumption
	--Dulhu
	mod:AddTimerLine(DBM:EJ_GetSectionInfo(10417))
	local warnGraspingVine				= mod:NewTargetNoFilterAnnounce(168375, 2)

	local specWarnNoxious				= mod:NewSpecialWarningRun(175997, nil, nil, 2, 4, 2)
	local specWarnSlash					= mod:NewSpecialWarningDodge(168383, nil, nil, nil, 2, 2)
	local yellSlash						= mod:NewYell(168383)

	local timerNoxiousCD				= mod:NewCDTimer(16, 175997, nil, "Melee", nil, 2)
	local timerGraspingVineCD			= mod:NewNextTimer(30.4, 168375, nil, nil, nil, 3)

	mod.vb.lastGrasping = nil

	--[[
	local function scanBosses(self, delay)
		for i = 1, 3 do
			local unitID = "boss"..i
			if UnitExists(unitID) then
				local cid = self:GetUnitCreatureId(unitID)
				local bossGUID = UnitGUID(unitID)
				if cid == 83894 then--Dulhu

				elseif cid == 83892 then--Gola

				else--Telu

				end
			end
		end
	end
	--]]

	function mod:OnCombatStart(delay)
		self.vb.lastGrasping = nil
		if self.Options.NPAuraOnFort then
			DBM:FireEvent("BossMod_EnableHostileNameplates")
		end
	end

	function mod:OnCombatEnd()
		if self.Options.NPAuraOnFort then
			DBM.Nameplate:Hide(true, nil, nil, nil, true, true)
		end
	end

	function mod:GraspingVineTarget(targetname, uId)
		if not targetname then
			self.vb.lastGrasping = nil
			return
		end
		warnGraspingVine:Show(targetname)
		self.vb.lastGrasping = targetname
	end

	function mod:SPELL_CAST_START(args)
		local spellId = args.spellId
		if spellId == 168082 and self:CheckInterruptFilter(args.sourceGUID, false, true) then
			specWarnRevitalizingWaters:Show(args.sourceName)
			specWarnRevitalizingWaters:Play("kickcast")
		elseif spellId == 168041 and self:CheckInterruptFilter(args.sourceGUID, false, true) then
			specWarnBriarskin:Show(args.sourceName)
			specWarnBriarskin:Play("kickcast")
		elseif spellId == 168383 then
			if self.vb.lastGrasping and self.vb.lastGrasping == UnitName("player") then
				yellSlash:Yell()
			else
				specWarnSlash:Show()
				specWarnSlash:Play("watchstep")
			end
		elseif spellId == 175997 then
			specWarnNoxious:Show()
			timerNoxiousCD:Start(nil, args.sourceGUID)
			specWarnNoxious:Play("justrun")
		end
	end

	function mod:SPELL_CAST_SUCCESS(args)
		if args.spellId == 168375 then
			self:BossTargetScanner(83894, "GraspingVineTarget", 0.05, 10)
			timerGraspingVineCD:Start(nil, args.sourceGUID)
		end
	end

	function mod:SPELL_AURA_APPLIED(args)
		local spellId = args.spellId
		if spellId == 168105 then
			specWarnRapidTidesDispel:Show(args.destName)
			specWarnRapidTidesDispel:Play("dispelboss")
		elseif spellId == 168041 then
			specWarnBriarskinDispel:Show(args.destName)
			specWarnBriarskinDispel:Play("dispelboss")
		elseif spellId == 168520 then
			warnShapersFortitude:Show(args.destName)
			timerShapersFortitude:Start(args.destName)
			if self.Options.NPAuraOnFort then
				DBM.Nameplate:Show(true, args.destGUID, spellId, nil, 8)
			end
		end
	end

	function mod:SPELL_AURA_REMOVED(args)
		local spellId = args.spellId
		if spellId == 168520 then
			timerShapersFortitude:Cancel(args.destName)
			if self.Options.NPAuraOnFort then
				DBM.Nameplate:Hide(true, args.destGUID, spellId)
			end
		end
	end

	function mod:SPELL_PERIODIC_DAMAGE(_, _, _, _, destGUID, _, _, _, spellId, spellName)
		if spellId == 167977 and destGUID == UnitGUID("player") and self:AntiSpam(2, 1) then
			specWarnBramble:Show(spellName)
			specWarnBramble:Play("watchfeet")
		end
	end
	mod.SPELL_ABSORBED = mod.SPELL_PERIODIC_DAMAGE

	function mod:UNIT_DIED(args)
		local cid = self:GetCIDFromGUID(args.destGUID)
		if cid == 83894 then
			timerNoxiousCD:Cancel()
		end
	end
end
