name: Legendary
card_text: Cannot be Normal Summoned/Set. Must be Special Summoned (from your hand) by Tributing all monsters you control. This card's ATK becomes the combined original ATK of the Tributed monsters. If this card attacks a Defense Position monster, inflict piercing battle damage.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	--spsummon condition
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetCode(EFFECT_SPSUMMON_CONDITION)
  	c:RegisterEffect(e1)
  	--special summon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_SPSUMMON_PROC)
  	e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e2:SetRange(LOCATION_HAND)
  	e2:SetCondition(s.spcon)
  	e2:SetOperation(s.spop)
  	c:RegisterEffect(e2)
  	--pierce
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_SINGLE)
  	e3:SetCode(EFFECT_PIERCE)
  	c:RegisterEffect(e3)
  end
  function s.spcon(e, c)
  	if c == nil then
  		return true
  	end
  	local tp = c:GetControler()
  	local g = Duel.GetFieldGroup(tp, LOCATION_MZONE, 0)
  	local rg = Duel.GetReleaseGroup(tp, false, REASON_SPSUMMON)
  	return (g:GetCount() > 0 or rg:GetCount() > 0) and g:FilterCount(Card.IsReleasable, nil, REASON_SPSUMMON) == g:GetCount()
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp, c)
  	local g = Duel.GetReleaseGroup(tp)
  	Duel.Release(g, REASON_SPSUMMON)
  	local atk = 0
  	local tc = g:GetFirst()
  	while tc do
  		local batk = tc:GetTextAttack()
  		if batk > 0 then
  			atk = atk + batk
  		end
  		tc = g:GetNext()
  	end
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_SET_ATTACK)
  	e1:SetValue(atk)
  	e1:SetReset(RESET_EVENT + 0xff0000)
  	c:RegisterEffect(e1)
  end
  
  
source_text: Legendary
  Cannot be Normal Summoned/Set. Must be Special Summoned (from your hand) by Tributing all monsters you control. This card's ATK becomes the combined original ATK of the Tributed monsters. If this card attacks a Defense Position monster, inflict piercing battle damage.
target_text: -- Legendary
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	--spsummon condition
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetCode(EFFECT_SPSUMMON_CONDITION)
  	c:RegisterEffect(e1)
  	--special summon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_SPSUMMON_PROC)
  	e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e2:SetRange(LOCATION_HAND)
  	e2:SetCondition(s.spcon)
  	e2:SetOperation(s.spop)
  	c:RegisterEffect(e2)
  	--pierce
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_SINGLE)
  	e3:SetCode(EFFECT_PIERCE)
  	c:RegisterEffect(e3)
  end
  function s.spcon(e, c)
  	if c == nil then
  		return true
  	end
  	local tp = c:GetControler()
  	local g = Duel.GetFieldGroup(tp, LOCATION_MZONE, 0)
  	local rg = Duel.GetReleaseGroup(tp, false, REASON_SPSUMMON)
  	return (g:GetCount() > 0 or rg:GetCount() > 0) and g:FilterCount(Card.IsReleasable, nil, REASON_SPSUMMON) == g:GetCount()
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp, c)
  	local g = Duel.GetReleaseGroup(tp)
  	Duel.Release(g, REASON_SPSUMMON)
  	local atk = 0
  	local tc = g:GetFirst()
  	while tc do
  		local batk = tc:GetTextAttack()
  		if batk > 0 then
  			atk = atk + batk
  		end
  		tc = g:GetNext()
  	end
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_SET_ATTACK)
  	e1:SetValue(atk)
  	e1:SetReset(RESET_EVENT + 0xff0000)
  	c:RegisterEffect(e1)
  end
  
  