name: Elemental
card_text: 1 "Elemental HERO" monster + 1 LIGHT monster
  Must be Fusion Summoned and cannot be Special Summoned by other ways. This card gains 300 ATK for each of your banished "Elemental HERO" monsters. When this card is sent from the field to the Graveyard: You can target up to 2 of your banished "Elemental HERO" monsters; add those targets to your hand.
external_ids: local SETCARD_ID_0 = 0x3008 --Elemental
  
lua: local SETCARD_ID_0 = 0x3008 --Elemental
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--fusion material
  	c:EnableReviveLimit()
  	aux.AddFusionProcFun2(c, aux.FilterBoolFunction(Card.IsFusionSetCard, SETCARD_ID_0), aux.FilterBoolFunction(Card.IsFusionAttribute, ATTRIBUTE_LIGHT), true)
  	--tohand
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_TOHAND)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET + EFFECT_FLAG_DAMAGE_STEP)
  	e2:SetCode(EVENT_TO_GRAVE)
  	e2:SetCondition(s.thcon)
  	e2:SetTarget(s.thtg)
  	e2:SetOperation(s.thop)
  	c:RegisterEffect(e2)
  	--atkup
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_SINGLE)
  	e3:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCode(EFFECT_UPDATE_ATTACK)
  	e3:SetValue(s.atkup)
  	c:RegisterEffect(e3)
  	--spsummon condition
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_SINGLE)
  	e4:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e4:SetCode(EFFECT_SPSUMMON_CONDITION)
  	e4:SetValue(aux.fuslimit)
  	c:RegisterEffect(e4)
  end
  s.material_setcode = 0x8
  function s.atkfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER)
  end
  function s.atkup(e, c)
  	return Duel.GetMatchingGroupCount(s.atkfilter, c:GetControler(), LOCATION_REMOVED, 0, nil) * 300
  end
  function s.thcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsPreviousLocation(LOCATION_ONFIELD)
  end
  function s.filter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) and c:IsAbleToHand()
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_REMOVED) and s.filter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_REMOVED, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectTarget(tp, s.filter, tp, LOCATION_REMOVED, 0, 1, 2, nil)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, g, g:GetCount(), 0, 0)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS)
  	local sg = g:Filter(Card.IsRelateToEffect, nil, e)
  	Duel.SendtoHand(sg, nil, REASON_EFFECT)
  end
  
  
source_text: Elemental
  1 "Elemental HERO" monster + 1 LIGHT monster
  Must be Fusion Summoned and cannot be Special Summoned by other ways. This card gains 300 ATK for each of your banished "Elemental HERO" monsters. When this card is sent from the field to the Graveyard: You can target up to 2 of your banished "Elemental HERO" monsters; add those targets to your hand.
target_text: -- Elemental
  local SETCARD_ID_0 = 0x3008 --Elemental
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--fusion material
  	c:EnableReviveLimit()
  	aux.AddFusionProcFun2(c, aux.FilterBoolFunction(Card.IsFusionSetCard, SETCARD_ID_0), aux.FilterBoolFunction(Card.IsFusionAttribute, ATTRIBUTE_LIGHT), true)
  	--tohand
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_TOHAND)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET + EFFECT_FLAG_DAMAGE_STEP)
  	e2:SetCode(EVENT_TO_GRAVE)
  	e2:SetCondition(s.thcon)
  	e2:SetTarget(s.thtg)
  	e2:SetOperation(s.thop)
  	c:RegisterEffect(e2)
  	--atkup
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_SINGLE)
  	e3:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCode(EFFECT_UPDATE_ATTACK)
  	e3:SetValue(s.atkup)
  	c:RegisterEffect(e3)
  	--spsummon condition
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_SINGLE)
  	e4:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e4:SetCode(EFFECT_SPSUMMON_CONDITION)
  	e4:SetValue(aux.fuslimit)
  	c:RegisterEffect(e4)
  end
  s.material_setcode = 0x8
  function s.atkfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER)
  end
  function s.atkup(e, c)
  	return Duel.GetMatchingGroupCount(s.atkfilter, c:GetControler(), LOCATION_REMOVED, 0, nil) * 300
  end
  function s.thcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsPreviousLocation(LOCATION_ONFIELD)
  end
  function s.filter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) and c:IsAbleToHand()
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_REMOVED) and s.filter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_REMOVED, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectTarget(tp, s.filter, tp, LOCATION_REMOVED, 0, 1, 2, nil)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, g, g:GetCount(), 0, 0)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS)
  	local sg = g:Filter(Card.IsRelateToEffect, nil, e)
  	Duel.SendtoHand(sg, nil, REASON_EFFECT)
  end
  
  