name: Rikka
card_text: If you control a "Rikka" monster: You can Set 1 "Rikka" Spell/Trap directly from your Deck to your Spell & Trap Zone, also you cannot Special Summon monsters for the rest of this turn, except Plant monsters. You can only use this effect of "Rikka Konkon" once per turn. Once per turn, if you would Tribute a Plant monster you control to activate a "Rikka" card or effect, you can Tribute any 1 face-up monster your opponent controls, even though you do not control it.
external_ids: local SETCARD_ID_0 = 0x141 --Rikka
  
lua: local SETCARD_ID_0 = 0x141 --Rikka
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e1)
  	--set
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_FZONE)
  	e2:SetCountLimit(1, id)
  	e2:SetCondition(s.stcon)
  	e2:SetTarget(s.sttg)
  	e2:SetOperation(s.stop)
  	c:RegisterEffect(e2)
  	--release replace
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD)
  	e3:SetCode(EFFECT_EXTRA_RELEASE_NONSUM)
  	e3:SetRange(LOCATION_FZONE)
  	e3:SetTargetRange(0, LOCATION_MZONE)
  	e3:SetTarget(aux.TRUE)
  	e3:SetCountLimit(1)
  	e3:SetValue(s.relval)
  	c:RegisterEffect(e3)
  	local e4 = e3:Clone()
  	e4:SetCode(id)
  	c:RegisterEffect(e4)
  end
  function s.filter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsFaceup()
  end
  function s.stcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_MZONE, 0, 1, nil)
  end
  function s.stfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_SPELL + TYPE_TRAP) and not c:IsType(TYPE_FIELD) and c:IsSSetable()
  end
  function s.sttg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_SZONE) > 0 and Duel.IsExistingMatchingCard(s.stfilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  end
  function s.stop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_SZONE) > 0 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SET)
  		local g = Duel.SelectMatchingCard(tp, s.stfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  		local tc = g:GetFirst()
  		if tc then
  			Duel.SSet(tp, tc)
  		end
  	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)
  end
  function s.relval(e, re, r, rp)
  	return re:IsActivated() and re:GetHandler():IsSetCard(SETCARD_ID_0) and bit.band(r, REASON_COST) ~= 0
  end
  
  
source_text: Rikka
  If you control a "Rikka" monster: You can Set 1 "Rikka" Spell/Trap directly from your Deck to your Spell & Trap Zone, also you cannot Special Summon monsters for the rest of this turn, except Plant monsters. You can only use this effect of "Rikka Konkon" once per turn. Once per turn, if you would Tribute a Plant monster you control to activate a "Rikka" card or effect, you can Tribute any 1 face-up monster your opponent controls, even though you do not control it.
target_text: -- Rikka
  local SETCARD_ID_0 = 0x141 --Rikka
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e1)
  	--set
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_FZONE)
  	e2:SetCountLimit(1, id)
  	e2:SetCondition(s.stcon)
  	e2:SetTarget(s.sttg)
  	e2:SetOperation(s.stop)
  	c:RegisterEffect(e2)
  	--release replace
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD)
  	e3:SetCode(EFFECT_EXTRA_RELEASE_NONSUM)
  	e3:SetRange(LOCATION_FZONE)
  	e3:SetTargetRange(0, LOCATION_MZONE)
  	e3:SetTarget(aux.TRUE)
  	e3:SetCountLimit(1)
  	e3:SetValue(s.relval)
  	c:RegisterEffect(e3)
  	local e4 = e3:Clone()
  	e4:SetCode(id)
  	c:RegisterEffect(e4)
  end
  function s.filter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsFaceup()
  end
  function s.stcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_MZONE, 0, 1, nil)
  end
  function s.stfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_SPELL + TYPE_TRAP) and not c:IsType(TYPE_FIELD) and c:IsSSetable()
  end
  function s.sttg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_SZONE) > 0 and Duel.IsExistingMatchingCard(s.stfilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  end
  function s.stop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_SZONE) > 0 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SET)
  		local g = Duel.SelectMatchingCard(tp, s.stfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  		local tc = g:GetFirst()
  		if tc then
  			Duel.SSet(tp, tc)
  		end
  	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)
  end
  function s.relval(e, re, r, rp)
  	return re:IsActivated() and re:GetHandler():IsSetCard(SETCARD_ID_0) and bit.band(r, REASON_COST) ~= 0
  end
  
  