name: Senet
card_text: Once per turn: You can target 1 monster in your Main Monster Zone and choose 1 of its unused adjacent (horizontal) Monster Zones; move that target to the chosen adjacent zone.
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)
  	c:RegisterEffect(e1)
  	--move
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetCountLimit(1)
  	e2:SetTarget(s.seqtg)
  	e2:SetOperation(s.seqop)
  	c:RegisterEffect(e2)
  end
  function s.filter(c, tp)
  	local seq = c:GetSequence()
  	if seq > 4 then
  		return false
  	end
  	return (seq > 0 and Duel.CheckLocation(tp, LOCATION_MZONE, seq - 1)) or (seq < 4 and Duel.CheckLocation(tp, LOCATION_MZONE, seq + 1))
  end
  function s.chkfilter(c, cseq)
  	local seq = c:GetSequence()
  	return seq < 5 and math.abs(seq - cseq) == 1
  end
  function s.seqtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.chkfilter(chkc, e:GetLabel())
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_MZONE, 0, 1, nil, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, aux.Stringid(id, 1))
  	local g = Duel.SelectTarget(tp, s.filter, tp, LOCATION_MZONE, 0, 1, 1, nil, tp)
  	local seq = g:GetFirst():GetSequence()
  	local flag = 0
  	if seq > 0 and Duel.CheckLocation(tp, LOCATION_MZONE, seq - 1) then
  		flag = flag | (1 << (seq - 1))
  	end
  	if seq < 4 and Duel.CheckLocation(tp, LOCATION_MZONE, seq + 1) then
  		flag = flag | (1 << (seq + 1))
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOZONE)
  	local s = Duel.SelectDisableField(tp, 1, LOCATION_MZONE, 0, ~flag)
  	local nseq = math.log(s, 2)
  	e:SetLabel(nseq)
  	Duel.Hint(HINT_ZONE, tp, s)
  end
  function s.seqop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	local seq = e:GetLabel()
  	local tseq = tc:GetSequence()
  	if not tc:IsRelateToEffect(e) or tc:IsControler(1 - tp) or tseq > 4 or math.abs(tseq - seq) ~= 1 or not Duel.CheckLocation(tp, LOCATION_MZONE, seq) then
  		return
  	end
  	Duel.MoveSequence(tc, seq)
  end
  
  
source_text: Senet
  Once per turn: You can target 1 monster in your Main Monster Zone and choose 1 of its unused adjacent (horizontal) Monster Zones; move that target to the chosen adjacent zone.
target_text: -- Senet
  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)
  	c:RegisterEffect(e1)
  	--move
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetCountLimit(1)
  	e2:SetTarget(s.seqtg)
  	e2:SetOperation(s.seqop)
  	c:RegisterEffect(e2)
  end
  function s.filter(c, tp)
  	local seq = c:GetSequence()
  	if seq > 4 then
  		return false
  	end
  	return (seq > 0 and Duel.CheckLocation(tp, LOCATION_MZONE, seq - 1)) or (seq < 4 and Duel.CheckLocation(tp, LOCATION_MZONE, seq + 1))
  end
  function s.chkfilter(c, cseq)
  	local seq = c:GetSequence()
  	return seq < 5 and math.abs(seq - cseq) == 1
  end
  function s.seqtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.chkfilter(chkc, e:GetLabel())
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_MZONE, 0, 1, nil, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, aux.Stringid(id, 1))
  	local g = Duel.SelectTarget(tp, s.filter, tp, LOCATION_MZONE, 0, 1, 1, nil, tp)
  	local seq = g:GetFirst():GetSequence()
  	local flag = 0
  	if seq > 0 and Duel.CheckLocation(tp, LOCATION_MZONE, seq - 1) then
  		flag = flag | (1 << (seq - 1))
  	end
  	if seq < 4 and Duel.CheckLocation(tp, LOCATION_MZONE, seq + 1) then
  		flag = flag | (1 << (seq + 1))
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOZONE)
  	local s = Duel.SelectDisableField(tp, 1, LOCATION_MZONE, 0, ~flag)
  	local nseq = math.log(s, 2)
  	e:SetLabel(nseq)
  	Duel.Hint(HINT_ZONE, tp, s)
  end
  function s.seqop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	local seq = e:GetLabel()
  	local tseq = tc:GetSequence()
  	if not tc:IsRelateToEffect(e) or tc:IsControler(1 - tp) or tseq > 4 or math.abs(tseq - seq) ~= 1 or not Duel.CheckLocation(tp, LOCATION_MZONE, seq) then
  		return
  	end
  	Duel.MoveSequence(tc, seq)
  end
  
  