name: Nouvelles
card_text: While you control a "Nouvelles" Monster Card, all face-up monsters your opponent controls are changed to Attack Position. Each time a monster(s) is Tributed by a Ritual Monster's effect, your opponent pays 850 LP. Once per turn, if you Special Summon a Ritual Monster(s) (except during the Damage Step): You can target 1 of them; add 1 "Recipe" or "Nouvelles" card from your Deck to your hand, except a Continuous Spell, and if you do, increase that monster's Level by 1. You can only activate 1 "Nouvelles Recipe Book "Recettes de Nouvellez"" per turn.
external_ids: local SETCARD_ID_0 = 0x196 --Nouvelles
  
lua: local SETCARD_ID_0 = 0x196 --Nouvelles
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	c:RegisterEffect(e1)
  	--Pos Change
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_SET_POSITION)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetCondition(s.poscon)
  	e2:SetTarget(s.target)
  	e2:SetTargetRange(0, LOCATION_MZONE)
  	e2:SetValue(POS_FACEUP_ATTACK)
  	c:RegisterEffect(e2)
  	--lp
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e3:SetCode(EVENT_RELEASE)
  	e3:SetProperty(EFFECT_FLAG_DELAY)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetCondition(s.lpcon)
  	e3:SetOperation(s.lpop)
  	c:RegisterEffect(e3)
  	--search
  	local custom_code = aux.RegisterMergedDelayedEvent_ToSingleCard(c, id, EVENT_SPSUMMON_SUCCESS)
  	local e4 = Effect.CreateEffect(c)
  	e4:SetDescription(aux.Stringid(id, 2))
  	e4:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e4:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e4:SetCode(custom_code)
  	e4:SetRange(LOCATION_SZONE)
  	e4:SetProperty(EFFECT_FLAG_CARD_TARGET + EFFECT_FLAG_DELAY)
  	e4:SetCountLimit(1)
  	e4:SetCondition(s.thcon)
  	e4:SetTarget(s.thtg)
  	e4:SetOperation(s.thop)
  	c:RegisterEffect(e4)
  end
  function s.cfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:GetOriginalType() & TYPE_MONSTER == TYPE_MONSTER
  end
  function s.poscon(e)
  	return Duel.IsExistingMatchingCard(s.cfilter, e:GetHandlerPlayer(), LOCATION_ONFIELD, 0, 1, nil)
  end
  function s.target(e, c)
  	return c:IsFaceup()
  end
  function s.cfilter2(c)
  	return c:IsType(TYPE_MONSTER) and c:IsReason(REASON_EFFECT)
  end
  function s.lpcon(e, tp, eg, ep, ev, re, r, rp)
  	return re and re:GetHandler():IsAllTypes(TYPE_RITUAL + TYPE_MONSTER) and eg:IsExists(s.cfilter2, 1, nil)
  end
  function s.lpop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLP(1 - tp) >= 850 then
  		Duel.Hint(HINT_CARD, 0, id)
  		Duel.PayLPCost(1 - tp, 850)
  	end
  end
  function s.cfilter3(c, tp, e)
  	return c:IsLocation(LOCATION_MZONE) and c:IsSummonPlayer(tp) and c:IsFaceup() and c:IsCanBeEffectTarget(e) and c:IsType(TYPE_RITUAL) and c:IsLevelAbove(1)
  end
  function s.thcon(e, tp, eg, ep, ev, re, r, rp)
  	return eg:IsExists(s.cfilter3, 1, nil, tp, e)
  end
  function s.thfilter(c)
  	return c:IsSetCard(SETCARD_ID_0, 0x197) and not c:IsAllTypes(TYPE_CONTINUOUS + TYPE_SPELL) and c:IsAbleToHand()
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	local g = eg:Filter(s.cfilter3, nil, tp, e)
  	if chkc then
  		return g:IsContains(chkc)
  	end
  	if chk == 0 then
  		return #g > 0 and Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	local sg
  	if g:GetCount() == 1 then
  		sg = g:Clone()
  		Duel.SetTargetCard(sg)
  	else
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  		sg = Duel.SelectTarget(tp, aux.IsInGroup, tp, LOCATION_MZONE, 0, 1, 1, nil, g)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectMatchingCard(tp, s.thfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, g)
  		local tc = Duel.GetFirstTarget()
  		if tc:IsFaceup() and tc:IsRelateToChain() and tc:IsType(TYPE_MONSTER) then
  			local e1 = Effect.CreateEffect(e:GetHandler())
  			e1:SetType(EFFECT_TYPE_SINGLE)
  			e1:SetCode(EFFECT_UPDATE_LEVEL)
  			e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  			e1:SetValue(1)
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  			tc:RegisterEffect(e1)
  		end
  	end
  end
  
  
