name: Wake
card_text: 1 "Elemental HERO" Fusion Monster + 1+ Warrior monsters
  Must be Fusion Summoned. Gains 300 ATK for each material used for its Summon. This card can make a number of attacks on monsters each Battle Phase, up to the number of Fusion Monsters used as material for its Summon. After damage calculation, if this card battled a monster: Destroy that monster, and if you do, inflict damage to your opponent equal to its original ATK. If this Fusion Summoned card is destroyed: Special Summon 1 Warrior monster from your hand or Deck.
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)
  	c:EnableReviveLimit()
  	--fusion material
  	aux.AddFusionProcFunFunRep(c, s.mfilter1, aux.FilterBoolFunction(Card.IsRace, RACE_WARRIOR), 1, 127, true)
  	--spsummon condition
  	local e0 = Effect.CreateEffect(c)
  	e0:SetType(EFFECT_TYPE_SINGLE)
  	e0:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e0:SetCode(EFFECT_SPSUMMON_CONDITION)
  	e0:SetValue(aux.fuslimit)
  	c:RegisterEffect(e0)
  	--m-atk & atk-up
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_CONTINUOUS + EFFECT_TYPE_SINGLE)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetCondition(s.mtcon)
  	e1:SetOperation(s.mtop)
  	c:RegisterEffect(e1)
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetCode(EFFECT_MATERIAL_CHECK)
  	e2:SetValue(s.valcheck)
  	e2:SetLabelObject(e1)
  	c:RegisterEffect(e2)
  	--destroy burn
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetCategory(CATEGORY_DESTROY + CATEGORY_DAMAGE)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e3:SetCode(EVENT_BATTLED)
  	e3:SetCondition(s.descon)
  	e3:SetTarget(s.destg)
  	e3:SetOperation(s.desop)
  	c:RegisterEffect(e3)
  	--spsummon
  	local e4 = Effect.CreateEffect(c)
  	e4:SetDescription(aux.Stringid(id, 1))
  	e4:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e4:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e4:SetCode(EVENT_DESTROYED)
  	e4:SetCondition(s.spcon)
  	e4:SetTarget(s.sptg)
  	e4:SetOperation(s.spop)
  	c:RegisterEffect(e4)
  end
  s.material_setcode = 0x8
  function s.mfilter1(c)
  	return c:IsFusionSetCard(SETCARD_ID_0) and c:IsFusionType(TYPE_FUSION)
  end
  function s.valcheck(e, c)
  	local ct1 = c:GetMaterialCount()
  	local ct2 = c:GetMaterial():FilterCount(Card.IsFusionType, nil, TYPE_FUSION)
  	e:GetLabelObject():SetLabel(ct1, ct2)
  end
  function s.mtcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_FUSION) and e:GetLabel() > 0
  end
  function s.mtop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local ct1, ct2 = e:GetLabel()
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_UPDATE_ATTACK)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE)
  	e1:SetValue(ct1 * 300)
  	c:RegisterEffect(e1)
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetCode(EFFECT_EXTRA_ATTACK_MONSTER)
  	e2:SetReset(RESET_EVENT + RESETS_STANDARD)
  	e2:SetValue(ct2 - 1)
  	c:RegisterEffect(e2)
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local bc = c:GetBattleTarget()
  	return bc and bc:IsRelateToBattle()
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	local bc = e:GetHandler():GetBattleTarget()
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, bc, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, bc:GetBaseAttack())
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local bc = c:GetBattleTarget()
  	if bc:IsRelateToBattle() and Duel.Destroy(bc, REASON_EFFECT) > 0 then
  		local dam = bc:GetBaseAttack()
  		if dam > 0 then
  			Duel.Damage(1 - tp, dam, REASON_EFFECT)
  		end
  	end
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return c:IsPreviousLocation(LOCATION_MZONE) and c:IsSummonType(SUMMON_TYPE_FUSION)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_HAND + LOCATION_DECK)
  end
  function s.spfilter(c, e, tp)
  	return c:IsRace(RACE_WARRIOR) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_DECK + LOCATION_HAND, 0, 1, 1, nil, e, tp)
  	if g:GetCount() > 0 then
  		Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  
  
