From 7038100d3f08839cd351996102ca4b78c74c64a5 Mon Sep 17 00:00:00 2001 From: MrZ_26 <1046101471@qq.com> Date: Fri, 10 May 2024 03:44:43 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=9B=E4=B8=80=E6=AD=A5=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E7=90=BC=E6=99=B6=E6=B6=88=E9=99=A4=E7=BB=93=E7=AE=97=E6=B5=81?= =?UTF-8?q?=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/game/gelaPlayer.lua | 116 ++++++++++++++++++------------------- 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/assets/game/gelaPlayer.lua b/assets/game/gelaPlayer.lua index 4b55c84a..f64557fa 100644 --- a/assets/game/gelaPlayer.lua +++ b/assets/game/gelaPlayer.lua @@ -661,12 +661,8 @@ function GP:gelaDropped() -- Drop & lock gela, and trigger a lot of things self:finish('CE') end - -- Trimmed self:updField() - if self:canFall() then - self.fallTimer=self.settings.fallDelay - else - self:checkClear() - end + -- Update field + self:updField() -- Discard hand self.hand=false @@ -674,6 +670,11 @@ function GP:gelaDropped() -- Drop & lock gela, and trigger a lot of things -- Fresh hand if self.settings.spawnDelay<=0 then + -- TODO + -- Trigger garbage + if self.chain<=0 or not self.settings.clearStuck then + self:checkGarbage() + end if self.fallTimer<=0 and self.clearTimer<=0 then self:popNext() end @@ -749,26 +750,23 @@ function GP:checkPosition(x,y) self:getGroup(x,y,cell,set) end - -- Record the group, mark cells, trigger clearing (or later) + -- Record the group, mark cells if TABLE.getSize(set)>=self.settings.clearGroupSize then ins(self.clearingGroups,set) self:checkDig(set) for k in next,set do k.clearing=true end - if self.settings.clearDelay<=0 then - self:clearField() - self:updField() - else - self.clearTimer=self.settings.clearDelay - end end end -function GP:updField() +---@param byTimer? boolean Only true when called by P:update, trigger falling, otherwise only start the falling timer but not do fall +function GP:updField(byTimer) if self:canFall() then if self.settings.fallDelay<=0 then - while self:fieldFall() do end + while self:doFall() do end self:checkClear() else - self:fieldFall() + if byTimer then + self:doFall() + end self.fallTimer=self.settings.fallDelay end else @@ -785,7 +783,7 @@ function GP:canFall() end end end end -function GP:fieldFall() +function GP:doFall() local F=self.field local fallen=false for x=1,self.settings.fieldW do @@ -808,34 +806,6 @@ function GP:fieldFall() end return fallen end -function GP:checkGarbage() - local i=1 - while true do - l=self.garbageBuffer[i] - if not l then break end - if l._time==l.time then - self:dropGarbage(l.power*2) - rem(self.garbageBuffer,i) - i=i-1 -- Avoid index error - elseif l.mode==1 then - l._time=l._time+1 - end - i=i+1 - end -end -function GP:dropGarbage(count) - local F=self.field - local w=self.settings.fieldW - for _=1,count do - local x=self:random(w) - local y=self.settings.spawnH+1 - while F:getCell(x,y) do y=y+1 end - F:setCell({ - color=555, - diggable=true, - },x,y) - end -end function GP:checkClear() local F=self.field for y=1,F:getHeight() do for x=1,self.settings.fieldW do @@ -846,23 +816,25 @@ function GP:checkClear() end end if #self.clearingGroups>0 then self:playSound('desuffocate') - end - if self.clearTimer<=0 then - -- Attack - local atk=GAME.initAtk(self:atkEvent('clear')) - if atk then - GAME.send(self,atk) + if self.settings.clearDelay<=0 then + self:doClear() + self:updField() + else + self.clearTimer=self.settings.clearDelay end end - if self.clearTimer<=0 or not self.settings.clearStuck then - self:checkGarbage() - end end -function GP:clearField() +function GP:doClear() self.chain=self.chain+1 self:playSound('chain',self.chain) self:playSound('clear',#self.clearingGroups) + -- Attack + local atk=GAME.initAtk(self:atkEvent('clear')) + if atk then + GAME.send(self,atk) + end + local F=self.field for i=1,#self.clearingGroups do local set=self.clearingGroups[i] @@ -880,6 +852,34 @@ function GP:clearField() end self.clearingGroups={} end +function GP:checkGarbage() + local i=1 + while true do + l=self.garbageBuffer[i] + if not l then break end + if l._time==l.time then + self:dropGarbage(l.power*2) + rem(self.garbageBuffer,i) + i=i-1 -- Avoid index error + elseif l.mode==1 then + l._time=l._time+1 + end + i=i+1 + end +end +function GP:dropGarbage(count) + local F=self.field + local w=self.settings.fieldW + for _=1,count do + local x=self:random(w) + local y=self.settings.spawnH+1 + while F:getCell(x,y) do y=y+1 end + F:setCell({ + color=555, + diggable=true, + },x,y) + end +end function GP:changeFieldWidth(w,origPos) if w>0 and w%1==0 then if not origPos then origPos=1 end @@ -1024,14 +1024,14 @@ function GP:updateFrame() if self.fallTimer>0 then self.fallTimer=self.fallTimer-1 if self.fallTimer<=0 then - self:updField() + self:updField(true) end break end if self.clearTimer>0 then self.clearTimer=self.clearTimer-1 if self.clearTimer<=0 then - self:clearField() + self:doClear() self:updField() self:triggerEvent('afterClear') @@ -1342,7 +1342,7 @@ local baseEnv={ maxFreshTime=6200, -- Attack - atkSys='none', + atkSys='classic', allowCancel=true, clearStuck=true,