name: Myutant
card_text: During your opponent's Main Phase, if "Myutant Evolution Lab" is in your Field Zone (Quick Effect): You can Special Summon this card from your hand. If this card is Special Summoned during your opponent's turn: You can Tribute this card, then banish 1 card from your hand or face-up field; Special Summon 1 of your Level 8 "Myutant" monsters that is banished or in your GY. You can only use each effect of "Myutant GB-88" once per turn.
external_ids: local CARD_ID_1 = 34572613 --Myutant Evolution Lab
  local SETCARD_ID_0 = 0x157 --Myutant
  
lua: local CARD_ID_1 = 34572613 --Myutant Evolution Lab
  local SETCARD_ID_0 = 0x157 --Myutant
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_1)
  	--self spsummon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_QUICK_O)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCountLimit(1, id)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_MAIN_END)
  	e1:SetCondition(s.spcon)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--spsummon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetProperty(EFFECT_FLAG_DAMAGE_STEP + EFFECT_FLAG_DELAY)
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetCondition(s.sp2con)
  	e2:SetCost(s.sp2cost)
  	e2:SetTarget(s.sp2tg)
  	e2:SetOperation(s.sp2op)
  	c:RegisterEffect(e2)
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsEnvironment(CARD_ID_1, tp, LOCATION_FZONE) and Duel.GetTurnPlayer() ~= tp and (Duel.GetCurrentPhase() == PHASE_MAIN1 or Duel.GetCurrentPhase() == PHASE_MAIN2)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return c:IsCanBeSpecialSummoned(e, 0, tp, false, false) and Duel.GetMZoneCount(tp) > 0
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, c, 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if not c:IsRelateToEffect(e) then
  		return
  	end
  	Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP)
  end
  function s.sp2con(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetTurnPlayer() ~= tp
  end
  function s.sp2costfilter(c, tp, tc)
  	local tg = Group.FromCards(c, tc)
  	return c:IsAbleToRemoveAsCost() and (c:IsFaceup() or c:IsLocation(LOCATION_HAND)) and Duel.GetMZoneCount(tp, tg) > 0
  end
  function s.sp2cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return c:IsReleasable() and Duel.IsExistingMatchingCard(s.sp2costfilter, tp, LOCATION_HAND + LOCATION_ONFIELD, 0, 1, c, tp, c)
  	end
  	Duel.Release(c, REASON_COST)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local cost = Duel.SelectMatchingCard(tp, s.sp2costfilter, tp, LOCATION_HAND + LOCATION_ONFIELD, 0, 1, 1, c, tp, c)
  	Duel.Remove(cost, POS_FACEUP, REASON_COST)
  end
  function s.sp2tgfilter(c, e, tp)
  	return c:IsCanBeSpecialSummoned(e, 0, tp, false, false) and c:IsSetCard(SETCARD_ID_0) and c:IsLevel(8) and (c:IsFaceup() or c:IsLocation(LOCATION_GRAVE))
  end
  function s.sp2tg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.sp2tgfilter, tp, LOCATION_GRAVE + LOCATION_REMOVED, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_GRAVE + LOCATION_REMOVED)
  end
  function s.sp2op(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 tc = Duel.SelectMatchingCard(tp, aux.NecroValleyFilter(s.sp2tgfilter), tp, LOCATION_GRAVE + LOCATION_REMOVED, 0, 1, 1, nil, e, tp)
  	if tc then
  		Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  
  
source_text: Myutant
  During your opponent's Main Phase, if "Myutant Evolution Lab" is in your Field Zone (Quick Effect): You can Special Summon this card from your hand. If this card is Special Summoned during your opponent's turn: You can Tribute this card, then banish 1 card from your hand or face-up field; Special Summon 1 of your Level 8 "Myutant" monsters that is banished or in your GY. You can only use each effect of "Myutant GB-88" once per turn.
target_text: -- Myutant
  local CARD_ID_1 = 34572613 --Myutant Evolution Lab
  local SETCARD_ID_0 = 0x157 --Myutant
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_1)
  	--self spsummon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_QUICK_O)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCountLimit(1, id)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_MAIN_END)
  	e1:SetCondition(s.spcon)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--spsummon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetProperty(EFFECT_FLAG_DAMAGE_STEP + EFFECT_FLAG_DELAY)
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetCondition(s.sp2con)
  	e2:SetCost(s.sp2cost)
  	e2:SetTarget(s.sp2tg)
  	e2:SetOperation(s.sp2op)
  	c:RegisterEffect(e2)
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsEnvironment(CARD_ID_1, tp, LOCATION_FZONE) and Duel.GetTurnPlayer() ~= tp and (Duel.GetCurrentPhase() == PHASE_MAIN1 or Duel.GetCurrentPhase() == PHASE_MAIN2)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return c:IsCanBeSpecialSummoned(e, 0, tp, false, false) and Duel.GetMZoneCount(tp) > 0
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, c, 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if not c:IsRelateToEffect(e) then
  		return
  	end
  	Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP)
  end
  function s.sp2con(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetTurnPlayer() ~= tp
  end
  function s.sp2costfilter(c, tp, tc)
  	local tg = Group.FromCards(c, tc)
  	return c:IsAbleToRemoveAsCost() and (c:IsFaceup() or c:IsLocation(LOCATION_HAND)) and Duel.GetMZoneCount(tp, tg) > 0
  end
  function s.sp2cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return c:IsReleasable() and Duel.IsExistingMatchingCard(s.sp2costfilter, tp, LOCATION_HAND + LOCATION_ONFIELD, 0, 1, c, tp, c)
  	end
  	Duel.Release(c, REASON_COST)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local cost = Duel.SelectMatchingCard(tp, s.sp2costfilter, tp, LOCATION_HAND + LOCATION_ONFIELD, 0, 1, 1, c, tp, c)
  	Duel.Remove(cost, POS_FACEUP, REASON_COST)
  end
  function s.sp2tgfilter(c, e, tp)
  	return c:IsCanBeSpecialSummoned(e, 0, tp, false, false) and c:IsSetCard(SETCARD_ID_0) and c:IsLevel(8) and (c:IsFaceup() or c:IsLocation(LOCATION_GRAVE))
  end
  function s.sp2tg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.sp2tgfilter, tp, LOCATION_GRAVE + LOCATION_REMOVED, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_GRAVE + LOCATION_REMOVED)
  end
  function s.sp2op(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 tc = Duel.SelectMatchingCard(tp, aux.NecroValleyFilter(s.sp2tgfilter), tp, LOCATION_GRAVE + LOCATION_REMOVED, 0, 1, 1, nil, e, tp)
  	if tc then
  		Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  
  