name: Sunvine
card_text: When your opponent activates a card or effect that targets a Plant monster(s) you control that was Special Summoned from the Extra Deck (Quick Effect): You can Special Summon this card from your hand, and if you do, negate that effect. You can only use this effect of "Sunvine Maiden" once per turn. Your opponent cannot target "Sunavalon" or "Sunvine" Spells/Traps you control with card effects.
external_ids: local SETCARD_ID_0 = 0x1158 --Sunvine
  
lua: local SETCARD_ID_0 = 0x1158 --Sunvine
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--negate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_DISABLE + CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_QUICK_O)
  	e1:SetCode(EVENT_CHAINING)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.negcon)
  	e1:SetTarget(s.negtg)
  	e1:SetOperation(s.negop)
  	c:RegisterEffect(e1)
  	--cannot be target
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  	e2:SetTargetRange(LOCATION_ONFIELD, 0)
  	e2:SetTarget(s.tgtg)
  	e2:SetValue(aux.tgoval)
  	c:RegisterEffect(e2)
  end
  function s.cfilter(c, tp)
  	return c:IsControler(tp) and c:IsLocation(LOCATION_MZONE) and c:IsFaceup() and c:IsRace(RACE_PLANT) and c:IsSummonLocation(LOCATION_EXTRA)
  end
  function s.negcon(e, tp, eg, ep, ev, re, r, rp)
  	if not (rp == 1 - tp and re:IsHasProperty(EFFECT_FLAG_CARD_TARGET)) then
  		return false
  	end
  	local g = Duel.GetChainInfo(ev, CHAININFO_TARGET_CARDS)
  	return g and g:IsExists(s.cfilter, 1, nil, tp) and Duel.IsChainDisablable(ev)
  end
  function s.negtg(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_DISABLE, eg, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
  end
  function s.negop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if not c:IsRelateToEffect(e) then
  		return
  	end
  	if Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP) ~= 0 then
  		Duel.NegateEffect(ev)
  	end
  end
  function s.tgtg(e, c)
  	return c:IsSetCard(SETCARD_ID_0, 0x2158) and c:IsType(TYPE_SPELL + TYPE_TRAP)
  end
  
  
source_text: Sunvine
  When your opponent activates a card or effect that targets a Plant monster(s) you control that was Special Summoned from the Extra Deck (Quick Effect): You can Special Summon this card from your hand, and if you do, negate that effect. You can only use this effect of "Sunvine Maiden" once per turn. Your opponent cannot target "Sunavalon" or "Sunvine" Spells/Traps you control with card effects.
target_text: -- Sunvine
  local SETCARD_ID_0 = 0x1158 --Sunvine
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--negate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_DISABLE + CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_QUICK_O)
  	e1:SetCode(EVENT_CHAINING)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.negcon)
  	e1:SetTarget(s.negtg)
  	e1:SetOperation(s.negop)
  	c:RegisterEffect(e1)
  	--cannot be target
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  	e2:SetTargetRange(LOCATION_ONFIELD, 0)
  	e2:SetTarget(s.tgtg)
  	e2:SetValue(aux.tgoval)
  	c:RegisterEffect(e2)
  end
  function s.cfilter(c, tp)
  	return c:IsControler(tp) and c:IsLocation(LOCATION_MZONE) and c:IsFaceup() and c:IsRace(RACE_PLANT) and c:IsSummonLocation(LOCATION_EXTRA)
  end
  function s.negcon(e, tp, eg, ep, ev, re, r, rp)
  	if not (rp == 1 - tp and re:IsHasProperty(EFFECT_FLAG_CARD_TARGET)) then
  		return false
  	end
  	local g = Duel.GetChainInfo(ev, CHAININFO_TARGET_CARDS)
  	return g and g:IsExists(s.cfilter, 1, nil, tp) and Duel.IsChainDisablable(ev)
  end
  function s.negtg(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_DISABLE, eg, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
  end
  function s.negop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if not c:IsRelateToEffect(e) then
  		return
  	end
  	if Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP) ~= 0 then
  		Duel.NegateEffect(ev)
  	end
  end
  function s.tgtg(e, c)
  	return c:IsSetCard(SETCARD_ID_0, 0x2158) and c:IsType(TYPE_SPELL + TYPE_TRAP)
  end
  
  