name: Super
card_text: Your opponent cannot target "Super Quant" cards on the field with card effects during your Main Phase 1. You can target 1 "Super Quant" Xyz Monster you control; attach 1 other face-up monster you control to it as material. You can only use this effect of "Super Quantal Union - Magnaformation" once per turn.
external_ids: local SETCARD_ID_0 = 0xdc --Super
  
lua: local SETCARD_ID_0 = 0xdc --Super
  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)
  	c:RegisterEffect(e1)
  	--cannot be target
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
  	e2:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetTargetRange(LOCATION_ONFIELD, LOCATION_ONFIELD)
  	e2:SetCondition(s.tgcon)
  	e2:SetTarget(s.tglimit)
  	e2:SetValue(aux.tgoval)
  	c:RegisterEffect(e2)
  	--material
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetType(EFFECT_TYPE_QUICK_O)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e3:SetCode(EVENT_FREE_CHAIN)
  	e3:SetCountLimit(1, id)
  	e3:SetTarget(s.mttg)
  	e3:SetOperation(s.mtop)
  	c:RegisterEffect(e3)
  end
  function s.tgcon(e)
  	return Duel.GetCurrentPhase() == PHASE_MAIN1 and Duel.GetTurnPlayer() == e:GetHandlerPlayer()
  end
  function s.tglimit(e, c)
  	return c:IsSetCard(SETCARD_ID_0)
  end
  function s.filter1(c, e, tp)
  	return c:IsFaceup() and c:IsType(TYPE_XYZ) and c:IsSetCard(SETCARD_ID_0) and Duel.IsExistingMatchingCard(s.filter2, tp, LOCATION_MZONE, 0, 1, c)
  end
  function s.filter2(c, e)
  	return c:IsType(TYPE_MONSTER) and c:IsFaceup() and c:IsCanOverlay() and not (e and c:IsImmuneToEffect(e))
  end
  function s.mttg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_MZONE) and s.filter1(chkc, e, tp)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter1, tp, LOCATION_MZONE, 0, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	Duel.SelectTarget(tp, s.filter1, tp, LOCATION_MZONE, 0, 1, 1, nil, e, tp)
  end
  function s.mtop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if not tc:IsRelateToEffect(e) or tc:IsImmuneToEffect(e) then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_XMATERIAL)
  	local g = Duel.SelectMatchingCard(tp, s.filter2, tp, LOCATION_MZONE, 0, 1, 1, tc, e)
  	if g:GetCount() > 0 then
  		local og = g:GetFirst():GetOverlayGroup()
  		if og:GetCount() > 0 then
  			Duel.SendtoGrave(og, REASON_RULE)
  		end
  		Duel.Overlay(tc, g)
  	end
  end
  
  
source_text: Super
  Your opponent cannot target "Super Quant" cards on the field with card effects during your Main Phase 1. You can target 1 "Super Quant" Xyz Monster you control; attach 1 other face-up monster you control to it as material. You can only use this effect of "Super Quantal Union - Magnaformation" once per turn.
target_text: -- Super
  local SETCARD_ID_0 = 0xdc --Super
  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)
  	c:RegisterEffect(e1)
  	--cannot be target
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
  	e2:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetTargetRange(LOCATION_ONFIELD, LOCATION_ONFIELD)
  	e2:SetCondition(s.tgcon)
  	e2:SetTarget(s.tglimit)
  	e2:SetValue(aux.tgoval)
  	c:RegisterEffect(e2)
  	--material
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetType(EFFECT_TYPE_QUICK_O)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e3:SetCode(EVENT_FREE_CHAIN)
  	e3:SetCountLimit(1, id)
  	e3:SetTarget(s.mttg)
  	e3:SetOperation(s.mtop)
  	c:RegisterEffect(e3)
  end
  function s.tgcon(e)
  	return Duel.GetCurrentPhase() == PHASE_MAIN1 and Duel.GetTurnPlayer() == e:GetHandlerPlayer()
  end
  function s.tglimit(e, c)
  	return c:IsSetCard(SETCARD_ID_0)
  end
  function s.filter1(c, e, tp)
  	return c:IsFaceup() and c:IsType(TYPE_XYZ) and c:IsSetCard(SETCARD_ID_0) and Duel.IsExistingMatchingCard(s.filter2, tp, LOCATION_MZONE, 0, 1, c)
  end
  function s.filter2(c, e)
  	return c:IsType(TYPE_MONSTER) and c:IsFaceup() and c:IsCanOverlay() and not (e and c:IsImmuneToEffect(e))
  end
  function s.mttg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_MZONE) and s.filter1(chkc, e, tp)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter1, tp, LOCATION_MZONE, 0, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	Duel.SelectTarget(tp, s.filter1, tp, LOCATION_MZONE, 0, 1, 1, nil, e, tp)
  end
  function s.mtop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if not tc:IsRelateToEffect(e) or tc:IsImmuneToEffect(e) then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_XMATERIAL)
  	local g = Duel.SelectMatchingCard(tp, s.filter2, tp, LOCATION_MZONE, 0, 1, 1, tc, e)
  	if g:GetCount() > 0 then
  		local og = g:GetFirst():GetOverlayGroup()
  		if og:GetCount() > 0 then
  			Duel.SendtoGrave(og, REASON_RULE)
  		end
  		Duel.Overlay(tc, g)
  	end
  end
  
  