name: Rikka
card_text: Target 1 face-up monster your opponent controls, also, you can Tribute 1 Plant monster; players cannot activate that face-up monster's effects on the field this turn, then, if you Tributed a monster when you activated this card, take control of that monster until the End Phase, and if you do, it becomes a Plant monster until the End Phase. You can only activate 1 "Rikka Sheet" per turn.
external_ids: local CARD_ID_0 = 76869711 --Rikka Konkon
  
lua: local CARD_ID_0 = 76869711 --Rikka Konkon
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	--cost
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_CONTROL)
  	e2:SetType(EFFECT_TYPE_ACTIVATE)
  	e2:SetCode(EVENT_FREE_CHAIN)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE)
  	e2:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e2:SetCost(s.cost)
  	e2:SetTarget(s.target2)
  	e2:SetOperation(s.activate2)
  	c:RegisterEffect(e2)
  end
  function s.filter(c, check)
  	return c:IsFaceup() and (c:IsType(TYPE_EFFECT) or bit.band(c:GetOriginalType(), TYPE_EFFECT) == TYPE_EFFECT) and (check or c:IsAbleToChangeControler())
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsControler(1 - tp) and chkc:IsLocation(LOCATION_MZONE) and s.filter(chkc, true)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, 0, LOCATION_MZONE, 1, nil, true)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	Duel.SelectTarget(tp, s.filter, tp, 0, LOCATION_MZONE, 1, 1, nil, true)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsFaceup() and tc:IsRelateToEffect(e) then
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_CANNOT_TRIGGER)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		tc:RegisterEffect(e1, true)
  	end
  end
  function s.rfilter(c, tp)
  	return Duel.GetMZoneCount(tp, c) > 0
  		and (c:IsControler(tp) or c:IsFaceup())
  		and (c:IsRace(RACE_PLANT) or c:IsHasEffect(CARD_ID_0, tp) and c:IsControler(1 - tp))
  		and Duel.IsExistingTarget(s.filter, tp, 0, LOCATION_MZONE, 1, c)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.CheckReleaseGroup(tp, s.rfilter, 1, nil, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_RELEASE)
  	local g = Duel.SelectReleaseGroup(tp, s.rfilter, 1, 1, nil, tp)
  	Duel.Release(g, REASON_COST)
  end
  function s.target2(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsControler(1 - tp) and chkc:IsLocation(LOCATION_MZONE) and s.filter(chkc, false)
  	end
  	if chk == 0 then
  		return e:IsHasType(EFFECT_TYPE_ACTIVATE) and Duel.IsExistingTarget(s.filter, tp, 0, LOCATION_MZONE, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	local g = Duel.SelectTarget(tp, s.filter, tp, 0, LOCATION_MZONE, 1, 1, nil, false)
  	Duel.SetOperationInfo(0, CATEGORY_CONTROL, g, 1, 0, 0)
  end
  function s.activate2(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsFaceup() and tc:IsRelateToEffect(e) then
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_CANNOT_TRIGGER)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		tc:RegisterEffect(e1, true)
  		if e:IsHasType(EFFECT_TYPE_ACTIVATE) and tc:IsAbleToChangeControler() then
  			Duel.BreakEffect()
  			if Duel.GetControl(tc, tp, PHASE_END, 1) ~= 0 then
  				local e2 = Effect.CreateEffect(e:GetHandler())
  				e2:SetType(EFFECT_TYPE_SINGLE)
  				e2:SetCode(EFFECT_CHANGE_RACE)
  				e2:SetValue(RACE_PLANT)
  				e2:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  				tc:RegisterEffect(e2)
  			end
  		end
  	end
  end
  
  
source_text: Rikka
  Target 1 face-up monster your opponent controls, also, you can Tribute 1 Plant monster; players cannot activate that face-up monster's effects on the field this turn, then, if you Tributed a monster when you activated this card, take control of that monster until the End Phase, and if you do, it becomes a Plant monster until the End Phase. You can only activate 1 "Rikka Sheet" per turn.
target_text: -- Rikka
  local CARD_ID_0 = 76869711 --Rikka Konkon
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	--cost
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_CONTROL)
  	e2:SetType(EFFECT_TYPE_ACTIVATE)
  	e2:SetCode(EVENT_FREE_CHAIN)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE)
  	e2:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e2:SetCost(s.cost)
  	e2:SetTarget(s.target2)
  	e2:SetOperation(s.activate2)
  	c:RegisterEffect(e2)
  end
  function s.filter(c, check)
  	return c:IsFaceup() and (c:IsType(TYPE_EFFECT) or bit.band(c:GetOriginalType(), TYPE_EFFECT) == TYPE_EFFECT) and (check or c:IsAbleToChangeControler())
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsControler(1 - tp) and chkc:IsLocation(LOCATION_MZONE) and s.filter(chkc, true)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, 0, LOCATION_MZONE, 1, nil, true)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	Duel.SelectTarget(tp, s.filter, tp, 0, LOCATION_MZONE, 1, 1, nil, true)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsFaceup() and tc:IsRelateToEffect(e) then
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_CANNOT_TRIGGER)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		tc:RegisterEffect(e1, true)
  	end
  end
  function s.rfilter(c, tp)
  	return Duel.GetMZoneCount(tp, c) > 0
  		and (c:IsControler(tp) or c:IsFaceup())
  		and (c:IsRace(RACE_PLANT) or c:IsHasEffect(CARD_ID_0, tp) and c:IsControler(1 - tp))
  		and Duel.IsExistingTarget(s.filter, tp, 0, LOCATION_MZONE, 1, c)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.CheckReleaseGroup(tp, s.rfilter, 1, nil, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_RELEASE)
  	local g = Duel.SelectReleaseGroup(tp, s.rfilter, 1, 1, nil, tp)
  	Duel.Release(g, REASON_COST)
  end
  function s.target2(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsControler(1 - tp) and chkc:IsLocation(LOCATION_MZONE) and s.filter(chkc, false)
  	end
  	if chk == 0 then
  		return e:IsHasType(EFFECT_TYPE_ACTIVATE) and Duel.IsExistingTarget(s.filter, tp, 0, LOCATION_MZONE, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	local g = Duel.SelectTarget(tp, s.filter, tp, 0, LOCATION_MZONE, 1, 1, nil, false)
  	Duel.SetOperationInfo(0, CATEGORY_CONTROL, g, 1, 0, 0)
  end
  function s.activate2(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsFaceup() and tc:IsRelateToEffect(e) then
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_CANNOT_TRIGGER)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		tc:RegisterEffect(e1, true)
  		if e:IsHasType(EFFECT_TYPE_ACTIVATE) and tc:IsAbleToChangeControler() then
  			Duel.BreakEffect()
  			if Duel.GetControl(tc, tp, PHASE_END, 1) ~= 0 then
  				local e2 = Effect.CreateEffect(e:GetHandler())
  				e2:SetType(EFFECT_TYPE_SINGLE)
  				e2:SetCode(EFFECT_CHANGE_RACE)
  				e2:SetValue(RACE_PLANT)
  				e2:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  				tc:RegisterEffect(e2)
  			end
  		end
  	end
  end
  
  