diff --git a/parts/bot/bot_cc.lua b/parts/bot/bot_cc.lua index bc4e4ede..21abac02 100644 --- a/parts/bot/bot_cc.lua +++ b/parts/bot/bot_cc.lua @@ -28,7 +28,7 @@ function bot_cc:checkDest(b2b,atk,exblock,yomi) return end end - local should_spawn = self.P:getNextSpawn() - 1 + local should_spawn = self.P:getSpawnY(self.P.nextQueue[1]) - 1 if dest.spawn ~= should_spawn then assert(dest.spawn > should_spawn) -- print('wrong spawn: should be '..dest.spawn..' but '..should_spawn) @@ -104,7 +104,7 @@ function bot_cc:updateField() F[i],i=F0[y][x]>0,i+1 end end while i<=400 do F[i],i=false,i+1 end - local y = P:getNextSpawn()-1 + local y = P:getSpawnY(P.nextQueue[1])-1 if not pcall(self.ccBot.reset,self.ccBot,F,P.b2b,P.combo,P.stat.pc,P.stat.row,y) then print("CC is dead ("..P.id..")","error") for y=#F0,1,-1 do diff --git a/parts/player/draw.lua b/parts/player/draw.lua index 6e273bcb..f379f121 100644 --- a/parts/player/draw.lua +++ b/parts/player/draw.lua @@ -356,11 +356,9 @@ local function _drawBlock(CB,curX,curY,texture) end end gc_setShader() end -local function _drawNextPreview(B,fieldH,fieldBeneath) +local function _drawNextPreview(B,x,y) gc_setColor(1,1,1,.8) - local y=floor(fieldH+1-modf(B.RS.centerPos[B.id][B.dir][1]))+ceil(fieldBeneath/30) B=B.bk - local x=floor(6-#B[1]*.5) local cross=TEXTURE.puzzleMark[-1] for i=1,#B do for j=1,#B[1] do if B[i][j] then @@ -368,11 +366,10 @@ local function _drawNextPreview(B,fieldH,fieldBeneath) end end end end -local function _drawHoldPreview(B,fieldH,fieldBeneath) +local function _drawHoldPreview(B,x,y) gc_setColor(1,1,1,.3) - local y=floor(fieldH+1-modf(B.RS.centerPos[B.id][B.dir][1]))+ceil(fieldBeneath/30)+.14 + y=y+.14 B=B.bk - local x=floor(6-#B[1]*.5) local cross=TEXTURE.puzzleMark[-1] for i=1,#B do for j=1,#B[1] do if B[i][j] then @@ -886,8 +883,8 @@ function draw.norm(P,repMode) -- Draw next preview if ENV.nextPos then - if P.nextQueue[1] then _drawNextPreview(P.nextQueue[1],ENV.fieldH,P.fieldBeneath) end - if P.holdQueue[1] then _drawHoldPreview(P.holdQueue[1],ENV.fieldH,P.fieldBeneath) end + if P.nextQueue[1] then _drawNextPreview(P.nextQueue[1],P:getSpawnX(P.nextQueue[1]),P:getSpawnY(P.nextQueue[1])) end + if P.holdQueue[1] then _drawHoldPreview(P.holdQueue[1],P:getSpawnX(P.holdQueue[1]),P:getSpawnY(P.holdQueue[1])) end end -- Draw AI's drop destination @@ -1082,7 +1079,7 @@ function draw.demo(P) -- Draw hold local N=1 - while P.holdQueue[N] do + while ENV.holdMode=='hold' and N<=ENV.holdCount and P.holdQueue[N] do local id=P.holdQueue[N].id local _=BLOCK_COLORS[skinSet[id]] gc_setColor(_[1],_[2],_[3],.3) diff --git a/parts/player/player.lua b/parts/player/player.lua index 6d2581e3..d2cb2434 100644 --- a/parts/player/player.lua +++ b/parts/player/player.lua @@ -1155,8 +1155,8 @@ function Player:resetBlock()-- Reset Block's position and execute I*S local C=self.cur local sc=C.RS.centerPos[C.id][C.dir] - self.curX=floor(6-#C.bk[1]*.5) - local y=floor(self.gameEnv.fieldH+1-modf(sc[1]))+ceil(self.fieldBeneath/30) + self.curX=self:getSpawnX(C) + local y=self:getSpawnY(C) self.curY=y self.minY=y+sc[1] @@ -1195,9 +1195,10 @@ function Player:resetBlock()-- Reset Block's position and execute I*S SFX.fplay(spawnSFX_name[C.id],SETTING.sfx_spawn) end end - -function Player:getNextSpawn() - local cur = self.nextQueue[1] +function Player:getSpawnX(cur) + return floor(6-#cur.bk[1]*.5) +end +function Player:getSpawnY(cur) return floor(self.gameEnv.fieldH+1-modf(cur.RS.centerPos[cur.id][cur.dir][1]))+ceil(self.fieldBeneath/30) end @@ -1317,6 +1318,11 @@ function Player:hold_norm(ifpre) hb.color=C.color hb.name=C.name ins(self.holdQueue,hb) + if self:willDieWith(self.holdQueue[1]) then + self.cur=nil + self.waiting=ENV.hang + return + end end self.cur=rem(self.holdQueue,1) @@ -1381,10 +1387,19 @@ function Player:hold_swap(ifpre) else-- Normal hold self.spinLast=false - local hb=self:getBlock(C.id) - hb.color=C.color - hb.name=C.name - self.cur,self.nextQueue[hid]=self.nextQueue[hid],hb + if C then + local hb=self:getBlock(C.id) + hb.color=C.color + hb.name=C.name + ins(self.holdQueue,self.nextQueue[hid]) + self.nextQueue[hid]=hb + if self:willDieWith(self.holdQueue[1]) then + self.cur=nil + self.waiting=ENV.hang + return + end + end + self.cur=rem(self.holdQueue,1) self.cur.bagLine=nil self:resetBlock() @@ -1444,7 +1459,9 @@ function Player:popNext(ifhold)-- Pop nextQueue to hand self.spinLast=false self.ctrlCount=0 - if self.nextQueue[1] then + if #self.holdQueue>ENV.holdCount or ENV.holdMode=='swap' and #self.holdQueue>0 then + self:hold(true,true) + elseif self.nextQueue[1] then self.cur=rem(self.nextQueue,1) self.cur.bagLine=nil self:newNext() @@ -1480,6 +1497,9 @@ function Player:popNext(ifhold)-- Pop nextQueue to hand self:lose(true) end end +function Player:willDieWith(B) + return B and self:ifoverlap(B.bk,self:getSpawnX(B),self:getSpawnY(B)) +end function Player:cancel(N)-- Cancel Garbage local off=0-- Lines offseted @@ -2058,9 +2078,8 @@ do self.waiting=ENV.wait -- Prevent sudden death if hang>0 - if ENV.hang>ENV.wait and self.nextQueue[1] then - local B=self.nextQueue[1] - if self:ifoverlap(B.bk,floor(6-#B.bk[1]*.5),floor(ENV.fieldH+1-modf(B.RS.centerPos[B.id][B.dir][1]))+ceil(self.fieldBeneath/30)) then + if ENV.hang>ENV.wait then + if self:willDieWith(self.nextQueue[1]) then self.waiting=self.waiting+ENV.hang end end diff --git a/version.lua b/version.lua index 7def4b55..dd9996a6 100644 --- a/version.lua +++ b/version.lua @@ -2,6 +2,6 @@ return { ["apkCode"]=1715, ["code"]=1715, ["string"]="V0.17.15", - ["room"]="ver A-9", + ["room"]="ver A-10", ["name"]="暂停 Break", }