name: Icejade
card_text: When this card is activated: You can add 1 of your "Icejade" monsters that is banished or in your GY to your hand. Once per turn, if a monster(s) is Normal or Special Summoned (except during the Damage Step): You can target 1 WATER monster you control; that monster, along with any face-up monsters your opponent currently controls, loses ATK equal to the targeted monster's original ATK, until the end of this turn. You can only activate 1 "Icejade Cenote Enion Cradle" per turn.
external_ids: local SETCARD_ID_0 = 0x16c --Icejade
  
lua: local SETCARD_ID_0 = 0x16c --Icejade
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TOHAND)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	--atk down
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_ATKCHANGE)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_SUMMON_SUCCESS)
  	e2:SetProperty(EFFECT_FLAG_DELAY + EFFECT_FLAG_CARD_TARGET)
  	e2:SetRange(LOCATION_FZONE)
  	e2:SetCountLimit(1, EFFECT_COUNT_CODE_SINGLE)
  	e2:SetTarget(s.adtg)
  	e2:SetOperation(s.adop)
  	c:RegisterEffect(e2)
  	local e3 = e2:Clone()
  	e3:SetCode(EVENT_SPSUMMON_SUCCESS)
  	c:RegisterEffect(e3)
  end
  function s.thfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) and c:IsAbleToHand() and (c:IsLocation(LOCATION_GRAVE) or c:IsFaceup())
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(aux.NecroValleyFilter(s.thfilter), tp, LOCATION_GRAVE + LOCATION_REMOVED, 0, nil)
  	if g:GetCount() > 0 and Duel.SelectYesNo(tp, aux.Stringid(id, 0)) then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  		local sg = g:Select(tp, 1, 1, nil)
  		Duel.SendtoHand(sg, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, sg)
  	end
  end
  function s.adfilter(c)
  	return c:IsAttribute(ATTRIBUTE_WATER) and c:IsFaceup() and c:GetBaseAttack() > 0
  end
  function s.adtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.adfilter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.adfilter, tp, LOCATION_MZONE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	local g = Duel.SelectTarget(tp, s.adfilter, tp, LOCATION_MZONE, 0, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_ATKCHANGE, g, 1, 0, 0)
  end
  function s.adop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if not (tc:IsRelateToEffect(e) and tc:IsFaceup()) then
  		return
  	end
  	local g = Duel.GetMatchingGroup(Card.IsFaceup, tp, 0, LOCATION_MZONE, nil)
  	g:AddCard(tc)
  	local tc1 = g:GetFirst()
  	while tc1 do
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_ATTACK)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		e1:SetValue(-tc:GetBaseAttack())
  		tc1:RegisterEffect(e1)
  		tc1 = g:GetNext()
  	end
  end
  
  
source_text: Icejade
  When this card is activated: You can add 1 of your "Icejade" monsters that is banished or in your GY to your hand. Once per turn, if a monster(s) is Normal or Special Summoned (except during the Damage Step): You can target 1 WATER monster you control; that monster, along with any face-up monsters your opponent currently controls, loses ATK equal to the targeted monster's original ATK, until the end of this turn. You can only activate 1 "Icejade Cenote Enion Cradle" per turn.
target_text: -- Icejade
  local SETCARD_ID_0 = 0x16c --Icejade
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TOHAND)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	--atk down
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_ATKCHANGE)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_SUMMON_SUCCESS)
  	e2:SetProperty(EFFECT_FLAG_DELAY + EFFECT_FLAG_CARD_TARGET)
  	e2:SetRange(LOCATION_FZONE)
  	e2:SetCountLimit(1, EFFECT_COUNT_CODE_SINGLE)
  	e2:SetTarget(s.adtg)
  	e2:SetOperation(s.adop)
  	c:RegisterEffect(e2)
  	local e3 = e2:Clone()
  	e3:SetCode(EVENT_SPSUMMON_SUCCESS)
  	c:RegisterEffect(e3)
  end
  function s.thfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) and c:IsAbleToHand() and (c:IsLocation(LOCATION_GRAVE) or c:IsFaceup())
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(aux.NecroValleyFilter(s.thfilter), tp, LOCATION_GRAVE + LOCATION_REMOVED, 0, nil)
  	if g:GetCount() > 0 and Duel.SelectYesNo(tp, aux.Stringid(id, 0)) then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  		local sg = g:Select(tp, 1, 1, nil)
  		Duel.SendtoHand(sg, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, sg)
  	end
  end
  function s.adfilter(c)
  	return c:IsAttribute(ATTRIBUTE_WATER) and c:IsFaceup() and c:GetBaseAttack() > 0
  end
  function s.adtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.adfilter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.adfilter, tp, LOCATION_MZONE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	local g = Duel.SelectTarget(tp, s.adfilter, tp, LOCATION_MZONE, 0, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_ATKCHANGE, g, 1, 0, 0)
  end
  function s.adop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if not (tc:IsRelateToEffect(e) and tc:IsFaceup()) then
  		return
  	end
  	local g = Duel.GetMatchingGroup(Card.IsFaceup, tp, 0, LOCATION_MZONE, nil)
  	g:AddCard(tc)
  	local tc1 = g:GetFirst()
  	while tc1 do
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_ATTACK)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		e1:SetValue(-tc:GetBaseAttack())
  		tc1:RegisterEffect(e1)
  		tc1 = g:GetNext()
  	end
  end
  
  