ReSolfachord
Pendulum Scale = 7
[ 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 a "Solfachord" Pendulum Monster Card(s) you control would be destroyed by your opponent's card effect, you can destroy this card instead of 1 of those cards. If you control a "Solfachord" card in your Pendulum Zone: You can Special Summon this card from your hand. You can only use this effect of "ReSolfachord Dreamia" once per turn.
local SETCARD_ID_0 = 0x162 --Solfachord

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)
	--spsummon
	local e2 = Effect.CreateEffect(c)
	e2:SetDescription(aux.Stringid(id, 0))
	e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
	e2:SetType(EFFECT_TYPE_IGNITION)
	e2:SetRange(LOCATION_HAND)
	e2:SetCountLimit(1, id)
	e2:SetCondition(s.spcon)
	e2:SetTarget(s.sptg)
	e2:SetOperation(s.spop)
	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.spcon(e, tp, eg, ep, ev, re, r, rp)
	return Duel.IsExistingMatchingCard(Card.IsSetCard, tp, LOCATION_PZONE, 0, 1, nil, 0x162)
end
function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and e:GetHandler():IsCanBeSpecialSummoned(e, 0, tp, false, false)
	end
	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
end
function s.spop(e, tp, eg, ep, ev, re, r, rp)
	local c = e:GetHandler()
	if c:IsRelateToEffect(e) then
		Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP)
	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:IsOnField()
		and c:IsSetCard(SETCARD_ID_0)
		and c:GetOriginalType() & TYPE_PENDULUM ~= 0
		and c:IsReason(REASON_EFFECT)
		and c:GetReasonPlayer() == 1 - tp
		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
		local sg = eg:Filter(s.repfilter, c, tp)
		if sg:GetCount() > 1 then
			Duel.Hint(HINT_SELECTMSG, tp, aux.Stringid(id, 1))
			sg = sg:Select(tp, 1, 1, nil)
		end
		sg:KeepAlive()
		e:SetLabelObject(sg)
		Duel.Destroy(c, REASON_EFFECT + REASON_REPLACE)
		return true
	else
		return false
	end
end
function s.repval(e, c)
	local g = e:GetLabelObject()
	return g:IsContains(c)
end


ReSolfachord
Pendulum Scale = 7
[ 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 a "Solfachord" Pendulum Monster Card(s) you control would be destroyed by your opponent's card effect, you can destroy this card instead of 1 of those cards. If you control a "Solfachord" card in your Pendulum Zone: You can Special Summon this card from your hand. You can only use this effect of "ReSolfachord Dreamia" once per turn.
-- ReSolfachord
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)
	--spsummon
	local e2 = Effect.CreateEffect(c)
	e2:SetDescription(aux.Stringid(id, 0))
	e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
	e2:SetType(EFFECT_TYPE_IGNITION)
	e2:SetRange(LOCATION_HAND)
	e2:SetCountLimit(1, id)
	e2:SetCondition(s.spcon)
	e2:SetTarget(s.sptg)
	e2:SetOperation(s.spop)
	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.spcon(e, tp, eg, ep, ev, re, r, rp)
	return Duel.IsExistingMatchingCard(Card.IsSetCard, tp, LOCATION_PZONE, 0, 1, nil, 0x162)
end
function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and e:GetHandler():IsCanBeSpecialSummoned(e, 0, tp, false, false)
	end
	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
end
function s.spop(e, tp, eg, ep, ev, re, r, rp)
	local c = e:GetHandler()
	if c:IsRelateToEffect(e) then
		Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP)
	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:IsOnField()
		and c:IsSetCard(SETCARD_ID_0)
		and c:GetOriginalType() & TYPE_PENDULUM ~= 0
		and c:IsReason(REASON_EFFECT)
		and c:GetReasonPlayer() == 1 - tp
		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
		local sg = eg:Filter(s.repfilter, c, tp)
		if sg:GetCount() > 1 then
			Duel.Hint(HINT_SELECTMSG, tp, aux.Stringid(id, 1))
			sg = sg:Select(tp, 1, 1, nil)
		end
		sg:KeepAlive()
		e:SetLabelObject(sg)
		Duel.Destroy(c, REASON_EFFECT + REASON_REPLACE)
		return true
	else
		return false
	end
end
function s.repval(e, c)
	local g = e:GetLabelObject()
	return g:IsContains(c)
end

