name: Refrain
card_text: Pendulum Scale = 1
  [ Pendulum Effect ]
  You can target 1 "Melodious" Fusion Monster you control; send 1 "Melodious" monster from your Deck to the GY, and if you do, the targeted monster gains ATK equal to the Level of that monster sent to the GY x 200 until the end of this turn. You can only use this effect of "Refrain the Melodious Songstress" once per turn.
  ----------------------------------------
  [ Monster Effect ]
  If this card is Normal or Special Summoned: You can add 1 "Melodious" monster from your Deck to your hand, except "Refrain the Melodious Songstress". If a "Melodious" Fusion Monster(s) is Special Summoned to your field, while this card is face-up in your Extra Deck (except during the Damage Step): You can place this card in your Pendulum Zone. You can only use each effect of "Refrain the Melodious Songstress" once per turn.
external_ids: local SETCARD_ID_0 = 0x9b --Melodious
  
lua: local SETCARD_ID_0 = 0x9b --Melodious
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.EnablePendulumAttribute(c)
  	--
  	local e0 = Effect.CreateEffect(c)
  	e0:SetDescription(aux.Stringid(id, 0))
  	e0:SetCategory(CATEGORY_ATKCHANGE)
  	e0:SetType(EFFECT_TYPE_IGNITION)
  	e0:SetRange(LOCATION_PZONE)
  	e0:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e0:SetCountLimit(1, id)
  	e0:SetTarget(s.atktg)
  	e0:SetOperation(s.atkop)
  	c:RegisterEffect(e0)
  	--
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 1))
  	e1:SetCategory(CATEGORY_SEARCH + CATEGORY_TOHAND)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_SUMMON_SUCCESS)
  	e1:SetCountLimit(1, id + 1)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetTarget(s.thtg)
  	e1:SetOperation(s.thop)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	c:RegisterEffect(e2)
  	--
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 2))
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e3:SetProperty(EFFECT_FLAG_DELAY)
  	e3:SetRange(LOCATION_EXTRA)
  	e3:SetCountLimit(1, id + 2)
  	e3:SetCondition(s.pencon)
  	e3:SetTarget(s.pentg)
  	e3:SetOperation(s.penop)
  	c:RegisterEffect(e3)
  end
  function s.tgfilter(c)
  	return c:IsType(TYPE_MONSTER) and c:IsSetCard(SETCARD_ID_0) and c:IsAbleToGrave()
  end
  function s.filter(c)
  	return c:IsType(TYPE_FUSION) and c:IsSetCard(SETCARD_ID_0) and c:IsFaceup()
  end
  function s.atktg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.filter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_MZONE, 0, 1, nil) and Duel.IsExistingMatchingCard(s.tgfilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
  	local g = Duel.SelectTarget(tp, s.filter, tp, LOCATION_MZONE, 0, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_ATKCHANGE, g, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, nil, 1, tp, LOCATION_DECK)
  end
  function s.atkop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local tg = Duel.SelectMatchingCard(tp, s.tgfilter, tp, LOCATION_DECK, 0, 1, 1, nil):GetFirst()
  	if tg and Duel.SendtoGrave(tg, REASON_COST) ~= 0 and tg:IsLocation(LOCATION_GRAVE) then
  		local tc = Duel.GetFirstTarget()
  		if tc:IsRelateToEffect(e) and tc:IsFaceup() then
  			local e0 = Effect.CreateEffect(c)
  			e0:SetType(EFFECT_TYPE_SINGLE)
  			e0:SetCode(EFFECT_UPDATE_ATTACK)
  			e0:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  			e0:SetValue(tg:GetLevel() * 200)
  			tc:RegisterEffect(e0)
  		end
  	end
  end
  function s.thfilter(c)
  	return not c:IsCode(id) and c:IsType(TYPE_MONSTER) and c:IsSetCard(SETCARD_ID_0) and c:IsAbleToHand()
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_DECK, 0, 1, nil)
  	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 > 0 then
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, g)
  	end
  end
  function s.cfilter(c, tp)
  	return c:IsFaceup() and c:IsType(TYPE_FUSION) and c:IsSetCard(SETCARD_ID_0) and c:IsControler(tp)
  end
  function s.pencon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsFaceup() and eg:IsExists(s.cfilter, 1, nil, tp)
  end
  function s.pentg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.CheckLocation(tp, LOCATION_PZONE, 0) or Duel.CheckLocation(tp, LOCATION_PZONE, 1)
  	end
  end
  function s.penop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) and (Duel.CheckLocation(tp, LOCATION_PZONE, 0) or Duel.CheckLocation(tp, LOCATION_PZONE, 1)) then
  		Duel.MoveToField(c, tp, tp, LOCATION_PZONE, POS_FACEUP, true)
  	end
  end
  
  
