代码规范:把所有的tab换成空格

This commit is contained in:
MrZ626
2021-08-25 04:28:52 +08:00
parent 8f910f95f4
commit 295e79984f
271 changed files with 35384 additions and 35379 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,65 +1,65 @@
return{
das=10,arr=2,
dascut=0,dropcut=0,
sddas=2,sdarr=2,
ihs=true,irs=true,ims=true,
swap=true,
das=10,arr=2,
dascut=0,dropcut=0,
sddas=2,sdarr=2,
ihs=true,irs=true,ims=true,
swap=true,
ghostType='gray',
block=true,ghost=.3,center=1,
smooth=false,grid=.16,lineNum=.5,
upEdge=true,
bagLine=true,
text=true,
score=true,
lockFX=2,
dropFX=2,
moveFX=2,
clearFX=2,
splashFX=2,
shakeFX=2,
atkFX=2,
ghostType='gray',
block=true,ghost=.3,center=1,
smooth=false,grid=.16,lineNum=.5,
upEdge=true,
bagLine=true,
text=true,
score=true,
lockFX=2,
dropFX=2,
moveFX=2,
clearFX=2,
splashFX=2,
shakeFX=2,
atkFX=2,
bufferWarn=false,
highCam=false,
nextPos=false,
showSpike=false,
bufferWarn=false,
highCam=false,
nextPos=false,
showSpike=false,
hideBoard=false,
flipBoard=false,
hideBoard=false,
flipBoard=false,
drop=60,lock=60,
wait=0,fall=0,
bone=false,
fieldH=20,heightLimit=1e99,
nextCount=6,nextStartPos=1,
holdCount=1,infHold=false,phyHold=false,
ospin=true,deepDrop=false,
RS='TRS',
sequence='bag',
seqData={1,2,3,4,5,6,7},
skinSet='crystal_scf',
face=false,skin=false,
mission=false,
drop=60,lock=60,
wait=0,fall=0,
bone=false,
fieldH=20,heightLimit=1e99,
nextCount=6,nextStartPos=1,
holdCount=1,infHold=false,phyHold=false,
ospin=true,deepDrop=false,
RS='TRS',
sequence='bag',
seqData={1,2,3,4,5,6,7},
skinSet='crystal_scf',
face=false,skin=false,
mission=false,
life=0,
garbageSpeed=1,
pushSpeed=3,
noTele=false,
visible='show',
freshLimit=1e99,easyFresh=true,
bufferLimit=1e99,
fillClear=true,
life=0,
garbageSpeed=1,
pushSpeed=3,
noTele=false,
visible='show',
freshLimit=1e99,easyFresh=true,
bufferLimit=1e99,
fillClear=true,
fkey1=false,fkey2=false,
keyCancel={},
fine=false,fineKill=false,
b2bKill=false,
missionKill=false,
dropPiece=NULL,
mindas=0,minarr=0,minsdarr=0,
noInitSZO=false,
fkey1=false,fkey2=false,
keyCancel={},
fine=false,fineKill=false,
b2bKill=false,
missionKill=false,
dropPiece=NULL,
mindas=0,minarr=0,minsdarr=0,
noInitSZO=false,
bg='none',bgm='race',
allowMod=true,
bg='none',bgm='race',
allowMod=true,
}

View File

