name: FaSolfachord
card_text: Pendulum Scale = 5
  [ Pendulum Effect ]
  Pendulum Summons of your "Solfachord" Pendulum Monsters cannot be negated.
  ----------------------------------------
  [ Monster Effect ]
  While you have an odd Pendulum Scale in your Pendulum Zone, if your "Solfachord" Pendulum Monster would be destroyed by battle, you can destroy this card instead. During your Main Phase: You can add 1 "Solfachord" Pendulum Monster from your Deck to your Extra Deck face-up, except "FaSolfachord Fancia". You can only use this effect of "FaSolfachord Fancia" once per turn.
external_ids: local SETCARD_ID_0 = 0x162 --Solfachord
  
lua: local SETCARD_ID_0 = 0x162 --Solfachord
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--pendulum summon
  	aux.EnablePendulumAttribute(c)
  	--cannot disable spsummon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CANNOT_DISABLE_SPSUMMON)
  	e1:SetProperty(EFFECT_FLAG_IGNORE_RANGE + EFFECT_FLAG_SET_AVAILABLE)
  	e1:SetRange(LOCATION_PZONE)
  	e1:SetTarget(s.distg)
  	c:RegisterEffect(e1)
  	--to extra
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_TOEXTRA)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1, id)
  	e2:SetTarget(s.tetg)
  	e2:SetOperation(s.teop)
  	c:RegisterEffect(e2)
  	--destroy replace
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e3:SetCode(EFFECT_DESTROY_REPLACE)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCondition(s.repcon)
  	e3:SetTarget(s.reptg)
  	e3:SetValue(s.repval)
  	c:RegisterEffect(e3)
  end
  function s.distg(e, c)
  	return c:IsControler(e:GetHandlerPlayer()) and c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_PENDULUM) and c:IsSummonType(SUMMON_TYPE_PENDULUM)
  end
  function s.tefilter(c)
  	return not c:IsCode(id) and c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_PENDULUM)
  end
  function s.tetg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.tefilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOEXTRA, nil, 1, tp, LOCATION_DECK)
  end
  function s.teop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, aux.Stringid(id, 1))
  	local g = Duel.SelectMatchingCard(tp, s.tefilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.SendtoExtraP(g, nil, REASON_EFFECT)
  	end
  end
  function s.pfilter(c)
  	return c:GetCurrentScale() % 2 ~= 0
  end
  function s.repcon(e)
  	local tp = e:GetHandlerPlayer()
  	return Duel.IsExistingMatchingCard(s.pfilter, tp, LOCATION_PZONE, 0, 1, nil)
  end
  function s.repfilter(c, tp)
  	return c:IsFaceup()
  		and c:IsControler(tp)
  		and c:IsLocation(LOCATION_MZONE)
  		and c:IsSetCard(SETCARD_ID_0)
  		and c:IsType(TYPE_PENDULUM)
  		and c:IsReason(REASON_BATTLE)
  		and not c:IsReason(REASON_REPLACE)
  end
  function s.reptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return c:IsDestructable(e) and not c:IsStatus(STATUS_DESTROY_CONFIRMED) and eg:IsExists(s.repfilter, 1, c, tp)
  	end
  	if Duel.SelectEffectYesNo(tp, c, 96) then
  		Duel.Destroy(c, REASON_EFFECT + REASON_REPLACE)
  		return true
  	else
  		return false
  	end
  end
  function s.repval(e, c)
  	return s.repfilter(c, e:GetHandlerPlayer())
  end
  
  
source_text: FaSolfachord
  Pendulum Scale = 5
  [ Pendulum Effect ]
  Pendulum Summons of your "Solfachord" Pendulum Monsters cannot be negated.
  ----------------------------------------
  [ Monster Effect ]
  While you have an odd Pendulum Scale in your Pendulum Zone, if your "Solfachord" Pendulum Monster would be destroyed by battle, you can destroy this card instead. During your Main Phase: You can add 1 "Solfachord" Pendulum Monster from your Deck to your Extra Deck face-up, except "FaSolfachord Fancia". You can only use this effect of "FaSolfachord Fancia" once per turn.
target_text: -- FaSolfachord
  local SETCARD_ID_0 = 0x162 --Solfachord
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--pendulum summon
  	aux.EnablePendulumAttribute(c)
  	--cannot disable spsummon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CANNOT_DISABLE_SPSUMMON)
  	e1:SetProperty(EFFECT_FLAG_IGNORE_RANGE + EFFECT_FLAG_SET_AVAILABLE)
  	e1:SetRange(LOCATION_PZONE)
  	e1:SetTarget(s.distg)
  	c:RegisterEffect(e1)
  	--to extra
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_TOEXTRA)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1, id)
  	e2:SetTarget(s.tetg)
  	e2:SetOperation(s.teop)
  	c:RegisterEffect(e2)
  	--destroy replace
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e3:SetCode(EFFECT_DESTROY_REPLACE)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCondition(s.repcon)
  	e3:SetTarget(s.reptg)
  	e3:SetValue(s.repval)
  	c:RegisterEffect(e3)
  end
  function s.distg(e, c)
  	return c:IsControler(e:GetHandlerPlayer()) and c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_PENDULUM) and c:IsSummonType(SUMMON_TYPE_PENDULUM)
  end
  function s.tefilter(c)
  	return not c:IsCode(id) and c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_PENDULUM)
  end
  function s.tetg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.tefilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOEXTRA, nil, 1, tp, LOCATION_DECK)
  end
  function s.teop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, aux.Stringid(id, 1))
  	local g = Duel.SelectMatchingCard(tp, s.tefilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.SendtoExtraP(g, nil, REASON_EFFECT)
  	end
  end
  function s.pfilter(c)
  	return c:GetCurrentScale() % 2 ~= 0
  end
  function s.repcon(e)
  	local tp = e:GetHandlerPlayer()
  	return Duel.IsExistingMatchingCard(s.pfilter, tp, LOCATION_PZONE, 0, 1, nil)
  end
  function s.repfilter(c, tp)
  	return c:IsFaceup()
  		and c:IsControler(tp)
  		and c:IsLocation(LOCATION_MZONE)
  		and c:IsSetCard(SETCARD_ID_0)
  		and c:IsType(TYPE_PENDULUM)
  		and c:IsReason(REASON_BATTLE)
  		and not c:IsReason(REASON_REPLACE)
  end
  function s.reptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return c:IsDestructable(e) and not c:IsStatus(STATUS_DESTROY_CONFIRMED) and eg:IsExists(s.repfilter, 1, c, tp)
  	end
  	if Duel.SelectEffectYesNo(tp, c, 96) then
  		Duel.Destroy(c, REASON_EFFECT + REASON_REPLACE)
  		return true
  	else
  		return false
  	end
  end
  function s.repval(e, c)
  	return s.repfilter(c, e:GetHandlerPlayer())
  end
  
  