name: Yubel
card_text: 1 "Yubel" monster + 1+ Effect Monsters on the field
  If this card is Fusion Summoned: You can inflict 500 damage to your opponent for each material used. You can only use this effect of "Yubel - The Loving Defender Forever" once per turn. Cannot be destroyed by battle or card effects, also you take no battle damage from battles involving this card. At the end of the Damage Step, if this card battled an opponent's monster: Inflict damage to your opponent equal to that opponent's monster's ATK, and if you do, banish that monster.
external_ids: local SETCARD_ID_0 = 0x1a5 --Yubel
  
lua: local SETCARD_ID_0 = 0x1a5 --Yubel
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	--material
  	aux.AddFusionProcFunFunRep(c, aux.FilterBoolFunction(Card.IsFusionSetCard, SETCARD_ID_0), s.matfilter, 1, 63, true)
  	--damage
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_DAMAGE)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET + EFFECT_FLAG_DELAY)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.dmgcon)
  	e1:SetTarget(s.damtg)
  	e1:SetOperation(s.dmgop)
  	c:RegisterEffect(e1)
  	--damage&remove
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_DAMAGE + CATEGORY_REMOVE)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e2:SetCode(EVENT_DAMAGE_STEP_END)
  	e2:SetCondition(aux.dsercon)
  	e2:SetTarget(s.damrtg)
  	e2:SetOperation(s.damrop)
  	c:RegisterEffect(e2)
  	--indes
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_SINGLE)
  	e3:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
  	e3:SetValue(1)
  	c:RegisterEffect(e3)
  	local e4 = e3:Clone()
  	e4:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
  	c:RegisterEffect(e4)
  	--damage val
  	local e5 = e3:Clone()
  	e5:SetCode(EFFECT_AVOID_BATTLE_DAMAGE)
  	c:RegisterEffect(e5)
  end
  function s.matfilter(c)
  	return c:IsLocation(LOCATION_MZONE) and c:IsType(TYPE_EFFECT)
  end
  function s.dmgcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_FUSION)
  end
  function s.damtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	local c = e:GetHandler()
  	local damage = c:GetMaterialCount() * 500
  	Duel.SetTargetPlayer(1 - tp)
  	Duel.SetTargetParam(damage)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, damage)
  	e:SetLabel(damage)
  end
  function s.dmgop(e, tp, eg, ep, ev, re, r, rp)
  	local p, d = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER, CHAININFO_TARGET_PARAM)
  	Duel.Damage(p, d, REASON_EFFECT)
  end
  function s.damrtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	local bc = c:GetBattleTarget()
  	if chk == 0 then
  		return c:IsStatus(STATUS_OPPO_BATTLE) and bc ~= nil
  	end
  	if bc:GetAttack() > 0 then
  		Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, bc:GetAttack())
  	end
  end
  function s.damrop(e, tp, eg, ep, ev, re, r, rp)
  	local bc = e:GetHandler():GetBattleTarget()
  	local atk = bc:GetAttack()
  	local def = bc:GetDefense()
  	if atk < 0 then
  		atk = 0
  	end
  	if bc:IsControler(tp) or bc:IsFacedown() then
  		return
  	end
  	if Duel.Damage(1 - tp, atk, REASON_EFFECT, true) ~= 0 then
  		Duel.Remove(bc, POS_FACEUP, REASON_EFFECT)
  	end
  	Duel.RDComplete()
  end
  
  
source_text: Yubel
  1 "Yubel" monster + 1+ Effect Monsters on the field
  If this card is Fusion Summoned: You can inflict 500 damage to your opponent for each material used. You can only use this effect of "Yubel - The Loving Defender Forever" once per turn. Cannot be destroyed by battle or card effects, also you take no battle damage from battles involving this card. At the end of the Damage Step, if this card battled an opponent's monster: Inflict damage to your opponent equal to that opponent's monster's ATK, and if you do, banish that monster.
target_text: -- Yubel
  local SETCARD_ID_0 = 0x1a5 --Yubel
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	--material
  	aux.AddFusionProcFunFunRep(c, aux.FilterBoolFunction(Card.IsFusionSetCard, SETCARD_ID_0), s.matfilter, 1, 63, true)
  	--damage
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_DAMAGE)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET + EFFECT_FLAG_DELAY)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.dmgcon)
  	e1:SetTarget(s.damtg)
  	e1:SetOperation(s.dmgop)
  	c:RegisterEffect(e1)
  	--damage&remove
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_DAMAGE + CATEGORY_REMOVE)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e2:SetCode(EVENT_DAMAGE_STEP_END)
  	e2:SetCondition(aux.dsercon)
  	e2:SetTarget(s.damrtg)
  	e2:SetOperation(s.damrop)
  	c:RegisterEffect(e2)
  	--indes
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_SINGLE)
  	e3:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
  	e3:SetValue(1)
  	c:RegisterEffect(e3)
  	local e4 = e3:Clone()
  	e4:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
  	c:RegisterEffect(e4)
  	--damage val
  	local e5 = e3:Clone()
  	e5:SetCode(EFFECT_AVOID_BATTLE_DAMAGE)
  	c:RegisterEffect(e5)
  end
  function s.matfilter(c)
  	return c:IsLocation(LOCATION_MZONE) and c:IsType(TYPE_EFFECT)
  end
  function s.dmgcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_FUSION)
  end
  function s.damtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	local c = e:GetHandler()
  	local damage = c:GetMaterialCount() * 500
  	Duel.SetTargetPlayer(1 - tp)
  	Duel.SetTargetParam(damage)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, damage)
  	e:SetLabel(damage)
  end
  function s.dmgop(e, tp, eg, ep, ev, re, r, rp)
  	local p, d = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER, CHAININFO_TARGET_PARAM)
  	Duel.Damage(p, d, REASON_EFFECT)
  end
  function s.damrtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	local bc = c:GetBattleTarget()
  	if chk == 0 then
  		return c:IsStatus(STATUS_OPPO_BATTLE) and bc ~= nil
  	end
  	if bc:GetAttack() > 0 then
  		Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, bc:GetAttack())
  	end
  end
  function s.damrop(e, tp, eg, ep, ev, re, r, rp)
  	local bc = e:GetHandler():GetBattleTarget()
  	local atk = bc:GetAttack()
  	local def = bc:GetDefense()
  	if atk < 0 then
  		atk = 0
  	end
  	if bc:IsControler(tp) or bc:IsFacedown() then
  		return
  	end
  	if Duel.Damage(1 - tp, atk, REASON_EFFECT, true) ~= 0 then
  		Duel.Remove(bc, POS_FACEUP, REASON_EFFECT)
  	end
  	Duel.RDComplete()
  end
  
  