new bagline system (#963)

closes #940
This commit is contained in:
Imple Lee
2023-09-11 18:03:09 +08:00
committed by GitHub
parent 7141f46948
commit 452fa65748
4 changed files with 25 additions and 11 deletions

View File

@@ -569,8 +569,10 @@ local function _drawNext(P,repMode)
end end
if ENV.bagLine then if ENV.bagLine then
gc_setColor(.8,.8,.8,.8) gc_setColor(.8,.8,.8,.8)
for i=-P.pieceCount%ENV.bagLine,N-1,ENV.bagLine do-- i=phase for i=1,ENV.nextCount+1 do
gc_rectangle('fill',1,72*i+3,98,2) if queue[i] and queue[i].bagLine>0 then
gc_rectangle('fill',1,72*(i-1)+3,98,2)
end
end end
end end
gc_translate(-488,-20) gc_translate(-488,-20)

View File

@@ -331,8 +331,6 @@ local function _applyGameEnv(P)-- Finish gameEnv processing
ENV.arr=max(ENV.arr,ENV.minarr) ENV.arr=max(ENV.arr,ENV.minarr)
ENV.sdarr=max(ENV.sdarr,ENV.minsdarr) ENV.sdarr=max(ENV.sdarr,ENV.minsdarr)
ENV.bagLine=ENV.bagLine and (ENV.sequence=='bag' or ENV.sequence=='loop') and #ENV.seqData
if ENV.nextCount==0 then if ENV.nextCount==0 then
ENV.nextPos=false ENV.nextPos=false
end end
@@ -340,6 +338,7 @@ local function _applyGameEnv(P)-- Finish gameEnv processing
local seqGen=coroutine.create(getSeqGen(ENV.sequence)) local seqGen=coroutine.create(getSeqGen(ENV.sequence))
local seqCalled=false local seqCalled=false
local initSZOcount=0 local initSZOcount=0
local bagLineCounter=0
function P:newNext() function P:newNext()
local status,piece local status,piece
if seqCalled then if seqCalled then
@@ -348,7 +347,9 @@ local function _applyGameEnv(P)-- Finish gameEnv processing
status,piece=coroutine.resume(seqGen,P.seqRND,P.gameEnv.seqData) status,piece=coroutine.resume(seqGen,P.seqRND,P.gameEnv.seqData)
seqCalled=true seqCalled=true
end end
if status and piece then if not status then
assert(piece=='cannot resume dead coroutine')
elseif piece then
if ENV.noInitSZO and initSZOcount<5 then if ENV.noInitSZO and initSZOcount<5 then
initSZOcount=initSZOcount+1 initSZOcount=initSZOcount+1
if piece==1 or piece==2 or piece==6 then if piece==1 or piece==2 or piece==6 then
@@ -357,9 +358,13 @@ local function _applyGameEnv(P)-- Finish gameEnv processing
initSZOcount=5 initSZOcount=5
end end
end end
P:getNext(piece) P:getNext(piece,bagLineCounter)
elseif not status then bagLineCounter=0
assert(piece=='cannot resume dead coroutine') else
if ENV.bagLine then
bagLineCounter=bagLineCounter+1
end
P:newNext()
end end
end end
for _=1,ENV.trueNextCount do for _=1,ENV.trueNextCount do

View File

@@ -1415,7 +1415,7 @@ function Player:hold(ifpre,force)
end end
end end
function Player:getBlock(id,name,color)-- Get a block object function Player:getBlock(id,name,color,bagLineCounter)-- Get a block object
local ENV=self.gameEnv local ENV=self.gameEnv
local dir=ENV.face[id] local dir=ENV.face[id]
return { return {
@@ -1425,10 +1425,11 @@ function Player:getBlock(id,name,color)-- Get a block object
RS=self.RS, RS=self.RS,
name=name or id, name=name or id,
color=ENV.bone and 17 or color or ENV.skin[id], color=ENV.bone and 17 or color or ENV.skin[id],
bagLine=bagLineCounter,
} }
end end
function Player:getNext(id)-- Push a block to nextQueue function Player:getNext(id,bagLineCounter)-- Push a block to nextQueue
ins(self.nextQueue,self:getBlock(id)) ins(self.nextQueue,self:getBlock(id,nil,nil,bagLineCounter))
if self.bot then if self.bot then
self.bot:pushNewNext(id) self.bot:pushNewNext(id)
end end

View File

@@ -8,6 +8,7 @@ local seqGenerators={
local bag={} local bag={}
while true do while true do
if #bag==0 then if #bag==0 then
yield(nil)
for i=1,len do for i=1,len do
bag[i]=seq0[len-i+1] bag[i]=seq0[len-i+1]
end end
@@ -35,11 +36,13 @@ local seqGenerators={
end end
end end
-- Finish -- Finish
yield(nil)
for i=1,len do yield(bag[i]) end for i=1,len do yield(bag[i]) end
end end
bag={} bag={}
while true do while true do
if #bag==0 then if #bag==0 then
yield(nil)
for i=1,len do for i=1,len do
bag[i]=seq0[len-i+1] bag[i]=seq0[len-i+1]
end end
@@ -189,6 +192,7 @@ local seqGenerators={
local bufferSeq,bag={},{} local bufferSeq,bag={},{}
while true do while true do
if #bag==0 then if #bag==0 then
yield(nil)
for i=1,#seq0 do bufferSeq[i]=seq0[i] end for i=1,#seq0 do bufferSeq[i]=seq0[i] end
repeat repeat
local r=rem(bufferSeq,rndGen:random(#bag)) local r=rem(bufferSeq,rndGen:random(#bag))
@@ -210,6 +214,7 @@ local seqGenerators={
local bag={} local bag={}
while true do while true do
if #bag==0 then if #bag==0 then
yield(nil)
for i=1,len do for i=1,len do
bag[i]=seq0[len-i+1] bag[i]=seq0[len-i+1]
end end
@@ -235,6 +240,7 @@ local seqGenerators={
local unknown={} local unknown={}
local extra=-1 local extra=-1
local function init() local function init()
yield(nil)
for i=1,len do for i=1,len do
unknown[i]=1 unknown[i]=1
end end