彼岸の沈溺
1:自分フィールドの表側表示の「彼岸」モンスター2体を墓地へ送り、フィールドのカードを3枚まで対象として発動できる。
そのカードを破壊する。
local SETCARD_ID_0 = 0xb1 --彼岸

local SETCARD_ID_0 = 0xb1 --彼岸
local s, id, o = GetID()
function s.initial_effect(c)
	--Activate
	local e1 = Effect.CreateEffect(c)
	e1:SetCategory(CATEGORY_DESTROY)
	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
	e1:SetType(EFFECT_TYPE_ACTIVATE)
	e1:SetCode(EVENT_FREE_CHAIN)
	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.filter(c)
	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsAbleToGraveAsCost()
end
function s.costfilter(c, rg, dg)
	local a = 0
	if dg:IsContains(c) then
		a = 1
	end
	if c:GetEquipCount() == 0 then
		return rg:IsExists(s.costfilter2, 1, c, a, dg)
	end
	local eg = c:GetEquipGroup()
	local tc = eg:GetFirst()
	while tc do
		if dg:IsContains(tc) then
			a = a + 1
		end
		tc = eg:GetNext()
	end
	return rg:IsExists(s.costfilter2, 1, c, a, dg)
end
function s.costfilter2(c, a, dg)
	if dg:IsContains(c) then
		a = a + 1
	end
	if c:GetEquipCount() == 0 then
		return dg:GetCount() - a >= 1
	end
	local eg = c:GetEquipGroup()
	local tc = eg:GetFirst()
	while tc do
		if dg:IsContains(tc) then
			a = a + 1
		end
		tc = eg:GetNext()
	end
	return dg:GetCount() - a >= 1
end
function s.tgfilter(c, e)
	return c:IsCanBeEffectTarget(e)
end
function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
	e:SetLabel(1)
	return true
end
function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
	if chkc then
		return chkc:IsOnField()
	end
	if chk == 0 then
		if e:GetLabel() == 1 then
			e:SetLabel(0)
			local rg = Duel.GetMatchingGroup(s.filter, tp, LOCATION_MZONE, 0, nil)
			local dg = Duel.GetMatchingGroup(s.tgfilter, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, e:GetHandler(), e)
			return rg:IsExists(s.costfilter, 1, nil, rg, dg)
		else
			return Duel.IsExistingTarget(aux.TRUE, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, 1, e:GetHandler())
		end
	end
	if e:GetLabel() == 1 then
		e:SetLabel(0)
		local rg = Duel.GetMatchingGroup(s.filter, tp, LOCATION_MZONE, 0, nil)
		local dg = Duel.GetMatchingGroup(s.tgfilter, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, e:GetHandler(), e)
		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
		local sg1 = rg:FilterSelect(tp, s.costfilter, 1, 1, nil, rg, dg)
		local sc = sg1:GetFirst()
		local a = 0
		if dg:IsContains(sc) then
			a = 1
		end
		if sc:GetEquipCount() > 0 then
			local eqg = sc:GetEquipGroup()
			local tc = eqg:GetFirst()
			while tc do
				if dg:IsContains(tc) then
					a = a + 1
				end
				tc = eqg:GetNext()
			end
		end
		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
		local sg2 = rg:FilterSelect(tp, s.costfilter2, 1, 1, sc, a, dg)
		sg1:Merge(sg2)
		Duel.SendtoGrave(sg1, REASON_COST)
	end
	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
	local g = Duel.SelectTarget(tp, aux.TRUE, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, 1, 3, e:GetHandler())
	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, g:GetCount(), 0, 0)
end
function s.activate(e, tp, eg, ep, ev, re, r, rp)
	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS)
	local sg = g:Filter(Card.IsRelateToEffect, nil, e)
	Duel.Destroy(sg, REASON_EFFECT)
end


彼岸の沈溺
1:自分フィールドの表側表示の「彼岸」モンスター2体を墓地へ送り、フィールドのカードを3枚まで対象として発動できる。
そのカードを破壊する。
-- 彼岸の沈溺
local SETCARD_ID_0 = 0xb1 --彼岸
local s, id, o = GetID()
function s.initial_effect(c)
	--Activate
	local e1 = Effect.CreateEffect(c)
	e1:SetCategory(CATEGORY_DESTROY)
	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
	e1:SetType(EFFECT_TYPE_ACTIVATE)
	e1:SetCode(EVENT_FREE_CHAIN)
	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.filter(c)
	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsAbleToGraveAsCost()
end
function s.costfilter(c, rg, dg)
	local a = 0
	if dg:IsContains(c) then
		a = 1
	end
	if c:GetEquipCount() == 0 then
		return rg:IsExists(s.costfilter2, 1, c, a, dg)
	end
	local eg = c:GetEquipGroup()
	local tc = eg:GetFirst()
	while tc do
		if dg:IsContains(tc) then
			a = a + 1
		end
		tc = eg:GetNext()
	end
	return rg:IsExists(s.costfilter2, 1, c, a, dg)
end
function s.costfilter2(c, a, dg)
	if dg:IsContains(c) then
		a = a + 1
	end
	if c:GetEquipCount() == 0 then
		return dg:GetCount() - a >= 1
	end
	local eg = c:GetEquipGroup()
	local tc = eg:GetFirst()
	while tc do
		if dg:IsContains(tc) then
			a = a + 1
		end
		tc = eg:GetNext()
	end
	return dg:GetCount() - a >= 1
end
function s.tgfilter(c, e)
	return c:IsCanBeEffectTarget(e)
end
function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
	e:SetLabel(1)
	return true
end
function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
	if chkc then
		return chkc:IsOnField()
	end
	if chk == 0 then
		if e:GetLabel() == 1 then
			e:SetLabel(0)
			local rg = Duel.GetMatchingGroup(s.filter, tp, LOCATION_MZONE, 0, nil)
			local dg = Duel.GetMatchingGroup(s.tgfilter, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, e:GetHandler(), e)
			return rg:IsExists(s.costfilter, 1, nil, rg, dg)
		else
			return Duel.IsExistingTarget(aux.TRUE, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, 1, e:GetHandler())
		end
	end
	if e:GetLabel() == 1 then
		e:SetLabel(0)
		local rg = Duel.GetMatchingGroup(s.filter, tp, LOCATION_MZONE, 0, nil)
		local dg = Duel.GetMatchingGroup(s.tgfilter, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, e:GetHandler(), e)
		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
		local sg1 = rg:FilterSelect(tp, s.costfilter, 1, 1, nil, rg, dg)
		local sc = sg1:GetFirst()
		local a = 0
		if dg:IsContains(sc) then
			a = 1
		end
		if sc:GetEquipCount() > 0 then
			local eqg = sc:GetEquipGroup()
			local tc = eqg:GetFirst()
			while tc do
				if dg:IsContains(tc) then
					a = a + 1
				end
				tc = eqg:GetNext()
			end
		end
		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
		local sg2 = rg:FilterSelect(tp, s.costfilter2, 1, 1, sc, a, dg)
		sg1:Merge(sg2)
		Duel.SendtoGrave(sg1, REASON_COST)
	end
	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
	local g = Duel.SelectTarget(tp, aux.TRUE, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, 1, 3, e:GetHandler())
	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, g:GetCount(), 0, 0)
end
function s.activate(e, tp, eg, ep, ev, re, r, rp)
	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS)
	local sg = g:Filter(Card.IsRelateToEffect, nil, e)
	Duel.Destroy(sg, REASON_EFFECT)
end

