Sunvine
Special Summon 1 "Sunseed" monster from your Deck, and if you do, take 1000 damage. If you control no "Sunavalon" Link Monsters, you can only Special Summon "Sunseed Genius Loci" with this effect. For the rest of this turn after this card resolves, you cannot Special Summon monsters from the Extra Deck, except Plant monsters. If a Plant Link Monster(s) you control would be destroyed by battle or an opponent's card effect, you can banish this card from your GY instead. You can only activate 1 "Sunvine Sowing" per turn.
local CARD_ID_0 = 27520594 --Sunseed Genius Loci
local SETCARD_ID_0 = 0x2158 --Sunavalon
local SETCARD_ID_1 = 0x4158 --Sunseed

local CARD_ID_0 = 27520594 --Sunseed Genius Loci
local SETCARD_ID_0 = 0x2158 --Sunavalon
local SETCARD_ID_1 = 0x4158 --Sunseed
local s, id, o = GetID()
function s.initial_effect(c)
	--Activate
	local e1 = Effect.CreateEffect(c)
	e1:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_DAMAGE)
	e1:SetType(EFFECT_TYPE_ACTIVATE)
	e1:SetCode(EVENT_FREE_CHAIN)
	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
	e1:SetTarget(s.target)
	e1:SetOperation(s.activate)
	c:RegisterEffect(e1)
	--destroy replace
	local e2 = Effect.CreateEffect(c)
	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
	e2:SetCode(EFFECT_DESTROY_REPLACE)
	e2:SetRange(LOCATION_GRAVE)
	e2:SetTarget(s.reptg)
	e2:SetValue(s.repval)
	e2:SetOperation(s.repop)
	c:RegisterEffect(e2)
end
function s.spfilter(c, e, tp, check)
	return c:IsSetCard(SETCARD_ID_1) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false) and (check or c:IsCode(CARD_ID_0))
end
function s.cfilter(c)
	return c:IsFaceup() and c:IsType(TYPE_LINK) and c:IsSetCard(SETCARD_ID_1)
end
function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
	local check = Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil)
	if chk == 0 then
		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_DECK, 0, 1, nil, e, tp, check)
	end
	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_DECK)
	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, tp, 1000)
end
function s.activate(e, tp, eg, ep, ev, re, r, rp)
	if Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 then
		local check = Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil)
		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
		local g = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_DECK, 0, 1, 1, nil, e, tp, check)
		local tc = g:GetFirst()
		if tc and Duel.SpecialSummonStep(tc, 0, tp, tp, false, false, POS_FACEUP) then
			Duel.Damage(tp, 1000, REASON_EFFECT)
		end
		Duel.SpecialSummonComplete()
	end
	if not e:IsHasType(EFFECT_TYPE_ACTIVATE) then
		return
	end
	local e1 = Effect.CreateEffect(e:GetHandler())
	e1:SetType(EFFECT_TYPE_FIELD)
	e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
	e1:SetTargetRange(1, 0)
	e1:SetTarget(s.splimit)
	e1:SetReset(RESET_PHASE + PHASE_END)
	Duel.RegisterEffect(e1, tp)
end
function s.splimit(e, c)
	return not c:IsRace(RACE_PLANT) and c:IsLocation(LOCATION_EXTRA)
