name: Recardination
card_text: Target 1 "Flower Cardian" monster in your Graveyard; add it to your hand, then you can Special Summon 1 "Flower Cardian" monster from your hand, ignoring its Summoning conditions. If this card is sent to the Graveyard by a "Flower Cardian" monster's effect: You can excavate the top 5 cards of your Deck, and if you do, you can add 1 excavated Spell/Trap Card to your hand. Place the remaining cards on top of your Deck in any order.
external_ids: local SETCARD_ID_0 = 0xe6 --Flower
  
lua: local SETCARD_ID_0 = 0xe6 --Flower
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	--mill
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetProperty(EFFECT_FLAG_DELAY)
  	e2:SetCode(EVENT_TO_GRAVE)
  	e2:SetCondition(s.milcon)
  	e2:SetTarget(s.miltg)
  	e2:SetOperation(s.milop)
  	c:RegisterEffect(e2)
  end
  function s.filter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) and c:IsAbleToHand()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.filter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_GRAVE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectTarget(tp, s.filter, tp, LOCATION_GRAVE, 0, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, g, 1, 0, 0)
  end
  function s.spfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsCanBeSpecialSummoned(e, 0, tp, true, false)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and Duel.SendtoHand(tc, nil, REASON_EFFECT) ~= 0 and tc:IsLocation(LOCATION_HAND) then
  		local tg = Duel.GetMatchingGroup(s.spfilter, tp, LOCATION_HAND, 0, nil, e, tp)
  		if tg:GetCount() > 0 and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.SelectYesNo(tp, aux.Stringid(id, 2)) then
  			Duel.BreakEffect()
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  			local tc = tg:Select(tp, 1, 1, nil)
  			Duel.SpecialSummon(tc, 0, tp, tp, true, false, POS_FACEUP)
  		end
  	end
  end
  function s.milcon(e, tp, eg, ep, ev, re, r, rp)
  	if not re then
  		return false
  	end
  	local rc = re:GetHandler()
  	return e:GetHandler():IsReason(REASON_EFFECT) and rc:IsSetCard(SETCARD_ID_0) and rc:IsType(TYPE_MONSTER)
  end
  function s.miltg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetFieldGroupCount(tp, LOCATION_DECK, 0) > 4
  	end
  end
  function s.milfilter(c)
  	return c:IsType(TYPE_SPELL + TYPE_TRAP) and c:IsAbleToHand()
  end
  function s.milop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetFieldGroupCount(tp, LOCATION_DECK, 0) < 5 then
  		return
  	end
  	Duel.ConfirmDecktop(tp, 5)
  	local g = Duel.GetDecktopGroup(tp, 5)
  	if g:GetCount() > 0 then
  		Duel.DisableShuffleCheck()
  		if g:IsExists(s.milfilter, 1, nil) and Duel.SelectYesNo(tp, aux.Stringid(id, 3)) then
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  			local sg = g:FilterSelect(tp, s.milfilter, 1, 1, nil)
  			Duel.SendtoHand(sg, nil, REASON_EFFECT)
  			Duel.ConfirmCards(1 - tp, sg)
  			Duel.ShuffleHand(tp)
  			g:Sub(sg)
  		end
  		Duel.SortDecktop(tp, tp, g:GetCount())
  	end
  end
  
  
source_text: Recardination
  Target 1 "Flower Cardian" monster in your Graveyard; add it to your hand, then you can Special Summon 1 "Flower Cardian" monster from your hand, ignoring its Summoning conditions. If this card is sent to the Graveyard by a "Flower Cardian" monster's effect: You can excavate the top 5 cards of your Deck, and if you do, you can add 1 excavated Spell/Trap Card to your hand. Place the remaining cards on top of your Deck in any order.
target_text: -- Recardination
  local SETCARD_ID_0 = 0xe6 --Flower
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	--mill
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetProperty(EFFECT_FLAG_DELAY)
  	e2:SetCode(EVENT_TO_GRAVE)
  	e2:SetCondition(s.milcon)
  	e2:SetTarget(s.miltg)
  	e2:SetOperation(s.milop)
  	c:RegisterEffect(e2)
  end
  function s.filter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) and c:IsAbleToHand()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.filter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_GRAVE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectTarget(tp, s.filter, tp, LOCATION_GRAVE, 0, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, g, 1, 0, 0)
  end
  function s.spfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsCanBeSpecialSummoned(e, 0, tp, true, false)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and Duel.SendtoHand(tc, nil, REASON_EFFECT) ~= 0 and tc:IsLocation(LOCATION_HAND) then
  		local tg = Duel.GetMatchingGroup(s.spfilter, tp, LOCATION_HAND, 0, nil, e, tp)
  		if tg:GetCount() > 0 and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.SelectYesNo(tp, aux.Stringid(id, 2)) then
  			Duel.BreakEffect()
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  			local tc = tg:Select(tp, 1, 1, nil)
  			Duel.SpecialSummon(tc, 0, tp, tp, true, false, POS_FACEUP)
  		end
  	end
  end
  function s.milcon(e, tp, eg, ep, ev, re, r, rp)
  	if not re then
  		return false
  	end
  	local rc = re:GetHandler()
  	return e:GetHandler():IsReason(REASON_EFFECT) and rc:IsSetCard(SETCARD_ID_0) and rc:IsType(TYPE_MONSTER)
  end
  function s.miltg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetFieldGroupCount(tp, LOCATION_DECK, 0) > 4
  	end
  end
  function s.milfilter(c)
  	return c:IsType(TYPE_SPELL + TYPE_TRAP) and c:IsAbleToHand()
  end
  function s.milop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetFieldGroupCount(tp, LOCATION_DECK, 0) < 5 then
  		return
  	end
  	Duel.ConfirmDecktop(tp, 5)
  	local g = Duel.GetDecktopGroup(tp, 5)
  	if g:GetCount() > 0 then
  		Duel.DisableShuffleCheck()
  		if g:IsExists(s.milfilter, 1, nil) and Duel.SelectYesNo(tp, aux.Stringid(id, 3)) then
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  			local sg = g:FilterSelect(tp, s.milfilter, 1, 1, nil)
  			Duel.SendtoHand(sg, nil, REASON_EFFECT)
  			Duel.ConfirmCards(1 - tp, sg)
  			Duel.ShuffleHand(tp)
  			g:Sub(sg)
  		end
  		Duel.SortDecktop(tp, tp, g:GetCount())
  	end
  end
  
  