name: Superheavy
card_text: If you have no Spell/Trap Cards in your Graveyard, you can Special Summon this card (from your hand). After this card was Special Summoned this way, you cannot Special Summon monsters for the rest of this turn, except "Superheavy Samurai" monsters. You can Tribute this card, then activate 1 of these effects;
  ● Destroy 1 card in your opponent's Spell & Trap Zone, then you can Set the destroyed Spell/Trap Card on your side of the field.
  ● Destroy 1 card in your opponent's Pendulum Zone, then you can place the destroyed card in your Pendulum Zone.
external_ids: local SETCARD_ID_0 = 0x9a --Superheavy
  
lua: local SETCARD_ID_0 = 0x9a --Superheavy
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_SPSUMMON_PROC)
  	e1:SetProperty(EFFECT_FLAG_UNCOPYABLE)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCondition(s.hspcon)
  	e1:SetOperation(s.hspop)
  	c:RegisterEffect(e1)
  	--destroy
  	local e2 = Effect.CreateEffect(c)
  	e2:SetCategory(CATEGORY_DESTROY)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCost(s.descost)
  	e2:SetTarget(s.destg)
  	e2:SetOperation(s.desop)
  	c:RegisterEffect(e2)
  end
  function s.filter(c)
  	return c:IsType(TYPE_SPELL + TYPE_TRAP)
  end
  function s.hspcon(e, c)
  	if c == nil then
  		return true
  	end
  	local tp = c:GetControler()
  	return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and not Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_GRAVE, 0, 1, nil)
  end
  function s.hspop(e, tp, eg, ep, ev, re, r, rp)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET + EFFECT_FLAG_OATH)
  	e1:SetTargetRange(1, 0)
  	e1:SetTarget(s.splimit)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.splimit(e, c, sump, sumtype, sumpos, targetp, se)
  	return not c:IsSetCard(SETCARD_ID_0)
  end
  function s.descost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsReleasable()
  	end
  	Duel.Release(e:GetHandler(), REASON_COST)
  end
  function s.desfilter1(c)
  	return c:GetSequence() < 5
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		local sel = 0
  		if Duel.IsExistingMatchingCard(s.desfilter1, tp, 0, LOCATION_SZONE, 1, nil) then
  			sel = sel + 1
  		end
  		if Duel.GetFieldGroupCount(tp, 0, LOCATION_PZONE) > 0 then
  			sel = sel + 2
  		end
  		e:SetLabel(sel)
  		return sel ~= 0
  	end
  	local sel = e:GetLabel()
  	if sel == 3 then
  		sel = Duel.SelectOption(tp, aux.Stringid(id, 1), aux.Stringid(id, 2)) + 1
  	elseif sel == 1 then
  		Duel.SelectOption(tp, aux.Stringid(id, 1))
  	else
  		Duel.SelectOption(tp, aux.Stringid(id, 2))
  	end
  	e:SetLabel(sel)
  	if sel == 1 then
  		local g = Duel.GetMatchingGroup(s.desfilter1, tp, 0, LOCATION_SZONE, nil)
  		Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, 1, 0, 0)
  	else
  		local g = Duel.GetFieldGroup(tp, 0, LOCATION_PZONE)
  		Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, 1, 0, 0)
  	end
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local sel = e:GetLabel()
  	if sel == 1 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  		local g = Duel.SelectMatchingCard(tp, s.desfilter1, tp, 0, LOCATION_SZONE, 1, 1, nil)
  		local tc = g:GetFirst()
  		if not tc then
  			return
  		end
  		Duel.HintSelection(g)
  		if
  			Duel.Destroy(g, REASON_EFFECT) ~= 0
  			and Duel.GetLocationCount(tp, LOCATION_SZONE) > 0
  			and not tc:IsLocation(LOCATION_HAND + LOCATION_DECK)
  			and tc:IsType(TYPE_SPELL + TYPE_TRAP)
  			and tc:IsSSetable()
  			and Duel.SelectYesNo(tp, aux.Stringid(id, 3))
  		then
  			Duel.BreakEffect()
  			Duel.SSet(tp, tc)
  		end
  	else
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  		local g = Duel.GetFieldGroup(tp, 0, LOCATION_PZONE):Select(tp, 1, 1, nil)
  		local tc = g:GetFirst()
  		if not tc then
  			return
  		end
  		Duel.HintSelection(g)
  		if
  			Duel.Destroy(g, REASON_EFFECT) ~= 0
  			and (Duel.CheckLocation(tp, LOCATION_PZONE, 0) or Duel.CheckLocation(tp, LOCATION_PZONE, 1))
  			and not tc:IsLocation(LOCATION_HAND + LOCATION_DECK)
  			and not tc:IsForbidden()
  			and Duel.SelectYesNo(tp, aux.Stringid(id, 4))
  		then
  			Duel.BreakEffect()
  			Duel.MoveToField(tc, tp, tp, LOCATION_PZONE, POS_FACEUP, true)
  		end
  	end
  end
  
  
