name: Prank-Kids
card_text: 2 "Prank-Kids" monsters
  If this card is Link Summoned: You can add 1 "Prank-Kids" Spell/Trap from your Deck to your hand. You can Tribute this card, then target 2 "Prank-Kids" cards with different names in your GY, except Link Monsters; add them to your hand. You can only use each effect of "Prank-Kids Dodo-Doodle-Doo" once per turn.
external_ids: local CARD_ID_0 = 25725326 --Prank-Kids Meow-Meow-Mu
  local SETCARD_ID_0 = 0x120 --Prank-Kids
  
lua: local CARD_ID_0 = 25725326 --Prank-Kids Meow-Meow-Mu
  local SETCARD_ID_0 = 0x120 --Prank-Kids
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--link summon
  	aux.AddLinkProcedure(c, aux.FilterBoolFunction(Card.IsLinkSetCard, SETCARD_ID_0), 2)
  	c:EnableReviveLimit()
  	--search
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.thcon)
  	e1:SetTarget(s.thtg)
  	e1:SetOperation(s.thop)
  	c:RegisterEffect(e1)
  	--to hand
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_TOHAND)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetCost(s.thcost2)
  	e2:SetTarget(s.thtg2)
  	e2:SetOperation(s.thop2)
  	c:RegisterEffect(e2)
  end
  function s.thcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_LINK)
  end
  function s.thfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_SPELL + TYPE_TRAP) and c:IsAbleToHand()
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	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_ATOHAND)
  	local g = Duel.SelectMatchingCard(tp, s.thfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, g)
  	end
  end
  function s.excostfilter(c, tp)
  	return (c:IsFaceup() or c:IsLocation(LOCATION_GRAVE)) and c:IsAbleToRemoveAsCost() and c:IsHasEffect(CARD_ID_0, tp)
  end
  function s.costfilter(c, tp, g)
  	local tg = g:Clone()
  	tg:RemoveCard(c)
  	return tg:GetClassCount(Card.GetCode) >= 2
  end
  function s.thcost2(e, tp, eg, ep, ev, re, r, rp, chk)
  	e:SetLabel(0)
  	local g = Duel.GetMatchingGroup(s.excostfilter, tp, LOCATION_MZONE + LOCATION_GRAVE, 0, nil, tp)
  	local tg = Duel.GetMatchingGroup(s.thfilter2, tp, LOCATION_GRAVE, 0, nil, e)
  	if e:GetHandler():IsReleasable() then
  		g:AddCard(e:GetHandler())
  	end
  	if chk == 0 then
  		e:SetLabel(100)
  		return g:IsExists(s.costfilter, 1, nil, tp, tg)
  	end
  	local cg = g:Filter(s.costfilter, nil, tp, tg)
  	local tc
  	if #cg > 1 then
  		Duel.Hint(HINT_SELECTMSG, tp, aux.Stringid(CARD_ID_0, 0))
  		tc = cg:Select(tp, 1, 1, nil):GetFirst()
  	else
  		tc = cg:GetFirst()
  	end
  	local te = tc:IsHasEffect(CARD_ID_0, tp)
  	if te then
  		te:UseCountLimit(tp)
  		Duel.Remove(tc, POS_FACEUP, REASON_COST + REASON_REPLACE)
  	else
  		Duel.Release(tc, REASON_COST)
  	end
  end
  function s.thfilter2(c, e)
  	return c:IsSetCard(SETCARD_ID_0) and not c:IsType(TYPE_LINK) and c:IsCanBeEffectTarget(e) and c:IsAbleToHand()
  end
  function s.thtg2(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return false
  	end
  	if chk == 0 then
  		return e:GetLabel() == 100
  	end
  	e:SetLabel(0)
  	local g = Duel.GetMatchingGroup(s.thfilter2, tp, LOCATION_GRAVE, 0, nil, e)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g1 = g:SelectSubGroup(tp, aux.dncheck, false, 2, 2)
  	Duel.SetTargetCard(g1)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, g1, 2, 0, 0)
  end
  function s.thop2(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS):Filter(Card.IsRelateToEffect, nil, e)
  	if g:GetCount() > 0 then
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  	end
  end
  
  