end
function s.repfilter(c, tp)
	return c:IsFaceup()
		and c:IsLocation(LOCATION_MZONE)
		and c:IsControler(tp)
		and c:IsRace(RACE_PLANT)
		and c:IsType(TYPE_LINK)
		and (c:IsReason(REASON_BATTLE) or (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)
	if chk == 0 then
		return e:GetHandler():IsAbleToRemove() and eg:IsExists(s.repfilter, 1, nil, tp)
	end
	return Duel.SelectEffectYesNo(tp, e:GetHandler(), 96)
end
function s.repval(e, c)
	return s.repfilter(c, e:GetHandlerPlayer())
end
function s.repop(e, tp, eg, ep, ev, re, r, rp)
	Duel.Remove(e:GetHandler(), POS_FACEUP, REASON_EFFECT)
end


Sunvine
Special Summon 1 "Sunseed" monster from your Deck, and if you do, take 1000 damage. If you control no "Sunavalon" Link Monsters, you can only Special Summon "Sunseed Genius Loci" with this effect. For the rest of this turn after this card resolves, you cannot Special Summon monsters from the Extra Deck, except Plant monsters. If a Plant Link Monster(s) you control would be destroyed by battle or an opponent's card effect, you can banish this card from your GY instead. You can only activate 1 "Sunvine Sowing" per turn.
-- Sunvine
local CARD_ID_0 = 27520594 --Sunseed Genius Loci
local SETCARD_ID_0 = 0x2158 --Sunavalon
local SETCARD_ID_1 = 0x4158 --Sunseed
local s, id, o = GetID()
function s.initial_effect(c)
	--Activate
	local e1 = Effect.CreateEffect(c)
	e1:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_DAMAGE)
	e1:SetType(EFFECT_TYPE_ACTIVATE)
	e1:SetCode(EVENT_FREE_CHAIN)
	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
	e1:SetTarget(s.target)
	e1:SetOperation(s.activate)
	c:RegisterEffect(e1)
	--destroy replace
	local e2 = Effect.CreateEffect(c)
	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
	e2:SetCode(EFFECT_DESTROY_REPLACE)
	e2:SetRange(LOCATION_GRAVE)
	e2:SetTarget(s.reptg)
	e2:SetValue(s.repval)
	e2:SetOperation(s.repop)
	c:RegisterEffect(e2)
end
function s.spfilter(c, e, tp, check)
	return c:IsSetCard(SETCARD_ID_1) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false) and (check or c:IsCode(CARD_ID_0))
end
function s.cfilter(c)
	return c:IsFaceup() and c:IsType(TYPE_LINK) and c:IsSetCard(SETCARD_ID_1)
end
function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
	local check = Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil)
	if chk == 0 then
		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_DECK, 0, 1, nil, e, tp, check)
	end
	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_DECK)
	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, tp, 1000)
end
function s.activate(e, tp, eg, ep, ev, re, r, rp)
	if Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 then
		local check = Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil)
		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
		local g = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_DECK, 0, 1, 1, nil, e, tp, check)
		local tc = g:GetFirst()
		if tc and Duel.SpecialSummonStep(tc, 0, tp, tp, false, false, POS_FACEUP) then
			Duel.Damage(tp, 1000, REASON_EFFECT)
		end
		Duel.SpecialSummonComplete()
	end
	if not e:IsHasType(EFFECT_TYPE_ACTIVATE) then
		return
	end
	local e1 = Effect.CreateEffect(e:GetHandler())
	e1:SetType(EFFECT_TYPE_FIELD)
	e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
	e1:SetTargetRange(1, 0)
	e1:SetTarget(s.splimit)
	e1:SetReset(RESET_PHASE + PHASE_END)
	Duel.RegisterEffect(e1, tp)
end
function s.splimit(e, c)
	return not c:IsRace(RACE_PLANT) and c:IsLocation(LOCATION_EXTRA)
end
function s.repfilter(c, tp)
	return c:IsFaceup()
		and c:IsLocation(LOCATION_MZONE)
		and c:IsControler(tp)
		and c:IsRace(RACE_PLANT)
		and c:IsType(TYPE_LINK)
		and (c:IsReason(REASON_BATTLE) or (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)
	if chk == 0 then
		return e:GetHandler():IsAbleToRemove() and eg:IsExists(s.repfilter, 1, nil, tp)
	end
	return Duel.SelectEffectYesNo(tp, e:GetHandler(), 96)
end
function s.repval(e, c)
	return s.repfilter(c, e:GetHandlerPlayer())
end
function s.repop(e, tp, eg, ep, ev, re, r, rp)
	Duel.Remove(e:GetHandler(), POS_FACEUP, REASON_EFFECT)
end

