From 6cffe74f36b0673eda63150d9c38e40670c438d5 Mon Sep 17 00:00:00 2001
From: MrZ626 <1046101471@qq.com>
Date: Mon, 29 Mar 2021 01:15:17 +0800
Subject: [PATCH] =?UTF-8?q?=E7=8E=A9=E5=AE=B6=E7=B1=BB=E6=89=80=E6=9C=89?=
=?UTF-8?q?=E6=96=B9=E6=B3=95=E6=94=B9=E7=94=A8=E5=86=92=E5=8F=B7=E5=92=8C?=
=?UTF-8?q?self?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
parts/player/player.lua | 1519 +++++++++++++++++++--------------------
1 file changed, 759 insertions(+), 760 deletions(-)
diff --git a/parts/player/player.lua b/parts/player/player.lua
index 1e822aca..1cd56cf6 100644
--- a/parts/player/player.lua
+++ b/parts/player/player.lua
@@ -1,7 +1,6 @@
-------------------------------------------------------
---Notice: anything in this file or in any other file,
---local var P stands for Player object. Don't forget it.
-------------------------------------------------------
+-------------------------------------------------
+--Var P in other files represent Player object!--
+-------------------------------------------------
local Player={}--Player class
local int,ceil,rnd=math.floor,math.ceil,math.random
@@ -12,96 +11,96 @@ local resume,yield=coroutine.resume,coroutine.yield
local kickList=require"parts.kickList"
----------------------------------------------------
-function Player.showText(P,text,dx,dy,font,style,spd,stop)
- if P.gameEnv.text then
- ins(P.bonus,TEXT.getText(text,150+dx,300+dy,font*P.size,style,spd,stop))
+function Player:showText(text,dx,dy,font,style,spd,stop)
+ if self.gameEnv.text then
+ ins(self.bonus,TEXT.getText(text,150+dx,300+dy,font*self.size,style,spd,stop))
end
end
-function Player.showTextF(P,text,dx,dy,font,style,spd,stop)
- ins(P.bonus,TEXT.getText(text,150+dx,300+dy,font*P.size,style,spd,stop))
+function Player:showTextF(text,dx,dy,font,style,spd,stop)
+ ins(self.bonus,TEXT.getText(text,150+dx,300+dy,font*self.size,style,spd,stop))
end
-function Player.createLockFX(P)
- local CB=P.cur.bk
- local t=12-P.gameEnv.lockFX*2
+function Player:createLockFX()
+ local CB=self.cur.bk
+ local t=12-self.gameEnv.lockFX*2
for i=1,#CB do
- local y=P.curY+i-1
- local L=P.clearedRow
+ local y=self.curY+i-1
+ local L=self.clearedRow
for j=1,#L do
if L[j]==y then goto CONTINUE_skip end
end
y=-30*y
for j=1,#CB[1]do
if CB[i][j]then
- ins(P.lockFX,{30*(P.curX+j-2),y,0,t})
+ ins(self.lockFX,{30*(self.curX+j-2),y,0,t})
end
end
::CONTINUE_skip::
end
end
-function Player.createDropFX(P,x,y,w,h)
- ins(P.dropFX,{x,y,w,h,0,13-2*P.gameEnv.dropFX})
+function Player:createDropFX(x,y,w,h)
+ ins(self.dropFX,{x,y,w,h,0,13-2*self.gameEnv.dropFX})
end
-function Player.createMoveFX(P,dir)
- local T=10-1.5*P.gameEnv.moveFX
- local C=P.cur.color
- local CB=P.cur.bk
- local x=P.curX-1
- local y=P.gameEnv.smooth and P.curY+P.dropDelay/P.gameEnv.drop-2 or P.curY-1
+function Player:createMoveFX(dir)
+ local T=10-1.5*self.gameEnv.moveFX
+ local C=self.cur.color
+ local CB=self.cur.bk
+ local x=self.curX-1
+ local y=self.gameEnv.smooth and self.curY+self.dropDelay/self.gameEnv.drop-2 or self.curY-1
if dir=="left"then
for i=1,#CB do for j=#CB[1],1,-1 do
- if P.cur.bk[i][j]then
- ins(P.moveFX,{C,x+j,y+i,0,T})
+ if self.cur.bk[i][j]then
+ ins(self.moveFX,{C,x+j,y+i,0,T})
break
end
end end
elseif dir=="right"then
for i=1,#CB do for j=1,#CB[1]do
- if P.cur.bk[i][j]then
- ins(P.moveFX,{C,x+j,y+i,0,T})
+ if self.cur.bk[i][j]then
+ ins(self.moveFX,{C,x+j,y+i,0,T})
break
end
end end
elseif dir=="down"then
for j=1,#CB[1]do for i=#CB,1,-1 do
- if P.cur.bk[i][j]then
- ins(P.moveFX,{C,x+j,y+i,0,T})
+ if self.cur.bk[i][j]then
+ ins(self.moveFX,{C,x+j,y+i,0,T})
break
end
end end
else
for i=1,#CB do for j=1,#CB[1]do
- if P.cur.bk[i][j]then
- ins(P.moveFX,{C,x+j,y+i,0,T})
+ if self.cur.bk[i][j]then
+ ins(self.moveFX,{C,x+j,y+i,0,T})
end
end end
end
end
-function Player.createSplashFX(P,h)
- local L=P.field[h]
- local size=P.size
- local y=P.fieldY+size*(P.fieldOff.y+P.fieldBeneath+P.fieldUp+615)
+function Player:createSplashFX(h)
+ local L=self.field[h]
+ local size=self.size
+ local y=self.fieldY+size*(self.fieldOff.y+self.fieldBeneath+self.fieldUp+615)
for x=1,10 do
local c=L[x]
if c>0 then
SYSFX.newCell(
- 2.5-P.gameEnv.splashFX*.4,
+ 2.5-self.gameEnv.splashFX*.4,
SKIN.curText[c],
size,
- P.fieldX+(30*x-15)*size,y-30*h*size,
+ self.fieldX+(30*x-15)*size,y-30*h*size,
rnd()*5-2.5,rnd()*-1,
0,.6
)
end
end
end
-function Player.createClearingFX(P,y,spd)
- ins(P.clearFX,{y,0,spd})
+function Player:createClearingFX(y,spd)
+ ins(self.clearFX,{y,0,spd})
end
-function Player.createBeam(P,R,send,color)
+function Player:createBeam(R,send,color)
local x1,y1,x2,y2
- if P.mini then x1,y1=P.centerX,P.centerY
- else x1,y1=P.x+(30*(P.curX+P.cur.sc[2])-30+15+150)*P.size,P.y+(600-30*(P.curY+P.cur.sc[1])+15)*P.size
+ if self.mini then x1,y1=self.centerX,self.centerY
+ else x1,y1=self.x+(30*(self.curX+self.cur.sc[2])-30+15+150)*self.size,self.y+(600-30*(self.curY+self.cur.sc[1])+15)*self.size
end
if R.small then x2,y2=R.centerX,R.centerY
else x2,y2=R.x+308*R.size,R.y+450*R.size
@@ -110,21 +109,21 @@ function Player.createBeam(P,R,send,color)
local r,g,b=unpack(minoColor[color])
r,g,b=r*2,g*2,b*2
- local a=GAME.modeEnv.royaleMode and not(P.type=="human"or R.type=="human")and .2 or 1
+ local a=GAME.modeEnv.royaleMode and not(self.type=="human"or R.type=="human")and .2 or 1
SYSFX.newAttack(1-SETTING.atkFX*.1,x1,y1,x2,y2,int(send^.7*(4+SETTING.atkFX)),r,g,b,a*(SETTING.atkFX+2)*.0626)
end
----------------------------------------------------
----------------------------------------------------
-function Player.RND(P,a,b)
- local R=P.randGen
+function Player:RND(a,b)
+ local R=self.randGen
return R:random(a,b)
end
-function Player.newTask(P,code,...)
+function Player:newTask(code,...)
local thread=coroutine.create(code)
- coroutine.resume(thread,P,...)
+ coroutine.resume(thread,self,...)
if coroutine.status(thread)~="dead"then
- P.tasks[#P.tasks+1]={
+ self.tasks[#self.tasks+1]={
thread=thread,
code=code,
args={...},
@@ -132,164 +131,164 @@ function Player.newTask(P,code,...)
end
end
-function Player.setPosition(P,x,y,size)
+function Player:setPosition(x,y,size)
size=size or 1
- P.x,P.y,P.size=x,y,size
- if P.mini or P.demo then
- P.fieldX,P.fieldY=x,y
- P.centerX,P.centerY=x+300*size,y+600*size
+ self.x,self.y,self.size=x,y,size
+ if self.mini or self.demo then
+ self.fieldX,self.fieldY=x,y
+ self.centerX,self.centerY=x+300*size,y+600*size
else
- P.fieldX,P.fieldY=x+150*size,y
- P.centerX,P.centerY=x+300*size,y+370*size
- P.absFieldX,P.absFieldY=x+150*size,y-10*size
+ self.fieldX,self.fieldY=x+150*size,y
+ self.centerX,self.centerY=x+300*size,y+370*size
+ self.absFieldX,self.absFieldY=x+150*size,y-10*size
end
end
-local function task_movePosition(P,x,y,size)
- local x1,y1,size1=P.x,P.y,P.size
+local function task_movePosition(self,x,y,size)
+ local x1,y1,size1=self.x,self.y,self.size
while true do
yield()
if (x1-x)^2+(y1-y)^2<1 then
- P:setPosition(x,y,size)
+ self:setPosition(x,y,size)
return true
else
x1=x1+(x-x1)*.126
y1=y1+(y-y1)*.126
size1=size1+(size-size1)*.126
- P:setPosition(x1,y1,size1)
+ self:setPosition(x1,y1,size1)
end
end
end
local function checkPlayer(obj,Ptar)
return obj.args[1]==Ptar
end
-function Player.movePosition(P,x,y,size)
- TASK.removeTask_iterate(checkPlayer,P)
- TASK.new(task_movePosition,P,x,y,size or P.size)
+function Player:movePosition(x,y,size)
+ TASK.removeTask_iterate(checkPlayer,self)
+ TASK.new(task_movePosition,self,x,y,size or self.size)
end
-function Player.switchKey(P,id,on)
- P.keyAvailable[id]=on
+function Player:switchKey(id,on)
+ self.keyAvailable[id]=on
if not on then
- P:releaseKey(id)
+ self:releaseKey(id)
end
- if P.type=="human"then
+ if self.type=="human"then
virtualkey[id].ava=on
end
end
-function Player.set20G(P,if20g)
- P._20G=if20g
- P:switchKey(7,not if20g)
- if if20g and P.AI_mode=="CC"then CC.switch20G(P)end
+function Player:set20G(if20g)
+ self._20G=if20g
+ self:switchKey(7,not if20g)
+ if if20g and self.AI_mode=="CC"then CC.switch20G(self)end
end
-function Player.setHold(P,count)--Set hold count (false/true as 0/1)
+function Player:setHold(count)--Set hold count (false/true as 0/1)
if not count then
count=0
elseif count==true then
count=1
end
- P.gameEnv.holdCount=count
- P.holdTime=count
- while P.holdQueue[count+1]do rem(P.holdQueue)end
+ self.gameEnv.holdCount=count
+ self.holdTime=count
+ while self.holdQueue[count+1]do rem(self.holdQueue)end
end
-function Player.setNext(P,next,hidden)--Set next count (use hidden=true if set env.nextStartPos>1)
- P.gameEnv.nextCount=next
+function Player:setNext(next,hidden)--Set next count (use hidden=true if set env.nextStartPos>1)
+ self.gameEnv.nextCount=next
if next==0 then
- P.drawNext=NULL
+ self.drawNext=NULL
elseif not hidden then
- P.drawNext=PLY.draw.drawNext_norm
+ self.drawNext=PLY.draw.drawNext_norm
else
- P.drawNext=PLY.draw.drawNext_hidden
+ self.drawNext=PLY.draw.drawNext_hidden
end
end
-function Player.setInvisible(P,time)--Time in frames
+function Player:setInvisible(time)--Time in frames
if time<0 then
- P.keepVisible=true
- P.showTime=1e99
+ self.keepVisible=true
+ self.showTime=1e99
else
- P.keepVisible=false
- P.showTime=time
+ self.keepVisible=false
+ self.showTime=time
end
end
-function Player.setRS(P,RSname)
- P.RS=kickList[RSname]
+function Player:setRS(RSname)
+ self.RS=kickList[RSname]
end
-function Player.setConf(P,confStr)
+function Player:setConf(confStr)
local _,conf=pcall(love.data.decode,"string","base64",confStr)
if _ then
for k,v in next,conf do
if not GAME.modeEnv[k]then
- P.gameEnv[k]=v
+ self.gameEnv[k]=v
end
end
else
- LOG.print("Bad conf from "..P.userName.."#"..P.userID)
+ LOG.print("Bad conf from "..self.userName.."#"..self.userID)
end
end
-function Player.getHolePos(P)--Get a good garbage-line hole position
- if P.garbageBeneath==0 then
- return generateLine(P:RND(10))
+function Player:getHolePos()--Get a good garbage-line hole position
+ if self.garbageBeneath==0 then
+ return generateLine(self:RND(10))
else
- local p=P:RND(10)
- if P.field[1][p]<=0 then
- return generateLine(P:RND(10))
+ local p=self:RND(10)
+ if self.field[1][p]<=0 then
+ return generateLine(self:RND(10))
end
return generateLine(p)
end
end
-function Player.garbageRelease(P)--Check garbage buffer and try to release them
+function Player:garbageRelease()--Check garbage buffer and try to release them
local n,flag=1
while true do
- local A=P.atkBuffer[n]
+ local A=self.atkBuffer[n]
if A and A.countdown<=0 and not A.sent then
- P:garbageRise(19+A.lv,A.amount,A.line)
- P.atkBuffer.sum=P.atkBuffer.sum-A.amount
+ self:garbageRise(19+A.lv,A.amount,A.line)
+ self.atkBuffer.sum=self.atkBuffer.sum-A.amount
A.sent,A.time=true,0
- P.stat.pend=P.stat.pend+A.amount
+ self.stat.pend=self.stat.pend+A.amount
n=n+1
flag=true
else
break
end
end
- if flag and P.AI_mode=="CC"and P.AI_bot then CC.updateField(P)end
+ if flag and self.AI_mode=="CC"and self.AI_bot then CC.updateField(self)end
end
-function Player.garbageRise(P,color,amount,line)--Release n-lines garbage to field
+function Player:garbageRise(color,amount,line)--Release n-lines garbage to field
local _
- local t=P.showTime*2
+ local t=self.showTime*2
for _=1,amount do
- ins(P.field,1,FREEROW.get(0,true))
- ins(P.visTime,1,FREEROW.get(t))
+ ins(self.field,1,FREEROW.get(0,true))
+ ins(self.visTime,1,FREEROW.get(t))
for i=1,10 do
- P.field[1][i]=bit.rshift(line,i-1)%2==1 and color or 0
+ self.field[1][i]=bit.rshift(line,i-1)%2==1 and color or 0
end
end
- P.fieldBeneath=P.fieldBeneath+amount*30
- if P.cur then
- P.curY=P.curY+amount
- P.ghoY=P.ghoY+amount
+ self.fieldBeneath=self.fieldBeneath+amount*30
+ if self.cur then
+ self.curY=self.curY+amount
+ self.ghoY=self.ghoY+amount
end
- P.garbageBeneath=P.garbageBeneath+amount
- for i=1,#P.clearingRow do
- P.clearingRow[i]=P.clearingRow[i]+amount
+ self.garbageBeneath=self.garbageBeneath+amount
+ for i=1,#self.clearingRow do
+ self.clearingRow[i]=self.clearingRow[i]+amount
end
- P:freshBlock("push")
- for i=1,#P.lockFX do
- _=P.lockFX[i]
+ self:freshBlock("push")
+ for i=1,#self.lockFX do
+ _=self.lockFX[i]
_[2]=_[2]-30*amount--Shift 30px per line cleared
end
- for i=1,#P.dropFX do
- _=P.dropFX[i]
+ for i=1,#self.dropFX do
+ _=self.dropFX[i]
_[3],_[5]=_[3]+amount,_[5]+amount
end
- if #P.field>42 then P:lose()end
+ if #self.field>42 then self:lose()end
end
local invList={2,1,4,3,5,6,7}
-function Player.pushLineList(P,L,mir)--Push some lines to field
+function Player:pushLineList(L,mir)--Push some lines to field
local l=#L
- local S=P.gameEnv.skin
+ local S=self.gameEnv.skin
for i=1,l do
local r=FREEROW.get(0)
if not mir then
@@ -301,44 +300,44 @@ function Player.pushLineList(P,L,mir)--Push some lines to field
r[j]=S[invList[L[i][11-j]]]or 0
end
end
- ins(P.field,1,r)
- ins(P.visTime,1,FREEROW.get(20))
+ ins(self.field,1,r)
+ ins(self.visTime,1,FREEROW.get(20))
end
- P.fieldBeneath=P.fieldBeneath+30*l
- P.curY=P.curY+l
- P.ghoY=P.ghoY+l
- P:freshBlock("push")
+ self.fieldBeneath=self.fieldBeneath+30*l
+ self.curY=self.curY+l
+ self.ghoY=self.ghoY+l
+ self:freshBlock("push")
end
-function Player.pushNextList(P,L,mir)--Push some nexts to nextQueue
+function Player:pushNextList(L,mir)--Push some nexts to nextQueue
for i=1,#L do
- P:getNext(mir and invList[L[i]]or L[i])
+ self:getNext(mir and invList[L[i]]or L[i])
end
end
-function Player.getCenterX(P)
- return P.curX+P.cur.sc[2]-5.5
+function Player:getCenterX()
+ return self.curX+self.cur.sc[2]-5.5
end
-function Player.solid(P,x,y)
+function Player:solid(x,y)
if x<1 or x>10 or y<1 then return true end
- if y>#P.field then return false end
- return P.field[y]
+ if y>#self.field then return false end
+ return self.field[y]
[x]>0--to catch bug (nil[*])
end
-function Player.ifoverlap(P,bk,x,y)
+function Player:ifoverlap(bk,x,y)
local C=#bk[1]
if x<1 or x+C>11 or y<1 then return true end
- if y>#P.field then return end
+ if y>#self.field then return end
for i=1,#bk do
- if P.field[y+i-1]then
+ if self.field[y+i-1]then
for j=1,C do
- if bk[i][j]and P.field[y+i-1][x+j-1]>0 then return true end
+ if bk[i][j]and self.field[y+i-1][x+j-1]>0 then return true end
end
end
end
end
-function Player.attack(P,R,send,time,line,fromStream)
+function Player:attack(R,send,time,line,fromStream)
if GAME.net then
- if P.type=="human"then--Local player attack others
+ if self.type=="human"then--Local player attack others
ins(GAME.rep,GAME.frame)
ins(GAME.rep,
R.subID+
@@ -351,21 +350,21 @@ function Player.attack(P,R,send,time,line,fromStream)
if fromStream and R.type=="human"then--Local player receiving lines
ins(GAME.rep,GAME.frame)
ins(GAME.rep,
- P.subID+
+ self.subID+
send*0x100+
time*0x10000+
line*0x100000000+
0x1000000000000
)
- R:receive(P,send,time,line)
+ R:receive(self,send,time,line)
end
else
- R:receive(P,send,time,line)
+ R:receive(self,send,time,line)
end
end
-function Player.receive(P,A,send,time,line)
- P.lastRecv=A
- local B=P.atkBuffer
+function Player:receive(A,send,time,line)
+ self.lastRecv=A
+ local B=self.atkBuffer
if B.sum<26 then
if send>26-B.sum then send=26-B.sum end
local m,k=#B,1
@@ -383,91 +382,91 @@ function Player.receive(P,A,send,time,line)
lv=min(int(send^.69),5),
}--Sorted insert(by time)
B.sum=B.sum+send
- P.stat.recv=P.stat.recv+send
- if P.sound then
+ self.stat.recv=self.stat.recv+send
+ if self.sound then
SFX.play(send<4 and"blip_1"or"blip_2",min(send+1,5)*.1)
end
end
end
-function Player.freshTarget(P)
- if P.atkMode==1 then
- if not P.atking or not P.atking.alive or rnd()<.1 then
- P:changeAtk(randomTarget(P))
+function Player:freshTarget()
+ if self.atkMode==1 then
+ if not self.atking or not self.atking.alive or rnd()<.1 then
+ self:changeAtk(randomTarget(self))
end
- elseif P.atkMode==2 then
- P:changeAtk(P~=GAME.mostBadge and GAME.mostBadge or GAME.secBadge or randomTarget(P))
- elseif P.atkMode==3 then
- P:changeAtk(P~=GAME.mostDangerous and GAME.mostDangerous or GAME.secDangerous or randomTarget(P))
- elseif P.atkMode==4 then
- for i=1,#P.atker do
- if not P.atker[i].alive then
- rem(P.atker,i)
+ elseif self.atkMode==2 then
+ self:changeAtk(self~=GAME.mostBadge and GAME.mostBadge or GAME.secBadge or randomTarget(self))
+ elseif self.atkMode==3 then
+ self:changeAtk(self~=GAME.mostDangerous and GAME.mostDangerous or GAME.secDangerous or randomTarget(self))
+ elseif self.atkMode==4 then
+ for i=1,#self.atker do
+ if not self.atker[i].alive then
+ rem(self.atker,i)
return
end
end
end
end
-function Player.changeAtkMode(P,m)
- if P.atkMode==m then return end
- P.atkMode=m
+function Player:changeAtkMode(m)
+ if self.atkMode==m then return end
+ self.atkMode=m
if m==1 then
- P:changeAtk(randomTarget(P))
+ self:changeAtk(randomTarget(self))
elseif m==2 or m==3 then
- P:freshTarget()
+ self:freshTarget()
elseif m==4 then
- P:changeAtk()
+ self:changeAtk()
end
end
-function Player.changeAtk(P,R)
- -- if P.type~="human"then R=PLAYERS[1]end--1vALL mode?
- if P.atking then
- local K=P.atking.atker
+function Player:changeAtk(R)
+ -- if self.type~="human"then R=PLAYERS[1]end--1vALL mode?
+ if self.atking then
+ local K=self.atking.atker
for i=1,#K do
- if K[i]==P then
+ if K[i]==self then
rem(K,i)
break
end
end
end
if R then
- P.atking=R
- ins(R.atker,P)
+ self.atking=R
+ ins(R.atker,self)
else
- P.atking=false
+ self.atking=false
end
end
-function Player.freshBlock(P,mode)--string mode: push/move/fresh/newBlock
- local ENV=P.gameEnv
+function Player:freshBlock(mode)--string mode: push/move/fresh/newBlock
+ local ENV=self.gameEnv
--Fresh ghost
- if(mode=="move"or mode=="newBlock"or mode=="push")and P.cur then
- local CB=P.cur.bk
- P.ghoY=min(#P.field+1,P.curY)
- if P._20G or ENV.sdarr==0 and P.keyPressing[7]and P.downing>ENV.sddas then
- local _=P.ghoY
+ if(mode=="move"or mode=="newBlock"or mode=="push")and self.cur then
+ local CB=self.cur.bk
+ self.ghoY=min(#self.field+1,self.curY)
+ if self._20G or ENV.sdarr==0 and self.keyPressing[7]and self.downing>ENV.sddas then
+ local _=self.ghoY
--Move ghost to bottom
- while not P:ifoverlap(CB,P.curX,P.ghoY-1)do
- P.ghoY=P.ghoY-1
+ while not self:ifoverlap(CB,self.curX,self.ghoY-1)do
+ self.ghoY=self.ghoY-1
end
--Cancel spinLast
- if _~=P.ghoY then
- P.spinLast=false
+ if _~=self.ghoY then
+ self.spinLast=false
end
--Create FX if dropped
- if P.curY>P.ghoY then
- if ENV.dropFX and ENV.block and P.curY-P.ghoY-#CB>-1 then
- P:createDropFX(P.curX,P.curY-1,#CB[1],P.curY-P.ghoY-#CB+1)
+ if self.curY>self.ghoY then
+ if ENV.dropFX and ENV.block and self.curY-self.ghoY-#CB>-1 then
+ self:createDropFX(self.curX,self.curY-1,#CB[1],self.curY-self.ghoY-#CB+1)
end
if ENV.shakeFX then
- P.fieldOff.vy=ENV.shakeFX*.5
+ self.fieldOff.vy=ENV.shakeFX*.5
end
- P.curY=P.ghoY
+ self.curY=self.ghoY
end
else
- while not P:ifoverlap(CB,P.curX,P.ghoY-1)do
- P.ghoY=P.ghoY-1
+ while not self:ifoverlap(CB,self.curX,self.ghoY-1)do
+ self.ghoY=self.ghoY-1
end
end
end
@@ -476,43 +475,43 @@ function Player.freshBlock(P,mode)--string mode: push/move/fresh/newBlock
if mode=="move"or mode=="newBlock"or mode=="fresh"then
local d0,l0=ENV.drop,ENV.lock
if ENV.easyFresh then
- if P.lockDelay0 then
+ if self.lockDelay0 then
if mode~="newBlock"then
- P.freshTime=P.freshTime-1
+ self.freshTime=self.freshTime-1
end
- P.lockDelay=l0
- P.dropDelay=d0
+ self.lockDelay=l0
+ self.dropDelay=d0
end
- if P.curY+P.cur.sc[1]0 then
- P.freshTime=P.freshTime-1
- P.dropDelay=d0
- P.lockDelay=l0
+ if self.curY+self.cur.sc[1]0 then
+ self.freshTime=self.freshTime-1
+ self.dropDelay=d0
+ self.lockDelay=l0
end
end
end
end
end
-function Player.lock(P)
- local dest=P.AI_dest
+function Player:lock()
+ local dest=self.AI_dest
local has_dest=dest~=nil
- local CB=P.cur.bk
+ local CB=self.cur.bk
for i=1,#CB do
- local y=P.curY+i-1
- if not P.field[y]then P.field[y],P.visTime[y]=FREEROW.get(0),FREEROW.get(0)end
+ local y=self.curY+i-1
+ if not self.field[y]then self.field[y],self.visTime[y]=FREEROW.get(0),FREEROW.get(0)end
for j=1,#CB[1]do
if CB[i][j]then
- P.field[y][P.curX+j-1]=P.cur.color
- P.visTime[y][P.curX+j-1]=P.showTime
+ self.field[y][self.curX+j-1]=self.cur.color
+ self.visTime[y][self.curX+j-1]=self.showTime
if dest then
- local x=P.curX+j-1
+ local x=self.curX+j-1
for k=1,#dest,2 do
if x==dest[k]+1 and y==dest[k+1]+1 then
rem(dest,k)rem(dest,k)
@@ -525,142 +524,142 @@ function Player.lock(P)
end
end
end
- if has_dest and not dest and P.AI_mode=="CC"and P.AI_bot then
- CC.updateField(P)
+ if has_dest and not dest and self.AI_mode=="CC"and self.AI_bot then
+ CC.updateField(self)
end
end
local spawnSFX_name={}for i=1,7 do spawnSFX_name[i]="spawn_"..i end
-function Player.resetBlock(P)--Reset Block's position and execute I*S
- local B=P.cur.bk
- P.curX=int(6-#B[1]*.5)
- local y=int(P.gameEnv.fieldH+1-modf(P.cur.sc[1]))+ceil(P.fieldBeneath/30)
- P.curY=y
- P.minY=y+P.cur.sc[1]
+function Player:resetBlock()--Reset Block's position and execute I*S
+ local B=self.cur.bk
+ self.curX=int(6-#B[1]*.5)
+ local y=int(self.gameEnv.fieldH+1-modf(self.cur.sc[1]))+ceil(self.fieldBeneath/30)
+ self.curY=y
+ self.minY=y+self.cur.sc[1]
- local _=P.keyPressing
+ local _=self.keyPressing
--IMS
- if P.gameEnv.ims and(_[1]and P.movDir==-1 or _[2]and P.movDir==1)and P.moving>=P.gameEnv.das then
- local x=P.curX+P.movDir
- if not P:ifoverlap(B,x,y)then
- P.curX=x
+ if self.gameEnv.ims and(_[1]and self.movDir==-1 or _[2]and self.movDir==1)and self.moving>=self.gameEnv.das then
+ local x=self.curX+self.movDir
+ if not self:ifoverlap(B,x,y)then
+ self.curX=x
end
end
--IRS
- if P.gameEnv.irs then
+ if self.gameEnv.irs then
if _[5]then
- P:spin(2,true)
+ self:spin(2,true)
else
if _[3]then
if _[4]then
- P:spin(2,true)
+ self:spin(2,true)
else
- P:spin(1,true)
+ self:spin(1,true)
end
elseif _[4]then
- P:spin(3,true)
+ self:spin(3,true)
end
end
end
--DAS cut
- if P.gameEnv.dascut>0 then
- P.moving=P.moving-(P.moving>0 and 1 or -1)*P.gameEnv.dascut
+ if self.gameEnv.dascut>0 then
+ self.moving=self.moving-(self.moving>0 and 1 or -1)*self.gameEnv.dascut
end
--Spawn SFX
- if P.sound and P.cur.id<8 then
- SFX.fplay(spawnSFX_name[P.cur.id],SETTING.sfx_spawn)
+ if self.sound and self.cur.id<8 then
+ SFX.fplay(spawnSFX_name[self.cur.id],SETTING.sfx_spawn)
end
end
-function Player.spin(P,d,ifpre)
- local kickData=P.RS[P.cur.id]
+function Player:spin(d,ifpre)
+ local kickData=self.RS[self.cur.id]
if type(kickData)=="table"then
- local idir=(P.cur.dir+d)%4
- kickData=kickData[P.cur.dir*10+idir]
+ local idir=(self.cur.dir+d)%4
+ kickData=kickData[self.cur.dir*10+idir]
if not kickData then
- P:freshBlock("move")
- SFX.play(ifpre and"prerotate"or"rotate",nil,P:getCenterX()*.15)
+ self:freshBlock("move")
+ SFX.play(ifpre and"prerotate"or"rotate",nil,self:getCenterX()*.15)
return
end
- local icb=BLOCKS[P.cur.id][idir]
- local isc=SCS[P.cur.id][idir]
- local ix,iy=P.curX+P.cur.sc[2]-isc[2],P.curY+P.cur.sc[1]-isc[1]
+ local icb=BLOCKS[self.cur.id][idir]
+ local isc=SCS[self.cur.id][idir]
+ local ix,iy=self.curX+self.cur.sc[2]-isc[2],self.curY+self.cur.sc[1]-isc[1]
for test=1,#kickData do
local x,y=ix+kickData[test][1],iy+kickData[test][2]
- if not P:ifoverlap(icb,x,y)and(P.freshTime>=0 or kickData[test][2]<0)then
+ if not self:ifoverlap(icb,x,y)and(self.freshTime>=0 or kickData[test][2]<0)then
ix,iy=x,y
- if P.gameEnv.moveFX and P.gameEnv.block then
- P:createMoveFX()
+ if self.gameEnv.moveFX and self.gameEnv.block then
+ self:createMoveFX()
end
- P.curX,P.curY,P.cur.dir=ix,iy,idir
- P.cur.sc,P.cur.bk=isc,icb
- P.spinLast=test==2 and 0 or 1
+ self.curX,self.curY,self.cur.dir=ix,iy,idir
+ self.cur.sc,self.cur.bk=isc,icb
+ self.spinLast=test==2 and 0 or 1
- local t=P.freshTime
+ local t=self.freshTime
if not ifpre then
- P:freshBlock("move")
+ self:freshBlock("move")
end
- if kickData[test][2]>0 and P.freshTime~=t and P.curY~=P.imgY then
- P.freshTime=P.freshTime-1
+ if kickData[test][2]>0 and self.freshTime~=t and self.curY~=self.imgY then
+ self.freshTime=self.freshTime-1
end
- if P.sound then
+ if self.sound then
local sfx
if ifpre then
sfx="prerotate"
- elseif P:ifoverlap(icb,ix,iy+1)and P:ifoverlap(icb,ix-1,iy)and P:ifoverlap(icb,ix+1,iy)then
+ elseif self:ifoverlap(icb,ix,iy+1)and self:ifoverlap(icb,ix-1,iy)and self:ifoverlap(icb,ix+1,iy)then
sfx="rotatekick"
- if P.gameEnv.shakeFX then
+ if self.gameEnv.shakeFX then
if d==1 or d==3 then
- P.fieldOff.va=P.fieldOff.va+(2-d)*P.gameEnv.shakeFX*6e-3
+ self.fieldOff.va=self.fieldOff.va+(2-d)*self.gameEnv.shakeFX*6e-3
else
- P.fieldOff.va=P.fieldOff.va+P:getCenterX()*P.gameEnv.shakeFX*3e-3
+ self.fieldOff.va=self.fieldOff.va+self:getCenterX()*self.gameEnv.shakeFX*3e-3
end
end
else
sfx="rotate"
end
- SFX.play(sfx,nil,P:getCenterX()*.15)
+ SFX.play(sfx,nil,self:getCenterX()*.15)
end
- P.stat.rotate=P.stat.rotate+1
+ self.stat.rotate=self.stat.rotate+1
return
end
end
elseif kickData then
- kickData(P,d)
+ kickData(self,d)
else
- P:freshBlock("move")
- SFX.play(ifpre and"prerotate"or"rotate",nil,P:getCenterX()*.15)
+ self:freshBlock("move")
+ SFX.play(ifpre and"prerotate"or"rotate",nil,self:getCenterX()*.15)
end
end
local phyHoldKickX={
[true]={0,-1,1},--X==?.0 tests
[false]={-.5,.5},--X==?.5 tests
}
-function Player.hold(P,ifpre)
- local ENV=P.gameEnv
- if P.holdTime>0 and(ifpre or P.waiting==-1)then
- if #P.holdQueue0 and(ifpre or self.waiting==-1)then
+ if #self.holdQueue
::BREAK_success::
- P.spinLast=false
- P.spinSeq=0
- local hb=P:getBlock(C.id)
+ self.spinLast=false
+ self.spinSeq=0
+ local hb=self:getBlock(C.id)
hb.name=C.name
hb.color=C.color
- ins(P.holdQueue,hb)
- P.cur=rem(P.holdQueue,1)
- P.curX,P.curY=x,y
+ ins(self.holdQueue,hb)
+ self.cur=rem(self.holdQueue,1)
+ self.curX,self.curY=x,y
else--Normal hold
- P.spinLast=false
- P.spinSeq=0
+ self.spinLast=false
+ self.spinSeq=0
if C then
- local hb=P:getBlock(C.id)
+ local hb=self:getBlock(C.id)
hb.color=C.color
hb.name=C.name
- ins(P.holdQueue,hb)
+ ins(self.holdQueue,hb)
end
- P.cur=rem(P.holdQueue,1)
+ self.cur=rem(self.holdQueue,1)
- P:resetBlock()
+ self:resetBlock()
end
- P:freshBlock("move")
- P.dropDelay=ENV.drop
- P.lockDelay=ENV.lock
- if P:ifoverlap(P.cur.bk,P.curX,P.curY)then
- P:lock()
- P:lose()
+ self:freshBlock("move")
+ self.dropDelay=ENV.drop
+ self.lockDelay=ENV.lock
+ if self:ifoverlap(self.cur.bk,self.curX,self.curY)then
+ self:lock()
+ self:lose()
end
end
- P.freshTime=int(min(P.freshTime+ENV.freshLimit*.25,ENV.freshLimit*((P.holdTime+1)/ENV.holdCount)))
+ self.freshTime=int(min(self.freshTime+ENV.freshLimit*.25,ENV.freshLimit*((self.holdTime+1)/ENV.holdCount)))
if not ENV.infHold then
- P.holdTime=P.holdTime-1
+ self.holdTime=self.holdTime-1
end
- if P.sound then
+ if self.sound then
SFX.play(ifpre and"prehold"or"hold")
end
- if P.AI_mode=="CC"then
- local next=P.nextQueue[P.AIdata.nextCount]
+ if self.AI_mode=="CC"then
+ local next=self.nextQueue[self.AIdata.nextCount]
if next then
- CC.addNext(P.AI_bot,next.id)
+ CC.addNext(self.AI_bot,next.id)
end
end
- P.stat.hold=P.stat.hold+1
+ self.stat.hold=self.stat.hold+1
end
end
-function Player.getBlock(P,n)--Get a block(id=n) object
- local E=P.gameEnv
+function Player:getBlock(n)--Get a block(id=n) object
+ local E=self.gameEnv
local dir=E.face[n]
return{
id=n,
@@ -743,10 +742,10 @@ function Player.getBlock(P,n)--Get a block(id=n) object
color=E.bone and 17 or E.skin[n],
}
end
-function Player.getNext(P,n)--Push a block(id=n) to nextQueue
- local E=P.gameEnv
+function Player:getNext(n)--Push a block(id=n) to nextQueue
+ local E=self.gameEnv
local dir=E.face[n]
- ins(P.nextQueue,{
+ ins(self.nextQueue,{
id=n,
bk=BLOCKS[n][dir],
sc=SCS[n][dir],
@@ -755,60 +754,60 @@ function Player.getNext(P,n)--Push a block(id=n) to nextQueue
color=E.bone and 17 or E.skin[n],
})
end
-function Player.popNext(P,ifhold)--Pop nextQueue to hand
+function Player:popNext(ifhold)--Pop nextQueue to hand
if not ifhold then
- P.holdTime=min(P.holdTime+1,P.gameEnv.holdCount)
+ self.holdTime=min(self.holdTime+1,self.gameEnv.holdCount)
end
- P.spinLast=false
- P.spinSeq=0
- P.ctrlCount=0
+ self.spinLast=false
+ self.spinSeq=0
+ self.ctrlCount=0
- P.cur=rem(P.nextQueue,1)
- assert(resume(P.newNext))
- if P.cur then
- P.pieceCount=P.pieceCount+1
- if P.AI_mode=="CC"then
- local next=P.nextQueue[P.AIdata.next]
+ self.cur=rem(self.nextQueue,1)
+ assert(resume(self.newNext))
+ if self.cur then
+ self.pieceCount=self.pieceCount+1
+ if self.AI_mode=="CC"then
+ local next=self.nextQueue[self.AIdata.next]
if next then
- CC.addNext(P.AI_bot,next.id)
+ CC.addNext(self.AI_bot,next.id)
end
end
- local _=P.keyPressing
+ local _=self.keyPressing
--IHS
- if not ifhold and _[8]and P.gameEnv.ihs then
- P:hold(true)
+ if not ifhold and _[8]and self.gameEnv.ihs then
+ self:hold(true)
_[8]=false
else
- P:resetBlock()
+ self:resetBlock()
end
- P.dropDelay=P.gameEnv.drop
- P.lockDelay=P.gameEnv.lock
- P.freshTime=P.gameEnv.freshLimit
+ self.dropDelay=self.gameEnv.drop
+ self.lockDelay=self.gameEnv.lock
+ self.freshTime=self.gameEnv.freshLimit
- if P.cur then
- if P:ifoverlap(P.cur.bk,P.curX,P.curY)then
- P:lock()
- P:lose()
+ if self.cur then
+ if self:ifoverlap(self.cur.bk,self.curX,self.curY)then
+ self:lock()
+ self:lose()
end
- P:freshBlock("newBlock")
+ self:freshBlock("newBlock")
end
--IHdS
if _[6]and not ifhold then
- P.act_hardDrop(P)
+ self.act_hardDrop(self)
_[6]=false
end
else
- P:hold()
+ self:hold()
end
end
-function Player.cancel(P,N)--Cancel Garbage
+function Player:cancel(N)--Cancel Garbage
local off=0--Lines offseted
- local bf=P.atkBuffer
+ local bf=self.atkBuffer
for i=1,#bf do
if bf.sum==0 or N==0 then break end
local A=bf[i]
@@ -826,7 +825,7 @@ function Player.cancel(P,N)--Cancel Garbage
end
return off
end
-do--Player.drop(P)--Place piece
+do--Player.drop(self)--Place piece
local clearSCR={80,200,400}--Techrash:1K; B2Bmul:1.3/1.8
local spinSCR={
{200,750,1300,2000},--Z
@@ -879,7 +878,7 @@ do--Player.drop(P)--Place piece
1,2
},--Z5
8,--S5
- 3,--P
+ 3,--self
3,--Q
{
{1,2,1,0,1,2,2,1},
@@ -950,17 +949,17 @@ do--Player.drop(P)--Place piece
end
end
- function Player.drop(P)
+ function Player:drop()
local _
local CHN=VOC.getFreeChannel()
- P.dropTime[11]=ins(P.dropTime,1,GAME.frame)--Update speed dial
- local ENV=P.gameEnv
- local STAT=P.stat
- local piece=P.lastPiece
+ self.dropTime[11]=ins(self.dropTime,1,GAME.frame)--Update speed dial
+ local ENV=self.gameEnv
+ local STAT=self.stat
+ local piece=self.lastPiece
local finish
- local cmb=P.combo
- local C,CB,CX,CY=P.cur,P.cur.bk,P.curX,P.curY
+ local cmb=self.combo
+ local C,CB,CX,CY=self.cur,self.cur.bk,self.curX,self.curY
local clear--If clear with no line fall
local cc,gbcc=0,0--Row/garbage-row cleared,full-part
local atk,exblock=0,0--Attack & extra defense
@@ -969,44 +968,44 @@ do--Player.drop(P)--Place piece
local dospin,mini=0
piece.id,piece.name=C.id,C.name
- P.waiting=ENV.wait
+ self.waiting=ENV.wait
--Tri-corner spin check
- if P.spinLast then
+ if self.spinLast then
if C.id<6 then
- local x,y=CX+P.cur.sc[2],CY+P.cur.sc[1]
+ local x,y=CX+self.cur.sc[2],CY+self.cur.sc[1]
local c=0
- if P:solid(x-1,y+1)then c=c+1 end
- if P:solid(x+1,y+1)then c=c+1 end
+ if self:solid(x-1,y+1)then c=c+1 end
+ if self:solid(x+1,y+1)then c=c+1 end
if c~=0 then
- if P:solid(x-1,y-1)then c=c+1 end
- if P:solid(x+1,y-1)then c=c+1 end
+ if self:solid(x-1,y-1)then c=c+1 end
+ if self:solid(x+1,y-1)then c=c+1 end
if c>2 then dospin=dospin+2 end
end
end
end
--Immovable spin check
- if P:ifoverlap(CB,CX,CY+1)and P:ifoverlap(CB,CX-1,CY)and P:ifoverlap(CB,CX+1,CY)then
+ if self:ifoverlap(CB,CX,CY+1)and self:ifoverlap(CB,CX-1,CY)and self:ifoverlap(CB,CX+1,CY)then
dospin=dospin+2
end
--Lock block to field
- P:lock()
+ self:lock()
--Clear list of cleared-rows
- if P.clearedRow[1]then P.clearedRow={}end
+ if self.clearedRow[1]then self.clearedRow={}end
--Check line clear
for i=1,#CB do
local h=CY+i-2
--Bomb trigger
- if h>0 and P.field[h]and P.clearedRow[cc]~=h then
+ if h>0 and self.field[h]and self.clearedRow[cc]~=h then
for x=1,#CB[1]do
- if CB[i][x]and P.field[h][CX+x-1]==19 then
+ if CB[i][x]and self.field[h][CX+x-1]==19 then
cc=cc+1
- P.clearingRow[cc]=h-cc+1
- P.clearedRow[cc]=h
+ self.clearingRow[cc]=h-cc+1
+ self.clearedRow[cc]=h
break
end
end
@@ -1015,13 +1014,13 @@ do--Player.drop(P)--Place piece
h=h+1
--Row filled
for x=1,10 do
- if P.field[h][x]<=0 then
+ if self.field[h][x]<=0 then
goto CONTINUE_notFull
end
end
cc=cc+1
- P.clearingRow[cc]=h-cc+1
- P.clearedRow[cc]=h
+ self.clearingRow[cc]=h-cc+1
+ self.clearedRow[cc]=h
::CONTINUE_notFull::
end
@@ -1029,10 +1028,10 @@ do--Player.drop(P)--Place piece
if cc>0 and ENV.clearFX then
local t=7-ENV.clearFX*1
for i=1,cc do
- local y=P.clearedRow[i]
- P:createClearingFX(y,t)
+ local y=self.clearedRow[i]
+ self:createClearingFX(y,t)
if ENV.splashFX then
- P:createSplashFX(y)
+ self:createSplashFX(y)
end
end
end
@@ -1040,12 +1039,12 @@ do--Player.drop(P)--Place piece
--Create locking FX
if ENV.lockFX then
if cc==0 then
- P:createLockFX()
+ self:createLockFX()
else
- _=#P.lockFX
+ _=#self.lockFX
if _>0 then
for _=1,_ do
- rem(P.lockFX)
+ rem(self.lockFX)
end
end
end
@@ -1054,7 +1053,7 @@ do--Player.drop(P)--Place piece
--Final spin check
if dospin>0 then
if cc>0 then
- dospin=dospin+(P.spinLast or 0)
+ dospin=dospin+(self.spinLast or 0)
if dospin<3 then
mini=C.id<6 and cc<#CB
end
@@ -1077,8 +1076,8 @@ do--Player.drop(P)--Place piece
local testX=CX+x-1--Optimize
--Test the whole column of field to find roof
- for testY=CY+y,#P.field do
- if P:solid(testX,testY)then
+ for testY=CY+y,#self.field do
+ if self:solid(testX,testY)then
finesse=true
goto BERAK_roofFound
end
@@ -1090,24 +1089,24 @@ do--Player.drop(P)--Place piece
--Remove rows need to be cleared
if cc>0 then
for i=cc,1,-1 do
- _=P.clearedRow[i]
- if P.field[_].garbage then
- P.garbageBeneath=P.garbageBeneath-1
+ _=self.clearedRow[i]
+ if self.field[_].garbage then
+ self.garbageBeneath=self.garbageBeneath-1
gbcc=gbcc+1
end
- FREEROW.discard(rem(P.field,_))
- FREEROW.discard(rem(P.visTime,_))
+ FREEROW.discard(rem(self.field,_))
+ FREEROW.discard(rem(self.visTime,_))
end
end
--Cancel no-sense clearing FX
- _=#P.clearingRow
- while _>0 and P.clearingRow[_]>#P.field do
- P.clearingRow[_]=nil
+ _=#self.clearingRow
+ while _>0 and self.clearingRow[_]>#self.field do
+ self.clearingRow[_]=nil
_=_-1
end
- if P.clearingRow[1]then
- P.falling=ENV.fall
+ if self.clearingRow[1]then
+ self.falling=ENV.fall
elseif cc>=#C.bk then
clear=true
end
@@ -1115,9 +1114,9 @@ do--Player.drop(P)--Place piece
--Finesse check (control)
local finePts
if not finesse then
- if dospin then P.ctrlCount=P.ctrlCount-2 end--Allow 2 more step for roof-less spin
+ if dospin then self.ctrlCount=self.ctrlCount-2 end--Allow 2 more step for roof-less spin
local id=C.id
- local d=P.ctrlCount-finesseList[id][P.cur.dir+1][CX]
+ local d=self.ctrlCount-finesseList[id][self.cur.dir+1][CX]
finePts=d<=0 and 5 or max(3-d,0)
else
finePts=5
@@ -1130,25 +1129,25 @@ do--Player.drop(P)--Place piece
if ENV.fineKill then
finish=true
end
- if P.sound then
+ if self.sound then
if ENV.fineKill then
SFX.play("finesseError_long",.6)
elseif ENV.fine then
SFX.play("finesseError",.8)
else
- SFX.play("lock",nil,P:getCenterX()*.15)
+ SFX.play("lock",nil,self:getCenterX()*.15)
end
end
- elseif P.sound then
- SFX.play("lock",nil,P:getCenterX()*.15)
+ elseif self.sound then
+ SFX.play("lock",nil,self:getCenterX()*.15)
end
if finePts<=1 then
- P.finesseCombo=0
+ self.finesseCombo=0
else
- P.finesseCombo=P.finesseCombo+1
- if P.finesseCombo>2 then
- P.finesseComboTime=12
+ self.finesseCombo=self.finesseCombo+1
+ if self.finesseCombo>2 then
+ self.finesseComboTime=12
end
end
@@ -1159,88 +1158,88 @@ do--Player.drop(P)--Place piece
cmb=cmb+1
if dospin then
cscore=(spinSCR[C.name]or spinSCR[8])[cc]
- if P.b2b>800 then
- P:showText(text.b3b..text.block[C.name]..text.spin.." "..text.clear[cc],0,-30,35,"stretch")
+ if self.b2b>800 then
+ self:showText(text.b3b..text.block[C.name]..text.spin.." "..text.clear[cc],0,-30,35,"stretch")
atk=b2bATK[cc]+cc*.5
exblock=exblock+1
cscore=cscore*2
STAT.b3b=STAT.b3b+1
- if P.sound then
+ if self.sound then
VOC.play("b3b",CHN)
end
- elseif P.b2b>=50 then
- P:showText(text.b2b..text.block[C.name]..text.spin.." "..text.clear[cc],0,-30,35,"spin")
+ elseif self.b2b>=50 then
+ self:showText(text.b2b..text.block[C.name]..text.spin.." "..text.clear[cc],0,-30,35,"spin")
atk=b2bATK[cc]
cscore=cscore*1.2
STAT.b2b=STAT.b2b+1
- if P.sound then
+ if self.sound then
VOC.play("b2b",CHN)
end
else
- P:showText(text.block[C.name]..text.spin.." "..text.clear[cc],0,-30,45,"spin")
+ self:showText(text.block[C.name]..text.spin.." "..text.clear[cc],0,-30,45,"spin")
atk=2*cc
end
sendTime=20+atk*20
if mini then
- P:showText(text.mini,0,-80,35,"appear")
+ self:showText(text.mini,0,-80,35,"appear")
atk=atk*.25
sendTime=sendTime+60
cscore=cscore*.5
- P.b2b=P.b2b+b2bPoint[cc]*.5
- if P.sound then
+ self.b2b=self.b2b+b2bPoint[cc]*.5
+ if self.sound then
VOC.play("mini",CHN)
end
else
- P.b2b=P.b2b+b2bPoint[cc]
+ self.b2b=self.b2b+b2bPoint[cc]
end
piece.mini=mini
piece.special=true
- if P.sound then
+ if self.sound then
SFX.play(spinSFX[cc]or"spin_3")
VOC.play(spinVoice[C.name],CHN)
end
elseif cc>=4 then
cscore=cc==4 and 1000 or cc==5 and 1500 or 2000
- if P.b2b>800 then
- P:showText(text.b3b..text.clear[cc],0,-30,50,"fly")
+ if self.b2b>800 then
+ self:showText(text.b3b..text.clear[cc],0,-30,50,"fly")
atk=4*cc-10
sendTime=100
exblock=exblock+1
cscore=cscore*1.8
STAT.b3b=STAT.b3b+1
- if P.sound then
+ if self.sound then
VOC.play("b3b",CHN)
end
- elseif P.b2b>=50 then
- P:showText(text.b2b..text.clear[cc],0,-30,50,"drive")
+ elseif self.b2b>=50 then
+ self:showText(text.b2b..text.clear[cc],0,-30,50,"drive")
sendTime=80
atk=3*cc-7
cscore=cscore*1.3
STAT.b2b=STAT.b2b+1
- if P.sound then
+ if self.sound then
VOC.play("b2b",CHN)
end
else
- P:showText(text.clear[cc],0,-30,70,"stretch")
+ self:showText(text.clear[cc],0,-30,70,"stretch")
sendTime=60
atk=2*cc-4
end
- P.b2b=P.b2b+cc*100-300
+ self.b2b=self.b2b+cc*100-300
piece.special=true
else
piece.special=false
end
- if P.sound then
+ if self.sound then
VOC.play(clearVoice[cc],CHN)
end
--Normal clear,reduce B2B point
if not piece.special then
- P.b2b=max(P.b2b-250,0)
- if P.b2b<50 and ENV.b2bKill then
+ self.b2b=max(self.b2b-250,0)
+ if self.b2b<50 and ENV.b2bKill then
finish=true
end
- P:showText(text.clear[cc],0,-30,35,"appear",(8-cc)*.3)
+ self:showText(text.clear[cc],0,-30,35,"appear",(8-cc)*.3)
atk=cc-.5
sendTime=20+int(atk*20)
cscore=cscore+clearSCR[cc]
@@ -1253,37 +1252,37 @@ do--Player.drop(P)--Place piece
if cmb>=3 then
atk=atk+1
end
- P:showText(text.cmb[min(cmb,21)],0,25,15+min(cmb,15)*5,cmb<10 and"appear"or"flicker")
+ self:showText(text.cmb[min(cmb,21)],0,25,15+min(cmb,15)*5,cmb<10 and"appear"or"flicker")
cscore=cscore+min(50*cmb,500)*(2*cc-1)
end
--PC/HPC
- if clear and #P.field==0 then
- P:showText(text.PC,0,-80,50,"flicker")
+ if clear and #self.field==0 then
+ self:showText(text.PC,0,-80,50,"flicker")
atk=max(atk,min(8+STAT.pc*2,16))
exblock=exblock+2
sendTime=sendTime+120
if STAT.row+cc>4 then
- P.b2b=1000
+ self.b2b=1000
cscore=cscore+300*min(6+STAT.pc,10)
else
cscore=cscore+626
end
STAT.pc=STAT.pc+1
- if P.sound then
+ if self.sound then
SFX.play("clear")
VOC.play("perfect_clear",CHN)
end
piece.pc=true
piece.special=true
- elseif clear and(cc>1 or #P.field==P.garbageBeneath)then
- P:showText(text.HPC,0,-80,50,"fly")
+ elseif clear and(cc>1 or #self.field==self.garbageBeneath)then
+ self:showText(text.HPC,0,-80,50,"fly")
atk=atk+2
exblock=exblock+2
sendTime=sendTime+60
cscore=cscore+626
STAT.hpc=STAT.hpc+1
- if P.sound then
+ if self.sound then
SFX.play("clear")
VOC.play("half_clear",CHN)
end
@@ -1291,11 +1290,11 @@ do--Player.drop(P)--Place piece
piece.special=true
end
- if P.b2b>1000 then P.b2b=1000 end
+ if self.b2b>1000 then self.b2b=1000 end
--Bonus atk/def when focused
if GAME.modeEnv.royaleMode then
- local i=min(#P.atker,9)
+ local i=min(#self.atker,9)
if i>1 then
atk=atk+reAtk[i]
exblock=exblock+reDef[i]
@@ -1303,52 +1302,52 @@ do--Player.drop(P)--Place piece
end
--Send Lines
- atk=int(atk*(1+P.strength*.25))--Badge Buff
+ atk=int(atk*(1+self.strength*.25))--Badge Buff
send=atk
if exblock>0 then
- exblock=int(exblock*(1+P.strength*.25))--Badge Buff
- P:showText("+"..exblock,0,53,20,"fly")
- off=off+P:cancel(exblock)
+ exblock=int(exblock*(1+self.strength*.25))--Badge Buff
+ self:showText("+"..exblock,0,53,20,"fly")
+ off=off+self:cancel(exblock)
end
if send>=1 then
- P:showText(send,0,80,35,"zoomout")
- _=P:cancel(send)
+ self:showText(send,0,80,35,"zoomout")
+ _=self:cancel(send)
send=send-_
off=off+_
if send>0 then
local T
if GAME.modeEnv.royaleMode then
- if P.atkMode==4 then
- local M=#P.atker
+ if self.atkMode==4 then
+ local M=#self.atker
if M>0 then
for i=1,M do
- P:attack(P.atker[i],send,sendTime,generateLine(P:RND(10)))
+ self:attack(self.atker[i],send,sendTime,generateLine(self:RND(10)))
if SETTING.atkFX>0 then
- P:createBeam(P.atker[i],send,C.color)
+ self:createBeam(self.atker[i],send,C.color)
end
end
else
- T=randomTarget(P)
+ T=randomTarget(self)
end
else
- T=P.atking
- P:freshTarget()
+ T=self.atking
+ self:freshTarget()
end
elseif #PLAYERS.alive>1 then
- T=randomTarget(P)
+ T=randomTarget(self)
end
if T then
- P:attack(T,send,sendTime,generateLine(P:RND(10)))
+ self:attack(T,send,sendTime,generateLine(self:RND(10)))
if SETTING.atkFX>0 then
- P:createBeam(T,send,C.color)
+ self:createBeam(T,send,C.color)
end
end
end
- if P.sound and send>3 then SFX.play("emit",min(send,7)*.1)end
+ if self.sound and send>3 then SFX.play("emit",min(send,7)*.1)end
end
--SFX & Vibrate
- if P.sound then
+ if self.sound then
SFX.play(clearSFX[cc]or"clear_4")
SFX.play(renSFX[min(cmb,11)])
if cmb>14 then SFX.play("ren_mega",(cmb-10)*.1)end
@@ -1359,25 +1358,25 @@ do--Player.drop(P)--Place piece
--Spin bonus
if dospin then
- P:showText(text.block[C.name]..text.spin,0,-30,45,"appear")
- P.b2b=P.b2b+20
- if P.sound then
+ self:showText(text.block[C.name]..text.spin,0,-30,45,"appear")
+ self.b2b=self.b2b+20
+ if self.sound then
SFX.play("spin_0")
VOC.play(spinVoice[C.name],CHN)
end
cscore=30
end
- if P.b2b>800 then
- P.b2b=max(P.b2b-40,800)
+ if self.b2b>800 then
+ self.b2b=max(self.b2b-40,800)
end
- P:garbageRelease()
+ self:garbageRelease()
end
- P.combo=cmb
+ self.combo=cmb
--DropSpeed bonus
- if P._20G then
+ if self._20G then
cscore=cscore*2
elseif ENV.drop<1 then
cscore=cscore*1.5
@@ -1386,13 +1385,13 @@ do--Player.drop(P)--Place piece
end
--Speed bonus
- if P.dropSpeed>60 then
- cscore=cscore*(.9+P.dropSpeed/600)
+ if self.dropSpeed>60 then
+ cscore=cscore*(.9+self.dropSpeed/600)
end
cscore=int(cscore)
if ENV.score then
- P:showText(cscore,(P.curX+P.cur.sc[2]-5.5)*30,(10-P.curY-P.cur.sc[1])*30+P.fieldBeneath+P.fieldUp,40-600/(cscore+20),"score",2)
+ self:showText(cscore,(self.curX+self.cur.sc[2]-5.5)*30,(10-self.curY-self.cur.sc[1])*30+self.fieldBeneath+self.fieldUp,40-600/(cscore+20),"score",2)
end
piece.row,piece.dig=cc,gbcc
@@ -1401,8 +1400,8 @@ do--Player.drop(P)--Place piece
piece.off,piece.send=off,send
--Check clearing task
- if cc>0 and P.curMission then
- local t=ENV.mission[P.curMission]
+ if cc>0 and self.curMission then
+ local t=ENV.mission[self.curMission]
local success
if t<5 then
if piece.row==t and not piece.spin then
@@ -1422,14 +1421,14 @@ do--Player.drop(P)--Place piece
end
end
if success then
- P.curMission=P.curMission+1
+ self.curMission=self.curMission+1
SFX.play("reach")
- if P.curMission>#ENV.mission then
- P.curMission=false
+ if self.curMission>#ENV.mission then
+ self.curMission=false
if not finish then finish="finish"end
end
elseif ENV.missionKill then
- P:showText(text.missionFailed,0,140,40,"flicker",.5)
+ self:showText(text.missionFailed,0,140,40,"flicker",.5)
SFX.play("finesseError_long",.6)
finish=true
end
@@ -1439,8 +1438,8 @@ do--Player.drop(P)--Place piece
STAT.score=STAT.score+cscore
STAT.piece=STAT.piece+1
STAT.row=STAT.row+cc
- STAT.maxFinesseCombo=max(STAT.maxFinesseCombo,P.finesseCombo)
- STAT.maxCombo=max(STAT.maxCombo,P.combo)
+ STAT.maxFinesseCombo=max(STAT.maxFinesseCombo,self.finesseCombo)
+ STAT.maxCombo=max(STAT.maxCombo,self.combo)
if atk>0 then
STAT.atk=STAT.atk+atk
if send>0 then
@@ -1466,55 +1465,55 @@ do--Player.drop(P)--Place piece
end
if finish then
- if finish==true then P:lose()end
- _=ENV.dropPiece if _ then _(P)end
- if finish then P:win(finish)end
+ if finish==true then self:lose()end
+ _=ENV.dropPiece if _ then _(self)end
+ if finish then self:win(finish)end
else
- _=ENV.dropPiece if _ then _(P)end
+ _=ENV.dropPiece if _ then _(self)end
end
end
end
-function Player.loadAI(P,data)--Load AI params
+function Player:loadAI(data)--Load AI params
if not CC then
data.type="9S"
data.delta=int(data.delta*.3)
end
- P.AI_mode=data.type
- P.AI_keys={}
- P.AI_delay=min(int(P.gameEnv.drop*.8),data.delta*rnd()*4)
- P.AI_delay0=data.delta
- P.AIdata={
+ self.AI_mode=data.type
+ self.AI_keys={}
+ self.AI_delay=min(int(self.gameEnv.drop*.8),data.delta*rnd()*4)
+ self.AI_delay0=data.delta
+ self.AIdata={
type=data.type,
delay=data.delay,
delta=data.delta,
next=data.next,
hold=data.hold,
- _20G=P._20G,
+ _20G=self._20G,
bag=data.bag,
node=data.node,
}
- if P.AI_mode=="CC"then
- P:setRS("SRS")
+ if self.AI_mode=="CC"then
+ self:setRS("SRS")
local opt,wei=CC.getConf()
CC.fastWeights(wei)
- CC.setHold(opt,P.AIdata.hold)
- CC.set20G(opt,P.AIdata._20G)
- CC.setBag(opt,P.AIdata.bag=="bag")
- CC.setNode(opt,P.AIdata.node)
- P.AI_bot=CC.new(opt,wei)
+ CC.setHold(opt,self.AIdata.hold)
+ CC.set20G(opt,self.AIdata._20G)
+ CC.setBag(opt,self.AIdata.bag=="bag")
+ CC.setNode(opt,self.AIdata.node)
+ self.AI_bot=CC.new(opt,wei)
CC.free(opt)CC.free(wei)
- for i=1,P.AIdata.next do
- CC.addNext(P.AI_bot,P.nextQueue[i].id)
+ for i=1,self.AIdata.next do
+ CC.addNext(self.AI_bot,self.nextQueue[i].id)
end
- if P.gameEnv.holdCount and P.gameEnv.holdCount>1 then
- P:setHold(1)
+ if self.gameEnv.holdCount and self.gameEnv.holdCount>1 then
+ self:setHold(1)
end
else
- P:setRS("TRS")
+ self:setRS("TRS")
end
- P.AI_thread=coroutine.create(AIFUNC[data.type])
- coroutine.resume(P.AI_thread,P,P.AI_keys)
+ self.AI_thread=coroutine.create(AIFUNC[data.type])
+ coroutine.resume(self.AI_thread,self,self.AI_keys)
end
----------------------------------------------------
@@ -1547,49 +1546,49 @@ local function tick_throwBadge(ifAI,sender,time)
if time<=0 then return end
end
end
-local function tick_finish(P)
+local function tick_finish(self)
while true do
yield()
- P.endCounter=P.endCounter+1
- if P.endCounter<40 then
+ self.endCounter=self.endCounter+1
+ if self.endCounter<40 then
--Make field visible
- for j=1,#P.field do for i=1,10 do
- if P.visTime[j][i]<20 then P.visTime[j][i]=P.visTime[j][i]+.5 end
+ for j=1,#self.field do for i=1,10 do
+ if self.visTime[j][i]<20 then self.visTime[j][i]=self.visTime[j][i]+.5 end
end end
- elseif P.endCounter==60 then
+ elseif self.endCounter==60 then
return
end
end
end
-local function tick_lose(P)
+local function tick_lose(self)
while true do
yield()
- P.endCounter=P.endCounter+1
- if P.endCounter<40 then
+ self.endCounter=self.endCounter+1
+ if self.endCounter<40 then
--Make field visible
- for j=1,#P.field do for i=1,10 do
- if P.visTime[j][i]<20 then P.visTime[j][i]=P.visTime[j][i]+.5 end
+ for j=1,#self.field do for i=1,10 do
+ if self.visTime[j][i]<20 then self.visTime[j][i]=self.visTime[j][i]+.5 end
end end
- elseif P.endCounter>80 then
- for i=1,#P.field do
+ elseif self.endCounter>80 then
+ for i=1,#self.field do
for j=1,10 do
- if P.visTime[i][j]>0 then
- P.visTime[i][j]=P.visTime[i][j]-1
+ if self.visTime[i][j]>0 then
+ self.visTime[i][j]=self.visTime[i][j]-1
end
end
end
- if P.endCounter==120 then
- for _=#P.field,1,-1 do
- FREEROW.discard(P.field[_])
- FREEROW.discard(P.visTime[_])
- P.field[_],P.visTime[_]=nil
+ if self.endCounter==120 then
+ for _=#self.field,1,-1 do
+ FREEROW.discard(self.field[_])
+ FREEROW.discard(self.visTime[_])
+ self.field[_],self.visTime[_]=nil
end
return
end
end
if not GAME.modeEnv.royaleMode and #PLAYERS>1 then
- P.y=P.y+P.endCounter*.26
- P.absFieldY=P.absFieldY+P.endCounter*.26
+ self.y=self.y+self.endCounter*.26
+ self.absFieldY=self.absFieldY+self.endCounter*.26
end
end
end
@@ -1667,33 +1666,33 @@ local function gameOver()--Save record
end
end
-function Player.die(P)--Called both when win/lose!
- P.alive=false
- P.timing=false
- P.control=false
- P.update=PLY.update.dead
- P.waiting=1e99
- P.b2b=0
- P.tasks={}
- for i=1,#P.atkBuffer do
- P.atkBuffer[i].sent=true
- P.atkBuffer[i].time=0
+function Player:die()--Called both when win/lose!
+ self.alive=false
+ self.timing=false
+ self.control=false
+ self.update=PLY.update.dead
+ self.waiting=1e99
+ self.b2b=0
+ self.tasks={}
+ for i=1,#self.atkBuffer do
+ self.atkBuffer[i].sent=true
+ self.atkBuffer[i].time=0
end
- for i=1,#P.field do
+ for i=1,#self.field do
for j=1,10 do
- P.visTime[i][j]=min(P.visTime[i][j],20)
+ self.visTime[i][j]=min(self.visTime[i][j],20)
end
end
end
-function Player.win(P,result)
- if P.result then return end
- P:die()
- P.result="WIN"
+function Player:win(result)
+ if self.result then return end
+ self:die()
+ self.result="WIN"
if GAME.modeEnv.royaleMode then
- P.modeData.place=1
- P:changeAtk()
+ self.modeData.place=1
+ self:changeAtk()
end
- if P.type=="human"then
+ if self.type=="human"then
GAME.result=result or"win"
SFX.play("win")
VOC.play("win")
@@ -1702,92 +1701,92 @@ function Player.win(P,result)
end
end
if GAME.curMode.id=="custom_puzzle"then
- P:showTextF(text.win,0,0,90,"beat",.4)
+ self:showTextF(text.win,0,0,90,"beat",.4)
else
- P:showTextF(text.win,0,0,90,"beat",.5,.2)
+ self:showTextF(text.win,0,0,90,"beat",.5,.2)
end
- if P.type=="human"then
+ if self.type=="human"then
gameOver()
TASK.new(tick_autoPause)
end
- P:newTask(tick_finish)
+ self:newTask(tick_finish)
end
-function Player.lose(P,force)
- if P.result then return end
- if P.life>0 and not force then
- P.waiting=62
- local h=#P.field
+function Player:lose(force)
+ if self.result then return end
+ if self.life>0 and not force then
+ self.waiting=62
+ local h=#self.field
for _=h,1,-1 do
- FREEROW.discard(P.field[_])
- FREEROW.discard(P.visTime[_])
- P.field[_],P.visTime[_]=nil
+ FREEROW.discard(self.field[_])
+ FREEROW.discard(self.visTime[_])
+ self.field[_],self.visTime[_]=nil
end
- P.garbageBeneath=0
+ self.garbageBeneath=0
- if P.AI_mode=="CC"then
- CC.destroy(P.AI_bot)
- while P.holdQueue[1]do rem(P.holdQueue)end
- P:loadAI(P.AIdata)
+ if self.AI_mode=="CC"then
+ CC.destroy(self.AI_bot)
+ while self.holdQueue[1]do rem(self.holdQueue)end
+ self:loadAI(self.AIdata)
end
- P.life=P.life-1
- P.fieldBeneath=0
- P.b2b=0
- for i=1,#P.atkBuffer do
- local A=P.atkBuffer[i]
+ self.life=self.life-1
+ self.fieldBeneath=0
+ self.b2b=0
+ for i=1,#self.atkBuffer do
+ local A=self.atkBuffer[i]
if not A.sent then
A.sent=true
A.time=0
end
end
- P.atkBuffer.sum=0
+ self.atkBuffer.sum=0
for i=1,h do
- P:createClearingFX(i,1.5)
+ self:createClearingFX(i,1.5)
end
- SYSFX.newShade(1.4,P.fieldX,P.fieldY,300*P.size,610*P.size)
- SYSFX.newRectRipple(2,P.fieldX,P.fieldY,300*P.size,610*P.size)
- SYSFX.newRipple(2,P.x+(475+25*(P.life<3 and P.life or 0)+12)*P.size,P.y+(665+12)*P.size,20)
+ SYSFX.newShade(1.4,self.fieldX,self.fieldY,300*self.size,610*self.size)
+ SYSFX.newRectRipple(2,self.fieldX,self.fieldY,300*self.size,610*self.size)
+ SYSFX.newRipple(2,self.x+(475+25*(self.life<3 and self.life or 0)+12)*self.size,self.y+(665+12)*self.size,20)
SFX.play("clear_3")
SFX.play("emit")
return
end
- P:die()
+ self:die()
for i=1,#PLAYERS.alive do
- if PLAYERS.alive[i]==P then
+ if PLAYERS.alive[i]==self then
rem(PLAYERS.alive,i)
break
end
end
- P.result="K.O."
+ self.result="K.O."
if GAME.modeEnv.royaleMode then
- P:changeAtk()
- P.modeData.place=#PLAYERS.alive+1
- P.strength=0
- if P.lastRecv then
- local A,i=P,0
+ self:changeAtk()
+ self.modeData.place=#PLAYERS.alive+1
+ self.strength=0
+ if self.lastRecv then
+ local A,i=self,0
repeat
A,i=A.lastRecv,i+1
- until not A or A.alive or A==P or i==3
+ until not A or A.alive or A==self or i==3
if A and A.alive then
- if P.id==1 or A.id==1 then
- P.killMark=A.id==1
+ if self.id==1 or A.id==1 then
+ self.killMark=A.id==1
end
- A.modeData.ko,A.badge=A.modeData.ko+1,A.badge+P.badge+1
+ A.modeData.ko,A.badge=A.modeData.ko+1,A.badge+self.badge+1
for j=A.strength+1,4 do
if A.badge>=royaleData.powerUp[j]then
A.strength=j
A.frameColor=A.strength
end
end
- P.lastRecv=A
- if P.id==1 or A.id==1 then
- TASK.new(tick_throwBadge,not A.type=="human",P,max(3,P.badge)*4)
+ self.lastRecv=A
+ if self.id==1 or A.id==1 then
+ TASK.new(tick_throwBadge,not A.type=="human",self,max(3,self.badge)*4)
end
end
else
- P.badge=-1
+ self.badge=-1
end
freshMostBadge()
@@ -1795,30 +1794,30 @@ function Player.lose(P,force)
if #PLAYERS.alive==royaleData.stage[GAME.stage]then
royaleLevelup()
end
- P:showTextF(P.modeData.place,0,120,60,"appear",.26,.9)
+ self:showTextF(self.modeData.place,0,120,60,"appear",.26,.9)
end
- P.gameEnv.keepVisible=P.gameEnv.visible~="show"
- P:showTextF(text.gameover,0,0,60,"appear",.26,.9)
- if P.type=="human"then
+ self.gameEnv.keepVisible=self.gameEnv.visible~="show"
+ self:showTextF(text.gameover,0,0,60,"appear",.26,.9)
+ if self.type=="human"then
GAME.result="gameover"
SFX.play("fail")
VOC.play("lose")
if GAME.modeEnv.royaleMode then
- if P.modeData.place==2 then
+ if self.modeData.place==2 then
BGM.play("hay what kind of feeling")
else
BGM.play("end")
end
end
gameOver()
- P:newTask(#PLAYERS>1 and tick_lose or tick_finish)
+ self:newTask(#PLAYERS>1 and tick_lose or tick_finish)
if GAME.net then
NET.signal_die()
else
TASK.new(tick_autoPause)
end
else
- P:newTask(tick_lose)
+ self:newTask(tick_lose)
end
if #PLAYERS.alive==1 then
PLAYERS.alive[1]:win()
@@ -1827,269 +1826,269 @@ end
--------------------------<\Events>--------------------------
----------------------------------------------------
-function Player.act_moveLeft(P,auto)
+function Player:act_moveLeft(auto)
if not auto then
- P.ctrlCount=P.ctrlCount+1
+ self.ctrlCount=self.ctrlCount+1
end
- P.movDir=-1
- if P.keyPressing[9]then
- if P.gameEnv.swap then
- P:changeAtkMode(1)
- P.keyPressing[1]=false
+ self.movDir=-1
+ if self.keyPressing[9]then
+ if self.gameEnv.swap then
+ self:changeAtkMode(1)
+ self.keyPressing[1]=false
end
- elseif P.control and P.waiting==-1 then
- if P.cur and not P:ifoverlap(P.cur.bk,P.curX-1,P.curY)then
- if P.gameEnv.moveFX and P.gameEnv.block then
- P:createMoveFX("left")
+ elseif self.control and self.waiting==-1 then
+ if self.cur and not self:ifoverlap(self.cur.bk,self.curX-1,self.curY)then
+ if self.gameEnv.moveFX and self.gameEnv.block then
+ self:createMoveFX("left")
end
- P.curX=P.curX-1
- P:freshBlock("move")
- if P.sound and P.curY==P.ghoY then SFX.play("move")end
- if not auto then P.moving=0 end
- P.spinLast=false
+ self.curX=self.curX-1
+ self:freshBlock("move")
+ if self.sound and self.curY==self.ghoY then SFX.play("move")end
+ if not auto then self.moving=0 end
+ self.spinLast=false
else
- P.moving=P.gameEnv.das
+ self.moving=self.gameEnv.das
end
else
- P.moving=0
+ self.moving=0
end
end
-function Player.act_moveRight(P,auto)
+function Player:act_moveRight(auto)
if not auto then
- P.ctrlCount=P.ctrlCount+1
+ self.ctrlCount=self.ctrlCount+1
end
- P.movDir=1
- if P.keyPressing[9]then
- if P.gameEnv.swap then
- P:changeAtkMode(2)
- P.keyPressing[2]=false
+ self.movDir=1
+ if self.keyPressing[9]then
+ if self.gameEnv.swap then
+ self:changeAtkMode(2)
+ self.keyPressing[2]=false
end
- elseif P.control and P.waiting==-1 then
- if P.cur and not P:ifoverlap(P.cur.bk,P.curX+1,P.curY)then
- if P.gameEnv.moveFX and P.gameEnv.block then
- P:createMoveFX("right")
+ elseif self.control and self.waiting==-1 then
+ if self.cur and not self:ifoverlap(self.cur.bk,self.curX+1,self.curY)then
+ if self.gameEnv.moveFX and self.gameEnv.block then
+ self:createMoveFX("right")
end
- P.curX=P.curX+1
- P:freshBlock("move")
- if P.sound and P.curY==P.ghoY then SFX.play("move")end
- if not auto then P.moving=0 end
- P.spinLast=false
+ self.curX=self.curX+1
+ self:freshBlock("move")
+ if self.sound and self.curY==self.ghoY then SFX.play("move")end
+ if not auto then self.moving=0 end
+ self.spinLast=false
else
- P.moving=P.gameEnv.das
+ self.moving=self.gameEnv.das
end
else
- P.moving=0
+ self.moving=0
end
end
-function Player.act_rotRight(P)
- if P.control and P.waiting==-1 and P.cur then
- P.ctrlCount=P.ctrlCount+1
- P:spin(1)
- P.keyPressing[3]=false
+function Player:act_rotRight()
+ if self.control and self.waiting==-1 and self.cur then
+ self.ctrlCount=self.ctrlCount+1
+ self:spin(1)
+ self.keyPressing[3]=false
end
end
-function Player.act_rotLeft(P)
- if P.control and P.waiting==-1 and P.cur then
- P.ctrlCount=P.ctrlCount+1
- P:spin(3)
- P.keyPressing[4]=false
+function Player:act_rotLeft()
+ if self.control and self.waiting==-1 and self.cur then
+ self.ctrlCount=self.ctrlCount+1
+ self:spin(3)
+ self.keyPressing[4]=false
end
end
-function Player.act_rot180(P)
- if P.control and P.waiting==-1 and P.cur then
- P.ctrlCount=P.ctrlCount+2
- P:spin(2)
- P.keyPressing[5]=false
+function Player:act_rot180()
+ if self.control and self.waiting==-1 and self.cur then
+ self.ctrlCount=self.ctrlCount+2
+ self:spin(2)
+ self.keyPressing[5]=false
end
end
-function Player.act_hardDrop(P)
- if P.keyPressing[9]then
- if P.gameEnv.swap then
- P:changeAtkMode(3)
+function Player:act_hardDrop()
+ if self.keyPressing[9]then
+ if self.gameEnv.swap then
+ self:changeAtkMode(3)
end
- P.keyPressing[6]=false
- elseif P.control and P.waiting==-1 and P.cur then
- if P.curY>P.ghoY then
- local CB=P.cur.bk
- if P.gameEnv.dropFX and P.gameEnv.block and P.curY-P.ghoY-#CB>-1 then
- P:createDropFX(P.curX,P.curY-1,#CB[1],P.curY-P.ghoY-#CB+1)
+ self.keyPressing[6]=false
+ elseif self.control and self.waiting==-1 and self.cur then
+ if self.curY>self.ghoY then
+ local CB=self.cur.bk
+ if self.gameEnv.dropFX and self.gameEnv.block and self.curY-self.ghoY-#CB>-1 then
+ self:createDropFX(self.curX,self.curY-1,#CB[1],self.curY-self.ghoY-#CB+1)
end
- P.curY=P.ghoY
- P.spinLast=false
- if P.sound then
- SFX.play("drop",nil,P:getCenterX()*.15)
+ self.curY=self.ghoY
+ self.spinLast=false
+ if self.sound then
+ SFX.play("drop",nil,self:getCenterX()*.15)
VIB(1)
end
end
- if P.gameEnv.shakeFX then
- P.fieldOff.vy=P.gameEnv.shakeFX*.6
- P.fieldOff.va=P.fieldOff.va+P:getCenterX()*P.gameEnv.shakeFX*6e-4
+ if self.gameEnv.shakeFX then
+ self.fieldOff.vy=self.gameEnv.shakeFX*.6
+ self.fieldOff.va=self.fieldOff.va+self:getCenterX()*self.gameEnv.shakeFX*6e-4
end
- P.lockDelay=-1
- P:drop()
- P.keyPressing[6]=false
+ self.lockDelay=-1
+ self:drop()
+ self.keyPressing[6]=false
end
end
-function Player.act_softDrop(P)
- local ENV=P.gameEnv
- if P.keyPressing[9]then
+function Player:act_softDrop()
+ local ENV=self.gameEnv
+ if self.keyPressing[9]then
if ENV.swap then
- P:changeAtkMode(4)
+ self:changeAtkMode(4)
end
else
- P.downing=1
- if P.control and P.waiting==-1 and P.cur then
- if P.curY>P.ghoY then
- P.curY=P.curY-1
- P:freshBlock("fresh")
- P.spinLast=false
+ self.downing=1
+ if self.control and self.waiting==-1 and self.cur then
+ if self.curY>self.ghoY then
+ self.curY=self.curY-1
+ self:freshBlock("fresh")
+ self.spinLast=false
elseif ENV.deepDrop then
- local CB=P.cur.bk
- local y=P.curY-1
- while P:ifoverlap(CB,P.curX,y)and y>0 do
+ local CB=self.cur.bk
+ local y=self.curY-1
+ while self:ifoverlap(CB,self.curX,y)and y>0 do
y=y-1
end
if y>0 then
- if ENV.dropFX and ENV.block and P.curY-y-#CB>-1 then
- P:createDropFX(P.curX,P.curY-1,#CB[1],P.curY-y-#CB+1)
+ if ENV.dropFX and ENV.block and self.curY-y-#CB>-1 then
+ self:createDropFX(self.curX,self.curY-1,#CB[1],self.curY-y-#CB+1)
end
- P.curY=y
- P:freshBlock("move")
+ self.curY=y
+ self:freshBlock("move")
SFX.play("swipe")
end
end
end
end
end
-function Player.act_hold(P)
- if P.control and P.waiting==-1 then
- P:hold()
+function Player:act_hold()
+ if self.control and self.waiting==-1 then
+ self:hold()
end
end
-function Player.act_func1(P)
- P.gameEnv.fkey1(P)
+function Player:act_func1()
+ self.gameEnv.fkey1(self)
end
-function Player.act_func2(P)
- P.gameEnv.fkey2(P)
+function Player:act_func2()
+ self.gameEnv.fkey2(self)
end
-function Player.act_insLeft(P,auto)
- if not P.cur then return end
- local x0=P.curX
- while not P:ifoverlap(P.cur.bk,P.curX-1,P.curY)do
- if P.gameEnv.moveFX and P.gameEnv.block then
- P:createMoveFX("left")
+function Player:act_insLeft(auto)
+ if not self.cur then return end
+ local x0=self.curX
+ while not self:ifoverlap(self.cur.bk,self.curX-1,self.curY)do
+ if self.gameEnv.moveFX and self.gameEnv.block then
+ self:createMoveFX("left")
end
- P.curX=P.curX-1
- P:freshBlock("move")
+ self.curX=self.curX-1
+ self:freshBlock("move")
end
- if P.curX~=x0 then
- P.spinLast=false
+ if self.curX~=x0 then
+ self.spinLast=false
end
- if P.gameEnv.shakeFX then
- P.fieldOff.vx=-P.gameEnv.shakeFX*.5
+ if self.gameEnv.shakeFX then
+ self.fieldOff.vx=-self.gameEnv.shakeFX*.5
end
if auto then
- if P.ctrlCount==0 then P.ctrlCount=1 end
+ if self.ctrlCount==0 then self.ctrlCount=1 end
else
- P.ctrlCount=P.ctrlCount+1
+ self.ctrlCount=self.ctrlCount+1
end
end
-function Player.act_insRight(P,auto)
- if not P.cur then return end
- local x0=P.curX
- while not P:ifoverlap(P.cur.bk,P.curX+1,P.curY)do
- if P.gameEnv.moveFX and P.gameEnv.block then
- P:createMoveFX("right")
+function Player:act_insRight(auto)
+ if not self.cur then return end
+ local x0=self.curX
+ while not self:ifoverlap(self.cur.bk,self.curX+1,self.curY)do
+ if self.gameEnv.moveFX and self.gameEnv.block then
+ self:createMoveFX("right")
end
- P.curX=P.curX+1
- P:freshBlock("move")
+ self.curX=self.curX+1
+ self:freshBlock("move")
end
- if P.curX~=x0 then
- P.spinLast=false
+ if self.curX~=x0 then
+ self.spinLast=false
end
- if P.gameEnv.shakeFX then
- P.fieldOff.vx=P.gameEnv.shakeFX*.5
+ if self.gameEnv.shakeFX then
+ self.fieldOff.vx=self.gameEnv.shakeFX*.5
end
if auto then
- if P.ctrlCount==0 then P.ctrlCount=1 end
+ if self.ctrlCount==0 then self.ctrlCount=1 end
else
- P.ctrlCount=P.ctrlCount+1
+ self.ctrlCount=self.ctrlCount+1
end
end
-function Player.act_insDown(P)
- if P.cur and P.curY>P.ghoY then
- local ENV=P.gameEnv
- local CB=P.cur.bk
- if ENV.dropFX and ENV.block and P.curY-P.ghoY-#CB>-1 then
- P:createDropFX(P.curX,P.curY-1,#CB[1],P.curY-P.ghoY-#CB+1)
+function Player:act_insDown()
+ if self.cur and self.curY>self.ghoY then
+ local ENV=self.gameEnv
+ local CB=self.cur.bk
+ if ENV.dropFX and ENV.block and self.curY-self.ghoY-#CB>-1 then
+ self:createDropFX(self.curX,self.curY-1,#CB[1],self.curY-self.ghoY-#CB+1)
end
if ENV.shakeFX then
- P.fieldOff.vy=ENV.shakeFX*.5
+ self.fieldOff.vy=ENV.shakeFX*.5
end
- P.curY=P.ghoY
- P.lockDelay=ENV.lock
- P.spinLast=false
- P:freshBlock("fresh")
+ self.curY=self.ghoY
+ self.lockDelay=ENV.lock
+ self.spinLast=false
+ self:freshBlock("fresh")
end
end
-function Player.act_down1(P)
- if P.cur and P.curY>P.ghoY then
- if P.gameEnv.moveFX and P.gameEnv.block then
- P:createMoveFX("down")
+function Player:act_down1()
+ if self.cur and self.curY>self.ghoY then
+ if self.gameEnv.moveFX and self.gameEnv.block then
+ self:createMoveFX("down")
end
- P.curY=P.curY-1
- P:freshBlock("fresh")
- P.spinLast=false
+ self.curY=self.curY-1
+ self:freshBlock("fresh")
+ self.spinLast=false
end
end
-function Player.act_down4(P)
- if P.cur and P.curY>P.ghoY then
- local y=max(P.curY-4,P.ghoY)
- local CB=P.cur.bk
- if P.gameEnv.dropFX and P.gameEnv.block and P.curY-y-#CB>-1 then
- P:createDropFX(P.curX,P.curY-1,#CB[1],P.curY-y-#CB+1)
+function Player:act_down4()
+ if self.cur and self.curY>self.ghoY then
+ local y=max(self.curY-4,self.ghoY)
+ local CB=self.cur.bk
+ if self.gameEnv.dropFX and self.gameEnv.block and self.curY-y-#CB>-1 then
+ self:createDropFX(self.curX,self.curY-1,#CB[1],self.curY-y-#CB+1)
end
- P.curY=y
- P:freshBlock("fresh")
- P.spinLast=false
+ self.curY=y
+ self:freshBlock("fresh")
+ self.spinLast=false
end
end
-function Player.act_down10(P)
- if P.cur and P.curY>P.ghoY then
- local y=max(P.curY-10,P.ghoY)
- local CB=P.cur.bk
- if P.gameEnv.dropFX and P.gameEnv.block and P.curY-y-#CB>-1 then
- P:createDropFX(P.curX,P.curY-1,#CB[1],P.curY-y-#CB+1)
+function Player:act_down10()
+ if self.cur and self.curY>self.ghoY then
+ local y=max(self.curY-10,self.ghoY)
+ local CB=self.cur.bk
+ if self.gameEnv.dropFX and self.gameEnv.block and self.curY-y-#CB>-1 then
+ self:createDropFX(self.curX,self.curY-1,#CB[1],self.curY-y-#CB+1)
end
- P.curY=y
- P:freshBlock("fresh")
- P.spinLast=false
+ self.curY=y
+ self:freshBlock("fresh")
+ self.spinLast=false
end
end
-function Player.act_dropLeft(P)
- if not P.cur then return end
- P:act_insLeft()
- P:act_hardDrop()
+function Player:act_dropLeft()
+ if not self.cur then return end
+ self:act_insLeft()
+ self:act_hardDrop()
end
-function Player.act_dropRight(P)
- if not P.cur then return end
- P:act_insRight()
- P:act_hardDrop()
+function Player:act_dropRight()
+ if not self.cur then return end
+ self:act_insRight()
+ self:act_hardDrop()
end
-function Player.act_zangiLeft(P)
- if not P.cur then return end
- P:act_insLeft()
- P:act_insDown()
- P:act_insRight()
- P:act_hardDrop()
+function Player:act_zangiLeft()
+ if not self.cur then return end
+ self:act_insLeft()
+ self:act_insDown()
+ self:act_insRight()
+ self:act_hardDrop()
end
-function Player.act_zangiRight(P)
- if not P.cur then return end
- P:act_insRight()
- P:act_insDown()
- P:act_insLeft()
- P:act_hardDrop()
+function Player:act_zangiRight()
+ if not self.cur then return end
+ self:act_insRight()
+ self:act_insDown()
+ self:act_insLeft()
+ self:act_hardDrop()
end
Player.actList={
Player.act_moveLeft, --1