name: Hexa
card_text: While you control another "Ice Barrier" monster, monsters your opponent controls lose 500 ATK/DEF. During your Main Phase: You can send 1 Level 3 or lower "Ice Barrier" monster from your Deck to the GY, and if you do, this card's Level becomes the same as that monster's, until the end of this turn. You can only use this effect of "Hexa Spirit of the Ice Barrier" once per turn.
external_ids: local SETCARD_ID_0 = 0x2f --Ice
  
lua: local SETCARD_ID_0 = 0x2f --Ice
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--atk/def
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_UPDATE_ATTACK)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetTargetRange(0, LOCATION_MZONE)
  	e1:SetValue(-500)
  	e1:SetCondition(s.atkcon)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EFFECT_UPDATE_DEFENSE)
  	c:RegisterEffect(e2)
  	--lv
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetCategory(CATEGORY_TOGRAVE)
  	e3:SetType(EFFECT_TYPE_IGNITION)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCountLimit(1, id)
  	e3:SetTarget(s.lvtg)
  	e3:SetOperation(s.lvop)
  	c:RegisterEffect(e3)
  end
  function s.atkfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
  end
  function s.atkcon(e)
  	local tp = e:GetHandlerPlayer()
  	return Duel.IsExistingMatchingCard(s.atkfilter, tp, LOCATION_MZONE, 0, 1, e:GetHandler())
  end
  function s.tgfilter(c)
  	return c:IsLevelBelow(3) and c:IsSetCard(SETCARD_ID_0) and c:IsAbleToGrave()
  end
  function s.lvtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.tgfilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, nil, 1, tp, LOCATION_DECK)
  end
  function s.lvop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local g = Duel.SelectMatchingCard(tp, s.tgfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	local tc = g:GetFirst()
  	if tc and Duel.SendtoGrave(tc, REASON_EFFECT) ~= 0 and tc:IsLocation(LOCATION_GRAVE) and c:IsRelateToEffect(e) and c:IsFaceup() then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_CHANGE_LEVEL)
  		e1:SetValue(tc:GetLevel())
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE + RESET_PHASE + PHASE_END)
  		c:RegisterEffect(e1)
  	end
  end
  
  
source_text: Hexa
  While you control another "Ice Barrier" monster, monsters your opponent controls lose 500 ATK/DEF. During your Main Phase: You can send 1 Level 3 or lower "Ice Barrier" monster from your Deck to the GY, and if you do, this card's Level becomes the same as that monster's, until the end of this turn. You can only use this effect of "Hexa Spirit of the Ice Barrier" once per turn.
target_text: -- Hexa
  local SETCARD_ID_0 = 0x2f --Ice
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--atk/def
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_UPDATE_ATTACK)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetTargetRange(0, LOCATION_MZONE)
  	e1:SetValue(-500)
  	e1:SetCondition(s.atkcon)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EFFECT_UPDATE_DEFENSE)
  	c:RegisterEffect(e2)
  	--lv
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetCategory(CATEGORY_TOGRAVE)
  	e3:SetType(EFFECT_TYPE_IGNITION)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCountLimit(1, id)
  	e3:SetTarget(s.lvtg)
  	e3:SetOperation(s.lvop)
  	c:RegisterEffect(e3)
  end
  function s.atkfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
  end
  function s.atkcon(e)
  	local tp = e:GetHandlerPlayer()
  	return Duel.IsExistingMatchingCard(s.atkfilter, tp, LOCATION_MZONE, 0, 1, e:GetHandler())
  end
  function s.tgfilter(c)
  	return c:IsLevelBelow(3) and c:IsSetCard(SETCARD_ID_0) and c:IsAbleToGrave()
  end
  function s.lvtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.tgfilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, nil, 1, tp, LOCATION_DECK)
  end
  function s.lvop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local g = Duel.SelectMatchingCard(tp, s.tgfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	local tc = g:GetFirst()
  	if tc and Duel.SendtoGrave(tc, REASON_EFFECT) ~= 0 and tc:IsLocation(LOCATION_GRAVE) and c:IsRelateToEffect(e) and c:IsFaceup() then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_CHANGE_LEVEL)
  		e1:SetValue(tc:GetLevel())
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE + RESET_PHASE + PHASE_END)
  		c:RegisterEffect(e1)
  	end
  end
  
  