name: Junk
card_text: 1 "Synchron" Tuner + 1+ non-Tuner monsters
  If this card is Synchro Summoned: You can Special Summon as many "Synchron" Tuners as possible with different Levels from your Deck, in Defense Position. You cannot Special Summon monsters from the Extra Deck, except Synchro Monsters, the turn you activate this effect. When an attack is declared involving this card that was Synchro Summoned this turn and another monster: You can make this card's ATK become double its original ATK until the end of this turn. You can only use each effect of "Junk Speeder" once per turn.
external_ids: local CARD_ID_1 = 59822133 --Blue-Eyes Spirit Dragon
  local CARD_ID_2 = 20932152 --Quickdraw Synchron
  local SETCARD_ID_0 = 0x1017 --Synchron
  
lua: local CARD_ID_1 = 59822133 --Blue-Eyes Spirit Dragon
  local CARD_ID_2 = 20932152 --Quickdraw Synchron
  local SETCARD_ID_0 = 0x1017 --Synchron
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--synchro summon
  	aux.AddSynchroProcedure(c, s.tfilter, aux.NonTuner(nil), 1)
  	c:EnableReviveLimit()
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetCountLimit(1, id)
  	e1:SetCost(s.spcost)
  	e1:SetCondition(s.spcon)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--atk up
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e2:SetCondition(s.spcon)
  	e2:SetOperation(s.regop)
  	c:RegisterEffect(e2)
  	Duel.AddCustomActivityCounter(id, ACTIVITY_SPSUMMON, s.counterfilter)
  end
  s.material_setcode = 0x1017
  function s.tfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) or c:IsHasEffect(CARD_ID_2)
  end
  function s.counterfilter(c)
  	return not c:IsSummonLocation(LOCATION_EXTRA) or c:IsType(TYPE_SYNCHRO)
  end
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetCustomActivityCount(id, tp, ACTIVITY_SPSUMMON) == 0
  	end
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET + EFFECT_FLAG_OATH)
  	e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  	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:IsType(TYPE_SYNCHRO) and c:IsLocation(LOCATION_EXTRA)
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_SYNCHRO)
  end
  function s.filter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_TUNER) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP_DEFENSE)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_DECK, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_DECK)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local ft = Duel.GetLocationCount(tp, LOCATION_MZONE)
  	local g = Duel.GetMatchingGroup(s.filter, tp, LOCATION_DECK, 0, nil, e, tp)
  	if ft <= 0 or g:GetCount() == 0 then
  		return
  	end
  	if Duel.IsPlayerAffectedByEffect(tp, CARD_ID_1) then
  		ft = 1
  	end
  	local ct = math.min(g:GetClassCount(Card.GetLevel), ft)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	aux.GCheckAdditional = aux.dlvcheck
  	local sg = g:SelectSubGroup(tp, aux.TRUE, false, ct, ct)
  	aux.GCheckAdditional = nil
  	Duel.SpecialSummon(sg, 0, tp, tp, false, false, POS_FACEUP_DEFENSE)
  end
  function s.regop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 1))
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_ATTACK_ANNOUNCE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1, id + 1)
  	e1:SetCondition(s.atkcon)
  	e1:SetOperation(s.atkop)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  	c:RegisterEffect(e1)
  end
  function s.atkcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return c == Duel.GetAttacker() and Duel.GetAttackTarget() ~= nil or c == Duel.GetAttackTarget()
  end
  function s.atkop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) and c:IsFaceup() then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_SET_ATTACK_FINAL)
  		e1:SetValue(c:GetBaseAttack() * 2)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		c:RegisterEffect(e1)
  	end
  end
  
  
source_text: Junk
  1 "Synchron" Tuner + 1+ non-Tuner monsters
  If this card is Synchro Summoned: You can Special Summon as many "Synchron" Tuners as possible with different Levels from your Deck, in Defense Position. You cannot Special Summon monsters from the Extra Deck, except Synchro Monsters, the turn you activate this effect. When an attack is declared involving this card that was Synchro Summoned this turn and another monster: You can make this card's ATK become double its original ATK until the end of this turn. You can only use each effect of "Junk Speeder" once per turn.
target_text: -- Junk
  local CARD_ID_1 = 59822133 --Blue-Eyes Spirit Dragon
  local CARD_ID_2 = 20932152 --Quickdraw Synchron
  local SETCARD_ID_0 = 0x1017 --Synchron
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--synchro summon
  	aux.AddSynchroProcedure(c, s.tfilter, aux.NonTuner(nil), 1)
  	c:EnableReviveLimit()
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetCountLimit(1, id)
  	e1:SetCost(s.spcost)
  	e1:SetCondition(s.spcon)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--atk up
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e2:SetCondition(s.spcon)
  	e2:SetOperation(s.regop)
  	c:RegisterEffect(e2)
  	Duel.AddCustomActivityCounter(id, ACTIVITY_SPSUMMON, s.counterfilter)
  end
  s.material_setcode = 0x1017
  function s.tfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) or c:IsHasEffect(CARD_ID_2)
  end
  function s.counterfilter(c)
  	return not c:IsSummonLocation(LOCATION_EXTRA) or c:IsType(TYPE_SYNCHRO)
  end
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetCustomActivityCount(id, tp, ACTIVITY_SPSUMMON) == 0
  	end
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET + EFFECT_FLAG_OATH)
  	e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  	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:IsType(TYPE_SYNCHRO) and c:IsLocation(LOCATION_EXTRA)
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_SYNCHRO)
  end
  function s.filter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_TUNER) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP_DEFENSE)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_DECK, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_DECK)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local ft = Duel.GetLocationCount(tp, LOCATION_MZONE)
  	local g = Duel.GetMatchingGroup(s.filter, tp, LOCATION_DECK, 0, nil, e, tp)
  	if ft <= 0 or g:GetCount() == 0 then
  		return
  	end
  	if Duel.IsPlayerAffectedByEffect(tp, CARD_ID_1) then
  		ft = 1
  	end
  	local ct = math.min(g:GetClassCount(Card.GetLevel), ft)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	aux.GCheckAdditional = aux.dlvcheck
  	local sg = g:SelectSubGroup(tp, aux.TRUE, false, ct, ct)
  	aux.GCheckAdditional = nil
  	Duel.SpecialSummon(sg, 0, tp, tp, false, false, POS_FACEUP_DEFENSE)
  end
  function s.regop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 1))
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_ATTACK_ANNOUNCE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1, id + 1)
  	e1:SetCondition(s.atkcon)
  	e1:SetOperation(s.atkop)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  	c:RegisterEffect(e1)
  end
  function s.atkcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return c == Duel.GetAttacker() and Duel.GetAttackTarget() ~= nil or c == Duel.GetAttackTarget()
  end
  function s.atkop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) and c:IsFaceup() then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_SET_ATTACK_FINAL)
  		e1:SetValue(c:GetBaseAttack() * 2)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		c:RegisterEffect(e1)
  	end
  end
  
  