source_text: Prank-Kids
  2 "Prank-Kids" monsters
  If this card is Link Summoned: You can add 1 "Prank-Kids" Spell/Trap from your Deck to your hand. You can Tribute this card, then target 2 "Prank-Kids" cards with different names in your GY, except Link Monsters; add them to your hand. You can only use each effect of "Prank-Kids Dodo-Doodle-Doo" once per turn.
target_text: -- Prank-Kids
  local CARD_ID_0 = 25725326 --Prank-Kids Meow-Meow-Mu
  local SETCARD_ID_0 = 0x120 --Prank-Kids
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--link summon
  	aux.AddLinkProcedure(c, aux.FilterBoolFunction(Card.IsLinkSetCard, SETCARD_ID_0), 2)
  	c:EnableReviveLimit()
  	--search
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.thcon)
  	e1:SetTarget(s.thtg)
  	e1:SetOperation(s.thop)
  	c:RegisterEffect(e1)
  	--to hand
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_TOHAND)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetCost(s.thcost2)
  	e2:SetTarget(s.thtg2)
  	e2:SetOperation(s.thop2)
  	c:RegisterEffect(e2)
  end
  function s.thcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_LINK)
  end
  function s.thfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_SPELL + TYPE_TRAP) and c:IsAbleToHand()
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	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_ATOHAND)
  	local g = Duel.SelectMatchingCard(tp, s.thfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, g)
  	end
  end
  function s.excostfilter(c, tp)
  	return (c:IsFaceup() or c:IsLocation(LOCATION_GRAVE)) and c:IsAbleToRemoveAsCost() and c:IsHasEffect(CARD_ID_0, tp)
  end
  function s.costfilter(c, tp, g)
  	local tg = g:Clone()
  	tg:RemoveCard(c)
  	return tg:GetClassCount(Card.GetCode) >= 2
  end
  function s.thcost2(e, tp, eg, ep, ev, re, r, rp, chk)
  	e:SetLabel(0)
  	local g = Duel.GetMatchingGroup(s.excostfilter, tp, LOCATION_MZONE + LOCATION_GRAVE, 0, nil, tp)
  	local tg = Duel.GetMatchingGroup(s.thfilter2, tp, LOCATION_GRAVE, 0, nil, e)
  	if e:GetHandler():IsReleasable() then
  		g:AddCard(e:GetHandler())
  	end
  	if chk == 0 then
  		e:SetLabel(100)
  		return g:IsExists(s.costfilter, 1, nil, tp, tg)
  	end
  	local cg = g:Filter(s.costfilter, nil, tp, tg)
  	local tc
  	if #cg > 1 then
  		Duel.Hint(HINT_SELECTMSG, tp, aux.Stringid(CARD_ID_0, 0))
  		tc = cg:Select(tp, 1, 1, nil):GetFirst()
  	else
  		tc = cg:GetFirst()
  	end
  	local te = tc:IsHasEffect(CARD_ID_0, tp)
  	if te then
  		te:UseCountLimit(tp)
  		Duel.Remove(tc, POS_FACEUP, REASON_COST + REASON_REPLACE)
  	else
  		Duel.Release(tc, REASON_COST)
  	end
  end
  function s.thfilter2(c, e)
  	return c:IsSetCard(SETCARD_ID_0) and not c:IsType(TYPE_LINK) and c:IsCanBeEffectTarget(e) and c:IsAbleToHand()
  end
  function s.thtg2(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return false
  	end
  	if chk == 0 then
  		return e:GetLabel() == 100
  	end
  	e:SetLabel(0)
  	local g = Duel.GetMatchingGroup(s.thfilter2, tp, LOCATION_GRAVE, 0, nil, e)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g1 = g:SelectSubGroup(tp, aux.dncheck, false, 2, 2)
  	Duel.SetTargetCard(g1)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, g1, 2, 0, 0)
  end
  function s.thop2(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS):Filter(Card.IsRelateToEffect, nil, e)
  	if g:GetCount() > 0 then
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  	end
  end
  
  