name: Prank-Kids
card_text: You can discard 1 "Prank-Kids" card; Special Summon 1 "Prank-Kids Token" (Pyro/FIRE/Level 1/ATK 0/DEF 0), but it cannot be Tributed. During your End Phase: You can target 3 "Prank-Kids" cards in your GY, except "Prank-Kids Pranks"; shuffle all 3 into the Deck, then draw 1 card. You can only use each effect of "Prank-Kids Pranks" once per turn.
external_ids: local CARD_ID_0 = 43664495 --Prank-Kids Token
  local SETCARD_ID_0 = 0x120 --Prank-Kids
  
lua: local CARD_ID_0 = 43664495 --Prank-Kids Token
  local SETCARD_ID_0 = 0x120 --Prank-Kids
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e1)
  	--token
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_TOKEN)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetCountLimit(1, id)
  	e2:SetCost(s.tkcost)
  	e2:SetTarget(s.tktg)
  	e2:SetOperation(s.tkop)
  	c:RegisterEffect(e2)
  	--shuffle & draw
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_TODECK + CATEGORY_DRAW)
  	e3:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_PHASE + PHASE_END)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetCountLimit(1, id + 1)
  	e3:SetCondition(s.drcon)
  	e3:SetTarget(s.drtg)
  	e3:SetOperation(s.drop)
  	c:RegisterEffect(e3)
  end
  function s.cfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsDiscardable()
  end
  function s.tkcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_HAND, 0, 1, nil)
  	end
  	Duel.DiscardHand(tp, s.cfilter, 1, 1, REASON_COST + REASON_DISCARD)
  end
  function s.tktg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsPlayerCanSpecialSummonMonster(tp, id + 1, SETCARD_ID_0, TYPES_TOKEN_MONSTER, 0, 0, 1, RACE_PYRO, ATTRIBUTE_FIRE, POS_FACEUP)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOKEN, nil, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, 0)
  end
  function s.tkop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 or not Duel.IsPlayerCanSpecialSummonMonster(tp, id + 1, SETCARD_ID_0, TYPES_TOKEN_MONSTER, 0, 0, 1, RACE_PYRO, ATTRIBUTE_FIRE, POS_FACEUP) then
  		return
  	end
  	local token = Duel.CreateToken(tp, id + 1)
  	Duel.SpecialSummonStep(token, 0, tp, tp, false, false, POS_FACEUP)
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_UNRELEASABLE_SUM)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e1:SetValue(1)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  	token:RegisterEffect(e1, true)
  	local e2 = e1:Clone()
  	e2:SetCode(EFFECT_UNRELEASABLE_NONSUM)
  	token:RegisterEffect(e2, true)
  	Duel.SpecialSummonComplete()
  end
  function s.drcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetTurnPlayer() == tp
  end
  function s.tdfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and not c:IsCode(id) and c:IsAbleToDeck()
  end
  function s.drtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.tdfilter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsPlayerCanDraw(tp, 1) and Duel.IsExistingTarget(s.tdfilter, tp, LOCATION_GRAVE, 0, 3, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TODECK)
  	local g = Duel.SelectTarget(tp, s.tdfilter, tp, LOCATION_GRAVE, 0, 3, 3, nil)
  	Duel.SetOperationInfo(0, CATEGORY_TODECK, g, g:GetCount(), 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_DRAW, nil, 0, tp, 1)
  end
  function s.drop(e, tp, eg, ep, ev, re, r, rp)
  	local tg = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS):Filter(Card.IsRelateToEffect, nil, e)
  	if not tg or tg:FilterCount(Card.IsRelateToEffect, nil, e) ~= 3 then
  		return
  	end
  	Duel.SendtoDeck(tg, nil, SEQ_DECKSHUFFLE, REASON_EFFECT)
  	local g = Duel.GetOperatedGroup()
  	if g:IsExists(Card.IsLocation, 1, nil, LOCATION_DECK) then
  		Duel.ShuffleDeck(tp)
  	end
  	local ct = g:FilterCount(Card.IsLocation, nil, LOCATION_DECK + LOCATION_EXTRA)
  	if ct > 0 then
  		Duel.BreakEffect()
  		Duel.Draw(tp, 1, REASON_EFFECT)
  	end
  end
  
  
