From b394e77e140fe3903d5f5708e7bf30d63a030804 Mon Sep 17 00:00:00 2001 From: MrZ_26 <1046101471@qq.com> Date: Sun, 5 May 2024 07:21:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E7=90=86=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/game/mechanicLib/mino/sequence.lua | 57 +++++++++++------------ assets/game/minoPlayer.lua | 14 +++--- 2 files changed, 35 insertions(+), 36 deletions(-) diff --git a/assets/game/mechanicLib/mino/sequence.lua b/assets/game/mechanicLib/mino/sequence.lua index f9529be4..1bd7f892 100644 --- a/assets/game/mechanicLib/mino/sequence.lua +++ b/assets/game/mechanicLib/mino/sequence.lua @@ -1,24 +1,21 @@ local min=math.min local ins,rem=table.insert,table.remove ----@type Techmino.Mech.mino -local sequence={} - -local Tetros={1,2,3,4,5,6,7} -local Pentos={8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25} -local easyPentos={10,11,14,19,20,23,24,25} -- P Q T5 J5 L5 N H I5 -local hardPentos={8,9,12,13,15,16,17,18,21,22} -- Z5 S5 F E U V W X R Y - -- Fill list when empty, with source ---@return boolean #True when filled -local function supply(list,src) +local function supply(list,src,rep) if not list[1] then - TABLE.connect(list,src) + for _=1,rep or 1 do + TABLE.connect(list,src) + end return true end return false end +---@type Techmino.Mech.mino +local sequence={} + ---@param P Techmino.Player.mino ---@param d table cached data of generator ---@param init boolean true if this is the first initializating call @@ -29,6 +26,8 @@ end -------------------------------------------------------------- -- Tetro +local Tetros={1,2,3,4,5,6,7} + function sequence.bag7(P,d,init) if init then d.bag={} @@ -152,9 +151,8 @@ function sequence.bag7_steal1(P,d,init) -- bag7, but each bag steals a piece fro d.victim=TABLE.shift(Tetros) return end - if not d.bag[1] then + if supply(d.bag,Tetros) then d.bag,d.victim=d.victim,d.bag - d.victim=TABLE.shift(Tetros) ins(d.bag,rem(d.victim,P:random(#d.victim))) end return rem(d.bag,P:random(#d.bag)) @@ -165,8 +163,7 @@ function sequence.bag7p7p2_power(P,d,init) -- bag7+7+TI d.bag={} return end - if not d.bag[1] then - for _=1,2 do TABLE.connect(d.bag,Tetros) end + if supply(d.bag,Tetros,2) then TABLE.connect(d.bag,{5,7}) end return rem(d.bag,P:random(#d.bag)) @@ -177,8 +174,7 @@ function sequence.bag7p7p7p5_power(P,d,init) -- bag 7+7+7+TTOII d.bag={} return end - if not d.bag[1] then - for _=1,3 do TABLE.connect(d.bag,Tetros) end + if supply(d.bag,Tetros,3) then TABLE.connect(d.bag,{5,5,6,7,7}) end return rem(d.bag,P:random(#d.bag)) @@ -189,8 +185,10 @@ function sequence.bag6p6_drought(P,d,init) -- bag7+7 without I piece d.bag={} end if not d.bag[1] then - for i=1,12 do - ins(d.bag,(i-1)%6+1) + for _=1,2 do + for i=1,6 do + ins(d.bag,i) + end end end return rem(d.bag,P:random(#d.bag)) @@ -201,10 +199,8 @@ function sequence.bag7p6_flood(P,d,init) -- bag7 with extra 3 S pieces and 3 Z p d.bag={} return end - if not d.bag[1] then - d.bag=TABLE.shift(Tetros) - d.bag[8],d.bag[9],d.bag[10]=1,1,1 - d.bag[11],d.bag[12],d.bag[13]=2,2,2 + if supply(d.bag,Tetros) then + TABLE.connect(d.bag,{1,1,1,2,2,2}) end return rem(d.bag,P:random(#d.bag)) end @@ -345,6 +341,10 @@ end -------------------------------------------------------------- -- Pento +local Pentos={8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25} +local easyPentos={10,11,14,19,20,23,24,25} -- P Q T5 J5 L5 N H I5 +local hardPentos={8,9,12,13,15,16,17,18,21,22} -- Z5 S5 F E U V W X R Y + function sequence.bag18_pento(P,d,init) if init then d.bag={} @@ -356,18 +356,17 @@ end function sequence.bag8_pentoEZ_p4fromBag10_pentoHD(P,d,init) if init then - d.bag={} - d.extra={} + d.bag1={} + d.bag2={} return end - if not d.bag[1] then - d.bag=TABLE.shift(easyPentos) + if supply(d.bag1,easyPentos) then for _=1,4 do - supply(d.extra,hardPentos) - ins(d.bag,rem(d.extra,P:random(#d.extra))) + supply(d.bag2,hardPentos) + ins(d.bag1,rem(d.bag2,P:random(#d.bag2))) end end - return rem(d.bag,P:random(#d.bag)) + return rem(d.bag1,P:random(#d.bag1)) end return sequence diff --git a/assets/game/minoPlayer.lua b/assets/game/minoPlayer.lua index f490873e..a38446aa 100644 --- a/assets/game/minoPlayer.lua +++ b/assets/game/minoPlayer.lua @@ -1704,18 +1704,18 @@ function MP:render() if #self.floatHolds>0 then for n=1,#self.floatHolds do local H=self.floatHolds[n] - local unavailable=SET.holdMode=='float' and not SET.infHold and n<=self.holdTime + local disabled=SET.holdMode=='float' and not SET.infHold and n<=self.holdTime for y=1,#H do for x=1,#H[1] do if H[y][x] then local dx,dy=(self.handX+x-2)*40,-(self.handY+y-1)*40 gc_translate(dx,dy) - skin.drawFloatHoldCell(H[y][x],unavailable,H,x,y) + skin.drawFloatHoldCell(H[y][x],disabled,H,x,y) gc_translate(-dx,-dy) end end end local dx,dy=(self.handX-1+#H[1]/2)*40,-(self.handY+#H/2)*40+5 gc_translate(dx,dy) - skin.drawFloatHoldMark(n,unavailable) + skin.drawFloatHoldMark(n,disabled) gc_translate(-dx,-dy) end end @@ -1778,7 +1778,7 @@ function MP:render() gc_translate(200,-400) skin.drawNextBorder(SET.nextSlot) for n=1,min(#self.nextQueue,SET.nextSlot) do - local unavailable=SET.holdMode=='swap' and not SET.infHold and n<=self.holdTime + local disabled=SET.holdMode=='swap' and not SET.infHold and n<=self.holdTime local B=self.nextQueue[n].matrix gc_push('transform') gc_translate(100,100*n-50) @@ -1787,7 +1787,7 @@ function MP:render() if B[y][x] then local dx,dy=(x-#B[1]/2-1)*40,(y-#B/2)*-40 gc_translate(dx,dy) - skin.drawNextCell(B[y][x],unavailable,B,x,y) + skin.drawNextCell(B[y][x],disabled,B,x,y) gc_translate(-dx,-dy) end end end @@ -1800,7 +1800,7 @@ function MP:render() gc_translate(-200,-400) skin.drawHoldBorder(SET.holdMode,SET.holdSlot) for n=1,#self.holdQueue do - local unavailable=SET.holdMode=='hold' and not SET.infHold and n<=self.holdTime + local disabled=SET.holdMode=='hold' and not SET.infHold and n<=self.holdTime local B=self.holdQueue[n].matrix gc_push('transform') gc_translate(-100,100*n-50) @@ -1809,7 +1809,7 @@ function MP:render() if B[y][x] then local dx,dy=(x-#B[1]/2-1)*40,(y-#B/2)*-40 gc_translate(dx,dy) - skin.drawHoldCell(B[y][x],unavailable,B,x,y) + skin.drawHoldCell(B[y][x],disabled,B,x,y) gc_translate(-dx,-dy) end end end