Igknight
While this card is in your hand: You can target 3 "Igknight" cards you control; destroy them, and if you do, Special Summon this card. Once per turn: You can target 1 other "Igknight" monster you control; return it to the hand, and if you do, place 1 monster your opponent controls on the bottom of the Deck.
local SETCARD_ID_0 = 0xc8 --Igknight

local SETCARD_ID_0 = 0xc8 --Igknight
local s, id, o = GetID()
function s.initial_effect(c)
	--spsummon
	local e1 = Effect.CreateEffect(c)
	e1:SetCategory(CATEGORY_DESTROY + CATEGORY_SPECIAL_SUMMON)
	e1:SetType(EFFECT_TYPE_IGNITION)
	e1:SetRange(LOCATION_HAND)
	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
	e1:SetTarget(s.sptg)
	e1:SetOperation(s.spop)
	c:RegisterEffect(e1)
	--todeck
	local e2 = Effect.CreateEffect(c)
	e2:SetCategory(CATEGORY_TOHAND + CATEGORY_TODECK)
	e2:SetType(EFFECT_TYPE_IGNITION)
	e2:SetRange(LOCATION_MZONE)
	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
	e2:SetCountLimit(1)
	e2:SetTarget(s.tdtg)
	e2:SetOperation(s.tdop)
	c:RegisterEffect(e2)
end
function s.desfilter(c)
	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
end
function s.desfilter2(c, e)
	return s.desfilter(c) and c:IsCanBeEffectTarget(e)
end
function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
	if chkc then
		return chkc:IsOnField() and chkc:IsControler(tp) and s.desfilter(chkc)
	end
	local ft = Duel.GetLocationCount(tp, LOCATION_MZONE)
	local ct = -ft + 1
	if chk == 0 then
		return ct <= 3
			and e:GetHandler():IsCanBeSpecialSummoned(e, 0, tp, false, false)
			and Duel.IsExistingTarget(s.desfilter, tp, LOCATION_ONFIELD, 0, 3, nil)
			and (ct <= 0 or Duel.IsExistingTarget(s.desfilter, tp, LOCATION_MZONE, 0, ct, nil))
	end
	local g = nil
	if ct > 0 then
		local tg = Duel.GetMatchingGroup(s.desfilter2, tp, LOCATION_ONFIELD, 0, nil, e)
		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
		g = tg:FilterSelect(tp, Card.IsLocation, ct, ct, nil, LOCATION_MZONE)
		if ct < 3 then
			tg:Sub(g)
			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
			local g2 = tg:Select(tp, 3 - ct, 3 - ct, nil)
			g:Merge(g2)
		end
		Duel.SetTargetCard(g)
	else
		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
		g = Duel.SelectTarget(tp, s.desfilter, tp, LOCATION_ONFIELD, 0, 3, 3, nil)
	end
	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, 3, 0, 0)
	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
end
function s.spop(e, tp, eg, ep, ev, re, r, rp)
	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS):Filter(Card.IsRelateToEffect, nil, e)
	if Duel.Destroy(g, REASON_EFFECT) ~= 0 then
		local c = e:GetHandler()
		if not c:IsRelateToEffect(e) then
			return
		end
		Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP)
	end
end
function s.thfilter(c)
	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsAbleToHand()
end
function s.tdtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
	if chkc then
		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.thfilter(chkc) and chkc ~= e:GetHandler()
	end
	if chk == 0 then
		return Duel.IsExistingTarget(s.thfilter, tp, LOCATION_MZONE, 0, 1, e:GetHandler()) and Duel.IsExistingMatchingCard(Card.IsAbleToDeck, tp, 0, LOCATION_MZONE, 1, nil)
	end
	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
	local g = Duel.SelectTarget(tp, s.thfilter, tp, LOCATION_MZONE, 0, 1, 1, e:GetHandler())
	Duel.SetOperationInfo(0, CATEGORY_TOHAND, g, 1, 0, 0)
	Duel.SetOperationInfo(0, CATEGORY_TODECK, nil, 1, 1 - tp, LOCATION_MZONE)
end
function s.tdop(e, tp, eg, ep, ev, re, r, rp)
	local tc = Duel.GetFirstTarget()
	if tc:IsRelateToEffect(e) and Duel.SendtoHand(tc, nil, REASON_EFFECT) ~= 0 and tc:IsLocation(LOCATION_HAND) then
		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TODECK)
		local g = Duel.SelectMatchingCard(tp, Card.IsAbleToDeck, tp, 0, LOCATION_MZONE, 1, 1, nil)
		Duel.SendtoDeck(g, nil, SEQ_DECKBOTTOM, REASON_EFFECT)
	end