source_text: Prank-Kids
  You can discard 1 "Prank-Kids" card; Special Summon 1 "Prank-Kids Token" (Pyro/FIRE/Level 1/ATK 0/DEF 0), but it cannot be Tributed. During your End Phase: You can target 3 "Prank-Kids" cards in your GY, except "Prank-Kids Pranks"; shuffle all 3 into the Deck, then draw 1 card. You can only use each effect of "Prank-Kids Pranks" once per turn.
target_text: -- Prank-Kids
  local CARD_ID_0 = 43664495 --Prank-Kids Token
  local SETCARD_ID_0 = 0x120 --Prank-Kids
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e1)
  	--token
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_TOKEN)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetCountLimit(1, id)
  	e2:SetCost(s.tkcost)
  	e2:SetTarget(s.tktg)
  	e2:SetOperation(s.tkop)
  	c:RegisterEffect(e2)
  	--shuffle & draw
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_TODECK + CATEGORY_DRAW)
  	e3:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_PHASE + PHASE_END)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetCountLimit(1, id + 1)
  	e3:SetCondition(s.drcon)
  	e3:SetTarget(s.drtg)
  	e3:SetOperation(s.drop)
  	c:RegisterEffect(e3)
  end
  function s.cfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsDiscardable()
  end
  function s.tkcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_HAND, 0, 1, nil)
  	end
  	Duel.DiscardHand(tp, s.cfilter, 1, 1, REASON_COST + REASON_DISCARD)
  end
  function s.tktg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsPlayerCanSpecialSummonMonster(tp, id + 1, SETCARD_ID_0, TYPES_TOKEN_MONSTER, 0, 0, 1, RACE_PYRO, ATTRIBUTE_FIRE, POS_FACEUP)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOKEN, nil, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, 0)
  end
  function s.tkop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 or not Duel.IsPlayerCanSpecialSummonMonster(tp, id + 1, SETCARD_ID_0, TYPES_TOKEN_MONSTER, 0, 0, 1, RACE_PYRO, ATTRIBUTE_FIRE, POS_FACEUP) then
  		return
  	end
  	local token = Duel.CreateToken(tp, id + 1)
  	Duel.SpecialSummonStep(token, 0, tp, tp, false, false, POS_FACEUP)
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_UNRELEASABLE_SUM)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e1:SetValue(1)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  	token:RegisterEffect(e1, true)
  	local e2 = e1:Clone()
  	e2:SetCode(EFFECT_UNRELEASABLE_NONSUM)
  	token:RegisterEffect(e2, true)
  	Duel.SpecialSummonComplete()
  end
  function s.drcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetTurnPlayer() == tp
  end
  function s.tdfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and not c:IsCode(id) and c:IsAbleToDeck()
  end
  function s.drtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.tdfilter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsPlayerCanDraw(tp, 1) and Duel.IsExistingTarget(s.tdfilter, tp, LOCATION_GRAVE, 0, 3, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TODECK)
  	local g = Duel.SelectTarget(tp, s.tdfilter, tp, LOCATION_GRAVE, 0, 3, 3, nil)
  	Duel.SetOperationInfo(0, CATEGORY_TODECK, g, g:GetCount(), 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_DRAW, nil, 0, tp, 1)
  end
  function s.drop(e, tp, eg, ep, ev, re, r, rp)
  	local tg = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS):Filter(Card.IsRelateToEffect, nil, e)
  	if not tg or tg:FilterCount(Card.IsRelateToEffect, nil, e) ~= 3 then
  		return
  	end
  	Duel.SendtoDeck(tg, nil, SEQ_DECKSHUFFLE, REASON_EFFECT)
  	local g = Duel.GetOperatedGroup()
  	if g:IsExists(Card.IsLocation, 1, nil, LOCATION_DECK) then
  		Duel.ShuffleDeck(tp)
  	end
  	local ct = g:FilterCount(Card.IsLocation, nil, LOCATION_DECK + LOCATION_EXTRA)
  	if ct > 0 then
  		Duel.BreakEffect()
  		Duel.Draw(tp, 1, REASON_EFFECT)
  	end
  end
  
  