name: Avalon
card_text: Target 5 "Noble Knight" monsters in your Graveyard, including at least 1 "Artorigus" monster and at least 1 "Laundsallyn" monster; banish those targets, and if you do, destroy all cards on the field.
external_ids: local SETCARD_ID_0 = 0x107a --Noble
  
lua: local SETCARD_ID_0 = 0x107a --Noble
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_REMOVE + CATEGORY_DESTROY)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.filter(c, e)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) and c:IsAbleToRemove() and c:IsCanBeEffectTarget(e)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return false
  	end
  	local g = Duel.GetMatchingGroup(s.filter, tp, LOCATION_GRAVE, 0, nil, e)
  	if chk == 0 then
  		return g:GetCount() > 4
  			and g:IsExists(Card.IsSetCard, 1, nil, 0xa7)
  			and g:IsExists(Card.IsSetCard, 1, nil, 0xa8)
  			and Duel.IsExistingMatchingCard(aux.TRUE, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g1 = g:FilterSelect(tp, Card.IsSetCard, 1, 1, nil, 0xa7)
  	g:Sub(g1)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g2 = g:FilterSelect(tp, Card.IsSetCard, 1, 1, nil, 0xa8)
  	g:Sub(g2)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g3 = g:Select(tp, 3, 3, nil)
  	g1:Merge(g2)
  	g1:Merge(g3)
  	Duel.SetTargetCard(g1)
  	local dg = Duel.GetMatchingGroup(aux.TRUE, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, nil)
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, g1, 5, tp, LOCATION_GRAVE)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, dg, dg:GetCount(), 0, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local tg = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS)
  	local g = tg:Filter(Card.IsRelateToEffect, nil, e)
  	if g:GetCount() == 5 and Duel.Remove(g, POS_FACEUP, REASON_EFFECT) > 0 then
  		local dg = Duel.GetMatchingGroup(aux.TRUE, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, nil)
  		Duel.Destroy(dg, REASON_EFFECT)
  	end
  end
  
  
source_text: Avalon
  Target 5 "Noble Knight" monsters in your Graveyard, including at least 1 "Artorigus" monster and at least 1 "Laundsallyn" monster; banish those targets, and if you do, destroy all cards on the field.
target_text: -- Avalon
  local SETCARD_ID_0 = 0x107a --Noble
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_REMOVE + CATEGORY_DESTROY)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.filter(c, e)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) and c:IsAbleToRemove() and c:IsCanBeEffectTarget(e)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return false
  	end
  	local g = Duel.GetMatchingGroup(s.filter, tp, LOCATION_GRAVE, 0, nil, e)
  	if chk == 0 then
  		return g:GetCount() > 4
  			and g:IsExists(Card.IsSetCard, 1, nil, 0xa7)
  			and g:IsExists(Card.IsSetCard, 1, nil, 0xa8)
  			and Duel.IsExistingMatchingCard(aux.TRUE, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g1 = g:FilterSelect(tp, Card.IsSetCard, 1, 1, nil, 0xa7)
  	g:Sub(g1)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g2 = g:FilterSelect(tp, Card.IsSetCard, 1, 1, nil, 0xa8)
  	g:Sub(g2)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g3 = g:Select(tp, 3, 3, nil)
  	g1:Merge(g2)
  	g1:Merge(g3)
  	Duel.SetTargetCard(g1)
  	local dg = Duel.GetMatchingGroup(aux.TRUE, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, nil)
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, g1, 5, tp, LOCATION_GRAVE)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, dg, dg:GetCount(), 0, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local tg = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS)
  	local g = tg:Filter(Card.IsRelateToEffect, nil, e)
  	if g:GetCount() == 5 and Duel.Remove(g, POS_FACEUP, REASON_EFFECT) > 0 then
  		local dg = Duel.GetMatchingGroup(aux.TRUE, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, nil)
  		Duel.Destroy(dg, REASON_EFFECT)
  	end
  end
  
  