name: Focused
card_text: Add 1 "Gishki" monster from your Deck to your hand. During the End Phase, if you control a WATER Ritual Monster: You can banish this card from your GY; Set 1 "Aquamirror" Spell/Trap directly from your Deck or GY, except "Focused Aquamirror". You can only use this effect of "Focused Aquamirror" once per turn.
external_ids: local SETCARD_ID_0 = 0x18e --Aquamirror
  local SETCARD_ID_1 = 0x3a --Gishki
  
lua: local SETCARD_ID_0 = 0x18e --Aquamirror
  local SETCARD_ID_1 = 0x3a --Gishki
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	--set
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_PHASE + PHASE_END)
  	e2:SetRange(LOCATION_GRAVE)
  	e2:SetCountLimit(1, id)
  	e2:SetCondition(s.stcon)
  	e2:SetCost(aux.bfgcost)
  	e2:SetTarget(s.sttg)
  	e2:SetOperation(s.stop)
  	c:RegisterEffect(e2)
  end
  function s.filter(c)
  	return c:IsSetCard(SETCARD_ID_1) and c:IsType(TYPE_MONSTER) and c:IsAbleToHand()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, g)
  	end
  end
  function s.cfilter(c)
  	return c:IsAttribute(ATTRIBUTE_WATER) and c:IsType(TYPE_RITUAL) and c:IsFaceup()
  end
  function s.stcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil)
  end
  function s.stfilter(c)
  	return c:IsSetCard(SETCARD_ID_1) and not c:IsCode(id) and c:IsType(TYPE_SPELL + TYPE_TRAP) and c:IsSSetable()
  end
  function s.sttg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.stfilter, tp, LOCATION_DECK + LOCATION_GRAVE, 0, 1, nil)
  	end
  end
  function s.stop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SET)
  	local g = Duel.SelectMatchingCard(tp, aux.NecroValleyFilter(s.stfilter), tp, LOCATION_DECK + LOCATION_GRAVE, 0, 1, 1, nil)
  	local tc = g:GetFirst()
  	if tc then
  		Duel.SSet(tp, tc)
  	end
  end
  
  
source_text: Focused
  Add 1 "Gishki" monster from your Deck to your hand. During the End Phase, if you control a WATER Ritual Monster: You can banish this card from your GY; Set 1 "Aquamirror" Spell/Trap directly from your Deck or GY, except "Focused Aquamirror". You can only use this effect of "Focused Aquamirror" once per turn.
target_text: -- Focused
  local SETCARD_ID_0 = 0x18e --Aquamirror
  local SETCARD_ID_1 = 0x3a --Gishki
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	--set
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_PHASE + PHASE_END)
  	e2:SetRange(LOCATION_GRAVE)
  	e2:SetCountLimit(1, id)
  	e2:SetCondition(s.stcon)
  	e2:SetCost(aux.bfgcost)
  	e2:SetTarget(s.sttg)
  	e2:SetOperation(s.stop)
  	c:RegisterEffect(e2)
  end
  function s.filter(c)
  	return c:IsSetCard(SETCARD_ID_1) and c:IsType(TYPE_MONSTER) and c:IsAbleToHand()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, g)
  	end
  end
  function s.cfilter(c)
  	return c:IsAttribute(ATTRIBUTE_WATER) and c:IsType(TYPE_RITUAL) and c:IsFaceup()
  end
  function s.stcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil)
  end
  function s.stfilter(c)
  	return c:IsSetCard(SETCARD_ID_1) and not c:IsCode(id) and c:IsType(TYPE_SPELL + TYPE_TRAP) and c:IsSSetable()
  end
  function s.sttg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.stfilter, tp, LOCATION_DECK + LOCATION_GRAVE, 0, 1, nil)
  	end
  end
  function s.stop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SET)
  	local g = Duel.SelectMatchingCard(tp, aux.NecroValleyFilter(s.stfilter), tp, LOCATION_DECK + LOCATION_GRAVE, 0, 1, 1, nil)
  	local tc = g:GetFirst()
  	if tc then
  		Duel.SSet(tp, tc)
  	end
  end
  
  