干掉所有的goto来测试love.js

This commit is contained in:
MrZ_26
2023-06-12 11:42:17 +08:00
parent 91adc0d153
commit 514f0a17b5
13 changed files with 265 additions and 212 deletions

View File

@@ -38,13 +38,15 @@ local function restart()
end
local function checkBoard(b,p)
for i=1,8 do
local testNextLine
for j=1,3 do
if b[lines[i][j]]~=p then
goto CONTINUE_testNextLine
testNextLine=true
break-- goto CONTINUE_testNextLine
end
end
do return true end
::CONTINUE_testNextLine::
if not testNextLine then return true end
-- ::CONTINUE_testNextLine::
end
end
local function full(L)

View File

@@ -127,8 +127,9 @@ local function checkLink(x1,y1,x2,y2)
while ruy>1 and not field[ruy-1][x2] do ruy=ruy-1 end
while rdy<field.r and not field[rdy+1][x2] do rdy=rdy+1 end
for y=max(luy,ruy),min(ldy,rdy) do
for x=x1+1,x2-1 do if field[y][x] then goto CONTINUE_nextRow end end
do
local nextLine
for x=x1+1,x2-1 do if field[y][x] then nextLine=true break end end-- goto CONTINUE_nextRow
if not nextLine then
local len=abs(x1-x2)+abs(y-y1)+abs(y-y2)
if len<bestLen then
bestLen=len
@@ -138,7 +139,7 @@ local function checkLink(x1,y1,x2,y2)
addPoint(bestLine,x2,y2)
end
end
::CONTINUE_nextRow::
-- ::CONTINUE_nextRow::
end
end
-- X-Y-X Check
@@ -150,8 +151,9 @@ local function checkLink(x1,y1,x2,y2)
while dlx>1 and not field[y2][dlx-1] do dlx=dlx-1 end
while drx<field.c and not field[y2][drx+1] do drx=drx+1 end
for x=max(ulx,dlx),min(urx,drx) do
for y=y1+1,y2-1 do if field[y][x] then goto CONTINUE_nextCol end end
do
local nextLine
for y=y1+1,y2-1 do if field[y][x] then nextLine=true break end end-- goto CONTINUE_nextCol
if not nextLine then
local len=abs(y1-y2)+abs(x-x1)+abs(x-x2)
if len<bestLen then
bestLen=len
@@ -161,7 +163,7 @@ local function checkLink(x1,y1,x2,y2)
addPoint(bestLine,x2,y2)
end
end
::CONTINUE_nextCol::
-- ::CONTINUE_nextCol::
end
end
return bestLine

View File

@@ -153,32 +153,34 @@ function player:click(y,x)
SFX.play('touch')
local merged
::REPEAT_merge::
local cur=self.board[y][x]
local b1=TABLE.shift(self.board)
self.mergedTiles={}
local count=self:merge(b1,cur,y,x)
if count>2 then
merged=true
self.board=b1
b1[y][x]=cur+1
repeat-- ::REPEAT_merge::
local repeating
local cur=self.board[y][x]
local b1=TABLE.shift(self.board)
self.mergedTiles={}
local count=self:merge(b1,cur,y,x)
if count>2 then
merged=true
self.board=b1
b1[y][x]=cur+1
if cur+1>self.maxTile then
self.maxTile=cur+1
if self.maxTile>=6 then
ins(self.progress,("%s - %.3fs"):format(self.maxTile,TIME()-player.startTime))
if cur+1>self.maxTile then
self.maxTile=cur+1
if self.maxTile>=6 then
ins(self.progress,("%s - %.3fs"):format(self.maxTile,TIME()-player.startTime))
end
SFX.play('reach')
end
SFX.play('reach')
end
local getScore=4^cur*count
self.score=self.score+getScore
TEXT.show(getScore,player.x+self.selectX*100-50,player.y+self.selectY*100-50,40,'score',1.626/math.log(getScore,3))
for i=1,#self.mergedTiles do
newMergeFX(self.mergedTiles[i][1],self.mergedTiles[i][2],cur+1)
local getScore=4^cur*count
self.score=self.score+getScore
TEXT.show(getScore,player.x+self.selectX*100-50,player.y+self.selectY*100-50,40,'score',1.626/math.log(getScore,3))
for i=1,#self.mergedTiles do
newMergeFX(self.mergedTiles[i][1],self.mergedTiles[i][2],cur+1)
end
repeating=true-- goto REPEAT_merge
end
goto REPEAT_merge
end
until not repeating
ins(self.nexts,self:newTile())

