name: Superheavy
card_text: If you have no Spells/Traps in your GY, you can Special Summon this card (from your hand). You can only Special Summon "Superheavy Samurai Stealthy" once per turn this way. If you have no Spells/Traps in your GY (Quick Effect): You can Tribute this card, then target 1 Spell/Trap in your opponent's GY; Set it to your field, but banish it when it leaves the field. You can only use this effect of "Superheavy Samurai Stealthy" once per turn.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--spsummon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_SPSUMMON_PROC)
  	e1:SetProperty(EFFECT_FLAG_UNCOPYABLE)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCondition(s.spcon)
  	c:RegisterEffect(e1)
  	--set
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetCode(EVENT_FREE_CHAIN)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetHintTiming(0, TIMING_END_PHASE)
  	e2:SetCondition(s.setcon)
  	e2:SetCost(s.setcost)
  	e2:SetTarget(s.settg)
  	e2:SetOperation(s.setop)
  	c:RegisterEffect(e2)
  end
  function s.setcon(e, tp, eg, ep, ev, re, r, rp)
  	return not Duel.IsExistingMatchingCard(Card.IsType, tp, LOCATION_GRAVE, 0, 1, nil, TYPE_SPELL + TYPE_TRAP)
  end
  function s.spcon(e, c)
  	if c == nil then
  		return true
  	end
  	local tp = c:GetControler()
  	return s.setcon(e, tp) and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0
  end
  function s.setcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return c:IsReleasable()
  	end
  	Duel.Release(c, REASON_COST)
  end
  function s.setfilter(c, ft)
  	return c:IsType(TYPE_SPELL + TYPE_TRAP) and c:IsSSetable(true) and (c:IsType(TYPE_FIELD) or ft > 0)
  end
  function s.settg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	local ft = Duel.GetLocationCount(tp, LOCATION_SZONE)
  	if chkc then
  		return chkc:IsControler(1 - tp) and chkc:IsLocation(LOCATION_GRAVE) and s.setfilter(chkc, ft)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.setfilter, tp, 0, LOCATION_GRAVE, 1, nil, ft)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SET)
  	local g = Duel.SelectTarget(tp, s.setfilter, tp, 0, LOCATION_GRAVE, 1, 1, nil, ft)
  	Duel.SetOperationInfo(0, CATEGORY_LEAVE_GRAVE, g, 1, 0, 0)
  end
  function s.setop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and Duel.SSet(tp, tc) ~= 0 then
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_LEAVE_FIELD_REDIRECT)
  		e1:SetReset(RESET_EVENT + RESETS_REDIRECT)
  		e1:SetValue(LOCATION_REMOVED)
  		tc:RegisterEffect(e1, true)
  	end
  end
  
  
source_text: Superheavy
  If you have no Spells/Traps in your GY, you can Special Summon this card (from your hand). You can only Special Summon "Superheavy Samurai Stealthy" once per turn this way. If you have no Spells/Traps in your GY (Quick Effect): You can Tribute this card, then target 1 Spell/Trap in your opponent's GY; Set it to your field, but banish it when it leaves the field. You can only use this effect of "Superheavy Samurai Stealthy" once per turn.
target_text: -- Superheavy
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--spsummon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_SPSUMMON_PROC)
  	e1:SetProperty(EFFECT_FLAG_UNCOPYABLE)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCondition(s.spcon)
  	c:RegisterEffect(e1)
  	--set
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetCode(EVENT_FREE_CHAIN)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetHintTiming(0, TIMING_END_PHASE)
  	e2:SetCondition(s.setcon)
  	e2:SetCost(s.setcost)
  	e2:SetTarget(s.settg)
  	e2:SetOperation(s.setop)
  	c:RegisterEffect(e2)
  end
  function s.setcon(e, tp, eg, ep, ev, re, r, rp)
  	return not Duel.IsExistingMatchingCard(Card.IsType, tp, LOCATION_GRAVE, 0, 1, nil, TYPE_SPELL + TYPE_TRAP)
  end
  function s.spcon(e, c)
  	if c == nil then
  		return true
  	end
  	local tp = c:GetControler()
  	return s.setcon(e, tp) and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0
  end
  function s.setcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return c:IsReleasable()
  	end
  	Duel.Release(c, REASON_COST)
  end
  function s.setfilter(c, ft)
  	return c:IsType(TYPE_SPELL + TYPE_TRAP) and c:IsSSetable(true) and (c:IsType(TYPE_FIELD) or ft > 0)
  end
  function s.settg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	local ft = Duel.GetLocationCount(tp, LOCATION_SZONE)
  	if chkc then
  		return chkc:IsControler(1 - tp) and chkc:IsLocation(LOCATION_GRAVE) and s.setfilter(chkc, ft)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.setfilter, tp, 0, LOCATION_GRAVE, 1, nil, ft)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SET)
  	local g = Duel.SelectTarget(tp, s.setfilter, tp, 0, LOCATION_GRAVE, 1, 1, nil, ft)
  	Duel.SetOperationInfo(0, CATEGORY_LEAVE_GRAVE, g, 1, 0, 0)
  end
  function s.setop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and Duel.SSet(tp, tc) ~= 0 then
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_LEAVE_FIELD_REDIRECT)
  		e1:SetReset(RESET_EVENT + RESETS_REDIRECT)
  		e1:SetValue(LOCATION_REMOVED)
  		tc:RegisterEffect(e1, true)
  	end
  end
  
  