source_text: Refrain
  Pendulum Scale = 1
  [ Pendulum Effect ]
  You can target 1 "Melodious" Fusion Monster you control; send 1 "Melodious" monster from your Deck to the GY, and if you do, the targeted monster gains ATK equal to the Level of that monster sent to the GY x 200 until the end of this turn. You can only use this effect of "Refrain the Melodious Songstress" once per turn.
  ----------------------------------------
  [ Monster Effect ]
  If this card is Normal or Special Summoned: You can add 1 "Melodious" monster from your Deck to your hand, except "Refrain the Melodious Songstress". If a "Melodious" Fusion Monster(s) is Special Summoned to your field, while this card is face-up in your Extra Deck (except during the Damage Step): You can place this card in your Pendulum Zone. You can only use each effect of "Refrain the Melodious Songstress" once per turn.
target_text: -- Refrain
  local SETCARD_ID_0 = 0x9b --Melodious
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.EnablePendulumAttribute(c)
  	--
  	local e0 = Effect.CreateEffect(c)
  	e0:SetDescription(aux.Stringid(id, 0))
  	e0:SetCategory(CATEGORY_ATKCHANGE)
  	e0:SetType(EFFECT_TYPE_IGNITION)
  	e0:SetRange(LOCATION_PZONE)
  	e0:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e0:SetCountLimit(1, id)
  	e0:SetTarget(s.atktg)
  	e0:SetOperation(s.atkop)
  	c:RegisterEffect(e0)
  	--
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 1))
  	e1:SetCategory(CATEGORY_SEARCH + CATEGORY_TOHAND)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_SUMMON_SUCCESS)
  	e1:SetCountLimit(1, id + 1)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetTarget(s.thtg)
  	e1:SetOperation(s.thop)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	c:RegisterEffect(e2)
  	--
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 2))
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e3:SetProperty(EFFECT_FLAG_DELAY)
  	e3:SetRange(LOCATION_EXTRA)
  	e3:SetCountLimit(1, id + 2)
  	e3:SetCondition(s.pencon)
  	e3:SetTarget(s.pentg)
  	e3:SetOperation(s.penop)
  	c:RegisterEffect(e3)
  end
  function s.tgfilter(c)
  	return c:IsType(TYPE_MONSTER) and c:IsSetCard(SETCARD_ID_0) and c:IsAbleToGrave()
  end
  function s.filter(c)
  	return c:IsType(TYPE_FUSION) and c:IsSetCard(SETCARD_ID_0) and c:IsFaceup()
  end
  function s.atktg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.filter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_MZONE, 0, 1, nil) and Duel.IsExistingMatchingCard(s.tgfilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
  	local g = Duel.SelectTarget(tp, s.filter, tp, LOCATION_MZONE, 0, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_ATKCHANGE, g, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, nil, 1, tp, LOCATION_DECK)
  end
  function s.atkop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local tg = Duel.SelectMatchingCard(tp, s.tgfilter, tp, LOCATION_DECK, 0, 1, 1, nil):GetFirst()
  	if tg and Duel.SendtoGrave(tg, REASON_COST) ~= 0 and tg:IsLocation(LOCATION_GRAVE) then
  		local tc = Duel.GetFirstTarget()
  		if tc:IsRelateToEffect(e) and tc:IsFaceup() then
  			local e0 = Effect.CreateEffect(c)
  			e0:SetType(EFFECT_TYPE_SINGLE)
  			e0:SetCode(EFFECT_UPDATE_ATTACK)
  			e0:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  			e0:SetValue(tg:GetLevel() * 200)
  			tc:RegisterEffect(e0)
  		end
  	end
  end
  function s.thfilter(c)
  	return not c:IsCode(id) and c:IsType(TYPE_MONSTER) and c:IsSetCard(SETCARD_ID_0) and c:IsAbleToHand()
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_DECK, 0, 1, nil)
  	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 > 0 then
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, g)
  	end
  end
  function s.cfilter(c, tp)
  	return c:IsFaceup() and c:IsType(TYPE_FUSION) and c:IsSetCard(SETCARD_ID_0) and c:IsControler(tp)
  end
  function s.pencon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsFaceup() and eg:IsExists(s.cfilter, 1, nil, tp)
  end
  function s.pentg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.CheckLocation(tp, LOCATION_PZONE, 0) or Duel.CheckLocation(tp, LOCATION_PZONE, 1)
  	end
  end
  function s.penop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) and (Duel.CheckLocation(tp, LOCATION_PZONE, 0) or Duel.CheckLocation(tp, LOCATION_PZONE, 1)) then
  		Duel.MoveToField(c, tp, tp, LOCATION_PZONE, POS_FACEUP, true)
  	end
  end
  
  