修复小程序2048之前在删goto时造成的逻辑错误

This commit is contained in:
MrZ626
2021-04-13 00:26:02 +08:00
parent ca68a8ef87
commit 832c09980a

View File

@@ -128,33 +128,34 @@ local function squash(L)
local moved=false
while true do
p2=p1+1
while not L[p2]do
while not L[p2]and p2<5 do
p2=p2+1
if p2==5 then
p1=p1+1
if p1==4 then
return L[1],L[2],L[3],L[4],moved
end
break
end
end
if not L[p1]then--air←2
L[p1],L[p2]=L[p2],false
moved=true
elseif L[p1]==L[p2]then--2←2
L[p1],L[p2]=L[p1]+1,false
if L[p1]>maxTile then
freshMaxTile()
if p2==5 then
if p1==4 then
return L[1],L[2],L[3],L[4],moved
else
p1=p1+1
end
else
if not L[p1]then--air←2
L[p1],L[p2]=L[p2],false
moved=true
elseif L[p1]==L[p2]then--2←2
L[p1],L[p2]=L[p1]+1,false
if L[p1]>maxTile then
freshMaxTile()
end
L[p2]=false
p1=p1+1
moved=true
elseif p1+1~=p2 then--2←4
L[p1+1],L[p2]=L[p2],false
p1=p1+1
moved=true
else--2,4
p1=p1+1
end
L[p2]=false
p1=p1+1
moved=true
elseif p1+1~=p2 then--2←4
L[p1+1],L[p2]=L[p2],false
p1=p1+1
moved=true
else--2,4
p1=p1+1
end
end
end