name: Resonant
card_text: Each time a "Resonator" monster(s) is sent to the Graveyard as a Synchro Material: Target 1 card your opponent controls; destroy that target. Destroy this card during your 2nd End Phase after activation.
external_ids: local SETCARD_ID_0 = 0x57 --Resonator
  
lua: local SETCARD_ID_0 = 0x57 --Resonator
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetTarget(s.target)
  	c:RegisterEffect(e1)
  	--destroy
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetCode(EVENT_BE_MATERIAL)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetCondition(s.descon)
  	e2:SetTarget(s.destg)
  	e2:SetOperation(s.desop)
  	c:RegisterEffect(e2)
  	--self destroy
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e3:SetCode(EVENT_PHASE + PHASE_END)
  	e3:SetCountLimit(1)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetCondition(s.sdescon)
  	e3:SetOperation(s.sdesop)
  	c:RegisterEffect(e3)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	e:GetHandler():SetTurnCounter(0)
  end
  function s.cfilter(c)
  	return c:IsLocation(LOCATION_GRAVE) and c:IsSetCard(SETCARD_ID_0)
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	return r == REASON_SYNCHRO and eg:IsExists(s.cfilter, 1, nil)
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsControler(1 - tp) and chkc:IsOnField()
  	end
  	if chk == 0 then
  		return true
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local g = Duel.SelectTarget(tp, aux.TRUE, tp, 0, LOCATION_ONFIELD, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, g:GetCount(), 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc and tc:IsRelateToEffect(e) then
  		Duel.Destroy(tc, REASON_EFFECT)
  	end
  end
  function s.sdescon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetTurnPlayer() == tp
  end
  function s.sdesop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local ct = c:GetTurnCounter()
  	ct = ct + 1
  	c:SetTurnCounter(ct)
  	if ct == 2 then
  		Duel.Destroy(c, REASON_RULE)
  	end
  end
  
  
source_text: Resonant
  Each time a "Resonator" monster(s) is sent to the Graveyard as a Synchro Material: Target 1 card your opponent controls; destroy that target. Destroy this card during your 2nd End Phase after activation.
target_text: -- Resonant
  local SETCARD_ID_0 = 0x57 --Resonator
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetTarget(s.target)
  	c:RegisterEffect(e1)
  	--destroy
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetCode(EVENT_BE_MATERIAL)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetCondition(s.descon)
  	e2:SetTarget(s.destg)
  	e2:SetOperation(s.desop)
  	c:RegisterEffect(e2)
  	--self destroy
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e3:SetCode(EVENT_PHASE + PHASE_END)
  	e3:SetCountLimit(1)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetCondition(s.sdescon)
  	e3:SetOperation(s.sdesop)
  	c:RegisterEffect(e3)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	e:GetHandler():SetTurnCounter(0)
  end
  function s.cfilter(c)
  	return c:IsLocation(LOCATION_GRAVE) and c:IsSetCard(SETCARD_ID_0)
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	return r == REASON_SYNCHRO and eg:IsExists(s.cfilter, 1, nil)
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsControler(1 - tp) and chkc:IsOnField()
  	end
  	if chk == 0 then
  		return true
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local g = Duel.SelectTarget(tp, aux.TRUE, tp, 0, LOCATION_ONFIELD, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, g:GetCount(), 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc and tc:IsRelateToEffect(e) then
  		Duel.Destroy(tc, REASON_EFFECT)
  	end
  end
  function s.sdescon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetTurnPlayer() == tp
  end
  function s.sdesop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local ct = c:GetTurnCounter()
  	ct = ct + 1
  	c:SetTurnCounter(ct)
  	if ct == 2 then
  		Duel.Destroy(c, REASON_RULE)
  	end
  end
  
  