name: Accel
card_text: 1 Tuner + 1+ non-Tuner monsters
  Once per turn: You can send 1 "Synchron" monster from your Deck to the GY, then activate 1 of these effects;
  ● Increase this card's Level by the Level of the sent monster.
  ● Reduce this card's Level by the Level of the sent monster.
  During your opponent's Main Phase, you can (Quick Effect): Immediately after this effect resolves, Synchro Summon using this card you control. You can only Synchro Summon "Accel Synchron" once per turn.
external_ids: local SETCARD_ID_0 = 0x1017 --Synchron
  
lua: local SETCARD_ID_0 = 0x1017 --Synchron
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--synchro summon
  	aux.AddSynchroProcedure(c, nil, aux.NonTuner(nil), 1)
  	c:EnableReviveLimit()
  	--splimit
  	local e1 = Effect.CreateEffect(c)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetCondition(s.regcon)
  	e1:SetOperation(s.regop)
  	c:RegisterEffect(e1)
  	--lv
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1)
  	e2:SetCost(s.tgcost)
  	e2:SetTarget(s.tgtg)
  	e2:SetOperation(s.tgop)
  	c:RegisterEffect(e2)
  	--spsummon
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e3:SetType(EFFECT_TYPE_QUICK_O)
  	e3:SetCode(EVENT_FREE_CHAIN)
  	e3:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_MAIN_END)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCondition(s.spcon)
  	e3:SetTarget(s.sptg)
  	e3:SetOperation(s.spop)
  	c:RegisterEffect(e3)
  end
  function s.regcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_SYNCHRO)
  end
  function s.regop(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)
  	e1:SetTargetRange(1, 0)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	e1:SetTarget(s.splimit)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.splimit(e, c, sump, sumtype, sumpos, targetp, se)
  	return c:IsCode(id) and bit.band(sumtype, SUMMON_TYPE_SYNCHRO) == SUMMON_TYPE_SYNCHRO
  end
  function s.filter(c)
  	return c:GetLevel() > 0 and c:IsSetCard(SETCARD_ID_0) and c:IsAbleToGraveAsCost()
  end
  function s.tgcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	Duel.SendtoGrave(g, REASON_COST)
  	e:SetLabelObject(g:GetFirst())
  end
  function s.tgtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local lv = e:GetHandler():GetLevel()
  	if chk == 0 then
  		return lv > 0
  	end
  	local opt
  	if e:GetLabelObject():GetLevel() < lv then
  		opt = Duel.SelectOption(tp, aux.Stringid(id, 2), aux.Stringid(id, 3))
  	else
  		opt = Duel.SelectOption(tp, aux.Stringid(id, 2))
  	end
  	e:SetLabel(opt)
  end
  function s.tgop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local lv = e:GetLabelObject():GetLevel()
  	if c:IsRelateToEffect(e) and c:IsFaceup() then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_LEVEL)
  		if e:GetLabel() == 0 then
  			e1:SetValue(lv)
  		else
  			e1:SetValue(-lv)
  		end
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE)
  		c:RegisterEffect(e1)
  	end
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	local ph = Duel.GetCurrentPhase()
  	return Duel.GetTurnPlayer() ~= tp and (ph == PHASE_MAIN1 or ph == PHASE_MAIN2)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return not e:GetHandler():IsStatus(STATUS_CHAINING) and Duel.IsExistingMatchingCard(Card.IsSynchroSummonable, tp, LOCATION_EXTRA, 0, 1, nil, e:GetHandler())
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_EXTRA)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsControler(1 - tp) or not c:IsRelateToEffect(e) or c:IsFacedown() then
  		return
  	end
  	local g = Duel.GetMatchingGroup(Card.IsSynchroSummonable, tp, LOCATION_EXTRA, 0, nil, c)
  	if g:GetCount() > 0 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local sg = g:Select(tp, 1, 1, nil)
  		Duel.SynchroSummon(tp, sg:GetFirst(), c)
  	end
  end
  
  