@@ -11,419 +11,419 @@ local PLY={draw=ply_draw}
--------------------------<Libs>--------------------------
local modeDataMeta do
local rawset=rawset
modeDataMeta={
__index=function(self,k)rawset(self,k,0)return 0 end,
__newindex=function(self,k,v)rawset(self,k,v)end,
}
local rawset=rawset
modeDataMeta={
__index=function(self,k)rawset(self,k,0)return 0 end,
__newindex=function(self,k,v)rawset(self,k,v)end,
}
end
local function _getNewStatTable()
local T={
time=0,frame=0,score=0,
key=0,rotate=0,hold=0,
extraPiece=0,finesseRate=0,
piece=0,row=0,dig=0,
atk=0,digatk=0,
send=0,recv=0,pend=0,off=0,
clear={},clears={},spin={},spins={},
pc=0,hpc=0,b2b=0,b3b=0,
maxCombo=0,maxFinesseCombo=0,
}
for i=1,29 do
T.clear[i]={0,0,0,0,0,0}
T.spin[i]={0,0,0,0,0,0,0}
T.clears[i]=0
T.spins[i]=0
end
return T
local T={
time=0,frame=0,score=0,
key=0,rotate=0,hold=0,
extraPiece=0,finesseRate=0,
piece=0,row=0,dig=0,
atk=0,digatk=0,
send=0,recv=0,pend=0,off=0,
clear={},clears={},spin={},spins={},
pc=0,hpc=0,b2b=0,b3b=0,
maxCombo=0,maxFinesseCombo=0,
}
for i=1,29 do
T.clear[i]={0,0,0,0,0,0}
T.spin[i]={0,0,0,0,0,0,0}
T.clears[i]=0
T.spins[i]=0
end
return T
end
local function _pressKey(P,keyID)
if P.keyAvailable[keyID]and P.alive then
P.keyPressing[keyID]=true
P.actList[keyID](P)
P.stat.key=P.stat.key+1
end
if P.keyAvailable[keyID]and P.alive then
P.keyPressing[keyID]=true
P.actList[keyID](P)
P.stat.key=P.stat.key+1
end
end
local function _releaseKey(P,keyID)
P.keyPressing[keyID]=false
P.keyPressing[keyID]=false
end
local function _pressKey_Rec(P,keyID)
if P.keyAvailable[keyID]and P.alive then
local L=GAME.rep
ins(L,P.frameRun)
ins(L,keyID)
P.keyPressing[keyID]=true
P.actList[keyID](P)
P.stat.key=P.stat.key+1
end
if P.keyAvailable[keyID]and P.alive then
local L=GAME.rep
ins(L,P.frameRun)
ins(L,keyID)
P.keyPressing[keyID]=true
P.actList[keyID](P)
P.stat.key=P.stat.key+1
end
end
local function _releaseKey_Rec(P,keyID)
local L=GAME.rep
ins(L,P.frameRun)
ins(L,32+keyID)
P.keyPressing[keyID]=false
local L=GAME.rep
ins(L,P.frameRun)
ins(L,32+keyID)
P.keyPressing[keyID]=false
end
local function _newEmptyPlayer(id,mini)
local P={id=id}
PLAYERS[id]=P
PLY_ALIVE[id]=P
local P={id=id}
PLAYERS[id]=P
PLY_ALIVE[id]=P
--Inherit functions of Player class
for k,v in next,Player do P[k]=v end
--Inherit functions of Player class
for k,v in next,Player do P[k]=v end
--Set key/timer event
if P.id==1 and GAME.recording then
P.pressKey=_pressKey_Rec
P.releaseKey=_releaseKey_Rec
else
P.pressKey=_pressKey
P.releaseKey=_releaseKey
end
P.update=ply_update.alive
--Set key/timer event
if P.id==1 and GAME.recording then
P.pressKey=_pressKey_Rec
P.releaseKey=_releaseKey_Rec
else
P.pressKey=_pressKey
P.releaseKey=_releaseKey
end
P.update=ply_update.alive
--Field position
P.fieldOff={--Shake FX
x=0,y=0,
vx=0,vy=0,
a=0,va=0,
}
P.x,P.y,P.size=0,0,1
P.frameColor=COLOR.Z
--Field position
P.fieldOff={--Shake FX
x=0,y=0,
vx=0,vy=0,
a=0,va=0,
}
P.x,P.y,P.size=0,0,1
P.frameColor=COLOR.Z
--Set these at Player:setPosition()
-- P.fieldX,P.fieldY=...
-- P.centerX,P.centerY=...
-- P.absFieldX,P.absFieldY=...
--Set these at Player:setPosition()
-- P.fieldX,P.fieldY=...
-- P.centerX,P.centerY=...
-- P.absFieldX,P.absFieldY=...
--Minimode
P.miniMode=mini
if mini then
P.canvas=love.graphics.newCanvas(60,120)
P.frameWait=rnd(26,62)
P.draw=ply_draw.small
else
P.draw=ply_draw.norm
end
--Minimode
P.miniMode=mini
if mini then
P.canvas=love.graphics.newCanvas(60,120)
P.frameWait=rnd(26,62)
P.draw=ply_draw.small
else
P.draw=ply_draw.norm
end
--States
P.type='none'
P.sound=false
P.alive=true
P.control=false
P.timing=false
P.result=false--String: 'finish'|'win'|'lose'
P.stat=_getNewStatTable()
P.modeData=setmetatable({},modeDataMeta)--Data use by mode
P.keyPressing={}for i=1,12 do P.keyPressing[i]=false end
P.clearingRow,P.clearedRow={},{}--Clearing animation height,cleared row mark
P.dropFX,P.moveFX,P.lockFX,P.clearFX={},{},{},{}
P.tasks={}
P.bonus={}--Texts
--States
P.type='none'
P.sound=false
P.alive=true
P.control=false
P.timing=false
P.result=false--String: 'finish'|'win'|'lose'
P.stat=_getNewStatTable()
P.modeData=setmetatable({},modeDataMeta)--Data use by mode
P.keyPressing={}for i=1,12 do P.keyPressing[i]=false end
P.clearingRow,P.clearedRow={},{}--Clearing animation height,cleared row mark
P.dropFX,P.moveFX,P.lockFX,P.clearFX={},{},{},{}
P.tasks={}
P.bonus={}--Texts
--Times
P.frameRun=GAME.frameStart--Frame run, mainly for replay
P.endCounter=0--Used after gameover
P.dropTime={}for i=1,10 do P.dropTime[i]=-1e99 end P.dropSpeed=0
--Times
P.frameRun=GAME.frameStart--Frame run, mainly for replay
P.endCounter=0--Used after gameover
P.dropTime={}for i=1,10 do P.dropTime[i]=-1e99 end P.dropSpeed=0
--Randomizers
P.seqRND=love.math.newRandomGenerator(GAME.seed)
P.atkRND=love.math.newRandomGenerator(GAME.seed)
P.holeRND=love.math.newRandomGenerator(GAME.seed)
P.aiRND=love.math.newRandomGenerator(GAME.seed)
--Randomizers
P.seqRND=love.math.newRandomGenerator(GAME.seed)
P.atkRND=love.math.newRandomGenerator(GAME.seed)
P.holeRND=love.math.newRandomGenerator(GAME.seed)
P.aiRND=love.math.newRandomGenerator(GAME.seed)
--Field-related
P.field,P.visTime={},{}
P.keepVisible=true
P.showTime=false
P.garbageBeneath=0
P.fieldBeneath=0
P.fieldUp=0
--Field-related
P.field,P.visTime={},{}
P.keepVisible=true
P.showTime=false
P.garbageBeneath=0
P.fieldBeneath=0
P.fieldUp=0
--Attack-related
P.atkBuffer={}
P.atkBufferSum,P.atkBufferSum1=0,0
P.spike,P.spikeTime=0,0
P.spikeText=love.graphics.newText(getFont(100))
--Attack-related
P.atkBuffer={}
P.atkBufferSum,P.atkBufferSum1=0,0
P.spike,P.spikeTime=0,0
P.spikeText=love.graphics.newText(getFont(100))
--Attacker-related
P.badge,P.strength=0,0
P.atkMode,P.swappingAtkMode=1,20
P.atker,P.atking,P.lastRecv={}
--Attacker-related
P.badge,P.strength=0,0
P.atkMode,P.swappingAtkMode=1,20
P.atker,P.atking,P.lastRecv={}
--User-related
P.username=""
P.uid=false
P.sid=false
--User-related
P.username=""
P.uid=false
P.sid=false
--Block states
--[[
P.curX,P.curY,P.ghoY,P.minY=0,0,0,0--x,y,ghostY
P.cur={
id=shapeID,
bk=matrix[2],
sc=table[2],
dir=direction,
name=nameID
color=colorID,
}
P.newNext=false--Warped coroutine to get new next, loaded in applyGameEnv()
]]
P.movDir,P.moving,P.downing=0,0,0--Last move key,DAS charging,downDAS charging
P.dropDelay,P.lockDelay=0,0
P.waiting,P.falling=-1,-1
P.freshTime=0
P.spinLast=false
P.spinSeq=0--For Ospin, each digit mean a spin
P.ctrlCount=0--Key press time, for finesse check
--Block states
--[[
P.curX,P.curY,P.ghoY,P.minY=0,0,0,0--x,y,ghostY
P.cur={
id=shapeID,
bk=matrix[2],
sc=table[2],
dir=direction,
name=nameID
color=colorID,
}
P.newNext=false--Warped coroutine to get new next, loaded in applyGameEnv()
]]
P.movDir,P.moving,P.downing=0,0,0--Last move key,DAS charging,downDAS charging
P.dropDelay,P.lockDelay=0,0
P.waiting,P.falling=-1,-1
P.freshTime=0
P.spinLast=false
P.spinSeq=0--For Ospin, each digit mean a spin
P.ctrlCount=0--Key press time, for finesse check
--Game states
P.combo=0
P.b2b,P.b2b1=0,0--B2B point & Displayed B2B point
P.score1=0--Displayed score
P.pieceCount=0--Count pieces from next, for drawing bagline
P.finesseCombo,P.finesseComboTime=0,0
P.nextQueue={}
P.holdQueue={}
P.holdTime=0
P.lastPiece={
id=0,name=0,--block id/name
--Game states
P.combo=0
P.b2b,P.b2b1=0,0--B2B point & Displayed B2B point
P.score1=0--Displayed score
P.pieceCount=0--Count pieces from next, for drawing bagline
P.finesseCombo,P.finesseComboTime=0,0
P.nextQueue={}
P.holdQueue={}
P.holdTime=0
P.lastPiece={
id=0,name=0,--block id/name
curX=0,curY=0,--block position
centX=0,centY=0,--center position
dir=0,--direction
curX=0,curY=0,--block position
centX=0,centY=0,--center position
dir=0,--direction
frame=-1e99,--lock time
autoLock=true,--if lock with gravity
frame=-1e99,--lock time
autoLock=true,--if lock with gravity
finePts=0,--finesse Points
finePts=0,--finesse Points
row=0,dig=0,--lines/garbage cleared
score=0,--score gained
atk=0,exblock=0,--lines attack/defend
off=0,send=0,--lines offset/sent
row=0,dig=0,--lines/garbage cleared
score=0,--score gained
atk=0,exblock=0,--lines attack/defend
off=0,send=0,--lines offset/sent
spin=false,mini=false,--if spin/mini
pc=false,hpc=false,--if pc/hpc
special=false,--if special clear (spin, >=4, pc)
}
return P
spin=false,mini=false,--if spin/mini
pc=false,hpc=false,--if pc/hpc
special=false,--if special clear (spin, >=4, pc)
}
return P
end
local function _loadGameEnv(P)--Load gameEnv
P.gameEnv={}--Current game setting environment
local ENV=P.gameEnv
local GAME,SETTING=GAME,SETTING
--Load game settings
for k,v in next,gameEnv0 do
if GAME.modeEnv[k]~=nil then
v=GAME.modeEnv[k] --Mode setting
-- print("mode-"..k..":"..tostring(v))
elseif GAME.setting[k]~=nil then
v=GAME.setting[k] --Game setting
-- print("game-"..k..":"..tostring(v))
elseif SETTING[k]~=nil then
v=SETTING[k] --Global setting
-- print("global-"..k..":"..tostring(v))
-- else
-- print("default-"..k..":"..tostring(v))
end
if type(v)~='table'then--Default setting
ENV[k]=v
else
ENV[k]=TABLE.copy(v)
end
end
if ENV.allowMod then
for _,M in next,GAME.mod do
M.func(P,M.list and M.list[M.sel])
end
end
P.gameEnv={}--Current game setting environment
local ENV=P.gameEnv
local GAME,SETTING=GAME,SETTING
--Load game settings
for k,v in next,gameEnv0 do
if GAME.modeEnv[k]~=nil then
v=GAME.modeEnv[k] --Mode setting
-- print("mode-"..k..":"..tostring(v))
elseif GAME.setting[k]~=nil then
v=GAME.setting[k] --Game setting
-- print("game-"..k..":"..tostring(v))
elseif SETTING[k]~=nil then
v=SETTING[k] --Global setting
-- print("global-"..k..":"..tostring(v))
-- else
-- print("default-"..k..":"..tostring(v))
end
if type(v)~='table'then--Default setting
ENV[k]=v
else
ENV[k]=TABLE.copy(v)
end
end
if ENV.allowMod then
for _,M in next,GAME.mod do
M.func(P,M.list and M.list[M.sel])
end
end
end
local function _loadRemoteEnv(P,confStr)--Load gameEnv
confStr=JSON.decode(confStr)
if not confStr then
confStr={}
MES.new('warn',"Bad conf from "..P.username.."#"..P.uid)
end
confStr=JSON.decode(confStr)
if not confStr then
confStr={}
MES.new('warn',"Bad conf from "..P.username.."#"..P.uid)
end
P.gameEnv={}--Current game setting environment
local ENV=P.gameEnv
local GAME,SETTING=GAME,SETTING
--Load game settings
for k,v in next,gameEnv0 do
if GAME.modeEnv[k]~=nil then
v=GAME.modeEnv[k] --Mode setting
elseif confStr[k]~=nil then
v=confStr[k] --Game setting
elseif SETTING[k]~=nil then
v=SETTING[k] --Global setting
end
if type(v)~='table'then--Default setting
ENV[k]=v
else
ENV[k]=TABLE.copy(v)
end
end
P.gameEnv={}--Current game setting environment
local ENV=P.gameEnv
local GAME,SETTING=GAME,SETTING
--Load game settings
for k,v in next,gameEnv0 do
if GAME.modeEnv[k]~=nil then
v=GAME.modeEnv[k] --Mode setting
elseif confStr[k]~=nil then
v=confStr[k] --Game setting
elseif SETTING[k]~=nil then
v=SETTING[k] --Global setting
end
if type(v)~='table'then--Default setting
ENV[k]=v
else
ENV[k]=TABLE.copy(v)
end
end
end
local function _applyGameEnv(P)--Finish gameEnv processing
local ENV=P.gameEnv
local ENV=P.gameEnv
P._20G=ENV.drop==0
P.dropDelay=ENV.drop
P.lockDelay=ENV.lock
P.freshTime=ENV.freshLimit
P._20G=ENV.drop==0
P.dropDelay=ENV.drop
P.lockDelay=ENV.lock
P.freshTime=ENV.freshLimit
P.life=ENV.life
P.life=ENV.life
P.keyAvailable={true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true}
if ENV.noTele then
for i=11,20 do
if i~=14 then
P.keyAvailable[i]=false
end
end
end
if not ENV.fkey1 then P.keyAvailable[9]=false end
if not ENV.fkey2 then P.keyAvailable[10]=false end
for _,v in next,ENV.keyCancel do
P.keyAvailable[v]=false
end
P.keyAvailable={true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true}
if ENV.noTele then
for i=11,20 do
if i~=14 then
P.keyAvailable[i]=false
end
end
end
if not ENV.fkey1 then P.keyAvailable[9]=false end
if not ENV.fkey2 then P.keyAvailable[10]=false end
for _,v in next,ENV.keyCancel do
P.keyAvailable[v]=false
end
P.skinLib=SKIN.lib[ENV.skinSet]
P.skinLib=SKIN.lib[ENV.skinSet]
P:setInvisible(
ENV.visible=='show'and -1 or
ENV.visible=='easy'and 300 or
ENV.visible=='slow'and 100 or
ENV.visible=='medium'and 60 or
ENV.visible=='fast'and 20 or
ENV.visible=='none'and 0
)
P:set20G(P._20G)
P:setHold(ENV.holdCount)
P:setNext(ENV.nextCount,ENV.nextStartPos>1)
P:setRS(ENV.RS)
P:setInvisible(
ENV.visible=='show'and -1 or
ENV.visible=='easy'and 300 or
ENV.visible=='slow'and 100 or
ENV.visible=='medium'and 60 or
ENV.visible=='fast'and 20 or
ENV.visible=='none'and 0
)
P:set20G(P._20G)
P:setHold(ENV.holdCount)
P:setNext(ENV.nextCount,ENV.nextStartPos>1)
P:setRS(ENV.RS)
if type(ENV.mission)=='table'then
P.curMission=1
end
if type(ENV.mission)=='table'then
P.curMission=1
end
ENV.das=max(ENV.das,ENV.mindas)
ENV.arr=max(ENV.arr,ENV.minarr)
ENV.sdarr=max(ENV.sdarr,ENV.minsdarr)
ENV.das=max(ENV.das,ENV.mindas)
ENV.arr=max(ENV.arr,ENV.minarr)
ENV.sdarr=max(ENV.sdarr,ENV.minsdarr)
ENV.bagLine=(ENV.sequence=='bag'or ENV.sequence=='loop')and #ENV.seqData
ENV.bagLine=(ENV.sequence=='bag'or ENV.sequence=='loop')and #ENV.seqData
if ENV.nextCount==0 then ENV.nextPos=false end
if ENV.nextCount==0 then ENV.nextPos=false end
P.newNext=coroutine.wrap(getSeqGen(P))
P:newNext(P.gameEnv.seqData)
if ENV.noInitSZO then
for _=1,5 do
local C=P.nextQueue[1]
if C and(C.id==1 or C.id==2 or C.id==6)then
table.remove(P.nextQueue,1)
else
break
end
end
P:newNext()
end
P.newNext=coroutine.wrap(getSeqGen(P))
P:newNext(P.gameEnv.seqData)
if ENV.noInitSZO then
for _=1,5 do
local C=P.nextQueue[1]
if C and(C.id==1 or C.id==2 or C.id==6)then
table.remove(P.nextQueue,1)
else
break
end
end
P:newNext()
end
if P.miniMode then
ENV.lockFX=false
ENV.dropFX=false
ENV.moveFX=false
ENV.clearFX=false
ENV.splashFX=false
ENV.shakeFX=false
ENV.text=false
end
if ENV.lockFX==0 then ENV.lockFX=false end
if ENV.dropFX==0 then ENV.dropFX=false end
if ENV.moveFX==0 then ENV.moveFX=false end
if ENV.clearFX==0 then ENV.clearFX=false end
if ENV.splashFX==0 then ENV.splashFX=false end
if ENV.shakeFX==0 then ENV.shakeFX=false end
if ENV.atkFX==0 then ENV.atkFX=false end
if ENV.ghost==0 then ENV.ghost=false end
if ENV.grid==0 then ENV.grid=false end
if ENV.center==0 then ENV.center=false end
if ENV.lineNum==0 then ENV.lineNum=false end
if P.miniMode then
ENV.lockFX=false
ENV.dropFX=false
ENV.moveFX=false
ENV.clearFX=false
ENV.splashFX=false
ENV.shakeFX=false
ENV.text=false
end
if ENV.lockFX==0 then ENV.lockFX=false end
if ENV.dropFX==0 then ENV.dropFX=false end
if ENV.moveFX==0 then ENV.moveFX=false end
if ENV.clearFX==0 then ENV.clearFX=false end
if ENV.splashFX==0 then ENV.splashFX=false end
if ENV.shakeFX==0 then ENV.shakeFX=false end
if ENV.atkFX==0 then ENV.atkFX=false end
if ENV.ghost==0 then ENV.ghost=false end
if ENV.grid==0 then ENV.grid=false end
if ENV.center==0 then ENV.center=false end
if ENV.lineNum==0 then ENV.lineNum=false end
end
--------------------------</Libs>--------------------------
--------------------------<Public>--------------------------
local DemoEnv={
face={0,0,0,0,0,0,0},
das=10,arr=2,sddas=2,sdarr=2,
drop=60,lock=60,
wait=10,fall=20,
highCam=false,
life=1e99,
allowMod=false,
fine=false,
face={0,0,0,0,0,0,0},
das=10,arr=2,sddas=2,sdarr=2,
drop=60,lock=60,
wait=10,fall=20,
highCam=false,
life=1e99,
allowMod=false,
fine=false,
}
function PLY.newDemoPlayer(id)
local P=_newEmptyPlayer(id)
P.type='computer'
P.sound=true
P.demo=true
local P=_newEmptyPlayer(id)
P.type='computer'
P.sound=true
P.demo=true
P.frameRun=180
P.draw=ply_draw.demo
P.control=true
GAME.modeEnv=DemoEnv
_loadGameEnv(P)
_applyGameEnv(P)
P:loadAI{
type='CC',
next=5,
hold=true,
delay=6,
bag='bag',
node=100000,
}
P:popNext()
P.frameRun=180
P.draw=ply_draw.demo
P.control=true
GAME.modeEnv=DemoEnv
_loadGameEnv(P)
_applyGameEnv(P)
P:loadAI{
type='CC',
next=5,
hold=true,
delay=6,
bag='bag',
node=100000,
}
P:popNext()
end
function PLY.newRemotePlayer(id,mini,ply)
local P=_newEmptyPlayer(id,mini)
P.type='remote'
P.update=ply_update.remote_alive
local P=_newEmptyPlayer(id,mini)
P.type='remote'
P.update=ply_update.remote_alive
P.draw=ply_draw.norm
P.draw=ply_draw.norm
P.stream={}
P.streamProgress=1
P.stream={}
P.streamProgress=1
netPLY.setPlayerObj(ply,P)
P.uid=ply.uid
P.username=ply.username
P.sid=ply.sid
netPLY.setPlayerObj(ply,P)
P.uid=ply.uid
P.username=ply.username
P.sid=ply.sid
_loadRemoteEnv(P,ply.config)
_applyGameEnv(P)
_loadRemoteEnv(P,ply.config)
_applyGameEnv(P)
end
function PLY.newAIPlayer(id,AIdata,mini)
local P=_newEmptyPlayer(id,mini)
P.type='computer'
local P=_newEmptyPlayer(id,mini)
P.type='computer'
_loadGameEnv(P)
local ENV=P.gameEnv
ENV.face={0,0,0,0,0,0,0}
ENV.skin={1,7,11,3,14,4,9}
_applyGameEnv(P)
P:loadAI(AIdata)
_loadGameEnv(P)
local ENV=P.gameEnv
ENV.face={0,0,0,0,0,0,0}
ENV.skin={1,7,11,3,14,4,9}
_applyGameEnv(P)
P:loadAI(AIdata)
end
function PLY.newPlayer(id,mini)
local P=_newEmptyPlayer(id,mini)
P.type='human'
P.sound=true
local P=_newEmptyPlayer(id,mini)
P.type='human'
P.sound=true
P.uid=USER.uid
P.username=USERS.getUsername(USER.uid)
P.uid=USER.uid
P.username=USERS.getUsername(USER.uid)
_loadGameEnv(P)
_applyGameEnv(P)
_loadGameEnv(P)
_applyGameEnv(P)
end
--------------------------</Public>--------------------------
return PLY

