name: 創星の因子
card_text: 1:このカード以外の自分フィールドの「テラナイト」カードの数だけ、フィールドの魔法・罠カードを選んで破壊する。
external_ids: local SETCARD_ID_0 = 0x9c --テラナイト
  
lua: local SETCARD_ID_0 = 0x9c --テラナイト
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_DESTROY)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(0, TIMING_END_PHASE + TIMING_EQUIP)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.filter(c)
  	return c:IsType(TYPE_SPELL + TYPE_TRAP)
  end
  function s.cfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsFaceup()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	local ct = Duel.GetMatchingGroupCount(s.cfilter, tp, LOCATION_ONFIELD, 0, c)
  	if chk == 0 then
  		return ct > 0 and Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, ct, c)
  	end
  	local g = Duel.GetMatchingGroup(s.filter, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, c)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, ct, 0, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local ct = Duel.GetMatchingGroupCount(s.cfilter, tp, LOCATION_ONFIELD, 0, c)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, ct, ct, c)
  	Duel.Destroy(g, REASON_EFFECT)
  end
  
  
source_text: 創星の因子
  1:このカード以外の自分フィールドの「テラナイト」カードの数だけ、フィールドの魔法・罠カードを選んで破壊する。
target_text: -- 創星の因子
  local SETCARD_ID_0 = 0x9c --テラナイト
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_DESTROY)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(0, TIMING_END_PHASE + TIMING_EQUIP)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.filter(c)
  	return c:IsType(TYPE_SPELL + TYPE_TRAP)
  end
  function s.cfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsFaceup()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	local ct = Duel.GetMatchingGroupCount(s.cfilter, tp, LOCATION_ONFIELD, 0, c)
  	if chk == 0 then
  		return ct > 0 and Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, ct, c)
  	end
  	local g = Duel.GetMatchingGroup(s.filter, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, c)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, ct, 0, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local ct = Duel.GetMatchingGroupCount(s.cfilter, tp, LOCATION_ONFIELD, 0, c)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, ct, ct, c)
  	Duel.Destroy(g, REASON_EFFECT)
  end
  
  