source_text: Superheavy
  If you have no Spell/Trap Cards in your Graveyard, you can Special Summon this card (from your hand). After this card was Special Summoned this way, you cannot Special Summon monsters for the rest of this turn, except "Superheavy Samurai" monsters. You can Tribute this card, then activate 1 of these effects;
  ● Destroy 1 card in your opponent's Spell & Trap Zone, then you can Set the destroyed Spell/Trap Card on your side of the field.
  ● Destroy 1 card in your opponent's Pendulum Zone, then you can place the destroyed card in your Pendulum Zone.
target_text: -- Superheavy
  local SETCARD_ID_0 = 0x9a --Superheavy
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_SPSUMMON_PROC)
  	e1:SetProperty(EFFECT_FLAG_UNCOPYABLE)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCondition(s.hspcon)
  	e1:SetOperation(s.hspop)
  	c:RegisterEffect(e1)
  	--destroy
  	local e2 = Effect.CreateEffect(c)
  	e2:SetCategory(CATEGORY_DESTROY)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCost(s.descost)
  	e2:SetTarget(s.destg)
  	e2:SetOperation(s.desop)
  	c:RegisterEffect(e2)
  end
  function s.filter(c)
  	return c:IsType(TYPE_SPELL + TYPE_TRAP)
  end
  function s.hspcon(e, c)
  	if c == nil then
  		return true
  	end
  	local tp = c:GetControler()
  	return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and not Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_GRAVE, 0, 1, nil)
  end
  function s.hspop(e, tp, eg, ep, ev, re, r, rp)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET + EFFECT_FLAG_OATH)
  	e1:SetTargetRange(1, 0)
  	e1:SetTarget(s.splimit)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.splimit(e, c, sump, sumtype, sumpos, targetp, se)
  	return not c:IsSetCard(SETCARD_ID_0)
  end
  function s.descost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsReleasable()
  	end
  	Duel.Release(e:GetHandler(), REASON_COST)
  end
  function s.desfilter1(c)
  	return c:GetSequence() < 5
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		local sel = 0
  		if Duel.IsExistingMatchingCard(s.desfilter1, tp, 0, LOCATION_SZONE, 1, nil) then
  			sel = sel + 1
  		end
  		if Duel.GetFieldGroupCount(tp, 0, LOCATION_PZONE) > 0 then
  			sel = sel + 2
  		end
  		e:SetLabel(sel)
  		return sel ~= 0
  	end
  	local sel = e:GetLabel()
  	if sel == 3 then
  		sel = Duel.SelectOption(tp, aux.Stringid(id, 1), aux.Stringid(id, 2)) + 1
  	elseif sel == 1 then
  		Duel.SelectOption(tp, aux.Stringid(id, 1))
  	else
  		Duel.SelectOption(tp, aux.Stringid(id, 2))
  	end
  	e:SetLabel(sel)
  	if sel == 1 then
  		local g = Duel.GetMatchingGroup(s.desfilter1, tp, 0, LOCATION_SZONE, nil)
  		Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, 1, 0, 0)
  	else
  		local g = Duel.GetFieldGroup(tp, 0, LOCATION_PZONE)
  		Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, 1, 0, 0)
  	end
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local sel = e:GetLabel()
  	if sel == 1 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  		local g = Duel.SelectMatchingCard(tp, s.desfilter1, tp, 0, LOCATION_SZONE, 1, 1, nil)
  		local tc = g:GetFirst()
  		if not tc then
  			return
  		end
  		Duel.HintSelection(g)
  		if
  			Duel.Destroy(g, REASON_EFFECT) ~= 0
  			and Duel.GetLocationCount(tp, LOCATION_SZONE) > 0
  			and not tc:IsLocation(LOCATION_HAND + LOCATION_DECK)
  			and tc:IsType(TYPE_SPELL + TYPE_TRAP)
  			and tc:IsSSetable()
  			and Duel.SelectYesNo(tp, aux.Stringid(id, 3))
  		then
  			Duel.BreakEffect()
  			Duel.SSet(tp, tc)
  		end
  	else
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  		local g = Duel.GetFieldGroup(tp, 0, LOCATION_PZONE):Select(tp, 1, 1, nil)
  		local tc = g:GetFirst()
  		if not tc then
  			return
  		end
  		Duel.HintSelection(g)
  		if
  			Duel.Destroy(g, REASON_EFFECT) ~= 0
  			and (Duel.CheckLocation(tp, LOCATION_PZONE, 0) or Duel.CheckLocation(tp, LOCATION_PZONE, 1))
  			and not tc:IsLocation(LOCATION_HAND + LOCATION_DECK)
  			and not tc:IsForbidden()
  			and Duel.SelectYesNo(tp, aux.Stringid(id, 4))
  		then
  			Duel.BreakEffect()
  			Duel.MoveToField(tc, tp, tp, LOCATION_PZONE, POS_FACEUP, true)
  		end
  	end
  end
  
  