source_text: Wake
  1 "Elemental HERO" Fusion Monster + 1+ Warrior monsters
  Must be Fusion Summoned. Gains 300 ATK for each material used for its Summon. This card can make a number of attacks on monsters each Battle Phase, up to the number of Fusion Monsters used as material for its Summon. After damage calculation, if this card battled a monster: Destroy that monster, and if you do, inflict damage to your opponent equal to its original ATK. If this Fusion Summoned card is destroyed: Special Summon 1 Warrior monster from your hand or Deck.
target_text: -- Wake
  local SETCARD_ID_0 = 0x3008 --Elemental
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	--fusion material
  	aux.AddFusionProcFunFunRep(c, s.mfilter1, aux.FilterBoolFunction(Card.IsRace, RACE_WARRIOR), 1, 127, true)
  	--spsummon condition
  	local e0 = Effect.CreateEffect(c)
  	e0:SetType(EFFECT_TYPE_SINGLE)
  	e0:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e0:SetCode(EFFECT_SPSUMMON_CONDITION)
  	e0:SetValue(aux.fuslimit)
  	c:RegisterEffect(e0)
  	--m-atk & atk-up
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_CONTINUOUS + EFFECT_TYPE_SINGLE)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetCondition(s.mtcon)
  	e1:SetOperation(s.mtop)
  	c:RegisterEffect(e1)
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetCode(EFFECT_MATERIAL_CHECK)
  	e2:SetValue(s.valcheck)
  	e2:SetLabelObject(e1)
  	c:RegisterEffect(e2)
  	--destroy burn
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetCategory(CATEGORY_DESTROY + CATEGORY_DAMAGE)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e3:SetCode(EVENT_BATTLED)
  	e3:SetCondition(s.descon)
  	e3:SetTarget(s.destg)
  	e3:SetOperation(s.desop)
  	c:RegisterEffect(e3)
  	--spsummon
  	local e4 = Effect.CreateEffect(c)
  	e4:SetDescription(aux.Stringid(id, 1))
  	e4:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e4:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e4:SetCode(EVENT_DESTROYED)
  	e4:SetCondition(s.spcon)
  	e4:SetTarget(s.sptg)
  	e4:SetOperation(s.spop)
  	c:RegisterEffect(e4)
  end
  s.material_setcode = 0x8
  function s.mfilter1(c)
  	return c:IsFusionSetCard(SETCARD_ID_0) and c:IsFusionType(TYPE_FUSION)
  end
  function s.valcheck(e, c)
  	local ct1 = c:GetMaterialCount()
  	local ct2 = c:GetMaterial():FilterCount(Card.IsFusionType, nil, TYPE_FUSION)
  	e:GetLabelObject():SetLabel(ct1, ct2)
  end
  function s.mtcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_FUSION) and e:GetLabel() > 0
  end
  function s.mtop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local ct1, ct2 = e:GetLabel()
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_UPDATE_ATTACK)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE)
  	e1:SetValue(ct1 * 300)
  	c:RegisterEffect(e1)
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetCode(EFFECT_EXTRA_ATTACK_MONSTER)
  	e2:SetReset(RESET_EVENT + RESETS_STANDARD)
  	e2:SetValue(ct2 - 1)
  	c:RegisterEffect(e2)
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local bc = c:GetBattleTarget()
  	return bc and bc:IsRelateToBattle()
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	local bc = e:GetHandler():GetBattleTarget()
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, bc, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, bc:GetBaseAttack())
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local bc = c:GetBattleTarget()
  	if bc:IsRelateToBattle() and Duel.Destroy(bc, REASON_EFFECT) > 0 then
  		local dam = bc:GetBaseAttack()
  		if dam > 0 then
  			Duel.Damage(1 - tp, dam, REASON_EFFECT)
  		end
  	end
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return c:IsPreviousLocation(LOCATION_MZONE) and c:IsSummonType(SUMMON_TYPE_FUSION)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_HAND + LOCATION_DECK)
  end
  function s.spfilter(c, e, tp)
  	return c:IsRace(RACE_WARRIOR) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_DECK + LOCATION_HAND, 0, 1, 1, nil, e, tp)
  	if g:GetCount() > 0 then
  		Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  
  