name: 魔界劇団のゲネプロ
card_text: 1:自分メインフェイズ1開始時に発動できる。
  デッキから「魔界劇団」カード1枚と「魔界台本」魔法カード1枚を手札に加える。
  このカードの発動後、ターン終了時まで自分は「魔界劇団」モンスターしかP召喚できない。
external_ids: local SETCARD_ID_0 = 0x10ec --魔界劇団
  local SETCARD_ID_1 = 0x20ec --魔界台本
  
lua: local SETCARD_ID_0 = 0x10ec --魔界劇団
  local SETCARD_ID_1 = 0x20ec --魔界台本
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SEARCH + CATEGORY_TOHAND)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetCurrentPhase() == PHASE_MAIN1 and not Duel.CheckPhaseActivity()
  end
  function s.filter1(c, tp)
  	return c:IsSetCard(SETCARD_ID_1) and c:IsAbleToHand() and Duel.IsExistingMatchingCard(s.filter2, tp, LOCATION_DECK, 0, 1, c)
  end
  function s.filter2(c)
  	return c:IsSetCard(SETCARD_ID_1) and c:IsType(TYPE_SPELL) and c:IsAbleToHand()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.filter1, tp, LOCATION_DECK, 0, 1, nil, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 2, tp, LOCATION_DECK)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local g1 = Duel.GetMatchingGroup(s.filter1, tp, LOCATION_DECK, 0, nil, tp)
  	if g1:GetCount() > 0 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  		local sg1 = g1:Select(tp, 1, 1, nil)
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  		local sg2 = Duel.SelectMatchingCard(tp, s.filter2, tp, LOCATION_DECK, 0, 1, 1, sg1:GetFirst())
  		sg1:Merge(sg2)
  		Duel.SendtoHand(sg1, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, sg1)
  	end
  	if not e:IsHasType(EFFECT_TYPE_ACTIVATE) then
  		return
  	end
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetTargetRange(1, 0)
  	e1:SetTarget(s.splimit)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.splimit(e, c, sump, sumtype, sumpos, targetp, se)
  	return not c:IsSetCard(SETCARD_ID_1) and sumtype & SUMMON_TYPE_PENDULUM == SUMMON_TYPE_PENDULUM
  end
  
  
source_text: 魔界劇団のゲネプロ
  1:自分メインフェイズ1開始時に発動できる。
  デッキから「魔界劇団」カード1枚と「魔界台本」魔法カード1枚を手札に加える。
  このカードの発動後、ターン終了時まで自分は「魔界劇団」モンスターしかP召喚できない。
target_text: -- 魔界劇団のゲネプロ
  local SETCARD_ID_0 = 0x10ec --魔界劇団
  local SETCARD_ID_1 = 0x20ec --魔界台本
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SEARCH + CATEGORY_TOHAND)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetCurrentPhase() == PHASE_MAIN1 and not Duel.CheckPhaseActivity()
  end
  function s.filter1(c, tp)
  	return c:IsSetCard(SETCARD_ID_1) and c:IsAbleToHand() and Duel.IsExistingMatchingCard(s.filter2, tp, LOCATION_DECK, 0, 1, c)
  end
  function s.filter2(c)
  	return c:IsSetCard(SETCARD_ID_1) and c:IsType(TYPE_SPELL) and c:IsAbleToHand()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.filter1, tp, LOCATION_DECK, 0, 1, nil, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 2, tp, LOCATION_DECK)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local g1 = Duel.GetMatchingGroup(s.filter1, tp, LOCATION_DECK, 0, nil, tp)
  	if g1:GetCount() > 0 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  		local sg1 = g1:Select(tp, 1, 1, nil)
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  		local sg2 = Duel.SelectMatchingCard(tp, s.filter2, tp, LOCATION_DECK, 0, 1, 1, sg1:GetFirst())
  		sg1:Merge(sg2)
  		Duel.SendtoHand(sg1, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, sg1)
  	end
  	if not e:IsHasType(EFFECT_TYPE_ACTIVATE) then
  		return
  	end
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetTargetRange(1, 0)
  	e1:SetTarget(s.splimit)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.splimit(e, c, sump, sumtype, sumpos, targetp, se)
  	return not c:IsSetCard(SETCARD_ID_1) and sumtype & SUMMON_TYPE_PENDULUM == SUMMON_TYPE_PENDULUM
  end
  
  