From 365fdd617ac127e1d995e04a5d1c6cb1d7612ffb Mon Sep 17 00:00:00 2001 From: MrZ_26 <1046101471@qq.com> Date: Sun, 5 May 2024 07:23:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B0=94=E6=B3=A1=E5=BA=8F=E5=88=97=E7=94=9F?= =?UTF-8?q?=E6=88=90=E6=B5=81=E7=A8=8B=E6=8D=A2=E6=96=B0=E4=B8=BA=E6=96=B9?= =?UTF-8?q?=E5=9D=97=E7=9A=84=20=E4=BF=AE=E6=94=B9=E6=B0=94=E6=B3=A1?= =?UTF-8?q?=E5=BA=8F=E5=88=97=E5=90=8D=E7=A7=B0=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=9B=B4=E5=A4=9A=E6=B0=94=E6=B3=A1=E5=BA=8F=E5=88=97=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/game/mechanicLib/puyo/sequence.lua | 73 ++++++++++++++++------- assets/game/puyoPlayer.lua | 54 +++++++++++++++-- 2 files changed, 100 insertions(+), 27 deletions(-) diff --git a/assets/game/mechanicLib/puyo/sequence.lua b/assets/game/mechanicLib/puyo/sequence.lua index 41a29c4b..365dbef5 100644 --- a/assets/game/mechanicLib/puyo/sequence.lua +++ b/assets/game/mechanicLib/puyo/sequence.lua @@ -1,34 +1,65 @@ local ins,rem=table.insert,table.remove +-- Fill list when empty, with source +---@return boolean #True when filled +local function supply(list,src,rep) + if not list[1] then + for _=1,rep or 1 do + TABLE.connect(list,src) + end + return true + end + return false +end + ---@type Techmino.Mech.puyo local sequence={} -function sequence.none() - while true do coroutine.yield() end +---@param P Techmino.Player.puyo +---@param d table cached data of generator +---@param init boolean true if this is the first initializating call +---@diagnostic disable-next-line +function sequence.none(P,d,init) end -function sequence.double3color(P) - local l={} - while true do - if not l[1] then for i=1,3 do for j=1,3 do ins(l,{{i},{j}}) end end end - coroutine.yield(rem(l,P:random(#l))) - end -end +-------------------------------------------------------------- +-- Twin -function sequence.double4color(P) - local l={} - while true do - if not l[1] then for i=1,4 do for j=1,4 do ins(l,{{i},{j}}) end end end - coroutine.yield(rem(l,P:random(#l))) - end +-- Simply all permutations +local TwinSet={} +for i=1,8 do + TwinSet[i]={} + for x=1,i do for y=1,i do + ins(TwinSet[i],{{x},{y}}) + end end end - -function sequence.double5color(P) - local l={} - while true do - if not l[1] then for i=1,5 do for j=1,5 do ins(l,{{i},{j}}) end end end - coroutine.yield(rem(l,P:random(#l))) +for _,bagCount in next,{2,4,8} do for colors=3,8 do + sequence['twin_'..bagCount..'S'..colors..'C']=function(P,d,init) + if init then d.bag={} return end + supply(d.bag,TwinSet[colors],bagCount) + return rem(d.bag,P:random(#d.bag)) end +end end + +-- No repeat in one set +local NRTwinSet={} +for i=1,8 do + NRTwinSet[i]={} + for x=1,i do for y=1,x do + ins(NRTwinSet[i],{{x},{y}}) + end end end +for _,bagCount in next,{2,4,8} do for colors=3,8 do + sequence['twin_'..bagCount..'S'..colors..'NRC']=function(P,d,init) + if init then d.bag={} return end + supply(d.bag,NRTwinSet[colors],bagCount) + return rem(d.bag,P:random(#d.bag)) + end +end end + +-------------------------------------------------------------- +-- Multi + +-- TODO return sequence diff --git a/assets/game/puyoPlayer.lua b/assets/game/puyoPlayer.lua index 2c4e594b..c399892e 100644 --- a/assets/game/puyoPlayer.lua +++ b/assets/game/puyoPlayer.lua @@ -408,7 +408,7 @@ function PP:freshDelay(reason) end function PP:freshNextQueue() while #self.nextQueue