File diff suppressed because it is too large Load Diff

View File

@@ -3,234 +3,234 @@ local ceil=math.ceil
local yield=YIELD
local seqGenerators={
none=function()while true do yield()end end,
bag=function(P,seq0)
local rndGen=P.seqRND
local len=#seq0
local bag={}
while true do
while #P.nextQueue<12 do
if #bag==0 then
for i=1,len do
bag[i]=seq0[len-i+1]
end
end
P:getNext(rem(bag,rndGen:random(#bag)))
end
yield()
end
end,
his=function(P,seq0)
local rndGen=P.seqRND
local len=#seq0
local hisLen=ceil(len*.5)
local history=TABLE.new(0,hisLen)
while true do
while #P.nextQueue<12 do
local r
for _=1,hisLen do--Reroll up to [hisLen] times
r=rndGen:random(len)
for i=1,hisLen do
if r==history[i]then
goto CONTINUE_rollAgain
end
end
do break end
::CONTINUE_rollAgain::
end
if history[1]~=0 then P:getNext(seq0[r])end
rem(history,1)ins(history,r)
end
yield()
end
end,
hisPool=function(P,seq0)
local rndGen=P.seqRND
local len=#seq0
local hisLen=ceil(len*.5)
local history=TABLE.new(0,hisLen)--Indexes of mino-index
none=function()while true do yield()end end,
bag=function(P,seq0)
local rndGen=P.seqRND
local len=#seq0
local bag={}
while true do
while #P.nextQueue<12 do
if #bag==0 then
for i=1,len do
bag[i]=seq0[len-i+1]
end
end
P:getNext(rem(bag,rndGen:random(#bag)))
end
yield()
end
end,
his=function(P,seq0)
local rndGen=P.seqRND
local len=#seq0
local hisLen=ceil(len*.5)
local history=TABLE.new(0,hisLen)
while true do
while #P.nextQueue<12 do
local r
for _=1,hisLen do--Reroll up to [hisLen] times
r=rndGen:random(len)
for i=1,hisLen do
if r==history[i]then
goto CONTINUE_rollAgain
end
end
do break end
::CONTINUE_rollAgain::
end
if history[1]~=0 then P:getNext(seq0[r])end
rem(history,1)ins(history,r)
end
yield()
end
end,
hisPool=function(P,seq0)
local rndGen=P.seqRND
local len=#seq0
local hisLen=ceil(len*.5)
local history=TABLE.new(0,hisLen)--Indexes of mino-index
local poolLen=5*len
local droughtTimes=TABLE.new(len,len)--Drought times of seq0
local pool={}for i=1,len do for _=1,5 do ins(pool,i)end end--5 times indexes of seq0
local function _poolPick()
local r=rndGen:random(poolLen)
local res=pool[r]
local poolLen=5*len
local droughtTimes=TABLE.new(len,len)--Drought times of seq0
local pool={}for i=1,len do for _=1,5 do ins(pool,i)end end--5 times indexes of seq0
local function _poolPick()
local r=rndGen:random(poolLen)
local res=pool[r]
--Find droughtest(s) minoes
local droughtList={1}--Droughtst minoes' indexes of seq0
local maxTime=droughtTimes[1]
for i=2,len do
if droughtTimes[i]>maxTime then
maxTime=droughtTimes[i]
if #droughtList==1 then droughtList[1]=i else droughtList={i}end
elseif droughtTimes[i]==maxTime then
ins(droughtList,i)
end
end
--Find droughtest(s) minoes
local droughtList={1}--Droughtst minoes' indexes of seq0
local maxTime=droughtTimes[1]
for i=2,len do
if droughtTimes[i]>maxTime then
maxTime=droughtTimes[i]
if #droughtList==1 then droughtList[1]=i else droughtList={i}end
elseif droughtTimes[i]==maxTime then
ins(droughtList,i)
end
end
--Update droughtTimes
for i=1,len do droughtTimes[i]=droughtTimes[i]+1 end
droughtTimes[res]=0
--Update droughtTimes
for i=1,len do droughtTimes[i]=droughtTimes[i]+1 end
droughtTimes[res]=0
--Update pool
-- print("Rem "..res)
pool[r]=droughtList[rndGen:random(#droughtList)]
-- print("Add "..pool[r])
--Update pool
-- print("Rem "..res)
pool[r]=droughtList[rndGen:random(#droughtList)]
-- print("Add "..pool[r])
return res
end
return res
end
while true do
while #P.nextQueue<12 do
-- print"======================"
--Pick a mino from pool
local tryTime=0
::REPEAT_pickAgain::
local r=_poolPick()--Random mino-index in pool
for i=1,len do
if r==history[i]then
tryTime=tryTime+1
if tryTime<hisLen then goto REPEAT_pickAgain end
end
end
while true do
while #P.nextQueue<12 do
-- print"======================"
--Pick a mino from pool
local tryTime=0
::REPEAT_pickAgain::
local r=_poolPick()--Random mino-index in pool
for i=1,len do
if r==history[i]then
tryTime=tryTime+1
if tryTime<hisLen then goto REPEAT_pickAgain end
end
end
--Give mino to player & update history
if history[1]~=0 then P:getNext(seq0[r])end
rem(history,1)ins(history,r)
-- print("Player GET: "..r)
-- print("History: "..table.concat(history,","))
-- local L=TABLE.new("",len)
-- for _,v in next,pool do L[v]=L[v].."+"end
-- for i=1,#L do print(i,droughtTimes[i],L[i])end
end
yield()
end
end,
c2=function(P,seq0)
local rndGen=P.seqRND
local len=#seq0
local weight={}
for i=1,len do weight[i]=0 end
--Give mino to player & update history
if history[1]~=0 then P:getNext(seq0[r])end
rem(history,1)ins(history,r)
-- print("Player GET: "..r)
-- print("History: "..table.concat(history,","))
-- local L=TABLE.new("",len)
-- for _,v in next,pool do L[v]=L[v].."+"end
-- for i=1,#L do print(i,droughtTimes[i],L[i])end
end
yield()
end
end,
c2=function(P,seq0)
local rndGen=P.seqRND
local len=#seq0
local weight={}
for i=1,len do weight[i]=0 end
while true do
while #P.nextQueue<12 do
local maxK=1
for i=1,len do
weight[i]=weight[i]*.5+rndGen:random()
if weight[i]>weight[maxK]then
maxK=i
end
end
weight[maxK]=weight[maxK]/3.5
P:getNext(seq0[maxK])
end
yield()
end
end,
rnd=function(P,seq0)
if #seq0==1 then
local i=seq0[1]
while true do
while #P.nextQueue<12 do P:getNext(i)end
yield()
end
else
local rndGen=P.seqRND
local len=#seq0
local last=0
while true do
while #P.nextQueue<12 do
local r=rndGen:random(len-1)
if r>=last then r=r+1 end
P:getNext(seq0[r])
last=r
end
yield()
end
end
end,
mess=function(P,seq0)
local rndGen=P.seqRND
while true do
while #P.nextQueue<12 do
P:getNext(seq0[rndGen:random(#seq0)])
end
yield()
end
end,
reverb=function(P,seq0)
local rndGen=P.seqRND
local bufferSeq,bag={},{}
while true do
while #P.nextQueue<12 do
if #bag==0 then
for i=1,#seq0 do bufferSeq[i]=seq0[i]end
repeat
local r=rem(bufferSeq,rndGen:random(#bag))
local p=1
repeat
ins(bag,r)
p=p-.15-rndGen:random()
until p<0
until #bufferSeq==0
for i=1,#bag do
bufferSeq[i]=bag[i]
end
end
P:getNext(rem(bag,rndGen:random(#bag)))
end
yield()
end
end,
loop=function(P,seq0)
local len=#seq0
local bag={}
while true do
while #P.nextQueue<12 do
if #bag==0 then
for i=1,len do
bag[i]=seq0[len-i+1]
end
end
P:getNext(rem(bag))
end
yield()
end
end,
fixed=function(P,seq0)
local seq={}
for i=#seq0,1,-1 do
ins(seq,seq0[i])
end
while true do
while #P.nextQueue<12 do
if seq[1]then
P:getNext(rem(seq))
else
if not(P.cur or P.nextQueue[1]or P.holdQueue[1])then
P:lose(true)
end
break
end
end
yield()
end
end,
while true do
while #P.nextQueue<12 do
local maxK=1
for i=1,len do
weight[i]=weight[i]*.5+rndGen:random()
if weight[i]>weight[maxK]then
maxK=i
end
end
weight[maxK]=weight[maxK]/3.5
P:getNext(seq0[maxK])
end
yield()
end
end,
rnd=function(P,seq0)
if #seq0==1 then
local i=seq0[1]
while true do
while #P.nextQueue<12 do P:getNext(i)end
yield()
end
else
local rndGen=P.seqRND
local len=#seq0
local last=0
while true do
while #P.nextQueue<12 do
local r=rndGen:random(len-1)
if r>=last then r=r+1 end
P:getNext(seq0[r])
last=r
end
yield()
end
end
end,
mess=function(P,seq0)
local rndGen=P.seqRND
while true do
while #P.nextQueue<12 do
P:getNext(seq0[rndGen:random(#seq0)])
end
yield()
end
end,
reverb=function(P,seq0)
local rndGen=P.seqRND
local bufferSeq,bag={},{}
while true do
while #P.nextQueue<12 do
if #bag==0 then
for i=1,#seq0 do bufferSeq[i]=seq0[i]end
repeat
local r=rem(bufferSeq,rndGen:random(#bag))
local p=1
repeat
ins(bag,r)
p=p-.15-rndGen:random()
until p<0
until #bufferSeq==0
for i=1,#bag do
bufferSeq[i]=bag[i]
end
end
P:getNext(rem(bag,rndGen:random(#bag)))
end
yield()
end
end,
loop=function(P,seq0)
local len=#seq0
local bag={}
while true do
while #P.nextQueue<12 do
if #bag==0 then
for i=1,len do
bag[i]=seq0[len-i+1]
end
end
P:getNext(rem(bag))
end
yield()
end
end,
fixed=function(P,seq0)
local seq={}
for i=#seq0,1,-1 do
ins(seq,seq0[i])
end
while true do
while #P.nextQueue<12 do
if seq[1]then
P:getNext(rem(seq))
else
if not(P.cur or P.nextQueue[1]or P.holdQueue[1])then
P:lose(true)
end
break
end
end
yield()
end
end,
}
return function(P)--Return a piece-generating function for player P
local s=P.gameEnv.sequence
if type(s)=='function'then
return s
elseif type(s)=='string'and seqGenerators[s]then
return seqGenerators[s]
else
MES.new('warn',
type(s)=='string'and
"No sequence mode called "..s or
"Wrong sequence generator"
)
P.gameEnv.sequence='bag'
return seqGenerators.bag
end
local s=P.gameEnv.sequence
if type(s)=='function'then
return s
elseif type(s)=='string'and seqGenerators[s]then
return seqGenerators[s]
else
MES.new('warn',
type(s)=='string'and
"No sequence mode called "..s or
"Wrong sequence generator"
)
P.gameEnv.sequence='bag'
return seqGenerators.bag
end
end

View File

@@ -7,444 +7,444 @@ local TEXT,GAME=TEXT,GAME
local PLY_ALIVE=PLY_ALIVE
local function _updateMisc(P,dt)
--Finesse combo animation
if P.finesseComboTime>0 then
P.finesseComboTime=P.finesseComboTime-1
end
--Finesse combo animation
if P.finesseComboTime>0 then
P.finesseComboTime=P.finesseComboTime-1
end
--Update spike counter
if P.spikeTime>0 then P.spikeTime=P.spikeTime-1 end
--Update spike counter
if P.spikeTime>0 then P.spikeTime=P.spikeTime-1 end
--Update atkBuffer alert
local t=P.atkBufferSum1
if t<P.atkBufferSum then
P.atkBufferSum1=t+.25
elseif t>P.atkBufferSum then
P.atkBufferSum1=t-.5
end
--Update atkBuffer alert
local t=P.atkBufferSum1
if t<P.atkBufferSum then
P.atkBufferSum1=t+.25
elseif t>P.atkBufferSum then
P.atkBufferSum1=t-.5
end
--Update attack buffer
local bf=P.atkBuffer
for i=#bf,1,-1 do
local A=bf[i]
A.time=A.time+1
if not A.sent then
if A.countdown>0 then
A.countdown=max(A.countdown-P.gameEnv.garbageSpeed,0)
end
else
if A.time>20 then
rem(bf,i)
end
end
end
--Update attack buffer
local bf=P.atkBuffer
for i=#bf,1,-1 do
local A=bf[i]
A.time=A.time+1
if not A.sent then
if A.countdown>0 then
A.countdown=max(A.countdown-P.gameEnv.garbageSpeed,0)
end
else
if A.time>20 then
rem(bf,i)
end
end
end
--Push up garbages
local y=P.fieldBeneath
if y>0 then
P.fieldBeneath=max(y-P.gameEnv.pushSpeed,0)
end
--Push up garbages
local y=P.fieldBeneath
if y>0 then
P.fieldBeneath=max(y-P.gameEnv.pushSpeed,0)
end
--Move camera
if P.gameEnv.highCam then
if not P.alive then
y=0
else
y=30*max(min(#P.field-18.5-P.fieldBeneath/30,P.ghoY-17),0)
end
local f=P.fieldUp
if f~=y then
P.fieldUp=f>y and max(f*.95+y*.05-2,y)or min(f*.97+y*.03+1,y)
end
end
--Move camera
if P.gameEnv.highCam then
if not P.alive then
y=0
else
y=30*max(min(#P.field-18.5-P.fieldBeneath/30,P.ghoY-17),0)
end
local f=P.fieldUp
if f~=y then
P.fieldUp=f>y and max(f*.95+y*.05-2,y)or min(f*.97+y*.03+1,y)
end
end
--Update Score
if P.stat.score>P.score1 then
if P.stat.score-P.score1<10 then
P.score1=P.score1+1
else
P.score1=int(min(P.score1*.9+P.stat.score*.1+1))
end
end
--Update Score
if P.stat.score>P.score1 then
if P.stat.score-P.score1<10 then
P.score1=P.score1+1
else
P.score1=int(min(P.score1*.9+P.stat.score*.1+1))
end
end
--Update lock FX
for i=#P.lockFX,1,-1 do
local S=P.lockFX[i]
S[3]=S[3]+S[4]*dt
if S[3]>1 then
rem(P.lockFX,i)
end
end
--Update lock FX
for i=#P.lockFX,1,-1 do
local S=P.lockFX[i]
S[3]=S[3]+S[4]*dt
if S[3]>1 then
rem(P.lockFX,i)
end
end
--Update drop FX
for i=#P.dropFX,1,-1 do
local S=P.dropFX[i]
S[5]=S[5]+S[6]*dt
if S[5]>1 then
rem(P.dropFX,i)
end
end
--Update drop FX
for i=#P.dropFX,1,-1 do
local S=P.dropFX[i]
S[5]=S[5]+S[6]*dt
if S[5]>1 then
rem(P.dropFX,i)
end
end
--Update move FX
for i=#P.moveFX,1,-1 do
local S=P.moveFX[i]
S[4]=S[4]+S[5]*dt
if S[4]>1 then
rem(P.moveFX,i)
end
end
--Update move FX
for i=#P.moveFX,1,-1 do
local S=P.moveFX[i]
S[4]=S[4]+S[5]*dt
if S[4]>1 then
rem(P.moveFX,i)
end
end
--Update clear FX
for i=#P.clearFX,1,-1 do
local S=P.clearFX[i]
S[2]=S[2]+S[3]*dt
if S[2]>1 then
rem(P.clearFX,i)
end
end
--Update clear FX
for i=#P.clearFX,1,-1 do
local S=P.clearFX[i]
S[2]=S[2]+S[3]*dt
if S[2]>1 then
rem(P.clearFX,i)
end
end
--Field shaking
if P.gameEnv.shakeFX then
local O=P.fieldOff
O.vx=O.vx*.7-abs(O.x)^1.3*(O.x>0 and .1 or -.1)
O.x=O.x+O.vx
--Field shaking
if P.gameEnv.shakeFX then
local O=P.fieldOff
O.vx=O.vx*.7-abs(O.x)^1.3*(O.x>0 and .1 or -.1)
O.x=O.x+O.vx
O.vy=O.vy*.7-abs(O.y)^1.2*(O.y>0 and .1 or -.1)
O.y=O.y+O.vy
O.vy=O.vy*.7-abs(O.y)^1.2*(O.y>0 and .1 or -.1)
O.y=O.y+O.vy
O.va=O.va*.7-abs(O.a)^1.4*(O.a>0 and .08 or -.08)
O.a=O.a+O.va
if abs(O.a)<.0006 then O.a,O.va=0,0 end
end
O.va=O.va*.7-abs(O.a)^1.4*(O.a>0 and .08 or -.08)
O.a=O.a+O.va
if abs(O.a)<.0006 then O.a,O.va=0,0 end
end
--Update texts
if P.bonus then
TEXT.update(P.bonus)
end
--Update texts
if P.bonus then
TEXT.update(P.bonus)
end
--Update tasks
local L=P.tasks
for i=#L,1,-1 do
local tr=L[i].thread
assert(resume(tr))
if status(tr)=='dead'then
rem(L,i)
end
end
--Update tasks
local L=P.tasks
for i=#L,1,-1 do
local tr=L[i].thread
assert(resume(tr))
if status(tr)=='dead'then
rem(L,i)
end
end
end
local update={
}
function update.alive(P,dt)
local ENV=P.gameEnv
local S=P.stat
local ENV=P.gameEnv
local S=P.stat
P.frameRun=P.frameRun+1
if P.frameRun<=180 then
if P.frameRun==180 then
if P.id==1 then SFX.play('start')end
P.control=true
P.timing=true
P:popNext()
elseif P.frameRun==60 or P.frameRun==120 then
if P.id==1 then SFX.play('ready')end
end
if P.movDir~=0 then
if P.moving<P.gameEnv.das then
P.moving=P.moving+1
end
else
P.moving=0
end
return true
end
P.frameRun=P.frameRun+1
if P.frameRun<=180 then
if P.frameRun==180 then
if P.id==1 then SFX.play('start')end
P.control=true
P.timing=true
P:popNext()
elseif P.frameRun==60 or P.frameRun==120 then
if P.id==1 then SFX.play('ready')end
end
if P.movDir~=0 then
if P.moving<P.gameEnv.das then
P.moving=P.moving+1
end
else
P.moving=0
end
return true
end
if P.timing then
S.time=S.time+dt
S.frame=S.frame+1
end
if P.timing then
S.time=S.time+dt
S.frame=S.frame+1
end
--Calculate key speed
do
local v=0
for i=2,10 do v=v+i*(i-1)*72/(P.frameRun-P.dropTime[i])end
P.dropSpeed=P.dropSpeed*.99+v*.01
end
--Calculate key speed
do
local v=0
for i=2,10 do v=v+i*(i-1)*72/(P.frameRun-P.dropTime[i])end
P.dropSpeed=P.dropSpeed*.99+v*.01
end
if GAME.modeEnv.royaleMode then
local v=P.swappingAtkMode
if P.keyPressing[9]then
P.swappingAtkMode=min(v+2,30)
else
local tar=#P.field>15 and 4 or 8
if v~=tar then
P.swappingAtkMode=v+(v<tar and 1 or -1)
end
end
end
if GAME.modeEnv.royaleMode then
local v=P.swappingAtkMode
if P.keyPressing[9]then
P.swappingAtkMode=min(v+2,30)
else
local tar=#P.field>15 and 4 or 8
if v~=tar then
P.swappingAtkMode=v+(v<tar and 1 or -1)
end
end
end
if P.type=='computer'then
P.bot:update(dt)
end
if P.type=='computer'then
P.bot:update(dt)
end
--Fresh visible time
if not P.keepVisible then
local V=P.visTime
for j=1,#P.field do
local L=V[j]
for i=1,10 do
if L[i]>0 then L[i]=L[i]-1 end
end
end
end
--Fresh visible time
if not P.keepVisible then
local V=P.visTime
for j=1,#P.field do
local L=V[j]
for i=1,10 do
if L[i]>0 then L[i]=L[i]-1 end
end
end
end
--Moving pressed
if P.movDir~=0 then
local das,arr=ENV.das,ENV.arr
local mov=P.moving
if P.waiting==-1 then
if P.movDir==1 then
if P.keyPressing[2]then
if arr>0 then
if mov==das+arr or mov==das then
if not P.cur or P:ifoverlap(P.cur.bk,P.curX+1,P.curY)then
mov=das+arr-1
else
P:act_moveRight(true)
mov=das
end
end
mov=mov+1
else
if mov==das then
P:act_insRight(true)
else
mov=mov+1
end
end
if mov>=das and ENV.shakeFX and P.cur and P:ifoverlap(P.cur.bk,P.curX+1,P.curY)then
P.fieldOff.vx=.5
end
else
P.movDir=0
end
else
if P.keyPressing[1]then
if arr>0 then
if mov==das+arr or mov==das then
if not P.cur or P:ifoverlap(P.cur.bk,P.curX-1,P.curY)then
mov=das+arr-1
else
P:act_moveLeft(true)
mov=das
end
end
mov=mov+1
else
if mov==das then
P:act_insLeft(true)
else
mov=mov+1
end
end
if mov>=das and ENV.shakeFX and P.cur and P:ifoverlap(P.cur.bk,P.curX-1,P.curY)then
P.fieldOff.vx=-.5
end
else
P.movDir=0
end
end
elseif mov<das then
mov=mov+1
end
P.moving=mov
elseif P.keyPressing[1]then
P.movDir=-1
P.moving=0
elseif P.keyPressing[2]then
P.movDir=1
P.moving=0
end
--Moving pressed
if P.movDir~=0 then
local das,arr=ENV.das,ENV.arr
local mov=P.moving
if P.waiting==-1 then
if P.movDir==1 then
if P.keyPressing[2]then
if arr>0 then
if mov==das+arr or mov==das then
if not P.cur or P:ifoverlap(P.cur.bk,P.curX+1,P.curY)then
mov=das+arr-1
else
P:act_moveRight(true)
mov=das
end
end
mov=mov+1
else
if mov==das then
P:act_insRight(true)
else
mov=mov+1
end
end
if mov>=das and ENV.shakeFX and P.cur and P:ifoverlap(P.cur.bk,P.curX+1,P.curY)then
P.fieldOff.vx=.5
end
else
P.movDir=0
end
else
if P.keyPressing[1]then
if arr>0 then
if mov==das+arr or mov==das then
if not P.cur or P:ifoverlap(P.cur.bk,P.curX-1,P.curY)then
mov=das+arr-1
else
P:act_moveLeft(true)
mov=das
end
end
mov=mov+1
else
if mov==das then
P:act_insLeft(true)
else
mov=mov+1
end
end
if mov>=das and ENV.shakeFX and P.cur and P:ifoverlap(P.cur.bk,P.curX-1,P.curY)then
P.fieldOff.vx=-.5
end
else
P.movDir=0
end
end
elseif mov<das then
mov=mov+1
end
P.moving=mov
elseif P.keyPressing[1]then
P.movDir=-1
P.moving=0
elseif P.keyPressing[2]then
P.movDir=1
P.moving=0
end
--Drop pressed
if P.keyPressing[7]and not P.keyPressing[9]then
P.downing=P.downing+1
local d=P.downing-ENV.sddas
if d>1 then
if ENV.sdarr>0 then
if d%ENV.sdarr==0 then
P:act_down1()
end
else
P:act_insDown()
end
if ENV.shakeFX then
P.fieldOff.vy=.2
end
end
else
P.downing=0
end
--Drop pressed
if P.keyPressing[7]and not P.keyPressing[9]then
P.downing=P.downing+1
local d=P.downing-ENV.sddas
if d>1 then
if ENV.sdarr>0 then
if d%ENV.sdarr==0 then
P:act_down1()
end
else
P:act_insDown()
end
if ENV.shakeFX then
P.fieldOff.vy=.2
end
end
else
P.downing=0
end
--Falling animation
if P.falling>=0 then
P.falling=P.falling-1
if P.falling>=0 then
goto THROW_stop
else
local L=#P.clearingRow
if P.sound and ENV.fall>0 and #P.field+L>P.clearingRow[L]then SFX.play('fall')end
P.clearingRow={}
end
end
--Falling animation
if P.falling>=0 then
P.falling=P.falling-1
if P.falling>=0 then
goto THROW_stop
else
local L=#P.clearingRow
if P.sound and ENV.fall>0 and #P.field+L>P.clearingRow[L]then SFX.play('fall')end
P.clearingRow={}
end
end
--Update block state
if P.control then
--Try spawn new block
if P.waiting>=0 then
P.waiting=P.waiting-1
if P.waiting<0 then
P:popNext()
end
goto THROW_stop
end
--Update block state
if P.control then
--Try spawn new block
if P.waiting>=0 then
P.waiting=P.waiting-1
if P.waiting<0 then
P:popNext()
end
goto THROW_stop
end
--Natural block falling
if P.cur then
if P.curY>P.ghoY then
local D=P.dropDelay
if D>1 then
P.dropDelay=D-1
goto THROW_stop
end
--Natural block falling
if P.cur then
if P.curY>P.ghoY then
local D=P.dropDelay
if D>1 then
P.dropDelay=D-1
goto THROW_stop
end
if D==1 then
if ENV.moveFX and ENV.block then
P:createMoveFX('down')
end
P.curY=P.curY-1
else
D=min(1/D,P.curY-P.ghoY)--1/D=Drop dist, lowest to ghost
if ENV.moveFX and ENV.block then
for _=1,D do
P:createMoveFX('down')
P.curY=P.curY-1
end
else
P.curY=P.curY-D
end
end
P:freshBlock('fresh')
P.spinLast=false
if D==1 then
if ENV.moveFX and ENV.block then
P:createMoveFX('down')
end
P.curY=P.curY-1
else
D=min(1/D,P.curY-P.ghoY)--1/D=Drop dist, lowest to ghost
if ENV.moveFX and ENV.block then
for _=1,D do
P:createMoveFX('down')
P.curY=P.curY-1
end
else
P.curY=P.curY-D
end
end
P:freshBlock('fresh')
P.spinLast=false
if P.ghoY~=P.curY then
P.dropDelay=ENV.drop
end
else
P.lockDelay=P.lockDelay-1
if P.lockDelay>=0 then
goto THROW_stop
end
P:drop(true)
if P.bot then
P.bot:unexpectedLock()
end
end
end
end
::THROW_stop::
if P.ghoY~=P.curY then
P.dropDelay=ENV.drop
end
else
P.lockDelay=P.lockDelay-1
if P.lockDelay>=0 then
goto THROW_stop
end
P:drop(true)
if P.bot then
P.bot:unexpectedLock()
end
end
end
end
::THROW_stop::
--B2B bar animation
if P.b2b1==P.b2b then
elseif P.b2b1<P.b2b then
P.b2b1=min(P.b2b1*.98+P.b2b*.02+.4,P.b2b)
else
P.b2b1=max(P.b2b1*.95+P.b2b*.05-.6,P.b2b)
end
--B2B bar animation
if P.b2b1==P.b2b then
elseif P.b2b1<P.b2b then
P.b2b1=min(P.b2b1*.98+P.b2b*.02+.4,P.b2b)
else
P.b2b1=max(P.b2b1*.95+P.b2b*.05-.6,P.b2b)
end
--Others
_updateMisc(P,dt)
-- P:setPosition(640-150-(30*(P.curX+P.cur.sc[2])-15),30*(P.curY+P.cur.sc[1])+15-300+(ENV.smooth and P.ghoY~=P.curY and(P.dropDelay/ENV.drop-1)*30 or 0))
--Others
_updateMisc(P,dt)
-- P:setPosition(640-150-(30*(P.curX+P.cur.sc[2])-15),30*(P.curY+P.cur.sc[1])+15-300+(ENV.smooth and P.ghoY~=P.curY and(P.dropDelay/ENV.drop-1)*30 or 0))
end
function update.dead(P,dt)
local S=P.stat
local S=P.stat
--Final average speed
P.dropSpeed=P.dropSpeed*.96+S.piece/S.frame*144
--Final average speed
P.dropSpeed=P.dropSpeed*.96+S.piece/S.frame*144
if GAME.modeEnv.royaleMode then
P.swappingAtkMode=min(P.swappingAtkMode+2,30)
end
if GAME.modeEnv.royaleMode then
P.swappingAtkMode=min(P.swappingAtkMode+2,30)
end
if P.falling>=0 then
P.falling=P.falling-1
if P.falling<0 then
local L=#P.clearingRow
if P.sound and P.gameEnv.fall>0 and #P.field+L>P.clearingRow[L]then SFX.play('fall')end
P.clearingRow={}
end
end
if P.b2b1>0 then
P.b2b1=max(0,P.b2b1*.92-1)
end
_updateMisc(P,dt)
if P.falling>=0 then
P.falling=P.falling-1
if P.falling<0 then
local L=#P.clearingRow
if P.sound and P.gameEnv.fall>0 and #P.field+L>P.clearingRow[L]then SFX.play('fall')end
P.clearingRow={}
end
end
if P.b2b1>0 then
P.b2b1=max(0,P.b2b1*.92-1)
end
_updateMisc(P,dt)
end
function update.remote_alive(P,dt)
local frameRate=(P.stream[#P.stream-1]or 0)-P.frameRun
frameRate=
frameRate<26 and 1 or
frameRate<50 and 2 or
frameRate<80 and 3 or
frameRate<120 and 5 or
frameRate<160 and 7 or
frameRate<200 and 10 or
20
for _=1,frameRate do
local eventTime=P.stream[P.streamProgress]
if eventTime then--Normal state, event forward
if P.frameRun==eventTime then--Event time, execute action, read next so don't update immediately
local event=P.stream[P.streamProgress+1]
if event==0 then--Just wait
elseif event<=32 then--Press key
P:pressKey(event)
elseif event<=64 then--Release key
P:releaseKey(event-32)
elseif event>0x2000000000000 then--Sending lines
local sid=event%0x100
local amount=int(event/0x100)%0x100
local time=int(event/0x10000)%0x10000
local line=int(event/0x100000000)%0x10000
for _,p in next,PLY_ALIVE do
if p.sid==sid then
P:attack(p,amount,time,line,true)
if P.gameEnv.atkFX then
P:createBeam(p,amount,P.gameEnv.atkFX,P.cur.color)
end
break
end
end
elseif event>0x1000000000000 then--Receiving lines
local sid=event%0x100
for _,p in next,PLY_ALIVE do
if p.sid==sid then
P:receive(
p,
int(event/0x100)%0x100,--amount
int(event/0x10000)%0x10000,--time
int(event/0x100000000)%0x10000--line
)
break
end
end
end
P.streamProgress=P.streamProgress+2
else--No event now, run one frame
update.alive(P,dt/frameRate)
P.stat.time=P.frameRun/60
end
else--Pause state, no actions, quit loop
break
end
end
local frameRate=(P.stream[#P.stream-1]or 0)-P.frameRun
frameRate=
frameRate<26 and 1 or
frameRate<50 and 2 or
frameRate<80 and 3 or
frameRate<120 and 5 or
frameRate<160 and 7 or
frameRate<200 and 10 or
20
for _=1,frameRate do
local eventTime=P.stream[P.streamProgress]
if eventTime then--Normal state, event forward
if P.frameRun==eventTime then--Event time, execute action, read next so don't update immediately
local event=P.stream[P.streamProgress+1]
if event==0 then--Just wait
elseif event<=32 then--Press key
P:pressKey(event)
elseif event<=64 then--Release key
P:releaseKey(event-32)
elseif event>0x2000000000000 then--Sending lines
local sid=event%0x100
local amount=int(event/0x100)%0x100
local time=int(event/0x10000)%0x10000
local line=int(event/0x100000000)%0x10000
for _,p in next,PLY_ALIVE do
if p.sid==sid then
P:attack(p,amount,time,line,true)
if P.gameEnv.atkFX then
P:createBeam(p,amount,P.gameEnv.atkFX,P.cur.color)
end
break
end
end
elseif event>0x1000000000000 then--Receiving lines
local sid=event%0x100
for _,p in next,PLY_ALIVE do
if p.sid==sid then
P:receive(
p,
int(event/0x100)%0x100,--amount
int(event/0x10000)%0x10000,--time
int(event/0x100000000)%0x10000--line
)
break
end
end
end
P.streamProgress=P.streamProgress+2
else--No event now, run one frame
update.alive(P,dt/frameRate)
P.stat.time=P.frameRun/60
end
else--Pause state, no actions, quit loop
break
end
end
end
return update