name: Rampaging
card_text: Once per turn, this card can move to an adjacent (horizontal) unoccupied Monster Card Zone. If this card attacks the monster in its same column, this card gains 500 ATK during the Damage Step.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--move
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1)
  	e1:SetCondition(s.seqcon)
  	e1:SetTarget(s.seqtg)
  	e1:SetOperation(s.seqop)
  	c:RegisterEffect(e1)
  	--
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCode(EFFECT_UPDATE_ATTACK)
  	e2:SetCondition(s.atkcon)
  	e2:SetValue(500)
  	c:RegisterEffect(e2)
  end
  function s.seqcon(e, tp, eg, ep, ev, re, r, rp)
  	local seq = e:GetHandler():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.seqtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	local seq = e:GetHandler():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 c = e:GetHandler()
  	local seq = e:GetLabel()
  	if not c:IsRelateToEffect(e) or c:IsControler(1 - tp) or c:GetSequence() > 4 or not Duel.CheckLocation(tp, LOCATION_MZONE, seq) then
  		return
  	end
  	Duel.MoveSequence(c, seq)
  end
  function s.atkcon(e)
  	local ph = Duel.GetCurrentPhase()
  	local c = e:GetHandler()
  	local at = Duel.GetAttackTarget()
  	if (ph == PHASE_DAMAGE or ph == PHASE_DAMAGE_CAL) and Duel.GetAttacker() == c and at then
  		return c:GetColumnGroup():IsContains(at)
  	else
  		return false
  	end
  end
  
  
source_text: Rampaging
  Once per turn, this card can move to an adjacent (horizontal) unoccupied Monster Card Zone. If this card attacks the monster in its same column, this card gains 500 ATK during the Damage Step.
target_text: -- Rampaging
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--move
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1)
  	e1:SetCondition(s.seqcon)
  	e1:SetTarget(s.seqtg)
  	e1:SetOperation(s.seqop)
  	c:RegisterEffect(e1)
  	--
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCode(EFFECT_UPDATE_ATTACK)
  	e2:SetCondition(s.atkcon)
  	e2:SetValue(500)
  	c:RegisterEffect(e2)
  end
  function s.seqcon(e, tp, eg, ep, ev, re, r, rp)
  	local seq = e:GetHandler():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.seqtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	local seq = e:GetHandler():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 c = e:GetHandler()
  	local seq = e:GetLabel()
  	if not c:IsRelateToEffect(e) or c:IsControler(1 - tp) or c:GetSequence() > 4 or not Duel.CheckLocation(tp, LOCATION_MZONE, seq) then
  		return
  	end
  	Duel.MoveSequence(c, seq)
  end
  function s.atkcon(e)
  	local ph = Duel.GetCurrentPhase()
  	local c = e:GetHandler()
  	local at = Duel.GetAttackTarget()
  	if (ph == PHASE_DAMAGE or ph == PHASE_DAMAGE_CAL) and Duel.GetAttacker() == c and at then
  		return c:GetColumnGroup():IsContains(at)
  	else
  		return false
  	end
  end
  
  