-------------------------------------------------------------------------------
--  Module Declaration

local mod = BigWigs:NewBoss("Hungarfen", 726, 576)
if not mod then return end
mod.partyContent = true
mod.otherMenu = "Coilfang Reservoir"
mod:RegisterEnableMob(17770)
mod.toggleOptions = {"spores", "bosskill"}

-------------------------------------------------------------------------------
--  Locals

local sporesannounced = nil

-------------------------------------------------------------------------------
--  Localization

local L = LibStub("AceLocale-3.0"):NewLocale("Little Wigs: Hungarfen", "enUS", true)
if L then
	
	
end

L = LibStub("AceLocale-3.0"):GetLocale("Little Wigs: Hungarfen")
mod.locale = L

-------------------------------------------------------------------------------
--  Initialization

function mod:OnBossEnable()
	if bit.band(self.db.profile.spores, BigWigs.C.MESSAGE) == BigWigs.C.MESSAGE then
		self:RegisterEvent("UNIT_HEALTH")
	end
	self:Death("Win", 17770)

	self:RegisterEvent("PLAYER_REGEN_DISABLED", "CheckForEngage")
end

function mod:OnEnable()
	sporeannounced = nil
end

-------------------------------------------------------------------------------
--  Event Handlers

function mod:UNIT_HEALTH(event, msg)
	if UnitName(msg) ~= mod.displayName then return end
	local health = UnitHealth(msg)
	if health > 18 and health <= 24 and not sporesannounced then
		sporesannounced = true
		self:Message(L["spores_message"], "Urgent", nil, nil, nil, 31673)
	elseif health > 28 and sporesannounced then
		sporesannounced = nil
	end
end
