name: Snake-Eye
card_text: If this card is Normal or Special Summoned: You can target 1 of your Level 1 FIRE monsters that is banished or in your GY; either add it to your hand or Special Summon it. You can send 2 face-up cards you control to the GY, including this card; Special Summon 1 "Snake-Eye" monster from your hand or Deck, except "Snake-Eye Oak". You can only use each effect of "Snake-Eye Oak" once per turn.
external_ids: local SETCARD_ID_0 = 0x19c --Snake-Eye
  
lua: local SETCARD_ID_0 = 0x19c --Snake-Eye
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--revive
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_SUMMON_SUCCESS)
  	e1:SetCountLimit(1, id)
  	e1:SetProperty(EFFECT_FLAG_DELAY + EFFECT_FLAG_CARD_TARGET)
  	e1:SetTarget(s.rvtg)
  	e1:SetOperation(s.rvop)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	c:RegisterEffect(e2)
  	--spsummon
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e3:SetType(EFFECT_TYPE_IGNITION)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCountLimit(1, id + o)
  	e3:SetCost(s.cost)
  	e3:SetTarget(s.sptg)
  	e3:SetOperation(s.spop)
  	c:RegisterEffect(e3)
  end
  function s.filter(c, e, tp)
  	return c:IsFaceupEx()
  		and c:IsLevel(1)
  		and c:IsAttribute(ATTRIBUTE_FIRE)
  		and (c:IsAbleToHand() or Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and c:IsCanBeSpecialSummoned(e, 0, tp, false, false))
  end
  function s.rvtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE + LOCATION_REMOVED) and chkc:IsControler(tp) and s.filter(chkc, e, tp)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_GRAVE + LOCATION_REMOVED, 0, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	local tc = Duel.SelectTarget(tp, s.filter, tp, LOCATION_GRAVE + LOCATION_REMOVED, 0, 1, 1, nil, e, tp):GetFirst()
  	if tc:IsLocation(LOCATION_GRAVE) then
  		e:SetCategory(CATEGORY_TOHAND + CATEGORY_SPECIAL_SUMMON + CATEGORY_GRAVE_ACTION + CATEGORY_GRAVE_SPSUMMON)
  		Duel.SetOperationInfo(0, CATEGORY_LEAVE_GRAVE, tc, 1, 0, 0)
  	else
  		e:SetCategory(CATEGORY_TOHAND + CATEGORY_SPECIAL_SUMMON)
  	end
  end
  function s.rvop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if not tc:IsRelateToEffect(e) then
  		return
  	end
  	local op = aux.SelectFromOptions(tp, { tc:IsAbleToHand(), 1190 }, { Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and tc:IsCanBeSpecialSummoned(e, 0, tp, false, false), 1152 })
  	if op == 1 then
  		Duel.SendtoHand(tc, nil, REASON_EFFECT)
  	elseif op == 2 then
  		Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  function s.cfilter(c, tc, tp)
  	return c:IsFaceup() and c:IsAbleToGraveAsCost() and Duel.GetMZoneCount(tp, Group.FromCards(c, tc)) > 0
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return c:IsAbleToGraveAsCost() and Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_ONFIELD, 0, 1, c, c, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local g = Duel.SelectMatchingCard(tp, s.cfilter, tp, LOCATION_ONFIELD, 0, 1, 1, c, c, tp) + c
  	Duel.SendtoGrave(g, REASON_COST)
  end
  function s.sfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false) and not c:IsCode(id)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return (e:IsCostChecked() or Duel.GetLocationCount(tp, LOCATION_MZONE) > 0) and Duel.IsExistingMatchingCard(s.sfilter, tp, LOCATION_DECK + LOCATION_HAND, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_DECK + LOCATION_HAND)
  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, s.sfilter, tp, LOCATION_DECK + LOCATION_HAND, 0, 1, 1, nil, e, tp)
  	Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP)
  end
  
  
source_text: Snake-Eye
  If this card is Normal or Special Summoned: You can target 1 of your Level 1 FIRE monsters that is banished or in your GY; either add it to your hand or Special Summon it. You can send 2 face-up cards you control to the GY, including this card; Special Summon 1 "Snake-Eye" monster from your hand or Deck, except "Snake-Eye Oak". You can only use each effect of "Snake-Eye Oak" once per turn.
target_text: -- Snake-Eye
  local SETCARD_ID_0 = 0x19c --Snake-Eye
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--revive
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_SUMMON_SUCCESS)
  	e1:SetCountLimit(1, id)
  	e1:SetProperty(EFFECT_FLAG_DELAY + EFFECT_FLAG_CARD_TARGET)
  	e1:SetTarget(s.rvtg)
  	e1:SetOperation(s.rvop)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	c:RegisterEffect(e2)
  	--spsummon
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e3:SetType(EFFECT_TYPE_IGNITION)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCountLimit(1, id + o)
  	e3:SetCost(s.cost)
  	e3:SetTarget(s.sptg)
  	e3:SetOperation(s.spop)
  	c:RegisterEffect(e3)
  end
  function s.filter(c, e, tp)
  	return c:IsFaceupEx()
  		and c:IsLevel(1)
  		and c:IsAttribute(ATTRIBUTE_FIRE)
  		and (c:IsAbleToHand() or Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and c:IsCanBeSpecialSummoned(e, 0, tp, false, false))
  end
  function s.rvtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE + LOCATION_REMOVED) and chkc:IsControler(tp) and s.filter(chkc, e, tp)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_GRAVE + LOCATION_REMOVED, 0, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	local tc = Duel.SelectTarget(tp, s.filter, tp, LOCATION_GRAVE + LOCATION_REMOVED, 0, 1, 1, nil, e, tp):GetFirst()
  	if tc:IsLocation(LOCATION_GRAVE) then
  		e:SetCategory(CATEGORY_TOHAND + CATEGORY_SPECIAL_SUMMON + CATEGORY_GRAVE_ACTION + CATEGORY_GRAVE_SPSUMMON)
  		Duel.SetOperationInfo(0, CATEGORY_LEAVE_GRAVE, tc, 1, 0, 0)
  	else
  		e:SetCategory(CATEGORY_TOHAND + CATEGORY_SPECIAL_SUMMON)
  	end
  end
  function s.rvop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if not tc:IsRelateToEffect(e) then
  		return
  	end
  	local op = aux.SelectFromOptions(tp, { tc:IsAbleToHand(), 1190 }, { Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and tc:IsCanBeSpecialSummoned(e, 0, tp, false, false), 1152 })
  	if op == 1 then
  		Duel.SendtoHand(tc, nil, REASON_EFFECT)
  	elseif op == 2 then
  		Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  function s.cfilter(c, tc, tp)
  	return c:IsFaceup() and c:IsAbleToGraveAsCost() and Duel.GetMZoneCount(tp, Group.FromCards(c, tc)) > 0
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return c:IsAbleToGraveAsCost() and Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_ONFIELD, 0, 1, c, c, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local g = Duel.SelectMatchingCard(tp, s.cfilter, tp, LOCATION_ONFIELD, 0, 1, 1, c, c, tp) + c
  	Duel.SendtoGrave(g, REASON_COST)
  end
  function s.sfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false) and not c:IsCode(id)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return (e:IsCostChecked() or Duel.GetLocationCount(tp, LOCATION_MZONE) > 0) and Duel.IsExistingMatchingCard(s.sfilter, tp, LOCATION_DECK + LOCATION_HAND, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_DECK + LOCATION_HAND)
  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, s.sfilter, tp, LOCATION_DECK + LOCATION_HAND, 0, 1, 1, nil, e, tp)
  	Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP)
  end
  
  