name: Elemental
card_text: This card cannot be Normal Summoned or Set. This card cannot be Special Summoned except by sending an "Elemental Hero Bubbleman" you control and "Metamorphosis" in your hand to the Graveyard. This card's name is treated as "Elemental Hero Bubbleman" while it is face-up on the field. Destroy an opponent's monster that battles this card at the end of the Damage Step.
external_ids: local CARD_ID_0 = 79979666 --Elemental HERO Bubbleman
  local CARD_ID_1 = 46411259 --Metamorphosis
  
lua: local CARD_ID_0 = 79979666 --Elemental HERO Bubbleman
  local CARD_ID_1 = 46411259 --Metamorphosis
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	--cannot special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_SPSUMMON_CONDITION)
  	c:RegisterEffect(e1)
  	--special summon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_SPSUMMON_PROC)
  	e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e2:SetRange(LOCATION_HAND)
  	e2:SetCondition(s.spcon)
  	e2:SetTarget(s.sptg)
  	e2:SetOperation(s.spop)
  	c:RegisterEffect(e2)
  	--change code
  	aux.EnableChangeCode(c, CARD_ID_0)
  	--destroy
  	local e4 = Effect.CreateEffect(c)
  	e4:SetDescription(aux.Stringid(id, 0))
  	e4:SetCategory(CATEGORY_DESTROY)
  	e4:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e4:SetCode(EVENT_DAMAGE_STEP_END)
  	e4:SetCondition(aux.dsercon)
  	e4:SetTarget(s.destg)
  	e4:SetOperation(s.desop)
  	c:RegisterEffect(e4)
  end
  function s.spfilter(c)
  	return c:IsCode(CARD_ID_0, CARD_ID_1) and c:IsAbleToGraveAsCost()
  end
  function s.spfilter1(c, tp)
  	return c:IsCode(CARD_ID_0) and c:IsLocation(LOCATION_MZONE) and Duel.GetMZoneCount(tp, c) > 0
  end
  function s.spfilter2(c)
  	return c:IsCode(CARD_ID_1) and c:IsLocation(LOCATION_HAND)
  end
  function s.spcon(e, c)
  	if c == nil then
  		return true
  	end
  	local tp = c:GetControler()
  	local g = Duel.GetMatchingGroup(s.spfilter, tp, LOCATION_HAND + LOCATION_MZONE, 0, nil)
  	return g:CheckSubGroup(aux.gffcheck, 2, 2, s.spfilter1, tp, s.spfilter2, nil)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk, c)
  	local g = Duel.GetMatchingGroup(s.spfilter, tp, LOCATION_HAND + LOCATION_MZONE, 0, nil)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local sg = g:SelectSubGroup(tp, aux.gffcheck, true, 2, 2, s.spfilter1, tp, s.spfilter2, nil)
  	if sg then
  		sg:KeepAlive()
  		e:SetLabelObject(sg)
  		return true
  	else
  		return false
  	end
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp, c)
  	local g = e:GetLabelObject()
  	Duel.SendtoGrave(g, REASON_SPSUMMON)
  	g:DeleteGroup()
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local bc = e:GetHandler():GetBattleTarget()
  	if chk == 0 then
  		return bc and bc:IsRelateToBattle()
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, bc, 1, 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local bc = e:GetHandler():GetBattleTarget()
  	if bc:IsRelateToBattle() then
  		Duel.Destroy(bc, REASON_EFFECT)
  	end
  end
  
  
source_text: Elemental
  This card cannot be Normal Summoned or Set. This card cannot be Special Summoned except by sending an "Elemental Hero Bubbleman" you control and "Metamorphosis" in your hand to the Graveyard. This card's name is treated as "Elemental Hero Bubbleman" while it is face-up on the field. Destroy an opponent's monster that battles this card at the end of the Damage Step.
target_text: -- Elemental
  local CARD_ID_0 = 79979666 --Elemental HERO Bubbleman
  local CARD_ID_1 = 46411259 --Metamorphosis
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	--cannot special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_SPSUMMON_CONDITION)
  	c:RegisterEffect(e1)
  	--special summon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_SPSUMMON_PROC)
  	e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e2:SetRange(LOCATION_HAND)
  	e2:SetCondition(s.spcon)
  	e2:SetTarget(s.sptg)
  	e2:SetOperation(s.spop)
  	c:RegisterEffect(e2)
  	--change code
  	aux.EnableChangeCode(c, CARD_ID_0)
  	--destroy
  	local e4 = Effect.CreateEffect(c)
  	e4:SetDescription(aux.Stringid(id, 0))
  	e4:SetCategory(CATEGORY_DESTROY)
  	e4:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e4:SetCode(EVENT_DAMAGE_STEP_END)
  	e4:SetCondition(aux.dsercon)
  	e4:SetTarget(s.destg)
  	e4:SetOperation(s.desop)
  	c:RegisterEffect(e4)
  end
  function s.spfilter(c)
  	return c:IsCode(CARD_ID_0, CARD_ID_1) and c:IsAbleToGraveAsCost()
  end
  function s.spfilter1(c, tp)
  	return c:IsCode(CARD_ID_0) and c:IsLocation(LOCATION_MZONE) and Duel.GetMZoneCount(tp, c) > 0
  end
  function s.spfilter2(c)
  	return c:IsCode(CARD_ID_1) and c:IsLocation(LOCATION_HAND)
  end
  function s.spcon(e, c)
  	if c == nil then
  		return true
  	end
  	local tp = c:GetControler()
  	local g = Duel.GetMatchingGroup(s.spfilter, tp, LOCATION_HAND + LOCATION_MZONE, 0, nil)
  	return g:CheckSubGroup(aux.gffcheck, 2, 2, s.spfilter1, tp, s.spfilter2, nil)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk, c)
  	local g = Duel.GetMatchingGroup(s.spfilter, tp, LOCATION_HAND + LOCATION_MZONE, 0, nil)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local sg = g:SelectSubGroup(tp, aux.gffcheck, true, 2, 2, s.spfilter1, tp, s.spfilter2, nil)
  	if sg then
  		sg:KeepAlive()
  		e:SetLabelObject(sg)
  		return true
  	else
  		return false
  	end
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp, c)
  	local g = e:GetLabelObject()
  	Duel.SendtoGrave(g, REASON_SPSUMMON)
  	g:DeleteGroup()
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local bc = e:GetHandler():GetBattleTarget()
  	if chk == 0 then
  		return bc and bc:IsRelateToBattle()
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, bc, 1, 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local bc = e:GetHandler():GetBattleTarget()
  	if bc:IsRelateToBattle() then
  		Duel.Destroy(bc, REASON_EFFECT)
  	end
  end
  
  