name: Hellebore
card_text: When your opponent activates a monster effect that targets a monster(s) you control, while you control a "Rikka" monster (Quick Effect): You can Tribute this card from your hand or face-up field; negate that effect. If this card is in your GY: You can Tribute 1 Plant monster; Special Summon this card in Defense Position, but banish it when it leaves the field. You can only use each effect of "Hellebore the Rikka Fairy" once per turn.
external_ids: local CARD_ID_0 = 76869711 --Rikka Konkon
  local SETCARD_ID_0 = 0x141 --Rikka
  
lua: local CARD_ID_0 = 76869711 --Rikka Konkon
  local SETCARD_ID_0 = 0x141 --Rikka
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--disable
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_DISABLE)
  	e1:SetType(EFFECT_TYPE_QUICK_O)
  	e1:SetCode(EVENT_CHAINING)
  	e1:SetRange(LOCATION_MZONE + LOCATION_HAND)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.discon)
  	e1:SetCost(s.discost)
  	e1:SetTarget(s.distg)
  	e1:SetOperation(s.disop)
  	c:RegisterEffect(e1)
  	--spsummon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_GRAVE)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetCost(s.spcost)
  	e2:SetTarget(s.sptg)
  	e2:SetOperation(s.spop)
  	c:RegisterEffect(e2)
  end
  function s.cfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
  end
  function s.tfilter(c, tp)
  	return c:IsLocation(LOCATION_MZONE) and c:IsControler(tp)
  end
  function s.discon(e, tp, eg, ep, ev, re, r, rp)
  	if rp == tp or e:GetHandler():IsStatus(STATUS_BATTLE_DESTROYED) then
  		return false
  	end
  	if not re:IsHasProperty(EFFECT_FLAG_CARD_TARGET) or not re:IsActiveType(TYPE_MONSTER) then
  		return false
  	end
  	local tg = Duel.GetChainInfo(ev, CHAININFO_TARGET_CARDS)
  	if not Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil) then
  		return false
  	end
  	return tg and tg:IsExists(s.tfilter, 1, nil, tp) and Duel.IsChainDisablable(ev)
  end
  function s.discost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsReleasable()
  	end
  	Duel.Release(e:GetHandler(), REASON_COST)
  end
  function s.distg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DISABLE, eg, 1, 0, 0)
  end
  function s.disop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.NegateEffect(ev)
  end
  function s.spfilter(c, tp)
  	return (c:IsControler(tp) or c:IsFaceup()) and Duel.GetMZoneCount(tp, c) > 0 and (c:IsRace(RACE_PLANT) or c:IsHasEffect(CARD_ID_0, tp) and c:IsControler(1 - tp))
  end
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.CheckReleaseGroup(tp, s.spfilter, 1, nil, tp)
  	end
  	local g = Duel.SelectReleaseGroup(tp, s.spfilter, 1, 1, nil, tp)
  	Duel.Release(g, REASON_COST)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP_DEFENSE)
  	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
  		if Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP_DEFENSE) ~= 0 then
  			local e1 = Effect.CreateEffect(c)
  			e1:SetType(EFFECT_TYPE_SINGLE)
  			e1:SetCode(EFFECT_LEAVE_FIELD_REDIRECT)
  			e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  			e1:SetReset(RESET_EVENT + RESETS_REDIRECT)
  			e1:SetValue(LOCATION_REMOVED)
  			c:RegisterEffect(e1)
  		end
  	end
  end
  
  
source_text: Hellebore
  When your opponent activates a monster effect that targets a monster(s) you control, while you control a "Rikka" monster (Quick Effect): You can Tribute this card from your hand or face-up field; negate that effect. If this card is in your GY: You can Tribute 1 Plant monster; Special Summon this card in Defense Position, but banish it when it leaves the field. You can only use each effect of "Hellebore the Rikka Fairy" once per turn.
target_text: -- Hellebore
  local CARD_ID_0 = 76869711 --Rikka Konkon
  local SETCARD_ID_0 = 0x141 --Rikka
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--disable
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_DISABLE)
  	e1:SetType(EFFECT_TYPE_QUICK_O)
  	e1:SetCode(EVENT_CHAINING)
  	e1:SetRange(LOCATION_MZONE + LOCATION_HAND)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.discon)
  	e1:SetCost(s.discost)
  	e1:SetTarget(s.distg)
  	e1:SetOperation(s.disop)
  	c:RegisterEffect(e1)
  	--spsummon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_GRAVE)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetCost(s.spcost)
  	e2:SetTarget(s.sptg)
  	e2:SetOperation(s.spop)
  	c:RegisterEffect(e2)
  end
  function s.cfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
  end
  function s.tfilter(c, tp)
  	return c:IsLocation(LOCATION_MZONE) and c:IsControler(tp)
  end
  function s.discon(e, tp, eg, ep, ev, re, r, rp)
  	if rp == tp or e:GetHandler():IsStatus(STATUS_BATTLE_DESTROYED) then
  		return false
  	end
  	if not re:IsHasProperty(EFFECT_FLAG_CARD_TARGET) or not re:IsActiveType(TYPE_MONSTER) then
  		return false
  	end
  	local tg = Duel.GetChainInfo(ev, CHAININFO_TARGET_CARDS)
  	if not Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil) then
  		return false
  	end
  	return tg and tg:IsExists(s.tfilter, 1, nil, tp) and Duel.IsChainDisablable(ev)
  end
  function s.discost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsReleasable()
  	end
  	Duel.Release(e:GetHandler(), REASON_COST)
  end
  function s.distg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DISABLE, eg, 1, 0, 0)
  end
  function s.disop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.NegateEffect(ev)
  end
  function s.spfilter(c, tp)
  	return (c:IsControler(tp) or c:IsFaceup()) and Duel.GetMZoneCount(tp, c) > 0 and (c:IsRace(RACE_PLANT) or c:IsHasEffect(CARD_ID_0, tp) and c:IsControler(1 - tp))
  end
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.CheckReleaseGroup(tp, s.spfilter, 1, nil, tp)
  	end
  	local g = Duel.SelectReleaseGroup(tp, s.spfilter, 1, 1, nil, tp)
  	Duel.Release(g, REASON_COST)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP_DEFENSE)
  	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
  		if Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP_DEFENSE) ~= 0 then
  			local e1 = Effect.CreateEffect(c)
  			e1:SetType(EFFECT_TYPE_SINGLE)
  			e1:SetCode(EFFECT_LEAVE_FIELD_REDIRECT)
  			e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  			e1:SetReset(RESET_EVENT + RESETS_REDIRECT)
  			e1:SetValue(LOCATION_REMOVED)
  			c:RegisterEffect(e1)
  		end
  	end
  end
  
  