name: Evoltile
card_text: If a monster(s) you control would be destroyed by battle or card effect, you can Tribute 1 Reptile or Dinosaur monster you control instead. You can only use each of the following effects of "Evoltile Pholis" once per turn. If this card is Normal or Special Summoned: You can Special Summon 1 "Evoltile" monster from your hand or GY in face-down Defense Position. During your Main Phase: You can Set 1 "Evo-Force" or "Evo-Instant" directly from your Deck.
external_ids: local CARD_ID_0 = 24362891 --Evo-Instant
  local CARD_ID_1 = 5338223 --Evo-Force
  local SETCARD_ID_0 = 0x304e --Evoltile
  
lua: local CARD_ID_0 = 24362891 --Evo-Instant
  local CARD_ID_1 = 5338223 --Evo-Force
  local SETCARD_ID_0 = 0x304e --Evoltile
  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)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetCode(EVENT_SUMMON_SUCCESS)
  	e1:SetCountLimit(1, id)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	c:RegisterEffect(e2)
  	--set
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetType(EFFECT_TYPE_IGNITION)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCountLimit(1, id + o)
  	e3:SetTarget(s.settg)
  	e3:SetOperation(s.setop)
  	c:RegisterEffect(e3)
  	--replace
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_CONTINUOUS + EFFECT_TYPE_FIELD)
  	e4:SetCode(EFFECT_DESTROY_REPLACE)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetTarget(s.desreptg)
  	e4:SetValue(s.desrepval)
  	e4:SetOperation(s.desrepop)
  	c:RegisterEffect(e4)
  end
  function s.spfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEDOWN_DEFENSE)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_HAND + LOCATION_GRAVE, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_HAND + LOCATION_GRAVE)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, aux.NecroValleyFilter(s.spfilter), tp, LOCATION_HAND + LOCATION_GRAVE, 0, 1, 1, nil, e, tp)
  	if #g > 0 and Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEDOWN_DEFENSE) > 0 then
  		Duel.ConfirmCards(1 - tp, g)
  	end
  end
  function s.setfilter(c)
  	return c:IsCode(CARD_ID_1, CARD_ID_0) and c:IsSSetable()
  end
  function s.settg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.setfilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  end
  function s.setop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SET)
  	local g = Duel.SelectMatchingCard(tp, s.setfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if #g > 0 then
  		Duel.SSet(tp, g)
  	end
  end
  function s.desrepfilter(c, tp)
  	return c:IsControler(tp) and c:IsLocation(LOCATION_MZONE) and c:IsReason(REASON_BATTLE + REASON_EFFECT) and not c:IsReason(REASON_REPLACE)
  end
  function s.rfilter(c)
  	return c:IsRace(RACE_REPTILE + RACE_DINOSAUR) and not c:IsStatus(STATUS_DESTROY_CONFIRMED + STATUS_BATTLE_DESTROYED)
  end
  function s.desreptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return eg:IsExists(s.desrepfilter, 1, nil, tp) and Duel.CheckReleaseGroupEx(tp, s.rfilter, 1, REASON_EFFECT, false, nil)
  	end
  	return Duel.SelectEffectYesNo(tp, e:GetHandler(), 96)
  end
  function s.desrepval(e, c)
  	return s.desrepfilter(c, e:GetHandlerPlayer())
  end
  function s.desrepop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESREPLACE)
  	local g = Duel.SelectReleaseGroupEx(tp, s.rfilter, 1, 1, REASON_EFFECT, false, nil)
  	if #g > 0 then
  		Duel.Hint(HINT_CARD, 0, id)
  		Duel.HintSelection(g)
  		Duel.Release(g, REASON_EFFECT + REASON_REPLACE)
  	end
  end
  
  
source_text: Evoltile
  If a monster(s) you control would be destroyed by battle or card effect, you can Tribute 1 Reptile or Dinosaur monster you control instead. You can only use each of the following effects of "Evoltile Pholis" once per turn. If this card is Normal or Special Summoned: You can Special Summon 1 "Evoltile" monster from your hand or GY in face-down Defense Position. During your Main Phase: You can Set 1 "Evo-Force" or "Evo-Instant" directly from your Deck.
target_text: -- Evoltile
  local CARD_ID_0 = 24362891 --Evo-Instant
  local CARD_ID_1 = 5338223 --Evo-Force
  local SETCARD_ID_0 = 0x304e --Evoltile
  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)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetCode(EVENT_SUMMON_SUCCESS)
  	e1:SetCountLimit(1, id)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	c:RegisterEffect(e2)
  	--set
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetType(EFFECT_TYPE_IGNITION)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCountLimit(1, id + o)
  	e3:SetTarget(s.settg)
  	e3:SetOperation(s.setop)
  	c:RegisterEffect(e3)
  	--replace
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_CONTINUOUS + EFFECT_TYPE_FIELD)
  	e4:SetCode(EFFECT_DESTROY_REPLACE)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetTarget(s.desreptg)
  	e4:SetValue(s.desrepval)
  	e4:SetOperation(s.desrepop)
  	c:RegisterEffect(e4)
  end
  function s.spfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEDOWN_DEFENSE)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_HAND + LOCATION_GRAVE, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_HAND + LOCATION_GRAVE)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, aux.NecroValleyFilter(s.spfilter), tp, LOCATION_HAND + LOCATION_GRAVE, 0, 1, 1, nil, e, tp)
  	if #g > 0 and Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEDOWN_DEFENSE) > 0 then
  		Duel.ConfirmCards(1 - tp, g)
  	end
  end
  function s.setfilter(c)
  	return c:IsCode(CARD_ID_1, CARD_ID_0) and c:IsSSetable()
  end
  function s.settg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.setfilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  end
  function s.setop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SET)
  	local g = Duel.SelectMatchingCard(tp, s.setfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if #g > 0 then
  		Duel.SSet(tp, g)
  	end
  end
  function s.desrepfilter(c, tp)
  	return c:IsControler(tp) and c:IsLocation(LOCATION_MZONE) and c:IsReason(REASON_BATTLE + REASON_EFFECT) and not c:IsReason(REASON_REPLACE)
  end
  function s.rfilter(c)
  	return c:IsRace(RACE_REPTILE + RACE_DINOSAUR) and not c:IsStatus(STATUS_DESTROY_CONFIRMED + STATUS_BATTLE_DESTROYED)
  end
  function s.desreptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return eg:IsExists(s.desrepfilter, 1, nil, tp) and Duel.CheckReleaseGroupEx(tp, s.rfilter, 1, REASON_EFFECT, false, nil)
  	end
  	return Duel.SelectEffectYesNo(tp, e:GetHandler(), 96)
  end
  function s.desrepval(e, c)
  	return s.desrepfilter(c, e:GetHandlerPlayer())
  end
  function s.desrepop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESREPLACE)
  	local g = Duel.SelectReleaseGroupEx(tp, s.rfilter, 1, 1, REASON_EFFECT, false, nil)
  	if #g > 0 then
  		Duel.Hint(HINT_CARD, 0, id)
  		Duel.HintSelection(g)
  		Duel.Release(g, REASON_EFFECT + REASON_REPLACE)
  	end
  end
  
  