name: Performapal
card_text: During either player's turn: You can return 1 Level 5 or higher "Performapal" monster you control to the hand; Special Summon this card from your hand. You can only use this effect of "Performapal Sky Pupil" once per turn. If this card battles an opponent's monster, that monster has its effects negated until the end of the Damage Step. Before damage calculation, if this card attacked an opponent's monster while you control another "Performapal" monster: You can destroy that opponent's monster.
external_ids: local SETCARD_ID_0 = 0x9f --Performapal
  
lua: local SETCARD_ID_0 = 0x9f --Performapal
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--spsummon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_QUICK_O)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetHintTiming(0, TIMING_END_PHASE)
  	e1:SetCountLimit(1, id)
  	e1:SetCost(s.spcost)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--negate
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_DISABLE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetTargetRange(0, LOCATION_MZONE)
  	e2:SetTarget(s.distg)
  	c:RegisterEffect(e2)
  	--destroy
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_DESTROY)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_BATTLE_CONFIRM)
  	e3:SetCondition(s.descon)
  	e3:SetTarget(s.destg)
  	e3:SetOperation(s.desop)
  	c:RegisterEffect(e3)
  end
  function s.spcfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsLevelAbove(5) and c:IsAbleToHandAsCost()
  end
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.spcfilter, tp, LOCATION_MZONE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_RTOHAND)
  	local g = Duel.SelectMatchingCard(tp, s.spcfilter, tp, LOCATION_MZONE, 0, 1, 1, nil)
  	Duel.SendtoHand(g, nil, REASON_COST)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > -1 and e:GetHandler():IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if not c:IsRelateToEffect(e) then
  		return
  	end
  	Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP)
  end
  function s.distg(e, c)
  	return c == e:GetHandler():GetBattleTarget()
  end
  function s.descfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(s.descfilter, tp, LOCATION_MZONE, 0, 1, e:GetHandler())
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local t = Duel.GetAttackTarget()
  	if chk == 0 then
  		return Duel.GetAttacker() == e:GetHandler() and t ~= nil
  	end
  	Duel.SetTargetCard(t)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, t, 1, 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local t = Duel.GetFirstTarget()
  	if t:IsRelateToBattle() then
  		Duel.Destroy(t, REASON_EFFECT)
  	end
  end
  
  
source_text: Performapal
  During either player's turn: You can return 1 Level 5 or higher "Performapal" monster you control to the hand; Special Summon this card from your hand. You can only use this effect of "Performapal Sky Pupil" once per turn. If this card battles an opponent's monster, that monster has its effects negated until the end of the Damage Step. Before damage calculation, if this card attacked an opponent's monster while you control another "Performapal" monster: You can destroy that opponent's monster.
target_text: -- Performapal
  local SETCARD_ID_0 = 0x9f --Performapal
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--spsummon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_QUICK_O)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetHintTiming(0, TIMING_END_PHASE)
  	e1:SetCountLimit(1, id)
  	e1:SetCost(s.spcost)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--negate
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_DISABLE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetTargetRange(0, LOCATION_MZONE)
  	e2:SetTarget(s.distg)
  	c:RegisterEffect(e2)
  	--destroy
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_DESTROY)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_BATTLE_CONFIRM)
  	e3:SetCondition(s.descon)
  	e3:SetTarget(s.destg)
  	e3:SetOperation(s.desop)
  	c:RegisterEffect(e3)
  end
  function s.spcfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsLevelAbove(5) and c:IsAbleToHandAsCost()
  end
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.spcfilter, tp, LOCATION_MZONE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_RTOHAND)
  	local g = Duel.SelectMatchingCard(tp, s.spcfilter, tp, LOCATION_MZONE, 0, 1, 1, nil)
  	Duel.SendtoHand(g, nil, REASON_COST)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > -1 and e:GetHandler():IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if not c:IsRelateToEffect(e) then
  		return
  	end
  	Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP)
  end
  function s.distg(e, c)
  	return c == e:GetHandler():GetBattleTarget()
  end
  function s.descfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(s.descfilter, tp, LOCATION_MZONE, 0, 1, e:GetHandler())
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local t = Duel.GetAttackTarget()
  	if chk == 0 then
  		return Duel.GetAttacker() == e:GetHandler() and t ~= nil
  	end
  	Duel.SetTargetCard(t)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, t, 1, 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local t = Duel.GetFirstTarget()
  	if t:IsRelateToBattle() then
  		Duel.Destroy(t, REASON_EFFECT)
  	end
  end
  
  