name: The
card_text: Once per turn: You can target 1 face-up Spell/Trap Card; destroy that target. You must control a face-up "Six Samurai" monster with a different name to activate and to resolve this effect. This card cannot declare an attack during the turn this effect is activated. If this card would be destroyed, you can destroy another face-up "Six Samurai" monster you control instead.
external_ids: local SETCARD_ID_0 = 0x103d --Six
  
lua: local SETCARD_ID_0 = 0x103d --Six
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--destroy
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_DESTROY)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1)
  	e1:SetCondition(s.descon)
  	e1:SetCost(s.descost)
  	e1:SetTarget(s.destg)
  	e1:SetOperation(s.desop)
  	c:RegisterEffect(e1)
  	--Destroy replace
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_CONTINUOUS + EFFECT_TYPE_SINGLE)
  	e2:SetCode(EFFECT_DESTROY_REPLACE)
  	e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetTarget(s.desreptg)
  	e2:SetOperation(s.desrepop)
  	c:RegisterEffect(e2)
  end
  function s.cfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and not c:IsCode(id)
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil)
  end
  function s.descost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():GetAttackAnnouncedCount() == 0
  	end
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_CANNOT_ATTACK_ANNOUNCE)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  	e1:SetProperty(EFFECT_FLAG_OATH)
  	e:GetHandler():RegisterEffect(e1)
  end
  function s.desfilter(c)
  	return c:IsFaceup() and c:IsType(TYPE_SPELL + TYPE_TRAP)
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsOnField() and s.desfilter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.desfilter, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local g = Duel.SelectTarget(tp, s.desfilter, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, 1, 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if not Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil) then
  		return
  	end
  	if tc:IsFaceup() and tc:IsRelateToEffect(e) then
  		Duel.Destroy(tc, REASON_EFFECT)
  	end
  end
  function s.repfilter(c, e)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsDestructable(e) and not c:IsStatus(STATUS_DESTROY_CONFIRMED + STATUS_BATTLE_DESTROYED)
  end
  function s.desreptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return not c:IsReason(REASON_REPLACE) and c:IsOnField() and c:IsFaceup() and Duel.IsExistingMatchingCard(s.repfilter, tp, LOCATION_MZONE, 0, 1, c, e)
  	end
  	if Duel.SelectEffectYesNo(tp, c, 96) then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESREPLACE)
  		local g = Duel.SelectMatchingCard(tp, s.repfilter, tp, LOCATION_MZONE, 0, 1, 1, c, e)
  		e:SetLabelObject(g:GetFirst())
  		g:GetFirst():SetStatus(STATUS_DESTROY_CONFIRMED, true)
  		return true
  	else
  		return false
  	end
  end
  function s.desrepop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = e:GetLabelObject()
  	tc:SetStatus(STATUS_DESTROY_CONFIRMED, false)
  	Duel.Destroy(tc, REASON_EFFECT + REASON_REPLACE)
  end
  
  
source_text: The
  Once per turn: You can target 1 face-up Spell/Trap Card; destroy that target. You must control a face-up "Six Samurai" monster with a different name to activate and to resolve this effect. This card cannot declare an attack during the turn this effect is activated. If this card would be destroyed, you can destroy another face-up "Six Samurai" monster you control instead.
target_text: -- The
  local SETCARD_ID_0 = 0x103d --Six
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--destroy
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_DESTROY)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1)
  	e1:SetCondition(s.descon)
  	e1:SetCost(s.descost)
  	e1:SetTarget(s.destg)
  	e1:SetOperation(s.desop)
  	c:RegisterEffect(e1)
  	--Destroy replace
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_CONTINUOUS + EFFECT_TYPE_SINGLE)
  	e2:SetCode(EFFECT_DESTROY_REPLACE)
  	e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetTarget(s.desreptg)
  	e2:SetOperation(s.desrepop)
  	c:RegisterEffect(e2)
  end
  function s.cfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and not c:IsCode(id)
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil)
  end
  function s.descost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():GetAttackAnnouncedCount() == 0
  	end
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_CANNOT_ATTACK_ANNOUNCE)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  	e1:SetProperty(EFFECT_FLAG_OATH)
  	e:GetHandler():RegisterEffect(e1)
  end
  function s.desfilter(c)
  	return c:IsFaceup() and c:IsType(TYPE_SPELL + TYPE_TRAP)
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsOnField() and s.desfilter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.desfilter, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local g = Duel.SelectTarget(tp, s.desfilter, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, 1, 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if not Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil) then
  		return
  	end
  	if tc:IsFaceup() and tc:IsRelateToEffect(e) then
  		Duel.Destroy(tc, REASON_EFFECT)
  	end
  end
  function s.repfilter(c, e)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsDestructable(e) and not c:IsStatus(STATUS_DESTROY_CONFIRMED + STATUS_BATTLE_DESTROYED)
  end
  function s.desreptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return not c:IsReason(REASON_REPLACE) and c:IsOnField() and c:IsFaceup() and Duel.IsExistingMatchingCard(s.repfilter, tp, LOCATION_MZONE, 0, 1, c, e)
  	end
  	if Duel.SelectEffectYesNo(tp, c, 96) then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESREPLACE)
  		local g = Duel.SelectMatchingCard(tp, s.repfilter, tp, LOCATION_MZONE, 0, 1, 1, c, e)
  		e:SetLabelObject(g:GetFirst())
  		g:GetFirst():SetStatus(STATUS_DESTROY_CONFIRMED, true)
  		return true
  	else
  		return false
  	end
  end
  function s.desrepop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = e:GetLabelObject()
  	tc:SetStatus(STATUS_DESTROY_CONFIRMED, false)
  	Duel.Destroy(tc, REASON_EFFECT + REASON_REPLACE)
  end
  
  