source_text: Nouvelles
  While you control a "Nouvelles" Monster Card, all face-up monsters your opponent controls are changed to Attack Position. Each time a monster(s) is Tributed by a Ritual Monster's effect, your opponent pays 850 LP. Once per turn, if you Special Summon a Ritual Monster(s) (except during the Damage Step): You can target 1 of them; add 1 "Recipe" or "Nouvelles" card from your Deck to your hand, except a Continuous Spell, and if you do, increase that monster's Level by 1. You can only activate 1 "Nouvelles Recipe Book "Recettes de Nouvellez"" per turn.
target_text: -- Nouvelles
  local SETCARD_ID_0 = 0x196 --Nouvelles
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	c:RegisterEffect(e1)
  	--Pos Change
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_SET_POSITION)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetCondition(s.poscon)
  	e2:SetTarget(s.target)
  	e2:SetTargetRange(0, LOCATION_MZONE)
  	e2:SetValue(POS_FACEUP_ATTACK)
  	c:RegisterEffect(e2)
  	--lp
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e3:SetCode(EVENT_RELEASE)
  	e3:SetProperty(EFFECT_FLAG_DELAY)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetCondition(s.lpcon)
  	e3:SetOperation(s.lpop)
  	c:RegisterEffect(e3)
  	--search
  	local custom_code = aux.RegisterMergedDelayedEvent_ToSingleCard(c, id, EVENT_SPSUMMON_SUCCESS)
  	local e4 = Effect.CreateEffect(c)
  	e4:SetDescription(aux.Stringid(id, 2))
  	e4:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e4:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e4:SetCode(custom_code)
  	e4:SetRange(LOCATION_SZONE)
  	e4:SetProperty(EFFECT_FLAG_CARD_TARGET + EFFECT_FLAG_DELAY)
  	e4:SetCountLimit(1)
  	e4:SetCondition(s.thcon)
  	e4:SetTarget(s.thtg)
  	e4:SetOperation(s.thop)
  	c:RegisterEffect(e4)
  end
  function s.cfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:GetOriginalType() & TYPE_MONSTER == TYPE_MONSTER
  end
  function s.poscon(e)
  	return Duel.IsExistingMatchingCard(s.cfilter, e:GetHandlerPlayer(), LOCATION_ONFIELD, 0, 1, nil)
  end
  function s.target(e, c)
  	return c:IsFaceup()
  end
  function s.cfilter2(c)
  	return c:IsType(TYPE_MONSTER) and c:IsReason(REASON_EFFECT)
  end
  function s.lpcon(e, tp, eg, ep, ev, re, r, rp)
  	return re and re:GetHandler():IsAllTypes(TYPE_RITUAL + TYPE_MONSTER) and eg:IsExists(s.cfilter2, 1, nil)
  end
  function s.lpop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLP(1 - tp) >= 850 then
  		Duel.Hint(HINT_CARD, 0, id)
  		Duel.PayLPCost(1 - tp, 850)
  	end
  end
  function s.cfilter3(c, tp, e)
  	return c:IsLocation(LOCATION_MZONE) and c:IsSummonPlayer(tp) and c:IsFaceup() and c:IsCanBeEffectTarget(e) and c:IsType(TYPE_RITUAL) and c:IsLevelAbove(1)
  end
  function s.thcon(e, tp, eg, ep, ev, re, r, rp)
  	return eg:IsExists(s.cfilter3, 1, nil, tp, e)
  end
  function s.thfilter(c)
  	return c:IsSetCard(SETCARD_ID_0, 0x197) and not c:IsAllTypes(TYPE_CONTINUOUS + TYPE_SPELL) and c:IsAbleToHand()
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	local g = eg:Filter(s.cfilter3, nil, tp, e)
  	if chkc then
  		return g:IsContains(chkc)
  	end
  	if chk == 0 then
  		return #g > 0 and Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	local sg
  	if g:GetCount() == 1 then
  		sg = g:Clone()
  		Duel.SetTargetCard(sg)
  	else
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  		sg = Duel.SelectTarget(tp, aux.IsInGroup, tp, LOCATION_MZONE, 0, 1, 1, nil, g)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectMatchingCard(tp, s.thfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, g)
  		local tc = Duel.GetFirstTarget()
  		if tc:IsFaceup() and tc:IsRelateToChain() and tc:IsType(TYPE_MONSTER) then
  			local e1 = Effect.CreateEffect(e:GetHandler())
  			e1:SetType(EFFECT_TYPE_SINGLE)
  			e1:SetCode(EFFECT_UPDATE_LEVEL)
  			e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  			e1:SetValue(1)
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  			tc:RegisterEffect(e1)
  		end
  	end
  end
  
  