name: Nemleria
card_text: If you have a face-up Pendulum Monster in your Extra Deck, you can Special Summon this card (from your hand). You can only Special Summon "Nemleria Dream Defender - Oreiller" once per turn this way. If you have "Dreaming Nemleria" face-up in your Extra Deck (Quick Effect): You can banish 1 face-down card from your Extra Deck, face-down; this card gains 500 ATK for each monster your opponent currently controls, until the end of this turn. You can only use this effect of "Nemleria Dream Defender - Oreiller" once per turn.
external_ids: local CARD_ID_1 = 70155677 --Dreaming Nemleria
  
lua: local CARD_ID_1 = 70155677 --Dreaming Nemleria
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_SPSUMMON_PROC)
  	e1:SetProperty(EFFECT_FLAG_UNCOPYABLE)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCondition(s.sprcon)
  	c:RegisterEffect(e1)
  	--atk up
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_ATKCHANGE)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetProperty(EFFECT_FLAG_DAMAGE_STEP)
  	e2:SetCode(EVENT_FREE_CHAIN)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetHintTiming(TIMING_DAMAGE_STEP, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE + TIMING_DAMAGE_STEP)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetCondition(s.atkcon)
  	e2:SetCost(s.atkcost)
  	e2:SetOperation(s.atkop)
  	c:RegisterEffect(e2)
  end
  function s.sprcon(e, c)
  	if c == nil then
  		return true
  	end
  	local tp = c:GetControler()
  	return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(aux.AND(Card.IsFaceup, Card.IsType), tp, LOCATION_EXTRA, 0, 1, nil, TYPE_PENDULUM)
  end
  function s.atkcon(e, tp, eg, ep, ev, re, r, rp)
  	return aux.dscon(e, tp, eg, ep, ev, re, r, rp)
  		and Duel.GetFieldGroupCount(tp, 0, LOCATION_MZONE) > 0
  		and Duel.IsExistingMatchingCard(aux.AND(Card.IsFaceup, Card.IsCode), tp, LOCATION_EXTRA, 0, 1, nil, CARD_ID_1)
  end
  function s.rmfilter(c)
  	return c:IsFacedown() and c:IsAbleToRemoveAsCost(POS_FACEDOWN)
  end
  function s.atkcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	local g = Duel.GetMatchingGroup(s.rmfilter, tp, LOCATION_EXTRA, 0, nil)
  	if chk == 0 then
  		return #g > 0
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local rg = g:Select(tp, 1, 1, nil)
  	Duel.Remove(rg, POS_FACEDOWN, REASON_COST)
  end
  function s.atkop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local ct = Duel.GetFieldGroupCount(tp, 0, LOCATION_MZONE)
  	if c:IsFaceup() and c:IsRelateToEffect(e) and ct > 0 then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_ATTACK)
  		e1:SetValue(ct * 500)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE + RESET_PHASE + PHASE_END)
  		c:RegisterEffect(e1)
  	end
  end
  
  
source_text: Nemleria
  If you have a face-up Pendulum Monster in your Extra Deck, you can Special Summon this card (from your hand). You can only Special Summon "Nemleria Dream Defender - Oreiller" once per turn this way. If you have "Dreaming Nemleria" face-up in your Extra Deck (Quick Effect): You can banish 1 face-down card from your Extra Deck, face-down; this card gains 500 ATK for each monster your opponent currently controls, until the end of this turn. You can only use this effect of "Nemleria Dream Defender - Oreiller" once per turn.
target_text: -- Nemleria
  local CARD_ID_1 = 70155677 --Dreaming Nemleria
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_SPSUMMON_PROC)
  	e1:SetProperty(EFFECT_FLAG_UNCOPYABLE)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCondition(s.sprcon)
  	c:RegisterEffect(e1)
  	--atk up
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_ATKCHANGE)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetProperty(EFFECT_FLAG_DAMAGE_STEP)
  	e2:SetCode(EVENT_FREE_CHAIN)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetHintTiming(TIMING_DAMAGE_STEP, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE + TIMING_DAMAGE_STEP)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetCondition(s.atkcon)
  	e2:SetCost(s.atkcost)
  	e2:SetOperation(s.atkop)
  	c:RegisterEffect(e2)
  end
  function s.sprcon(e, c)
  	if c == nil then
  		return true
  	end
  	local tp = c:GetControler()
  	return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(aux.AND(Card.IsFaceup, Card.IsType), tp, LOCATION_EXTRA, 0, 1, nil, TYPE_PENDULUM)
  end
  function s.atkcon(e, tp, eg, ep, ev, re, r, rp)
  	return aux.dscon(e, tp, eg, ep, ev, re, r, rp)
  		and Duel.GetFieldGroupCount(tp, 0, LOCATION_MZONE) > 0
  		and Duel.IsExistingMatchingCard(aux.AND(Card.IsFaceup, Card.IsCode), tp, LOCATION_EXTRA, 0, 1, nil, CARD_ID_1)
  end
  function s.rmfilter(c)
  	return c:IsFacedown() and c:IsAbleToRemoveAsCost(POS_FACEDOWN)
  end
  function s.atkcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	local g = Duel.GetMatchingGroup(s.rmfilter, tp, LOCATION_EXTRA, 0, nil)
  	if chk == 0 then
  		return #g > 0
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local rg = g:Select(tp, 1, 1, nil)
  	Duel.Remove(rg, POS_FACEDOWN, REASON_COST)
  end
  function s.atkop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local ct = Duel.GetFieldGroupCount(tp, 0, LOCATION_MZONE)
  	if c:IsFaceup() and c:IsRelateToEffect(e) and ct > 0 then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_ATTACK)
  		e1:SetValue(ct * 500)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE + RESET_PHASE + PHASE_END)
  		c:RegisterEffect(e1)
  	end
  end
  
  