name: Starduston
card_text: Cannot be Normal Summoned/Set. Must be Special Summoned (from your hand) by sending any number of "Duston" monsters you control to the Graveyard, and cannot be Special Summoned by other ways. This card's ATK and DEF each become equal to the number of monsters sent to the Graveyard for its Summon x 1000. Your opponent cannot Flip or Special Summon any monsters, or activate any Set Spell/Trap Cards on the field. If you control more monsters than your opponent does, destroy this card.
external_ids: local SETCARD_ID_0 = 0x80 --Duston
  
lua: local SETCARD_ID_0 = 0x80 --Duston
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	--cannot special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	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:SetTarget(s.sptg)
  	e2:SetOperation(s.spop)
  	c:RegisterEffect(e2)
  	--
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD)
  	e3:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e3:SetCode(EFFECT_CANNOT_ACTIVATE)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetTargetRange(0, 1)
  	e3:SetValue(s.aclimit)
  	c:RegisterEffect(e3)
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_FIELD)
  	e4:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e4:SetCode(EFFECT_CANNOT_FLIP_SUMMON)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetTargetRange(0, 1)
  	c:RegisterEffect(e4)
  	local e5 = e4:Clone()
  	e5:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  	c:RegisterEffect(e5)
  	--self destroy
  	local e6 = Effect.CreateEffect(c)
  	e6:SetType(EFFECT_TYPE_SINGLE)
  	e6:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e6:SetRange(LOCATION_MZONE)
  	e6:SetCode(EFFECT_SELF_DESTROY)
  	e6:SetCondition(s.descon)
  	c:RegisterEffect(e6)
  end
  function s.aclimit(e, re, tp)
  	local rc = re:GetHandler()
  	return re:IsHasType(EFFECT_TYPE_ACTIVATE) and rc:IsLocation(LOCATION_SZONE) and rc:IsFacedown()
  end
  function s.filter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsAbleToGraveAsCost()
  end
  function s.mzfilter(c)
  	return c:GetSequence() < 5
  end
  function s.spcon(e, c)
  	if c == nil then
  		return true
  	end
  	local tp = c:GetControler()
  	local mg = Duel.GetMatchingGroup(s.filter, tp, LOCATION_MZONE, 0, nil)
  	local ft = Duel.GetLocationCount(tp, LOCATION_MZONE)
  	local ct = -ft + 1
  	return mg:GetCount() > 0 and (ft > 0 or mg:IsExists(s.mzfilter, ct, nil))
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk, c)
  	local g = Duel.GetMatchingGroup(s.filter, tp, LOCATION_MZONE, 0, nil)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local sg = g:SelectSubGroup(tp, aux.mzctcheck, true, 1, #g, tp)
  	if sg then
  		sg:KeepAlive()
  		e:SetLabelObject(sg)
  		return true
  	else
  		return false
  	end
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp, c)
  	local g = e:GetLabelObject()
  	local ct = Duel.SendtoGrave(g, REASON_SPSUMMON)
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_SET_ATTACK)
  	e1:SetValue(ct * 1000)
  	e1:SetReset(RESET_EVENT + 0xff0000)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EFFECT_SET_DEFENSE)
  	c:RegisterEffect(e2)
  	g:DeleteGroup()
  end
  function s.descon(e)
  	local tp = e:GetHandlerPlayer()
  	return Duel.GetFieldGroupCount(tp, 0, LOCATION_MZONE) < Duel.GetFieldGroupCount(tp, LOCATION_MZONE, 0)
  end
  
  
source_text: Starduston
  Cannot be Normal Summoned/Set. Must be Special Summoned (from your hand) by sending any number of "Duston" monsters you control to the Graveyard, and cannot be Special Summoned by other ways. This card's ATK and DEF each become equal to the number of monsters sent to the Graveyard for its Summon x 1000. Your opponent cannot Flip or Special Summon any monsters, or activate any Set Spell/Trap Cards on the field. If you control more monsters than your opponent does, destroy this card.
target_text: -- Starduston
  local SETCARD_ID_0 = 0x80 --Duston
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	--cannot special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	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:SetTarget(s.sptg)
  	e2:SetOperation(s.spop)
  	c:RegisterEffect(e2)
  	--
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD)
  	e3:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e3:SetCode(EFFECT_CANNOT_ACTIVATE)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetTargetRange(0, 1)
  	e3:SetValue(s.aclimit)
  	c:RegisterEffect(e3)
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_FIELD)
  	e4:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e4:SetCode(EFFECT_CANNOT_FLIP_SUMMON)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetTargetRange(0, 1)
  	c:RegisterEffect(e4)
  	local e5 = e4:Clone()
  	e5:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  	c:RegisterEffect(e5)
  	--self destroy
  	local e6 = Effect.CreateEffect(c)
  	e6:SetType(EFFECT_TYPE_SINGLE)
  	e6:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e6:SetRange(LOCATION_MZONE)
  	e6:SetCode(EFFECT_SELF_DESTROY)
  	e6:SetCondition(s.descon)
  	c:RegisterEffect(e6)
  end
  function s.aclimit(e, re, tp)
  	local rc = re:GetHandler()
  	return re:IsHasType(EFFECT_TYPE_ACTIVATE) and rc:IsLocation(LOCATION_SZONE) and rc:IsFacedown()
  end
  function s.filter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsAbleToGraveAsCost()
  end
  function s.mzfilter(c)
  	return c:GetSequence() < 5
  end
  function s.spcon(e, c)
  	if c == nil then
  		return true
  	end
  	local tp = c:GetControler()
  	local mg = Duel.GetMatchingGroup(s.filter, tp, LOCATION_MZONE, 0, nil)
  	local ft = Duel.GetLocationCount(tp, LOCATION_MZONE)
  	local ct = -ft + 1
  	return mg:GetCount() > 0 and (ft > 0 or mg:IsExists(s.mzfilter, ct, nil))
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk, c)
  	local g = Duel.GetMatchingGroup(s.filter, tp, LOCATION_MZONE, 0, nil)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local sg = g:SelectSubGroup(tp, aux.mzctcheck, true, 1, #g, tp)
  	if sg then
  		sg:KeepAlive()
  		e:SetLabelObject(sg)
  		return true
  	else
  		return false
  	end
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp, c)
  	local g = e:GetLabelObject()
  	local ct = Duel.SendtoGrave(g, REASON_SPSUMMON)
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_SET_ATTACK)
  	e1:SetValue(ct * 1000)
  	e1:SetReset(RESET_EVENT + 0xff0000)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EFFECT_SET_DEFENSE)
  	c:RegisterEffect(e2)
  	g:DeleteGroup()
  end
  function s.descon(e)
  	local tp = e:GetHandlerPlayer()
  	return Duel.GetFieldGroupCount(tp, 0, LOCATION_MZONE) < Duel.GetFieldGroupCount(tp, LOCATION_MZONE, 0)
  end
  
  