【警告:需要测试】
调整玩家能hold/移动/旋转方块的条件 修复cc复活后小bug 整理代码
This commit is contained in:
@@ -25,8 +25,8 @@ function bot_cc:revive()
|
|||||||
self.P:loadAI(self.data)
|
self.P:loadAI(self.data)
|
||||||
end
|
end
|
||||||
function bot_cc:pushNewNext(id)
|
function bot_cc:pushNewNext(id)
|
||||||
self.ccBot:addNext(rem(self.nexts,1))
|
self.ccBot:addNext(rem(self.bufferedNexts,1))
|
||||||
ins(self.nexts,id)
|
ins(self.bufferedNexts,id)
|
||||||
end
|
end
|
||||||
function bot_cc:thread()
|
function bot_cc:thread()
|
||||||
local P,keys=self.P,self.keys
|
local P,keys=self.P,self.keys
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ local baseBot={
|
|||||||
function baseBot.update(bot)
|
function baseBot.update(bot)
|
||||||
local P=bot.P
|
local P=bot.P
|
||||||
local keys=bot.keys
|
local keys=bot.keys
|
||||||
if P.control and P.waiting==0 then
|
if P.control and P.cur then
|
||||||
bot.delay=bot.delay-1
|
bot.delay=bot.delay-1
|
||||||
if not keys[1]then
|
if not keys[1]then
|
||||||
if bot.runningThread then
|
if bot.runningThread then
|
||||||
@@ -85,7 +85,7 @@ function BOT.new(P,data)
|
|||||||
if data.type=="CC"then
|
if data.type=="CC"then
|
||||||
P:setRS('SRS')
|
P:setRS('SRS')
|
||||||
bot.keys={}
|
bot.keys={}
|
||||||
bot.nexts={}
|
bot.bufferedNexts={}
|
||||||
bot.delay=data.delay
|
bot.delay=data.delay
|
||||||
bot.delay0=data.delay
|
bot.delay0=data.delay
|
||||||
if P.gameEnv.holdCount>1 then
|
if P.gameEnv.holdCount>1 then
|
||||||
@@ -109,20 +109,25 @@ function BOT.new(P,data)
|
|||||||
return
|
return
|
||||||
self.ccBot[k]and function(_,...)self.ccBot[k](self.ccBot,...)end or
|
self.ccBot[k]and function(_,...)self.ccBot[k](self.ccBot,...)end or
|
||||||
cc_lua[k]and function(_,...)cc_lua[k](self,...)end or
|
cc_lua[k]and function(_,...)cc_lua[k](self,...)end or
|
||||||
baseBot[k]and baseBot[k]or
|
assert(baseBot[k],"No CC action called "..k)
|
||||||
error("No actions called "..k)
|
|
||||||
end})
|
end})
|
||||||
|
|
||||||
for i,B in next,P.nextQueue do
|
local pushed=0
|
||||||
if i<=data.next then
|
if P.cur then
|
||||||
|
bot:addNext(P.cur.id)
|
||||||
|
pushed=pushed+1
|
||||||
|
end
|
||||||
|
for _,B in next,P.nextQueue do
|
||||||
|
if pushed<=data.next then
|
||||||
bot:addNext(B.id)
|
bot:addNext(B.id)
|
||||||
|
pushed=pushed+1
|
||||||
else
|
else
|
||||||
ins(bot.nexts,B.id)
|
ins(bot.bufferedNexts,B.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
bot.runningThread=coroutine.wrap(cc_lua.thread)
|
bot.runningThread=coroutine.wrap(cc_lua.thread)
|
||||||
bot.runningThread(bot)
|
bot.runningThread(bot)
|
||||||
elseif data.type=="9S"or true then--9s or else
|
else--if data.type=="9S"then--9s or else
|
||||||
TABLE.cover(baseBot,bot)
|
TABLE.cover(baseBot,bot)
|
||||||
TABLE.cover(require"parts.bot.bot_9s",bot)
|
TABLE.cover(require"parts.bot.bot_9s",bot)
|
||||||
P:setRS('TRS')
|
P:setRS('TRS')
|
||||||
|
|||||||
@@ -220,7 +220,7 @@ function Player:act_moveLeft(auto)
|
|||||||
self.ctrlCount=self.ctrlCount+1
|
self.ctrlCount=self.ctrlCount+1
|
||||||
end
|
end
|
||||||
self.movDir=-1
|
self.movDir=-1
|
||||||
if self.control and self.waiting==0 then
|
if self.cur then
|
||||||
if self.cur and not self:ifoverlap(self.cur.bk,self.curX-1,self.curY)then
|
if self.cur and not self:ifoverlap(self.cur.bk,self.curX-1,self.curY)then
|
||||||
self:createMoveFX('left')
|
self:createMoveFX('left')
|
||||||
self.curX=self.curX-1
|
self.curX=self.curX-1
|
||||||
@@ -241,7 +241,7 @@ function Player:act_moveRight(auto)
|
|||||||
self.ctrlCount=self.ctrlCount+1
|
self.ctrlCount=self.ctrlCount+1
|
||||||
end
|
end
|
||||||
self.movDir=1
|
self.movDir=1
|
||||||
if self.control and self.waiting==0 then
|
if self.cur then
|
||||||
if self.cur and not self:ifoverlap(self.cur.bk,self.curX+1,self.curY)then
|
if self.cur and not self:ifoverlap(self.cur.bk,self.curX+1,self.curY)then
|
||||||
self:createMoveFX('right')
|
self:createMoveFX('right')
|
||||||
self.curX=self.curX+1
|
self.curX=self.curX+1
|
||||||
@@ -258,21 +258,21 @@ function Player:act_moveRight(auto)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
function Player:act_rotRight()
|
function Player:act_rotRight()
|
||||||
if self.control and self.cur then
|
if self.cur then
|
||||||
self.ctrlCount=self.ctrlCount+1
|
self.ctrlCount=self.ctrlCount+1
|
||||||
self:spin(1)
|
self:spin(1)
|
||||||
self.keyPressing[3]=false
|
self.keyPressing[3]=false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function Player:act_rotLeft()
|
function Player:act_rotLeft()
|
||||||
if self.control and self.cur then
|
if self.cur then
|
||||||
self.ctrlCount=self.ctrlCount+1
|
self.ctrlCount=self.ctrlCount+1
|
||||||
self:spin(3)
|
self:spin(3)
|
||||||
self.keyPressing[4]=false
|
self.keyPressing[4]=false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function Player:act_rot180()
|
function Player:act_rot180()
|
||||||
if self.control and self.cur then
|
if self.cur then
|
||||||
self.ctrlCount=self.ctrlCount+2
|
self.ctrlCount=self.ctrlCount+2
|
||||||
self:spin(2)
|
self:spin(2)
|
||||||
self.keyPressing[5]=false
|
self.keyPressing[5]=false
|
||||||
@@ -280,7 +280,7 @@ function Player:act_rot180()
|
|||||||
end
|
end
|
||||||
function Player:act_hardDrop()
|
function Player:act_hardDrop()
|
||||||
local ENV=self.gameEnv
|
local ENV=self.gameEnv
|
||||||
if self.control and self.cur then
|
if self.cur then
|
||||||
if self.lastPiece.autoLock and self.frameRun-self.lastPiece.frame<ENV.dropcut then
|
if self.lastPiece.autoLock and self.frameRun-self.lastPiece.frame<ENV.dropcut then
|
||||||
SFX.play('drop_cancel',.3)
|
SFX.play('drop_cancel',.3)
|
||||||
else
|
else
|
||||||
@@ -305,7 +305,7 @@ function Player:act_hardDrop()
|
|||||||
end
|
end
|
||||||
function Player:act_softDrop()
|
function Player:act_softDrop()
|
||||||
self.downing=1
|
self.downing=1
|
||||||
if self.control and self.cur then
|
if self.cur then
|
||||||
if self.curY>self.ghoY then
|
if self.curY>self.ghoY then
|
||||||
self.curY=self.curY-1
|
self.curY=self.curY-1
|
||||||
self:freshBlock('fresh')
|
self:freshBlock('fresh')
|
||||||
@@ -317,7 +317,8 @@ function Player:act_softDrop()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
function Player:act_hold()
|
function Player:act_hold()
|
||||||
if self.control and self.cur then
|
print(self.control,self.cur)
|
||||||
|
if self.cur then
|
||||||
if self:hold()then
|
if self:hold()then
|
||||||
self.keyPressing[8]=false
|
self.keyPressing[8]=false
|
||||||
end
|
end
|
||||||
@@ -1325,7 +1326,7 @@ function Player:hold_swap(ifpre)
|
|||||||
self.stat.hold=self.stat.hold+1
|
self.stat.hold=self.stat.hold+1
|
||||||
end
|
end
|
||||||
function Player:hold(ifpre)
|
function Player:hold(ifpre)
|
||||||
if self.holdTime>0 and(ifpre or self.falling==0 and self.waiting==0)then
|
if self.holdTime>0 and(self.cur or ifpre)then
|
||||||
if self.gameEnv.holdMode=='hold'then
|
if self.gameEnv.holdMode=='hold'then
|
||||||
self:hold_norm(ifpre)
|
self:hold_norm(ifpre)
|
||||||
elseif self.gameEnv.holdMode=='swap'then
|
elseif self.gameEnv.holdMode=='swap'then
|
||||||
@@ -2048,7 +2049,7 @@ do
|
|||||||
return _cc,_gbcc
|
return _cc,_gbcc
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function Player:loadAI(data)--Load AI params
|
function Player:loadAI(data)--Load AI with params
|
||||||
self.bot=BOT.new(self,data)
|
self.bot=BOT.new(self,data)
|
||||||
self.bot.data=data
|
self.bot.data=data
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user