name: Minerva,
card_text: Each time a Counter Trap Card is activated, immediately after it resolves, this card gains 500 ATK, and if it does, and "The Sanctuary in the Sky" is on the field, add 1 Counter Trap with a different name from your GY to your hand.
external_ids: local CARD_ID_0 = 56433456 --The Sanctuary in the Sky
  
lua: local CARD_ID_0 = 56433456 --The Sanctuary in the Sky
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_0)
  	--atk
  	local e0 = Effect.CreateEffect(c)
  	e0:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e0:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e0:SetCode(EVENT_CHAINING)
  	e0:SetRange(LOCATION_MZONE)
  	e0:SetOperation(aux.chainreg)
  	c:RegisterEffect(e0)
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_ATKCHANGE + CATEGORY_TOHAND)
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e1:SetCode(EVENT_CHAIN_SOLVED)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCondition(s.atkcon)
  	e1:SetOperation(s.atkop)
  	c:RegisterEffect(e1)
  end
  function s.atkcon(e, tp, eg, ep, ev, re, r, rp)
  	return re:IsHasType(EFFECT_TYPE_ACTIVATE) and re:IsActiveType(TYPE_COUNTER) and e:GetHandler():GetFlagEffect(FLAG_ID_CHAINING) > 0
  end
  function s.thfilter(c, code)
  	return c:IsType(TYPE_COUNTER) and not c:IsCode(code) and c:IsAbleToHand()
  end
  function s.atkop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_UPDATE_ATTACK)
  	e1:SetValue(500)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE)
  	c:RegisterEffect(e1)
  	local rc = re:GetHandler()
  	local g = Duel.GetMatchingGroup(aux.NecroValleyFilter(s.thfilter), tp, LOCATION_GRAVE, 0, nil, rc:GetCode())
  	if Duel.IsEnvironment(CARD_ID_0) and g:GetCount() > 0 then
  		Duel.Hint(HINT_CARD, 0, id)
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  		local sg = g:Select(tp, 1, 1, nil)
  		Duel.SendtoHand(sg, nil, REASON_EFFECT)
  	end
  end
  
  
source_text: Minerva,
  Each time a Counter Trap Card is activated, immediately after it resolves, this card gains 500 ATK, and if it does, and "The Sanctuary in the Sky" is on the field, add 1 Counter Trap with a different name from your GY to your hand.
target_text: -- Minerva,
  local CARD_ID_0 = 56433456 --The Sanctuary in the Sky
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_0)
  	--atk
  	local e0 = Effect.CreateEffect(c)
  	e0:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e0:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e0:SetCode(EVENT_CHAINING)
  	e0:SetRange(LOCATION_MZONE)
  	e0:SetOperation(aux.chainreg)
  	c:RegisterEffect(e0)
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_ATKCHANGE + CATEGORY_TOHAND)
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e1:SetCode(EVENT_CHAIN_SOLVED)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCondition(s.atkcon)
  	e1:SetOperation(s.atkop)
  	c:RegisterEffect(e1)
  end
  function s.atkcon(e, tp, eg, ep, ev, re, r, rp)
  	return re:IsHasType(EFFECT_TYPE_ACTIVATE) and re:IsActiveType(TYPE_COUNTER) and e:GetHandler():GetFlagEffect(FLAG_ID_CHAINING) > 0
  end
  function s.thfilter(c, code)
  	return c:IsType(TYPE_COUNTER) and not c:IsCode(code) and c:IsAbleToHand()
  end
  function s.atkop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_UPDATE_ATTACK)
  	e1:SetValue(500)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE)
  	c:RegisterEffect(e1)
  	local rc = re:GetHandler()
  	local g = Duel.GetMatchingGroup(aux.NecroValleyFilter(s.thfilter), tp, LOCATION_GRAVE, 0, nil, rc:GetCode())
  	if Duel.IsEnvironment(CARD_ID_0) and g:GetCount() > 0 then
  		Duel.Hint(HINT_CARD, 0, id)
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  		local sg = g:Select(tp, 1, 1, nil)
  		Duel.SendtoHand(sg, nil, REASON_EFFECT)
  	end
  end
  
  