name: Performapal
card_text: While you control an "Odd-Eyes" monster, your opponent's monsters cannot target this card for attacks. While this card is in face-up Defense Position, your "Odd-Eyes" monsters cannot be destroyed by battle, also you take no battle damage from that battle. You can target 1 Level 1 monster in your GY; Special Summon it, but negate its effects, then, immediately after this effect resolves, Synchro Summon 1 monster using only this card and the Summoned monster. You can only use this effect of "Performapal Miss Director" once per turn.
external_ids: local SETCARD_ID_0 = 0x99 --Odd-Eyes
  
lua: local SETCARD_ID_0 = 0x99 --Odd-Eyes
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--can not be battle target
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCode(EFFECT_CANNOT_BE_BATTLE_TARGET)
  	e1:SetCondition(s.atcon)
  	e1:SetValue(aux.imval1)
  	c:RegisterEffect(e1)
  	--indes
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetTargetRange(LOCATION_MZONE, 0)
  	e2:SetTarget(aux.TargetBoolFunction(Card.IsSetCard, SETCARD_ID_0))
  	e2:SetCondition(s.indcon)
  	e2:SetValue(1)
  	c:RegisterEffect(e2)
  	--avoid battle damage
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD)
  	e3:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  	e3:SetCode(EFFECT_AVOID_BATTLE_DAMAGE)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetTargetRange(LOCATION_MZONE, 0)
  	e3:SetTarget(aux.TargetBoolFunction(Card.IsSetCard, SETCARD_ID_0))
  	e3:SetCondition(s.indcon)
  	e3:SetValue(1)
  	c:RegisterEffect(e3)
  	--special summon
  	local e4 = Effect.CreateEffect(c)
  	e4:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e4:SetType(EFFECT_TYPE_IGNITION)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e4:SetCountLimit(1, id)
  	e4:SetTarget(s.sctg)
  	e4:SetOperation(s.scop)
  	c:RegisterEffect(e4)
  end
  function s.cfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
  end
  function s.atcon(e)
  	return Duel.IsExistingMatchingCard(s.cfilter, e:GetHandlerPlayer(), LOCATION_MZONE, 0, 1, nil)
  end
  function s.indcon(e)
  	return e:GetHandler():IsDefensePos()
  end
  function s.scfilter1(c, e, tp, mc)
  	local mg = Group.FromCards(c, mc)
  	return c:IsLevel(1) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false) and Duel.IsExistingMatchingCard(s.scfilter2, tp, LOCATION_EXTRA, 0, 1, nil, mg)
  end
  function s.scfilter2(c, mg)
  	return c:IsSynchroSummonable(nil, mg)
  end
  function s.sctg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	local c = e:GetHandler()
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.scfilter1(chkc, e, tp, c)
  	end
  	if chk == 0 then
  		return Duel.IsPlayerCanSpecialSummonCount(tp, 2) and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingTarget(s.scfilter1, tp, LOCATION_GRAVE, 0, 1, nil, e, tp, c)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectTarget(tp, s.scfilter1, tp, LOCATION_GRAVE, 0, 1, 1, nil, e, tp, c)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, g, 2, tp, LOCATION_EXTRA)
  end
  function s.scop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if not tc:IsRelateToEffect(e) or not Duel.SpecialSummonStep(tc, 0, tp, tp, false, false, POS_FACEUP) then
  		return
  	end
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_DISABLE)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  	tc:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EFFECT_DISABLE_EFFECT)
  	e2:SetValue(RESET_TURN_SET)
  	tc:RegisterEffect(e2)
  	Duel.SpecialSummonComplete()
  	if not c:IsRelateToEffect(e) then
  		return
  	end
  	Duel.AdjustAll()
  	local mg = Group.FromCards(c, tc)
  	if mg:FilterCount(Card.IsLocation, nil, LOCATION_MZONE) < 2 then
  		return
  	end
  	local g = Duel.GetMatchingGroup(s.scfilter2, tp, LOCATION_EXTRA, 0, nil, mg)
  	if g:GetCount() > 0 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local sg = g:Select(tp, 1, 1, nil)
  		Duel.SynchroSummon(tp, sg:GetFirst(), nil, mg)
  	end
  end
  
  