View File

@@ -104,20 +104,23 @@ function scene.keyDown(key,isRep)
elseif key=='v' and kb.isDown('lctrl','rctrl') or key=='cV' then
local str=sys.getClipboardText()
local args=str:sub((str:find(":") or 0)+1):split("!")
if #args<4 then goto THROW_fail end
if not (
DATA.pasteQuestArgs(args[1]) and
DATA.pasteSequence(args[2]) and
DATA.pasteMission(args[3])
) then goto THROW_fail end
TABLE.cut(FIELD)
FIELD[1]=DATA.newBoard()
for i=4,#args do
if args[i]:find("%S") and not DATA.pasteBoard(args[i],i-3) and i<#args then goto THROW_fail end
end
MES.new('check',text.importSuccess)
do return end
::THROW_fail::MES.new('error',text.dataCorrupted)
repeat
if #args<4 then break end-- goto THROW_fail
if not (
DATA.pasteQuestArgs(args[1]) and
DATA.pasteSequence(args[2]) and
DATA.pasteMission(args[3])
) then break end-- goto THROW_fail
TABLE.cut(FIELD)
FIELD[1]=DATA.newBoard()
for i=4,#args do
if args[i]:find("%S") and not DATA.pasteBoard(args[i],i-3) and i<#args then break end-- goto THROW_fail
end
MES.new('check',text.importSuccess)
return
until true
-- ::THROW_fail::
MES.new('error',text.dataCorrupted)
else
return true
end

View File

@@ -195,14 +195,17 @@ function scene.keyDown(key)
local F=FIELD[page]
local cleared=false
for i=#F,1,-1 do
local full
for j=1,10 do
if F[i][j]<=0 then goto CONTINUE_notFull end
if F[i][j]<=0 then full=false break end-- goto CONTINUE_notFull
end
cleared=true
SYSFX.newShade(3,200,660-30*i,300,30)
SYSFX.newRectRipple(3,200,660-30*i,300,30)
rem(F,i)
::CONTINUE_notFull::
if full then
cleared=true
SYSFX.newShade(3,200,660-30*i,300,30)
SYSFX.newRectRipple(3,200,660-30*i,300,30)
rem(F,i)
end
-- ::CONTINUE_notFull::
end
if cleared then
SFX.play('clear_3',.8)

View File

@@ -195,15 +195,19 @@ function scene.touchMove()
for n=1,#keys do
local B=keys[n]
if B.ava then
local nextKey
for i=1,#L,2 do
if (L[i]-B.x)^2+(L[i+1]-B.y)^2<=B.r^2 then
goto CONTINUE_nextKey
nextKey=true
break-- goto CONTINUE_nextKey
end
end
PLAYERS[1]:releaseKey(n)
VK.release(n)
if not nextKey then
PLAYERS[1]:releaseKey(n)
VK.release(n)
end
-- ::CONTINUE_nextKey::
end
::CONTINUE_nextKey::
end
end
function scene.keyDown(key,isRep)

View File

@@ -109,15 +109,19 @@ function scene.touchMove()
for n=1,#keys do
local B=keys[n]
if B.ava then
local nextKey
for i=1,#L,2 do
if (L[i]-B.x)^2+(L[i+1]-B.y)^2<=B.r^2 then
goto CONTINUE_nextKey
nextKey=true
break-- goto CONTINUE_nextKey
end
end
PLAYERS[1]:releaseKey(n)
VK.release(n)
if not nextKey then
PLAYERS[1]:releaseKey(n)
VK.release(n)
end
-- ::CONTINUE_nextKey::
end
::CONTINUE_nextKey::
end
end
function scene.keyDown(key,isRep)