end


Igknight
While this card is in your hand: You can target 3 "Igknight" cards you control; destroy them, and if you do, Special Summon this card. Once per turn: You can target 1 other "Igknight" monster you control; return it to the hand, and if you do, place 1 monster your opponent controls on the bottom of the Deck.
-- Igknight
local SETCARD_ID_0 = 0xc8 --Igknight
local s, id, o = GetID()
function s.initial_effect(c)
	--spsummon
	local e1 = Effect.CreateEffect(c)
	e1:SetCategory(CATEGORY_DESTROY + CATEGORY_SPECIAL_SUMMON)
	e1:SetType(EFFECT_TYPE_IGNITION)
	e1:SetRange(LOCATION_HAND)
	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
	e1:SetTarget(s.sptg)
	e1:SetOperation(s.spop)
	c:RegisterEffect(e1)
	--todeck
	local e2 = Effect.CreateEffect(c)
	e2:SetCategory(CATEGORY_TOHAND + CATEGORY_TODECK)
	e2:SetType(EFFECT_TYPE_IGNITION)
	e2:SetRange(LOCATION_MZONE)
	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
	e2:SetCountLimit(1)
	e2:SetTarget(s.tdtg)
	e2:SetOperation(s.tdop)
	c:RegisterEffect(e2)
end
function s.desfilter(c)
	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
end
function s.desfilter2(c, e)
	return s.desfilter(c) and c:IsCanBeEffectTarget(e)
end
function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
	if chkc then
		return chkc:IsOnField() and chkc:IsControler(tp) and s.desfilter(chkc)
	end
	local ft = Duel.GetLocationCount(tp, LOCATION_MZONE)
	local ct = -ft + 1
	if chk == 0 then
		return ct <= 3
			and e:GetHandler():IsCanBeSpecialSummoned(e, 0, tp, false, false)
			and Duel.IsExistingTarget(s.desfilter, tp, LOCATION_ONFIELD, 0, 3, nil)
			and (ct <= 0 or Duel.IsExistingTarget(s.desfilter, tp, LOCATION_MZONE, 0, ct, nil))
	end
	local g = nil
	if ct > 0 then
		local tg = Duel.GetMatchingGroup(s.desfilter2, tp, LOCATION_ONFIELD, 0, nil, e)
		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
		g = tg:FilterSelect(tp, Card.IsLocation, ct, ct, nil, LOCATION_MZONE)
		if ct < 3 then
			tg:Sub(g)
			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
			local g2 = tg:Select(tp, 3 - ct, 3 - ct, nil)
			g:Merge(g2)
		end
		Duel.SetTargetCard(g)
	else
		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
		g = Duel.SelectTarget(tp, s.desfilter, tp, LOCATION_ONFIELD, 0, 3, 3, nil)
	end
	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, 3, 0, 0)
	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
end
function s.spop(e, tp, eg, ep, ev, re, r, rp)
	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS):Filter(Card.IsRelateToEffect, nil, e)
	if Duel.Destroy(g, REASON_EFFECT) ~= 0 then
		local c = e:GetHandler()
		if not c:IsRelateToEffect(e) then
			return
		end
		Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP)
	end
end
function s.thfilter(c)
	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsAbleToHand()
end
function s.tdtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
	if chkc then
		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.thfilter(chkc) and chkc ~= e:GetHandler()
	end
	if chk == 0 then
		return Duel.IsExistingTarget(s.thfilter, tp, LOCATION_MZONE, 0, 1, e:GetHandler()) and Duel.IsExistingMatchingCard(Card.IsAbleToDeck, tp, 0, LOCATION_MZONE, 1, nil)
	end
	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
	local g = Duel.SelectTarget(tp, s.thfilter, tp, LOCATION_MZONE, 0, 1, 1, e:GetHandler())
	Duel.SetOperationInfo(0, CATEGORY_TOHAND, g, 1, 0, 0)
	Duel.SetOperationInfo(0, CATEGORY_TODECK, nil, 1, 1 - tp, LOCATION_MZONE)
end
function s.tdop(e, tp, eg, ep, ev, re, r, rp)
	local tc = Duel.GetFirstTarget()
	if tc:IsRelateToEffect(e) and Duel.SendtoHand(tc, nil, REASON_EFFECT) ~= 0 and tc:IsLocation(LOCATION_HAND) then
		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TODECK)
		local g = Duel.SelectMatchingCard(tp, Card.IsAbleToDeck, tp, 0, LOCATION_MZONE, 1, 1, nil)
		Duel.SendtoDeck(g, nil, SEQ_DECKBOTTOM, REASON_EFFECT)
	end
end

