--Fog Warning
--Scripted by The Razgriz
local s,id=GetID()
function s.initial_effect(c)
	--Activate
	aux.AddSkillProcedure(c,2,false,nil,nil)
	local e1=Effect.CreateEffect(c)
	e1:SetProperty(EFFECT_FLAG_UNCOPYABLE+EFFECT_FLAG_CANNOT_DISABLE)
	e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
	e1:SetCode(EVENT_STARTUP)
	e1:SetCountLimit(1)
	e1:SetRange(0x5f)
	e1:SetLabelObject(e)
	e1:SetLabel(0)
	e1:SetOperation(s.op)
	c:RegisterEffect(e1)
end
s.counter_place_list={COUNTER_FOG}
function s.op(e,tp,eg,ep,ev,re,r,rp)
	Duel.Hint(HINT_SKILL_FLIP,tp,id|(1<<32))
	Duel.Hint(HINT_CARD,tp,id)

	--Each time you place a Fog Counter(s) on a monster(s), give it an additional Fog Counter.
	local old_func=Card.AddCounter
	function Card.AddCounter(c,countertype,count,singly)
		local triggering_player=Duel.GetChainInfo(0,CHAININFO_TRIGGERING_PLAYER)
		if countertype&COUNTER_FOG==COUNTER_FOG and triggering_player==tp then
			count=count+1
		end
		return old_func(c,countertype,count,singly)
	end
end

--[[function s.op(e,tp,eg,ep,ev,re,r,rp)
	(to be revisited later, requires core rework of counter placement to properly implement)
	Duel.Hint(HINT_SKILL_FLIP,tp,id|(1<<32))
	Duel.Hint(HINT_CARD,tp,id)
	local c=e:GetHandler()
	--Each time you place a Fog Counter(s) on a monster(s), give it an additional Fog Counter.
	local e1=Effect.CreateEffect(c)
	e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS)
	e1:SetCode(EVENT_ADD_COUNTER+COUNTER_FOG)
	e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
	e1:SetLabel(tp,id)
	e1:SetCondition(s.ctcon)
	e1:SetOperation(s.ctop)
	local e2=Effect.CreateEffect(c)
	e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_GRANT)
	e2:SetTargetRange(LOCATION_MZONE,LOCATION_MZONE)
	e2:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
	e2:SetLabelObject(e1)
	Duel.RegisterEffect(e2,tp)
end
function s.ctcon(e,tp,eg,ep,ev,re,r,rp)
	local _,flagLabel=re:GetLabel()
	return ep==e:GetLabel() and flagLabel~=id
end
function s.ctop(e,tp,eg,ep,ev,re,r,rp)
	e:GetHandler():AddCounter(COUNTER_FOG,1)
end]]--
