name: Evolution
card_text: Add 1 "Overload Fusion" from your Deck to your hand. If you Fusion Summon a monster this turn with "Overload Fusion", using 6 or more monsters as material, that monster can attack a number of times each Battle Phase this turn, up to the number of monsters used as its Fusion Materials. For the rest of this turn after this card resolves, you cannot Special Summon monsters, except with Spell effects. You can only activate 1 "Evolution End Burst" per turn.
external_ids: local CARD_ID_0 = 3659803 --Overload Fusion
  
lua: local CARD_ID_0 = 3659803 --Overload Fusion
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SEARCH + CATEGORY_TOHAND)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.thfilter(c)
  	return c:IsCode(CARD_ID_0) and c:IsAbleToHand()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectMatchingCard(tp, s.thfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, g)
  	end
  	--extra attack
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetCondition(s.excon)
  	e1:SetOperation(s.exop)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  	if not e:IsHasType(EFFECT_TYPE_ACTIVATE) then
  		return
  	end
  	--sumlimit
  	local e2 = Effect.CreateEffect(e:GetHandler())
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  	e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e2:SetTargetRange(1, 0)
  	e2:SetTarget(s.splimit)
  	e2:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e2, tp)
  end
  function s.cfilter(c)
  	return c:IsType(TYPE_FUSION) and c:IsSummonType(SUMMON_TYPE_FUSION) and c:GetMaterialCount() >= 6
  end
  function s.excon(e, tp, eg, ep, ev, re, r, rp)
  	return re and re:GetHandler():IsCode(CARD_ID_0) and eg:IsExists(s.cfilter, 1, nil)
  end
  function s.exop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = eg:Filter(s.cfilter, nil):GetFirst()
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_EXTRA_ATTACK)
  	e1:SetValue(tc:GetMaterialCount() - 1)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  	tc:RegisterEffect(e1)
  end
  function s.splimit(e, c, sump, sumtype, sumpos, targetp, se)
  	return not se:GetHandler():IsType(TYPE_SPELL)
  end
  
  
source_text: Evolution
  Add 1 "Overload Fusion" from your Deck to your hand. If you Fusion Summon a monster this turn with "Overload Fusion", using 6 or more monsters as material, that monster can attack a number of times each Battle Phase this turn, up to the number of monsters used as its Fusion Materials. For the rest of this turn after this card resolves, you cannot Special Summon monsters, except with Spell effects. You can only activate 1 "Evolution End Burst" per turn.
target_text: -- Evolution
  local CARD_ID_0 = 3659803 --Overload Fusion
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SEARCH + CATEGORY_TOHAND)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.thfilter(c)
  	return c:IsCode(CARD_ID_0) and c:IsAbleToHand()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectMatchingCard(tp, s.thfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, g)
  	end
  	--extra attack
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetCondition(s.excon)
  	e1:SetOperation(s.exop)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  	if not e:IsHasType(EFFECT_TYPE_ACTIVATE) then
  		return
  	end
  	--sumlimit
  	local e2 = Effect.CreateEffect(e:GetHandler())
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  	e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e2:SetTargetRange(1, 0)
  	e2:SetTarget(s.splimit)
  	e2:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e2, tp)
  end
  function s.cfilter(c)
  	return c:IsType(TYPE_FUSION) and c:IsSummonType(SUMMON_TYPE_FUSION) and c:GetMaterialCount() >= 6
  end
  function s.excon(e, tp, eg, ep, ev, re, r, rp)
  	return re and re:GetHandler():IsCode(CARD_ID_0) and eg:IsExists(s.cfilter, 1, nil)
  end
  function s.exop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = eg:Filter(s.cfilter, nil):GetFirst()
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_EXTRA_ATTACK)
  	e1:SetValue(tc:GetMaterialCount() - 1)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  	tc:RegisterEffect(e1)
  end
  function s.splimit(e, c, sump, sumtype, sumpos, targetp, se)
  	return not se:GetHandler():IsType(TYPE_SPELL)
  end
  
  