name: Mimikuril
card_text: During your Main Phase: You can excavate the top card of your Deck, and if it is a monster, Special Summon it, and if you do, place this card on the bottom of the Deck. If it wasn't a monster, or couldn't be Special Summoned, place it on the bottom of the Deck. Place the monster Special Summoned by this effect on the bottom of the Deck during the End Phase. You can only use this effect of "Mimikuril" once per turn.
external_ids: local CARD_ID_0 = 63060238 --Elemental HERO Blazeman
  
lua: local CARD_ID_0 = 63060238 --Elemental HERO Blazeman
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_TODECK)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1, id)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsPlayerCanSpecialSummon(tp)
  			and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0
  			and not Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0)
  			and Duel.GetFieldGroupCount(tp, LOCATION_DECK, 0) > 0
  	end
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetFieldGroupCount(tp, LOCATION_DECK, 0) == 0 then
  		return
  	end
  	Duel.ConfirmDecktop(tp, 1)
  	local g = Duel.GetDecktopGroup(tp, 1)
  	local tc = g:GetFirst()
  	if tc:IsCanBeSpecialSummoned(e, 0, tp, false, false) then
  		Duel.DisableShuffleCheck()
  		if Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP) ~= 0 then
  			local c = e:GetHandler()
  			local fid = c:GetFieldID()
  			tc:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD, 0, 1, fid)
  			local e1 = Effect.CreateEffect(c)
  			e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  			e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  			e1:SetCode(EVENT_PHASE + PHASE_END)
  			e1:SetCountLimit(1)
  			e1:SetLabel(fid)
  			e1:SetLabelObject(tc)
  			e1:SetCondition(s.retcon)
  			e1:SetOperation(s.retop)
  			Duel.RegisterEffect(e1, tp)
  			if c:IsRelateToEffect(e) then
  				Duel.SendtoDeck(c, nil, SEQ_DECKBOTTOM, REASON_EFFECT)
  			end
  		end
  	else
  		Duel.MoveSequence(tc, SEQ_DECKBOTTOM)
  	end
  end
  function s.retcon(e, tp, eg, ep, ev, re, r, rp)
  	local tc = e:GetLabelObject()
  	if tc:GetFlagEffectLabel(id) ~= e:GetLabel() then
  		e:Reset()
  		return false
  	else
  		return true
  	end
  end
  function s.retop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = e:GetLabelObject()
  	Duel.SendtoDeck(tc, nil, SEQ_DECKBOTTOM, REASON_EFFECT)
  end
  
  
source_text: Mimikuril
  During your Main Phase: You can excavate the top card of your Deck, and if it is a monster, Special Summon it, and if you do, place this card on the bottom of the Deck. If it wasn't a monster, or couldn't be Special Summoned, place it on the bottom of the Deck. Place the monster Special Summoned by this effect on the bottom of the Deck during the End Phase. You can only use this effect of "Mimikuril" once per turn.
target_text: -- Mimikuril
  local CARD_ID_0 = 63060238 --Elemental HERO Blazeman
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_TODECK)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1, id)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsPlayerCanSpecialSummon(tp)
  			and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0
  			and not Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0)
  			and Duel.GetFieldGroupCount(tp, LOCATION_DECK, 0) > 0
  	end
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetFieldGroupCount(tp, LOCATION_DECK, 0) == 0 then
  		return
  	end
  	Duel.ConfirmDecktop(tp, 1)
  	local g = Duel.GetDecktopGroup(tp, 1)
  	local tc = g:GetFirst()
  	if tc:IsCanBeSpecialSummoned(e, 0, tp, false, false) then
  		Duel.DisableShuffleCheck()
  		if Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP) ~= 0 then
  			local c = e:GetHandler()
  			local fid = c:GetFieldID()
  			tc:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD, 0, 1, fid)
  			local e1 = Effect.CreateEffect(c)
  			e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  			e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  			e1:SetCode(EVENT_PHASE + PHASE_END)
  			e1:SetCountLimit(1)
  			e1:SetLabel(fid)
  			e1:SetLabelObject(tc)
  			e1:SetCondition(s.retcon)
  			e1:SetOperation(s.retop)
  			Duel.RegisterEffect(e1, tp)
  			if c:IsRelateToEffect(e) then
  				Duel.SendtoDeck(c, nil, SEQ_DECKBOTTOM, REASON_EFFECT)
  			end
  		end
  	else
  		Duel.MoveSequence(tc, SEQ_DECKBOTTOM)
  	end
  end
  function s.retcon(e, tp, eg, ep, ev, re, r, rp)
  	local tc = e:GetLabelObject()
  	if tc:GetFlagEffectLabel(id) ~= e:GetLabel() then
  		e:Reset()
  		return false
  	else
  		return true
  	end
  end
  function s.retop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = e:GetLabelObject()
  	Duel.SendtoDeck(tc, nil, SEQ_DECKBOTTOM, REASON_EFFECT)
  end
  
  