name: Mira
card_text: If this card is in your hand: You can reveal 3 cards with different names from your hand and/or Deck that match the names of 3 different cards in your opponent's GY, and if you do, Special Summon this card. When your opponent activates a card or effect (Quick Effect): You can send this card Summoned by its previous effect to the GY; send 1 card with the same name as that opponent's card from your Deck or Extra Deck to the GY, and if you do, negate the activation. You can only use each effect of "Mira Match" once per turn.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCountLimit(1, id)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_NEGATE)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetCode(EVENT_CHAINING)
  	e2:SetProperty(EFFECT_FLAG_DAMAGE_STEP + EFFECT_FLAG_DAMAGE_CAL)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetCondition(s.negcon)
  	e2:SetCost(s.negcost)
  	e2:SetTarget(s.negtg)
  	e2:SetOperation(s.negop)
  	c:RegisterEffect(e2)
  end
  function s.cfilter(c, tp)
  	return Duel.IsExistingMatchingCard(Card.IsCode, tp, 0, LOCATION_GRAVE, 1, nil, c:GetCode()) and not c:IsPublic()
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local g = Duel.GetMatchingGroup(s.cfilter, tp, LOCATION_DECK + LOCATION_HAND, 0, nil, tp)
  	if chk == 0 then
  		return g:CheckSubGroup(aux.dncheck, 3, 3) and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and e:GetHandler():IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local g = Duel.GetMatchingGroup(s.cfilter, tp, LOCATION_DECK + LOCATION_HAND, 0, nil, tp)
  	if g:CheckSubGroup(aux.dncheck, 3, 3) then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CONFIRM)
  		local sg = g:SelectSubGroup(tp, aux.dncheck, false, 3, 3, nil)
  		Duel.ConfirmCards(1 - tp, sg)
  		Duel.ShuffleHand(tp)
  		Duel.ShuffleDeck(tp)
  		if not c:IsRelateToEffect(e) then
  			return
  		end
  		Duel.SpecialSummon(c, SUMMON_VALUE_SELF, tp, tp, false, false, POS_FACEUP)
  	end
  end
  function s.negcon(e, tp, eg, ep, ev, re, r, rp)
  	return not e:GetHandler():IsStatus(STATUS_BATTLE_DESTROYED) and ep ~= tp and Duel.IsChainNegatable(ev)
  end
  function s.negcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():GetSummonType() == SUMMON_TYPE_SPECIAL + SUMMON_VALUE_SELF and e:GetHandler():IsAbleToGraveAsCost()
  	end
  	Duel.SendtoGrave(e:GetHandler(), REASON_COST)
  end
  function s.filter(c, re)
  	return c:IsCode(re:GetHandler():GetCode()) and c:IsAbleToGrave()
  end
  function s.negtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_DECK + LOCATION_EXTRA, 0, 1, nil, re)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_NEGATE, eg, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, nil, 1, tp, LOCATION_DECK + LOCATION_EXTRA)
  end
  function s.negop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_DECK + LOCATION_EXTRA, 0, 1, 1, nil, re)
  	if g:GetCount() > 0 and Duel.SendtoGrave(g, REASON_EFFECT) ~= 0 and g:GetFirst():IsLocation(LOCATION_GRAVE) then
  		Duel.NegateActivation(ev)
  	end
  end
  
  
source_text: Mira
  If this card is in your hand: You can reveal 3 cards with different names from your hand and/or Deck that match the names of 3 different cards in your opponent's GY, and if you do, Special Summon this card. When your opponent activates a card or effect (Quick Effect): You can send this card Summoned by its previous effect to the GY; send 1 card with the same name as that opponent's card from your Deck or Extra Deck to the GY, and if you do, negate the activation. You can only use each effect of "Mira Match" once per turn.
target_text: -- Mira
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCountLimit(1, id)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_NEGATE)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetCode(EVENT_CHAINING)
  	e2:SetProperty(EFFECT_FLAG_DAMAGE_STEP + EFFECT_FLAG_DAMAGE_CAL)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetCondition(s.negcon)
  	e2:SetCost(s.negcost)
  	e2:SetTarget(s.negtg)
  	e2:SetOperation(s.negop)
  	c:RegisterEffect(e2)
  end
  function s.cfilter(c, tp)
  	return Duel.IsExistingMatchingCard(Card.IsCode, tp, 0, LOCATION_GRAVE, 1, nil, c:GetCode()) and not c:IsPublic()
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local g = Duel.GetMatchingGroup(s.cfilter, tp, LOCATION_DECK + LOCATION_HAND, 0, nil, tp)
  	if chk == 0 then
  		return g:CheckSubGroup(aux.dncheck, 3, 3) and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and e:GetHandler():IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local g = Duel.GetMatchingGroup(s.cfilter, tp, LOCATION_DECK + LOCATION_HAND, 0, nil, tp)
  	if g:CheckSubGroup(aux.dncheck, 3, 3) then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CONFIRM)
  		local sg = g:SelectSubGroup(tp, aux.dncheck, false, 3, 3, nil)
  		Duel.ConfirmCards(1 - tp, sg)
  		Duel.ShuffleHand(tp)
  		Duel.ShuffleDeck(tp)
  		if not c:IsRelateToEffect(e) then
  			return
  		end
  		Duel.SpecialSummon(c, SUMMON_VALUE_SELF, tp, tp, false, false, POS_FACEUP)
  	end
  end
  function s.negcon(e, tp, eg, ep, ev, re, r, rp)
  	return not e:GetHandler():IsStatus(STATUS_BATTLE_DESTROYED) and ep ~= tp and Duel.IsChainNegatable(ev)
  end
  function s.negcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():GetSummonType() == SUMMON_TYPE_SPECIAL + SUMMON_VALUE_SELF and e:GetHandler():IsAbleToGraveAsCost()
  	end
  	Duel.SendtoGrave(e:GetHandler(), REASON_COST)
  end
  function s.filter(c, re)
  	return c:IsCode(re:GetHandler():GetCode()) and c:IsAbleToGrave()
  end
  function s.negtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_DECK + LOCATION_EXTRA, 0, 1, nil, re)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_NEGATE, eg, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, nil, 1, tp, LOCATION_DECK + LOCATION_EXTRA)
  end
  function s.negop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_DECK + LOCATION_EXTRA, 0, 1, 1, nil, re)
  	if g:GetCount() > 0 and Duel.SendtoGrave(g, REASON_EFFECT) ~= 0 and g:GetFirst():IsLocation(LOCATION_GRAVE) then
  		Duel.NegateActivation(ev)
  	end
  end
  
  