修正解除自定义场地绘制高度限制后出现的其他衍生问题
“自定义场地页面”使用元表实现自动补充尺寸(编辑之后需要手动清空多余空行,目前仅一处)
This commit is contained in:
@@ -60,32 +60,21 @@ function DATA.pasteSequence(str)
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
function DATA.newBoard(f)--Generate a new board
|
local fieldMeta={__index=function(self,h)
|
||||||
if f then
|
for i=#self+1,h do
|
||||||
return TABLE.shift(f)
|
self[i]={0,0,0,0,0,0,0,0,0,0}
|
||||||
else
|
|
||||||
local F={}
|
|
||||||
for i=1,20 do F[i]={0,0,0,0,0,0,0,0,0,0}end
|
|
||||||
return F
|
|
||||||
end
|
end
|
||||||
|
return self[h]
|
||||||
|
end}
|
||||||
|
function DATA.newBoard(f)--Generate a new board
|
||||||
|
return setmetatable(f and TABLE.shift(f)or{},fieldMeta)
|
||||||
end
|
end
|
||||||
function DATA.copyBoard(page)--Copy the [page] board
|
function DATA.copyBoard(page)--Copy the [page] board
|
||||||
local F=FIELD[page or 1]
|
local F=FIELD[page or 1]
|
||||||
local str=""
|
local str=""
|
||||||
local H=0
|
|
||||||
|
|
||||||
for y=20,1,-1 do
|
|
||||||
for x=1,10 do
|
|
||||||
if F[y][x]~=0 then
|
|
||||||
H=y
|
|
||||||
goto BREAK_topFound
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
::BREAK_topFound::
|
|
||||||
|
|
||||||
--Encode field
|
--Encode field
|
||||||
for y=1,H do
|
for y=1,#F do
|
||||||
local S=""
|
local S=""
|
||||||
local L=F[y]
|
local L=F[y]
|
||||||
for x=1,10 do
|
for x=1,10 do
|
||||||
@@ -144,12 +133,6 @@ function DATA.pasteBoard(str,page)--Paste [str] data to [page] board
|
|||||||
p=p+1
|
p=p+1
|
||||||
end
|
end
|
||||||
|
|
||||||
for y=fY,20 do
|
|
||||||
for x=1,10 do
|
|
||||||
F[y][x]=0
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -4,15 +4,12 @@ return{
|
|||||||
load=function()
|
load=function()
|
||||||
applyCustomGame()
|
applyCustomGame()
|
||||||
|
|
||||||
for y=1,20 do
|
--Switch clear sprint mode on
|
||||||
if notEmptyLine(FIELD[1][y])then
|
if #FIELD[1]>0 then
|
||||||
--Switch clear sprint mode on
|
GAME.modeEnv.dropPiece=require'parts.eventsets.checkClearBoard'.dropPiece
|
||||||
GAME.modeEnv.dropPiece=require'parts.eventsets.checkClearBoard'.dropPiece
|
else
|
||||||
goto BREAK_clearMode
|
GAME.modeEnv.dropPiece=NULL
|
||||||
end
|
|
||||||
end
|
end
|
||||||
GAME.modeEnv.dropPiece=NULL
|
|
||||||
::BREAK_clearMode::
|
|
||||||
PLY.newPlayer(1)
|
PLY.newPlayer(1)
|
||||||
local AItype=GAME.modeEnv.opponent:sub(1,2)
|
local AItype=GAME.modeEnv.opponent:sub(1,2)
|
||||||
local AIlevel=tonumber(GAME.modeEnv.opponent:sub(-1))
|
local AIlevel=tonumber(GAME.modeEnv.opponent:sub(-1))
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ return{
|
|||||||
dropPiece=function(P)
|
dropPiece=function(P)
|
||||||
local D=P.modeData
|
local D=P.modeData
|
||||||
local F=FIELD[D.finished+1]
|
local F=FIELD[D.finished+1]
|
||||||
for y=1,20 do
|
for y=1,#F do
|
||||||
local L=P.field[y]
|
local L=P.field[y]
|
||||||
for x=1,10 do
|
for x=1,10 do
|
||||||
local a,b=F[y][x],L and L[x]or 0
|
local a,b=F[y][x],L and L[x]or 0
|
||||||
@@ -42,7 +42,7 @@ return{
|
|||||||
local mark=TEXTURE.puzzleMark
|
local mark=TEXTURE.puzzleMark
|
||||||
local F=FIELD[P.modeData.finished+1]
|
local F=FIELD[P.modeData.finished+1]
|
||||||
gc_setColor(1,1,1)
|
gc_setColor(1,1,1)
|
||||||
for y=1,20 do for x=1,10 do
|
for y=1,#F do for x=1,10 do
|
||||||
local T=F[y][x]
|
local T=F[y][x]
|
||||||
if T~=0 then
|
if T~=0 then
|
||||||
gc_draw(mark[T],30*x-30,600-30*y)
|
gc_draw(mark[T],30*x-30,600-30*y)
|
||||||
|
|||||||
@@ -2,13 +2,6 @@ local gc,kb,sys=love.graphics,love.keyboard,love.system
|
|||||||
local int=math.floor
|
local int=math.floor
|
||||||
local CUSTOMENV=CUSTOMENV
|
local CUSTOMENV=CUSTOMENV
|
||||||
|
|
||||||
local function _notAir(L)
|
|
||||||
for i=1,10 do
|
|
||||||
if L[i]>0 then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local sList={
|
local sList={
|
||||||
visible={"show","easy","slow","medium","fast","none"},
|
visible={"show","easy","slow","medium","fast","none"},
|
||||||
freshLimit={0,1,2,4,6,8,10,12,15,30,1e99},
|
freshLimit={0,1,2,4,6,8,10,12,15,30,1e99},
|
||||||
@@ -30,22 +23,11 @@ local sList={
|
|||||||
local scene={}
|
local scene={}
|
||||||
|
|
||||||
local sure
|
local sure
|
||||||
local initField
|
|
||||||
local function _freshMiniFieldVisible()
|
|
||||||
initField=false
|
|
||||||
for y=1,20 do
|
|
||||||
if _notAir(FIELD[1][y])then
|
|
||||||
initField=true
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
function scene.sceneInit()
|
function scene.sceneInit()
|
||||||
sure=0
|
sure=0
|
||||||
destroyPlayers()
|
destroyPlayers()
|
||||||
BG.set(CUSTOMENV.bg)
|
BG.set(CUSTOMENV.bg)
|
||||||
BGM.play(CUSTOMENV.bgm)
|
BGM.play(CUSTOMENV.bgm)
|
||||||
_freshMiniFieldVisible()
|
|
||||||
end
|
end
|
||||||
function scene.sceneBack()
|
function scene.sceneBack()
|
||||||
BGM.play()
|
BGM.play()
|
||||||
@@ -79,7 +61,7 @@ function scene.keyDown(key,isRep)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if key=="return2"or kb.isDown("lalt","lctrl","lshift")then
|
if key=="return2"or kb.isDown("lalt","lctrl","lshift")then
|
||||||
if initField then
|
if #FIELD[1]>0 then
|
||||||
FILE.save(CUSTOMENV,'conf/customEnv')
|
FILE.save(CUSTOMENV,'conf/customEnv')
|
||||||
loadGame('custom_puzzle',true)
|
loadGame('custom_puzzle',true)
|
||||||
end
|
end
|
||||||
@@ -97,7 +79,6 @@ function scene.keyDown(key,isRep)
|
|||||||
if sure>.3 then
|
if sure>.3 then
|
||||||
TABLE.cut(FIELD)TABLE.cut(BAG)TABLE.cut(MISSION)
|
TABLE.cut(FIELD)TABLE.cut(BAG)TABLE.cut(MISSION)
|
||||||
FIELD[1]=DATA.newBoard()
|
FIELD[1]=DATA.newBoard()
|
||||||
_freshMiniFieldVisible()
|
|
||||||
TABLE.clear(CUSTOMENV)
|
TABLE.clear(CUSTOMENV)
|
||||||
TABLE.complete(require"parts.customEnv0",CUSTOMENV)
|
TABLE.complete(require"parts.customEnv0",CUSTOMENV)
|
||||||
for _,W in next,scene.widgetList do W:reset()end
|
for _,W in next,scene.widgetList do W:reset()end
|
||||||
@@ -135,7 +116,6 @@ function scene.keyDown(key,isRep)
|
|||||||
for i=4,#args do
|
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
|
if args[i]:find("%S")and not DATA.pasteBoard(args[i],i-3)and i<#args then goto THROW_fail end
|
||||||
end
|
end
|
||||||
_freshMiniFieldVisible()
|
|
||||||
MES.new('check',text.importSuccess)
|
MES.new('check',text.importSuccess)
|
||||||
do return end
|
do return end
|
||||||
::THROW_fail::MES.new('error',text.dataCorrupted)
|
::THROW_fail::MES.new('error',text.dataCorrupted)
|
||||||
@@ -162,7 +142,7 @@ function scene.draw()
|
|||||||
end
|
end
|
||||||
|
|
||||||
--Field content
|
--Field content
|
||||||
if initField then
|
if #FIELD[1]>0 then
|
||||||
gc.push('transform')
|
gc.push('transform')
|
||||||
gc.translate(330,240)
|
gc.translate(330,240)
|
||||||
gc.scale(.5)
|
gc.scale(.5)
|
||||||
@@ -172,7 +152,7 @@ function scene.draw()
|
|||||||
local F=FIELD[1]
|
local F=FIELD[1]
|
||||||
local cross=TEXTURE.puzzleMark[-1]
|
local cross=TEXTURE.puzzleMark[-1]
|
||||||
local texture=SKIN.lib[SETTING.skinSet]
|
local texture=SKIN.lib[SETTING.skinSet]
|
||||||
for y=1,20 do for x=1,10 do
|
for y=1,#F do for x=1,10 do
|
||||||
local B=F[y][x]
|
local B=F[y][x]
|
||||||
if B>0 then
|
if B>0 then
|
||||||
gc.draw(texture[B],30*x-30,600-30*y)
|
gc.draw(texture[B],30*x-30,600-30*y)
|
||||||
@@ -240,7 +220,7 @@ scene.widgetList={
|
|||||||
WIDGET.newButton{name="copy", x=1070,y=300,w=310,h=70,color='lR',font=25,code=pressKey"cC"},
|
WIDGET.newButton{name="copy", x=1070,y=300,w=310,h=70,color='lR',font=25,code=pressKey"cC"},
|
||||||
WIDGET.newButton{name="paste", x=1070,y=380,w=310,h=70,color='lB',font=25,code=pressKey"cV"},
|
WIDGET.newButton{name="paste", x=1070,y=380,w=310,h=70,color='lB',font=25,code=pressKey"cV"},
|
||||||
WIDGET.newButton{name="clear", x=1070,y=460,w=310,h=70,color='lY',font=35,code=pressKey"return"},
|
WIDGET.newButton{name="clear", x=1070,y=460,w=310,h=70,color='lY',font=35,code=pressKey"return"},
|
||||||
WIDGET.newButton{name="puzzle", x=1070,y=540,w=310,h=70,color='lM',font=35,code=pressKey"return2",hideF=function()return not initField end},
|
WIDGET.newButton{name="puzzle", x=1070,y=540,w=310,h=70,color='lM',font=35,code=pressKey"return2",hideF=function()return #FIELD[1]==0 end},
|
||||||
WIDGET.newButton{name="back", x=1140,y=640,w=170,h=80,fText=TEXTURE.back,code=pressKey"escape"},
|
WIDGET.newButton{name="back", x=1140,y=640,w=170,h=80,fText=TEXTURE.back,code=pressKey"escape"},
|
||||||
|
|
||||||
--Rule set
|
--Rule set
|
||||||
|
|||||||
@@ -16,6 +16,12 @@ local penX,penY
|
|||||||
local demo--If show x
|
local demo--If show x
|
||||||
local page
|
local page
|
||||||
|
|
||||||
|
local function isEmpty(L)
|
||||||
|
for i=1,#L do
|
||||||
|
if L[i]~=0 then return end
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
local penKey={
|
local penKey={
|
||||||
["1"]=1,["2"]=2,["3"]=3,["4"]=4,["5"]=5,["6"]=6,["7"]=7,["8"]=8,
|
["1"]=1,["2"]=2,["3"]=3,["4"]=4,["5"]=5,["6"]=6,["7"]=7,["8"]=8,
|
||||||
q=9,w=10,e=11,r=12,t=13,y=14,u=15,i=16,
|
q=9,w=10,e=11,r=12,t=13,y=14,u=15,i=16,
|
||||||
@@ -100,13 +106,19 @@ local function _pDraw()
|
|||||||
C=0
|
C=0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local F=FIELD[page]
|
||||||
if C then
|
if C then
|
||||||
for i=1,l do
|
for i=1,l do
|
||||||
FIELD[page][penPath[i][2]][penPath[i][1]]=C
|
F[penPath[i][2]][penPath[i][1]]=C
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
penPath={}
|
penPath={}
|
||||||
penMode=0
|
penMode=0
|
||||||
|
|
||||||
|
while #F>0 and isEmpty(F[#F])do
|
||||||
|
rem(F)
|
||||||
|
end
|
||||||
|
print(#F)
|
||||||
end
|
end
|
||||||
|
|
||||||
function scene.sceneInit()
|
function scene.sceneInit()
|
||||||
@@ -174,7 +186,7 @@ function scene.keyDown(key)
|
|||||||
end
|
end
|
||||||
elseif key=="delete"then
|
elseif key=="delete"then
|
||||||
if sure>.3 then
|
if sure>.3 then
|
||||||
for y=1,20 do for x=1,10 do FIELD[page][y][x]=0 end end
|
FIELD[page]=DATA.newBoard()
|
||||||
sure=0
|
sure=0
|
||||||
SFX.play('finesseError',.7)
|
SFX.play('finesseError',.7)
|
||||||
else
|
else
|
||||||
@@ -187,19 +199,18 @@ function scene.keyDown(key)
|
|||||||
SFX.play('blip')
|
SFX.play('blip')
|
||||||
elseif key=="l"then
|
elseif key=="l"then
|
||||||
local F=FIELD[page]
|
local F=FIELD[page]
|
||||||
|
local cleared=false
|
||||||
for i=20,1,-1 do
|
for i=20,1,-1 do
|
||||||
for j=1,10 do
|
for j=1,10 do
|
||||||
if F[i][j]<=0 then goto CONTINUE_notFull end
|
if F[i][j]<=0 then goto CONTINUE_notFull end
|
||||||
end
|
end
|
||||||
|
cleared=true
|
||||||
SYSFX.newShade(3,200,660-30*i,300,30)
|
SYSFX.newShade(3,200,660-30*i,300,30)
|
||||||
SYSFX.newRectRipple(3,200,660-30*i,300,30)
|
SYSFX.newRectRipple(3,200,660-30*i,300,30)
|
||||||
rem(F,i)
|
rem(F,i)
|
||||||
::CONTINUE_notFull::
|
::CONTINUE_notFull::
|
||||||
end
|
end
|
||||||
if #F~=20 then
|
if cleared then
|
||||||
repeat
|
|
||||||
F[#F+1]={0,0,0,0,0,0,0,0,0,0}
|
|
||||||
until#F==20
|
|
||||||
SFX.play('clear_3',.8)
|
SFX.play('clear_3',.8)
|
||||||
SFX.play('fall',.8)
|
SFX.play('fall',.8)
|
||||||
end
|
end
|
||||||
@@ -279,7 +290,7 @@ function scene.draw()
|
|||||||
local cross=TEXTURE.puzzleMark[-1]
|
local cross=TEXTURE.puzzleMark[-1]
|
||||||
local F=FIELD[page]
|
local F=FIELD[page]
|
||||||
local texture=SKIN.lib[SETTING.skinSet]
|
local texture=SKIN.lib[SETTING.skinSet]
|
||||||
for y=1,20 do for x=1,10 do
|
for y=1,#F do for x=1,10 do
|
||||||
local B=F[y][x]
|
local B=F[y][x]
|
||||||
if B>0 then
|
if B>0 then
|
||||||
gc.draw(texture[B],30*x-30,600-30*y)
|
gc.draw(texture[B],30*x-30,600-30*y)
|
||||||
|
|||||||
Reference in New Issue
Block a user