name: Lubellion
card_text: 1 DARK monster + "Fallen of Albaz"
  If this card is Fusion Summoned: You can discard 1 card; Fusion Summon 1 Level 8 or lower Fusion Monster from your Extra Deck, except "Lubellion the Searing Dragon", by shuffling Fusion Materials mentioned on it into the Deck, from your monsters on the field, GY, and/or face-up banished cards. For the rest of this turn, this card cannot attack, also you cannot Special Summon from the Extra Deck, except Fusion Monsters. You can only use this effect of "Lubellion the Searing Dragon" once per turn.
external_ids: local CARD_ID_0 = 68468459 --Fallen of Albaz
  local CARD_ID_1 = 6205579 --Fusion Parasite
  
lua: local CARD_ID_0 = 68468459 --Fallen of Albaz
  local CARD_ID_1 = 6205579 --Fusion Parasite
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--fusion material
  	c:EnableReviveLimit()
  	aux.AddFusionProcCodeFun(c, CARD_ID_0, aux.FilterBoolFunction(Card.IsFusionAttribute, ATTRIBUTE_DARK), 1, true, true)
  	--spsummon
  	local e1 = FusionSpell.CreateSummonEffect(c, {
  		fusfilter = s.fusfilter,
  		pre_select_mat_location = LOCATION_GRAVE | LOCATION_MZONE | LOCATION_REMOVED,
  		mat_operation_code_map = {
  			{ [LOCATION_DECK] = FusionSpell.FUSION_OPERATION_GRAVE },
  			{ [0xff] = FusionSpell.FUSION_OPERATION_SHUFFLE },
  		},
  		extra_target = s.extra_target,
  		stage_x_operation = s.stage_x_operation,
  	})
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.spcon)
  	e1:SetCost(s.spcost)
  	c:RegisterEffect(e1)
  end
  
  function s.branded_fusion_check(tp, sg, fc)
  	return aux.gffcheck(sg, Card.IsFusionCode, CARD_ID_0, function(c)
  		return c:IsFusionAttribute(ATTRIBUTE_DARK) and (not c:IsHasEffect(CARD_ID_1))
  	end)
  end
  
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_FUSION)
  end
  
  function s.fusfilter(c)
  	return (not c:IsCode(id)) and c:IsLevelBelow(8)
  end
  
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsDiscardable, tp, LOCATION_HAND, 0, 1, nil)
  	end
  	Duel.DiscardHand(tp, Card.IsDiscardable, 1, 1, REASON_COST + REASON_DISCARD)
  end
  
  function s.extra_target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TODECK, nil, 1, tp, LOCATION_ONFIELD + LOCATION_GRAVE + LOCATION_REMOVED)
  end
  
  function s.stage_x_operation(e, tc, tp, stage)
  	if stage == FusionSpell.STAGE_AT_ALL_OPERATION_FINISH then
  		local c = e:GetHandler()
  		if c:IsRelateToChain() then
  			local e1 = Effect.CreateEffect(c)
  			e1:SetType(EFFECT_TYPE_SINGLE)
  			e1:SetCode(EFFECT_CANNOT_ATTACK)
  			e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  			c:RegisterEffect(e1)
  		end
  		local e2 = Effect.CreateEffect(c)
  		e2:SetType(EFFECT_TYPE_FIELD)
  		e2:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  		e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  		e2:SetTargetRange(1, 0)
  		e2:SetReset(RESET_PHASE + PHASE_END)
  		e2:SetTarget(s.splimit)
  		Duel.RegisterEffect(e2, tp)
  	end
  end
  
  function s.splimit(e, c)
  	return not c:IsType(TYPE_FUSION) and c:IsLocation(LOCATION_EXTRA)
  end
  
  
source_text: Lubellion
  1 DARK monster + "Fallen of Albaz"
  If this card is Fusion Summoned: You can discard 1 card; Fusion Summon 1 Level 8 or lower Fusion Monster from your Extra Deck, except "Lubellion the Searing Dragon", by shuffling Fusion Materials mentioned on it into the Deck, from your monsters on the field, GY, and/or face-up banished cards. For the rest of this turn, this card cannot attack, also you cannot Special Summon from the Extra Deck, except Fusion Monsters. You can only use this effect of "Lubellion the Searing Dragon" once per turn.
target_text: -- Lubellion
  local CARD_ID_0 = 68468459 --Fallen of Albaz
  local CARD_ID_1 = 6205579 --Fusion Parasite
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--fusion material
  	c:EnableReviveLimit()
  	aux.AddFusionProcCodeFun(c, CARD_ID_0, aux.FilterBoolFunction(Card.IsFusionAttribute, ATTRIBUTE_DARK), 1, true, true)
  	--spsummon
  	local e1 = FusionSpell.CreateSummonEffect(c, {
  		fusfilter = s.fusfilter,
  		pre_select_mat_location = LOCATION_GRAVE | LOCATION_MZONE | LOCATION_REMOVED,
  		mat_operation_code_map = {
  			{ [LOCATION_DECK] = FusionSpell.FUSION_OPERATION_GRAVE },
  			{ [0xff] = FusionSpell.FUSION_OPERATION_SHUFFLE },
  		},
  		extra_target = s.extra_target,
  		stage_x_operation = s.stage_x_operation,
  	})
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.spcon)
  	e1:SetCost(s.spcost)
  	c:RegisterEffect(e1)
  end
  
  function s.branded_fusion_check(tp, sg, fc)
  	return aux.gffcheck(sg, Card.IsFusionCode, CARD_ID_0, function(c)
  		return c:IsFusionAttribute(ATTRIBUTE_DARK) and (not c:IsHasEffect(CARD_ID_1))
  	end)
  end
  
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_FUSION)
  end
  
  function s.fusfilter(c)
  	return (not c:IsCode(id)) and c:IsLevelBelow(8)
  end
  
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsDiscardable, tp, LOCATION_HAND, 0, 1, nil)
  	end
  	Duel.DiscardHand(tp, Card.IsDiscardable, 1, 1, REASON_COST + REASON_DISCARD)
  end
  
  function s.extra_target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TODECK, nil, 1, tp, LOCATION_ONFIELD + LOCATION_GRAVE + LOCATION_REMOVED)
  end
  
  function s.stage_x_operation(e, tc, tp, stage)
  	if stage == FusionSpell.STAGE_AT_ALL_OPERATION_FINISH then
  		local c = e:GetHandler()
  		if c:IsRelateToChain() then
  			local e1 = Effect.CreateEffect(c)
  			e1:SetType(EFFECT_TYPE_SINGLE)
  			e1:SetCode(EFFECT_CANNOT_ATTACK)
  			e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  			c:RegisterEffect(e1)
  		end
  		local e2 = Effect.CreateEffect(c)
  		e2:SetType(EFFECT_TYPE_FIELD)
  		e2:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  		e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  		e2:SetTargetRange(1, 0)
  		e2:SetReset(RESET_PHASE + PHASE_END)
  		e2:SetTarget(s.splimit)
  		Duel.RegisterEffect(e2, tp)
  	end
  end
  
  function s.splimit(e, c)
  	return not c:IsType(TYPE_FUSION) and c:IsLocation(LOCATION_EXTRA)
  end
  
  