name: Ignis
card_text: Pendulum Scale = 7
  [ Pendulum Effect ]
  During your Main Phase: You can shuffle 1 face-up Pendulum Monster from your Extra Deck into the Deck, then add 1 non-Pendulum "Dracoslayer" or "Igknight" monster from your Deck to your hand. You can only use this effect of "Ignis Phoenix, the Dracoslayer" once per turn.
  ----------------------------------------
  [ Monster Effect ]
  (This card is always treated as an "Igknight" card.)
  If this card on the field is destroyed by battle or card effect: You can Special Summon 1 "Dracoslayer" or "Igknight" monster from your Deck, except "Ignis Phoenix, the Dracoslayer", and if you do, it is treated as a Tuner. You can only use this effect of "Ignis Phoenix, the Dracoslayer" once per turn.
external_ids: local SETCARD_ID_0 = 0xc7 --Dracoslayer
  
lua: local SETCARD_ID_0 = 0xc7 --Dracoslayer
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--pendulum summon
  	aux.EnablePendulumAttribute(c)
  	--to hand
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TODECK + CATEGORY_SEARCH + CATEGORY_TOHAND)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_PZONE)
  	e1:SetCountLimit(1, id)
  	e1:SetTarget(s.thtg)
  	e1:SetOperation(s.thop)
  	c:RegisterEffect(e1)
  	--spsummon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_DESTROYED)
  	e2:SetProperty(EFFECT_FLAG_DELAY)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetCondition(s.spcon)
  	e2:SetTarget(s.sptg)
  	e2:SetOperation(s.spop)
  	c:RegisterEffect(e2)
  end
  function s.tdfilter(c)
  	return c:IsType(TYPE_PENDULUM) and c:IsFaceup() and c:IsAbleToDeck()
  end
  function s.thfilter(c)
  	return c:IsSetCard(SETCARD_ID_0, 0xc8) and c:IsType(TYPE_MONSTER) and not c:IsType(TYPE_PENDULUM) and c:IsAbleToHand()
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.tdfilter, tp, LOCATION_EXTRA, 0, 1, nil) and Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TODECK, nil, 1, tp, LOCATION_EXTRA)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TODECK)
  	local tc = Duel.SelectMatchingCard(tp, s.tdfilter, tp, LOCATION_EXTRA, 0, 1, 1, nil):GetFirst()
  	if tc and Duel.SendtoDeck(tc, nil, SEQ_DECKSHUFFLE, REASON_EFFECT) > 0 and tc:IsLocation(LOCATION_DECK) then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  		local g = Duel.SelectMatchingCard(tp, s.thfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  		if g:GetCount() > 0 then
  			Duel.BreakEffect()
  			Duel.SendtoHand(g, nil, REASON_EFFECT)
  			Duel.ConfirmCards(1 - tp, g)
  		end
  	end
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return bit.band(r, REASON_EFFECT + REASON_BATTLE) ~= 0 and e:GetHandler():IsPreviousLocation(LOCATION_ONFIELD)
  end
  function s.spfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0, 0xc8) and not c:IsCode(id) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_DECK, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_DECK)
  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 tc = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_DECK, 0, 1, 1, nil, e, tp):GetFirst()
  	if tc then
  		if Duel.SpecialSummonStep(tc, 0, tp, tp, false, false, POS_FACEUP) then
  			local e1 = Effect.CreateEffect(e:GetHandler())
  			e1:SetType(EFFECT_TYPE_SINGLE)
  			e1:SetCode(EFFECT_ADD_TYPE)
  			e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  			e1:SetValue(TYPE_TUNER)
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  			tc:RegisterEffect(e1)
  		end
  		Duel.SpecialSummonComplete()
  	end
  end
  
  
source_text: Ignis
  Pendulum Scale = 7
  [ Pendulum Effect ]
  During your Main Phase: You can shuffle 1 face-up Pendulum Monster from your Extra Deck into the Deck, then add 1 non-Pendulum "Dracoslayer" or "Igknight" monster from your Deck to your hand. You can only use this effect of "Ignis Phoenix, the Dracoslayer" once per turn.
  ----------------------------------------
  [ Monster Effect ]
  (This card is always treated as an "Igknight" card.)
  If this card on the field is destroyed by battle or card effect: You can Special Summon 1 "Dracoslayer" or "Igknight" monster from your Deck, except "Ignis Phoenix, the Dracoslayer", and if you do, it is treated as a Tuner. You can only use this effect of "Ignis Phoenix, the Dracoslayer" once per turn.
target_text: -- Ignis
  local SETCARD_ID_0 = 0xc7 --Dracoslayer
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--pendulum summon
  	aux.EnablePendulumAttribute(c)
  	--to hand
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TODECK + CATEGORY_SEARCH + CATEGORY_TOHAND)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_PZONE)
  	e1:SetCountLimit(1, id)
  	e1:SetTarget(s.thtg)
  	e1:SetOperation(s.thop)
  	c:RegisterEffect(e1)
  	--spsummon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_DESTROYED)
  	e2:SetProperty(EFFECT_FLAG_DELAY)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetCondition(s.spcon)
  	e2:SetTarget(s.sptg)
  	e2:SetOperation(s.spop)
  	c:RegisterEffect(e2)
  end
  function s.tdfilter(c)
  	return c:IsType(TYPE_PENDULUM) and c:IsFaceup() and c:IsAbleToDeck()
  end
  function s.thfilter(c)
  	return c:IsSetCard(SETCARD_ID_0, 0xc8) and c:IsType(TYPE_MONSTER) and not c:IsType(TYPE_PENDULUM) and c:IsAbleToHand()
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.tdfilter, tp, LOCATION_EXTRA, 0, 1, nil) and Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TODECK, nil, 1, tp, LOCATION_EXTRA)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TODECK)
  	local tc = Duel.SelectMatchingCard(tp, s.tdfilter, tp, LOCATION_EXTRA, 0, 1, 1, nil):GetFirst()
  	if tc and Duel.SendtoDeck(tc, nil, SEQ_DECKSHUFFLE, REASON_EFFECT) > 0 and tc:IsLocation(LOCATION_DECK) then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  		local g = Duel.SelectMatchingCard(tp, s.thfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  		if g:GetCount() > 0 then
  			Duel.BreakEffect()
  			Duel.SendtoHand(g, nil, REASON_EFFECT)
  			Duel.ConfirmCards(1 - tp, g)
  		end
  	end
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return bit.band(r, REASON_EFFECT + REASON_BATTLE) ~= 0 and e:GetHandler():IsPreviousLocation(LOCATION_ONFIELD)
  end
  function s.spfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0, 0xc8) and not c:IsCode(id) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_DECK, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_DECK)
  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 tc = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_DECK, 0, 1, 1, nil, e, tp):GetFirst()
  	if tc then
  		if Duel.SpecialSummonStep(tc, 0, tp, tp, false, false, POS_FACEUP) then
  			local e1 = Effect.CreateEffect(e:GetHandler())
  			e1:SetType(EFFECT_TYPE_SINGLE)
  			e1:SetCode(EFFECT_ADD_TYPE)
  			e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  			e1:SetValue(TYPE_TUNER)
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  			tc:RegisterEffect(e1)
  		end
  		Duel.SpecialSummonComplete()
  	end
  end
  
  