name: Shiranui
card_text: Once per turn, if you control no monsters: You can send 1 card from your hand to the Graveyard, then activate 1 of these effects.
  ● Target 1 Zombie-Type monster with 0 DEF in your Graveyard; Special Summon it.
  ● Target 1 of your banished Zombie-Type monsters with 0 DEF; return it to the Graveyard.
  You can only activate 1 "Shiranui Style Synthesis" per turn.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	c:RegisterEffect(e1)
  	--special summon&tograve
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetCountLimit(1)
  	e2:SetRange(LOCATION_FZONE)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetCondition(s.condition)
  	e2:SetCost(s.cost)
  	e2:SetTarget(s.target)
  	e2:SetOperation(s.operation)
  	c:RegisterEffect(e2)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetFieldGroupCount(tp, LOCATION_MZONE, 0) == 0
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsAbleToGraveAsCost, tp, LOCATION_HAND, 0, 1, nil)
  	end
  	Duel.DiscardHand(tp, Card.IsAbleToGraveAsCost, 1, 1, REASON_COST)
  end
  function s.filter1(c, e, tp)
  	return c:IsRace(RACE_ZOMBIE) and c:IsDefense(0) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.filter2(c)
  	return c:IsFaceup() and c:IsRace(RACE_ZOMBIE) and c:IsDefense(0)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		if e:GetLabel() == 0 then
  			return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.filter1(chkc, e, tp)
  		else
  			return chkc:IsLocation(LOCATION_REMOVED) and chkc:IsControler(tp) and s.filter2(chkc)
  		end
  	end
  	local b1 = Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingTarget(s.filter1, tp, LOCATION_GRAVE, 0, 1, nil, e, tp)
  	local b2 = Duel.IsExistingTarget(s.filter2, tp, LOCATION_REMOVED, 0, 1, nil)
  	if chk == 0 then
  		return b1 or b2
  	end
  	local op = 0
  	if b1 and b2 then
  		op = Duel.SelectOption(tp, aux.Stringid(id, 0), aux.Stringid(id, 1))
  	elseif b1 then
  		op = Duel.SelectOption(tp, aux.Stringid(id, 0))
  	else
  		op = Duel.SelectOption(tp, aux.Stringid(id, 1)) + 1
  	end
  	e:SetLabel(op)
  	if op == 0 then
  		e:SetCategory(CATEGORY_SPECIAL_SUMMON)
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local g = Duel.SelectTarget(tp, s.filter1, tp, LOCATION_GRAVE, 0, 1, 1, nil, e, tp)
  		Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, g, 1, 0, 0)
  	else
  		e:SetCategory(CATEGORY_TOGRAVE)
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  		local g = Duel.SelectTarget(tp, s.filter2, tp, LOCATION_REMOVED, 0, 1, 1, nil)
  		Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, g, 1, 0, 0)
  	end
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if e:GetLabel() == 0 then
  		if tc:IsRelateToEffect(e) then
  			Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP)
  		end
  	else
  		if tc:IsRelateToEffect(e) then
  			Duel.SendtoGrave(tc, REASON_EFFECT + REASON_RETURN)
  		end
  	end
  end
  
  
source_text: Shiranui
  Once per turn, if you control no monsters: You can send 1 card from your hand to the Graveyard, then activate 1 of these effects.
  ● Target 1 Zombie-Type monster with 0 DEF in your Graveyard; Special Summon it.
  ● Target 1 of your banished Zombie-Type monsters with 0 DEF; return it to the Graveyard.
  You can only activate 1 "Shiranui Style Synthesis" per turn.
target_text: -- Shiranui
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	c:RegisterEffect(e1)
  	--special summon&tograve
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetCountLimit(1)
  	e2:SetRange(LOCATION_FZONE)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetCondition(s.condition)
  	e2:SetCost(s.cost)
  	e2:SetTarget(s.target)
  	e2:SetOperation(s.operation)
  	c:RegisterEffect(e2)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetFieldGroupCount(tp, LOCATION_MZONE, 0) == 0
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsAbleToGraveAsCost, tp, LOCATION_HAND, 0, 1, nil)
  	end
  	Duel.DiscardHand(tp, Card.IsAbleToGraveAsCost, 1, 1, REASON_COST)
  end
  function s.filter1(c, e, tp)
  	return c:IsRace(RACE_ZOMBIE) and c:IsDefense(0) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.filter2(c)
  	return c:IsFaceup() and c:IsRace(RACE_ZOMBIE) and c:IsDefense(0)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		if e:GetLabel() == 0 then
  			return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.filter1(chkc, e, tp)
  		else
  			return chkc:IsLocation(LOCATION_REMOVED) and chkc:IsControler(tp) and s.filter2(chkc)
  		end
  	end
  	local b1 = Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingTarget(s.filter1, tp, LOCATION_GRAVE, 0, 1, nil, e, tp)
  	local b2 = Duel.IsExistingTarget(s.filter2, tp, LOCATION_REMOVED, 0, 1, nil)
  	if chk == 0 then
  		return b1 or b2
  	end
  	local op = 0
  	if b1 and b2 then
  		op = Duel.SelectOption(tp, aux.Stringid(id, 0), aux.Stringid(id, 1))
  	elseif b1 then
  		op = Duel.SelectOption(tp, aux.Stringid(id, 0))
  	else
  		op = Duel.SelectOption(tp, aux.Stringid(id, 1)) + 1
  	end
  	e:SetLabel(op)
  	if op == 0 then
  		e:SetCategory(CATEGORY_SPECIAL_SUMMON)
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local g = Duel.SelectTarget(tp, s.filter1, tp, LOCATION_GRAVE, 0, 1, 1, nil, e, tp)
  		Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, g, 1, 0, 0)
  	else
  		e:SetCategory(CATEGORY_TOGRAVE)
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  		local g = Duel.SelectTarget(tp, s.filter2, tp, LOCATION_REMOVED, 0, 1, 1, nil)
  		Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, g, 1, 0, 0)
  	end
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if e:GetLabel() == 0 then
  		if tc:IsRelateToEffect(e) then
  			Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP)
  		end
  	else
  		if tc:IsRelateToEffect(e) then
  			Duel.SendtoGrave(tc, REASON_EFFECT + REASON_RETURN)
  		end
  	end
  end
  
  