source_text: Accel
  1 Tuner + 1+ non-Tuner monsters
  Once per turn: You can send 1 "Synchron" monster from your Deck to the GY, then activate 1 of these effects;
  ● Increase this card's Level by the Level of the sent monster.
  ● Reduce this card's Level by the Level of the sent monster.
  During your opponent's Main Phase, you can (Quick Effect): Immediately after this effect resolves, Synchro Summon using this card you control. You can only Synchro Summon "Accel Synchron" once per turn.
target_text: -- Accel
  local SETCARD_ID_0 = 0x1017 --Synchron
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--synchro summon
  	aux.AddSynchroProcedure(c, nil, aux.NonTuner(nil), 1)
  	c:EnableReviveLimit()
  	--splimit
  	local e1 = Effect.CreateEffect(c)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetCondition(s.regcon)
  	e1:SetOperation(s.regop)
  	c:RegisterEffect(e1)
  	--lv
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1)
  	e2:SetCost(s.tgcost)
  	e2:SetTarget(s.tgtg)
  	e2:SetOperation(s.tgop)
  	c:RegisterEffect(e2)
  	--spsummon
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e3:SetType(EFFECT_TYPE_QUICK_O)
  	e3:SetCode(EVENT_FREE_CHAIN)
  	e3:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_MAIN_END)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCondition(s.spcon)
  	e3:SetTarget(s.sptg)
  	e3:SetOperation(s.spop)
  	c:RegisterEffect(e3)
  end
  function s.regcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_SYNCHRO)
  end
  function s.regop(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)
  	e1:SetTargetRange(1, 0)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	e1:SetTarget(s.splimit)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.splimit(e, c, sump, sumtype, sumpos, targetp, se)
  	return c:IsCode(id) and bit.band(sumtype, SUMMON_TYPE_SYNCHRO) == SUMMON_TYPE_SYNCHRO
  end
  function s.filter(c)
  	return c:GetLevel() > 0 and c:IsSetCard(SETCARD_ID_0) and c:IsAbleToGraveAsCost()
  end
  function s.tgcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	Duel.SendtoGrave(g, REASON_COST)
  	e:SetLabelObject(g:GetFirst())
  end
  function s.tgtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local lv = e:GetHandler():GetLevel()
  	if chk == 0 then
  		return lv > 0
  	end
  	local opt
  	if e:GetLabelObject():GetLevel() < lv then
  		opt = Duel.SelectOption(tp, aux.Stringid(id, 2), aux.Stringid(id, 3))
  	else
  		opt = Duel.SelectOption(tp, aux.Stringid(id, 2))
  	end
  	e:SetLabel(opt)
  end
  function s.tgop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local lv = e:GetLabelObject():GetLevel()
  	if c:IsRelateToEffect(e) and c:IsFaceup() then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_LEVEL)
  		if e:GetLabel() == 0 then
  			e1:SetValue(lv)
  		else
  			e1:SetValue(-lv)
  		end
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE)
  		c:RegisterEffect(e1)
  	end
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	local ph = Duel.GetCurrentPhase()
  	return Duel.GetTurnPlayer() ~= tp and (ph == PHASE_MAIN1 or ph == PHASE_MAIN2)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return not e:GetHandler():IsStatus(STATUS_CHAINING) and Duel.IsExistingMatchingCard(Card.IsSynchroSummonable, tp, LOCATION_EXTRA, 0, 1, nil, e:GetHandler())
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_EXTRA)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsControler(1 - tp) or not c:IsRelateToEffect(e) or c:IsFacedown() then
  		return
  	end
  	local g = Duel.GetMatchingGroup(Card.IsSynchroSummonable, tp, LOCATION_EXTRA, 0, nil, c)
  	if g:GetCount() > 0 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local sg = g:Select(tp, 1, 1, nil)
  		Duel.SynchroSummon(tp, sg:GetFirst(), c)
  	end
  end
  
  