source_text: Performapal
  While you control an "Odd-Eyes" monster, your opponent's monsters cannot target this card for attacks. While this card is in face-up Defense Position, your "Odd-Eyes" monsters cannot be destroyed by battle, also you take no battle damage from that battle. You can target 1 Level 1 monster in your GY; Special Summon it, but negate its effects, then, immediately after this effect resolves, Synchro Summon 1 monster using only this card and the Summoned monster. You can only use this effect of "Performapal Miss Director" once per turn.
target_text: -- Performapal
  local SETCARD_ID_0 = 0x99 --Odd-Eyes
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--can not be battle target
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCode(EFFECT_CANNOT_BE_BATTLE_TARGET)
  	e1:SetCondition(s.atcon)
  	e1:SetValue(aux.imval1)
  	c:RegisterEffect(e1)
  	--indes
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetTargetRange(LOCATION_MZONE, 0)
  	e2:SetTarget(aux.TargetBoolFunction(Card.IsSetCard, SETCARD_ID_0))
  	e2:SetCondition(s.indcon)
  	e2:SetValue(1)
  	c:RegisterEffect(e2)
  	--avoid battle damage
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD)
  	e3:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  	e3:SetCode(EFFECT_AVOID_BATTLE_DAMAGE)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetTargetRange(LOCATION_MZONE, 0)
  	e3:SetTarget(aux.TargetBoolFunction(Card.IsSetCard, SETCARD_ID_0))
  	e3:SetCondition(s.indcon)
  	e3:SetValue(1)
  	c:RegisterEffect(e3)
  	--special summon
  	local e4 = Effect.CreateEffect(c)
  	e4:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e4:SetType(EFFECT_TYPE_IGNITION)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e4:SetCountLimit(1, id)
  	e4:SetTarget(s.sctg)
  	e4:SetOperation(s.scop)
  	c:RegisterEffect(e4)
  end
  function s.cfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
  end
  function s.atcon(e)
  	return Duel.IsExistingMatchingCard(s.cfilter, e:GetHandlerPlayer(), LOCATION_MZONE, 0, 1, nil)
  end
  function s.indcon(e)
  	return e:GetHandler():IsDefensePos()
  end
  function s.scfilter1(c, e, tp, mc)
  	local mg = Group.FromCards(c, mc)
  	return c:IsLevel(1) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false) and Duel.IsExistingMatchingCard(s.scfilter2, tp, LOCATION_EXTRA, 0, 1, nil, mg)
  end
  function s.scfilter2(c, mg)
  	return c:IsSynchroSummonable(nil, mg)
  end
  function s.sctg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	local c = e:GetHandler()
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.scfilter1(chkc, e, tp, c)
  	end
  	if chk == 0 then
  		return Duel.IsPlayerCanSpecialSummonCount(tp, 2) and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingTarget(s.scfilter1, tp, LOCATION_GRAVE, 0, 1, nil, e, tp, c)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectTarget(tp, s.scfilter1, tp, LOCATION_GRAVE, 0, 1, 1, nil, e, tp, c)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, g, 2, tp, LOCATION_EXTRA)
  end
  function s.scop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if not tc:IsRelateToEffect(e) or not Duel.SpecialSummonStep(tc, 0, tp, tp, false, false, POS_FACEUP) then
  		return
  	end
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_DISABLE)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  	tc:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EFFECT_DISABLE_EFFECT)
  	e2:SetValue(RESET_TURN_SET)
  	tc:RegisterEffect(e2)
  	Duel.SpecialSummonComplete()
  	if not c:IsRelateToEffect(e) then
  		return
  	end
  	Duel.AdjustAll()
  	local mg = Group.FromCards(c, tc)
  	if mg:FilterCount(Card.IsLocation, nil, LOCATION_MZONE) < 2 then
  		return
  	end
  	local g = Duel.GetMatchingGroup(s.scfilter2, tp, LOCATION_EXTRA, 0, nil, mg)
  	if g:GetCount() > 0 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local sg = g:Select(tp, 1, 1, nil)
  		Duel.SynchroSummon(tp, sg:GetFirst(), nil, mg)
  	end
  end
  
  