name: 魔救の救砕
card_text: 1:自分フィールドの「アダマシア」モンスターを任意の数だけリリースし、その数+1枚だけフィールドのカードを対象として発動できる。
  そのカードを破壊する。
external_ids: local SETCARD_ID_0 = 0x140 --魔救(アダマシア)
  
lua: local SETCARD_ID_0 = 0x140 --魔救(アダマシア)
  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:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.costfilter(c, tp)
  	return c:IsSetCard(SETCARD_ID_0) and (c:IsControler(tp) or c:IsFaceup())
  end
  function s.fselect(g, tp, exc)
  	local dg = g:Clone()
  	if exc then
  		dg:AddCard(exc)
  	end
  	if Duel.IsExistingTarget(nil, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, g:GetCount() + 1, dg) then
  		Duel.SetSelectedCard(g)
  		return Duel.CheckReleaseGroup(tp, nil, 0, nil)
  	else
  		return false
  	end
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	e:SetLabel(100, 0)
  	local exc = nil
  	if e:IsHasType(EFFECT_TYPE_ACTIVATE) then
  		exc = e:GetHandler()
  	end
  	local g = Duel.GetReleaseGroup(tp):Filter(s.costfilter, nil, tp)
  	if chk == 0 then
  		return g:CheckSubGroup(s.fselect, 1, g:GetCount(), tp, exc)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_RELEASE)
  	local rg = g:SelectSubGroup(tp, s.fselect, false, 1, g:GetCount(), tp, exc)
  	aux.UseExtraReleaseCount(rg, tp)
  	e:SetLabel(100, Duel.Release(rg, REASON_COST))
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	local exc = nil
  	if e:IsHasType(EFFECT_TYPE_ACTIVATE) then
  		exc = e:GetHandler()
  	end
  	local check, ct = e:GetLabel()
  	if chkc then
  		return chkc:IsOnField()
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(nil, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, 1, exc)
  	end
  	if check ~= 100 then
  		ct = 0
  	end
  	e:SetLabel(0, 0)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local g = Duel.SelectTarget(tp, nil, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, ct + 1, ct + 1, exc)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, g:GetCount(), 0, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local tg = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS):Filter(Card.IsRelateToEffect, nil, e)
  	if tg:GetCount() > 0 then
  		Duel.Destroy(tg, REASON_EFFECT)
  	end
  end
  
  
source_text: 魔救の救砕
  1:自分フィールドの「アダマシア」モンスターを任意の数だけリリースし、その数+1枚だけフィールドのカードを対象として発動できる。
  そのカードを破壊する。
target_text: -- 魔救の救砕
  local SETCARD_ID_0 = 0x140 --魔救(アダマシア)
  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:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.costfilter(c, tp)
  	return c:IsSetCard(SETCARD_ID_0) and (c:IsControler(tp) or c:IsFaceup())
  end
  function s.fselect(g, tp, exc)
  	local dg = g:Clone()
  	if exc then
  		dg:AddCard(exc)
  	end
  	if Duel.IsExistingTarget(nil, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, g:GetCount() + 1, dg) then
  		Duel.SetSelectedCard(g)
  		return Duel.CheckReleaseGroup(tp, nil, 0, nil)
  	else
  		return false
  	end
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	e:SetLabel(100, 0)
  	local exc = nil
  	if e:IsHasType(EFFECT_TYPE_ACTIVATE) then
  		exc = e:GetHandler()
  	end
  	local g = Duel.GetReleaseGroup(tp):Filter(s.costfilter, nil, tp)
  	if chk == 0 then
  		return g:CheckSubGroup(s.fselect, 1, g:GetCount(), tp, exc)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_RELEASE)
  	local rg = g:SelectSubGroup(tp, s.fselect, false, 1, g:GetCount(), tp, exc)
  	aux.UseExtraReleaseCount(rg, tp)
  	e:SetLabel(100, Duel.Release(rg, REASON_COST))
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	local exc = nil
  	if e:IsHasType(EFFECT_TYPE_ACTIVATE) then
  		exc = e:GetHandler()
  	end
  	local check, ct = e:GetLabel()
  	if chkc then
  		return chkc:IsOnField()
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(nil, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, 1, exc)
  	end
  	if check ~= 100 then
  		ct = 0
  	end
  	e:SetLabel(0, 0)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local g = Duel.SelectTarget(tp, nil, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, ct + 1, ct + 1, exc)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, g:GetCount(), 0, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local tg = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS):Filter(Card.IsRelateToEffect, nil, e)
  	if tg:GetCount() > 0 then
  		Duel.Destroy(tg, REASON_EFFECT)
  	end
  end
  
  