name: Geomancer
card_text: Once while face-up on the field: You can discard 1 card and declare 1 Attribute; monsters with that declared Attribute cannot target this card for attacks.
external_ids: local CARD_ID_0 = 18319762 --Revealer of the Ice Barrier
  local SETCARD_ID_0 = 0x2f --Ice
  
lua: local CARD_ID_0 = 18319762 --Revealer of the Ice Barrier
  local SETCARD_ID_0 = 0x2f --Ice
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--untargetable
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetProperty(EFFECT_FLAG_NO_TURN_RESET)
  	e1:SetCountLimit(1)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.costfilter(c, e, tp)
  	if c:IsLocation(LOCATION_HAND) then
  		return c:IsDiscardable()
  	else
  		return e:GetHandler():IsSetCard(SETCARD_ID_0) and c:IsAbleToRemove() and c:IsHasEffect(CARD_ID_0, tp)
  	end
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.costfilter, tp, LOCATION_HAND + LOCATION_GRAVE, 0, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DISCARD)
  	local g = Duel.SelectMatchingCard(tp, s.costfilter, tp, LOCATION_HAND + LOCATION_GRAVE, 0, 1, 1, nil, e, tp)
  	local tc = g:GetFirst()
  	local te = tc:IsHasEffect(CARD_ID_0, tp)
  	if te then
  		te:UseCountLimit(tp)
  		Duel.Remove(tc, POS_FACEUP, REASON_EFFECT + REASON_REPLACE)
  	else
  		Duel.SendtoGrave(tc, REASON_COST + REASON_DISCARD)
  	end
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATTRIBUTE)
  	local aat = Duel.AnnounceAttribute(tp, 1, ATTRIBUTE_ALL)
  	e:SetLabel(aat)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsFacedown() or not c:IsRelateToEffect(e) then
  		return
  	end
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e1:SetCode(EFFECT_CANNOT_BE_BATTLE_TARGET)
  	e1:SetLabel(e:GetLabel())
  	e1:SetValue(s.tgval)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  	c:RegisterEffect(e1)
  end
  function s.tgval(e, c)
  	return c:IsAttribute(e:GetLabel()) and not c:IsImmuneToEffect(e)
  end
  
  
source_text: Geomancer
  Once while face-up on the field: You can discard 1 card and declare 1 Attribute; monsters with that declared Attribute cannot target this card for attacks.
target_text: -- Geomancer
  local CARD_ID_0 = 18319762 --Revealer of the Ice Barrier
  local SETCARD_ID_0 = 0x2f --Ice
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--untargetable
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetProperty(EFFECT_FLAG_NO_TURN_RESET)
  	e1:SetCountLimit(1)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.costfilter(c, e, tp)
  	if c:IsLocation(LOCATION_HAND) then
  		return c:IsDiscardable()
  	else
  		return e:GetHandler():IsSetCard(SETCARD_ID_0) and c:IsAbleToRemove() and c:IsHasEffect(CARD_ID_0, tp)
  	end
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.costfilter, tp, LOCATION_HAND + LOCATION_GRAVE, 0, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DISCARD)
  	local g = Duel.SelectMatchingCard(tp, s.costfilter, tp, LOCATION_HAND + LOCATION_GRAVE, 0, 1, 1, nil, e, tp)
  	local tc = g:GetFirst()
  	local te = tc:IsHasEffect(CARD_ID_0, tp)
  	if te then
  		te:UseCountLimit(tp)
  		Duel.Remove(tc, POS_FACEUP, REASON_EFFECT + REASON_REPLACE)
  	else
  		Duel.SendtoGrave(tc, REASON_COST + REASON_DISCARD)
  	end
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATTRIBUTE)
  	local aat = Duel.AnnounceAttribute(tp, 1, ATTRIBUTE_ALL)
  	e:SetLabel(aat)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsFacedown() or not c:IsRelateToEffect(e) then
  		return
  	end
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e1:SetCode(EFFECT_CANNOT_BE_BATTLE_TARGET)
  	e1:SetLabel(e:GetLabel())
  	e1:SetValue(s.tgval)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  	c:RegisterEffect(e1)
  end
  function s.tgval(e, c)
  	return c:IsAttribute(e:GetLabel()) and not c:IsImmuneToEffect(e)
  end
  
  