PLAYERS.alive拿出来作为单独变量

This commit is contained in:
MrZ626
2021-03-29 11:40:36 +08:00
parent c0736132b1
commit ee02013fa5
19 changed files with 54 additions and 53 deletions

View File

@@ -205,7 +205,7 @@ local function noDevkeyPressed(key)
LOG.print(string.format("System:%s[%s]\nluaVer:%s\njitVer:%s\njitVerNum:%s",SYSTEM,jit.arch,_VERSION,jit.version,jit.version_num))
elseif key=="f3"then
for _=1,8 do
local P=PLAYERS.alive[rnd(#PLAYERS.alive)]
local P=PLY_ALIVE[rnd(#PLY_ALIVE)]
if P~=PLAYERS[1]then
P.lastRecv=PLAYERS[1]
P:lose()

View File

@@ -271,10 +271,10 @@ end
--Royale mode
function randomTarget(P)--Return a random opponent for P
if #PLAYERS.alive>1 then
if #PLY_ALIVE>1 then
local R
repeat
R=PLAYERS.alive[rnd(#PLAYERS.alive)]
R=PLY_ALIVE[rnd(#PLY_ALIVE)]
until R~=P
return R
end
@@ -282,28 +282,28 @@ end
function freshMostDangerous()
GAME.mostDangerous,GAME.secDangerous=false,false
local m,m2=0,0
for i=1,#PLAYERS.alive do
local h=#PLAYERS.alive[i].field
for i=1,#PLY_ALIVE do
local h=#PLY_ALIVE[i].field
if h>=m then
GAME.mostDangerous,GAME.secDangerous=PLAYERS.alive[i],GAME.mostDangerous
GAME.mostDangerous,GAME.secDangerous=PLY_ALIVE[i],GAME.mostDangerous
m,m2=h,m
elseif h>=m2 then
GAME.secDangerous=PLAYERS.alive[i]
GAME.secDangerous=PLY_ALIVE[i]
m2=h
end
end
for i=1,#PLAYERS.alive do
if PLAYERS.alive[i].atkMode==3 then
PLAYERS.alive[i]:freshTarget()
for i=1,#PLY_ALIVE do
if PLY_ALIVE[i].atkMode==3 then
PLY_ALIVE[i]:freshTarget()
end
end
end
function freshMostBadge()
GAME.mostBadge,GAME.secBadge=false,false
local m,m2=0,0
for i=1,#PLAYERS.alive do
local P=PLAYERS.alive[i]
for i=1,#PLY_ALIVE do
local P=PLY_ALIVE[i]
local b=P.badge
if b>=m then
GAME.mostBadge,GAME.secBadge=P,GAME.mostBadge
@@ -314,44 +314,44 @@ function freshMostBadge()
end
end
for i=1,#PLAYERS.alive do
if PLAYERS.alive[i].atkMode==4 then
PLAYERS.alive[i]:freshTarget()
for i=1,#PLY_ALIVE do
if PLY_ALIVE[i].atkMode==4 then
PLY_ALIVE[i]:freshTarget()
end
end
end
function royaleLevelup()
GAME.stage=GAME.stage+1
local spd
TEXT.show(text.royale_remain:gsub("$1",#PLAYERS.alive),640,200,40,"beat",.3)
TEXT.show(text.royale_remain:gsub("$1",#PLY_ALIVE),640,200,40,"beat",.3)
if GAME.stage==2 then
spd=30
elseif GAME.stage==3 then
spd=15
for _,P in next,PLAYERS.alive do
for _,P in next,PLY_ALIVE do
P.gameEnv.garbageSpeed=.6
end
if PLAYERS[1].alive then BGM.play("cruelty")end
elseif GAME.stage==4 then
spd=10
for _,P in next,PLAYERS.alive do
for _,P in next,PLY_ALIVE do
P.gameEnv.pushSpeed=3
end
elseif GAME.stage==5 then
spd=5
for _,P in next,PLAYERS.alive do
for _,P in next,PLY_ALIVE do
P.gameEnv.garbageSpeed=1
end
elseif GAME.stage==6 then
spd=3
if PLAYERS[1].alive then BGM.play("final")end
end
for _,P in next,PLAYERS.alive do
for _,P in next,PLY_ALIVE do
P.gameEnv.drop=spd
end
if GAME.curMode.name:find("_u")then
for i=1,#PLAYERS.alive do
local P=PLAYERS.alive[i]
for i=1,#PLY_ALIVE do
local P=PLY_ALIVE[i]
P.gameEnv.drop=int(P.gameEnv.drop*.3)
if P.gameEnv.drop==0 then
P.curY=P.ghoY
@@ -537,8 +537,8 @@ function destroyPlayers()--Destroy all player objects, restore freerows and free
end
PLAYERS[i]=nil
end
for i=#PLAYERS.alive,1,-1 do
PLAYERS.alive[i]=nil
for i=#PLY_ALIVE,1,-1 do
PLY_ALIVE[i]=nil
end
collectgarbage()
end
@@ -611,7 +611,7 @@ function loadGame(M,ifQuickPlay,ifNet)--Load a mode and go to game scene
end
end
function initPlayerPosition(sudden)--Set initial position for every player
local L=PLAYERS.alive
local L=PLY_ALIVE
if not sudden then
for i=1,#L do
L[i]:setPosition(640,#L<=5 and 360 or -62,0)

View File

@@ -142,7 +142,8 @@ for i=1,#MODOPT do
end
--Game tables
PLAYERS={alive={}}--Players data
PLAYERS={}--Players data
PLY_ALIVE={}
FIELD={}--Field(s) for custom game
BAG={}--Sequence for custom game
MISSION={}--Clearing mission for custom game

View File

@@ -71,7 +71,7 @@ return{
PLY.newAIPlayer(2,AIBUILDER("CC",2*AIlevel-1,math.floor(AIlevel*.5+1),true,20000+5000*AIlevel))
end
for _,P in next,PLAYERS.alive do
for _,P in next,PLY_ALIVE do
setField(P,1)
end
end,

View File

@@ -1,5 +1,5 @@
local function update_round(P)
if #PLAYERS.alive>1 then
if #PLY_ALIVE>1 then
P.control=false
local ID=P.id
repeat

View File

@@ -1,5 +1,5 @@
local function update_round(P)
if #PLAYERS.alive>1 then
if #PLY_ALIVE>1 then
P.control=false
local ID=P.id
repeat

View File

@@ -1,5 +1,5 @@
local function update_round(P)
if #PLAYERS.alive>1 then
if #PLY_ALIVE>1 then
P.control=false
local ID=P.id
repeat

View File

@@ -1,5 +1,5 @@
local function update_round(P)
if #PLAYERS.alive>1 then
if #PLY_ALIVE>1 then
P.control=false
local ID=P.id
repeat

View File

@@ -1,5 +1,5 @@
local function update_round(P)
if #PLAYERS.alive>1 then
if #PLY_ALIVE>1 then
P.control=false
local ID=P.id
repeat

View File

@@ -59,7 +59,7 @@ return{
end,
mesDisp=function(P)
setFont(35)
mStr(#PLAYERS.alive.."/49",69,175)
mStr(#PLY_ALIVE.."/49",69,175)
mStr(P.modeData.ko,80,215)
gc.draw(drawableText.ko,60-drawableText.ko:getWidth(),222)
setFont(20)

View File

@@ -59,7 +59,7 @@ return{
end,
mesDisp=function(P)
setFont(35)
mStr(#PLAYERS.alive.."/49",69,175)
mStr(#PLY_ALIVE.."/49",69,175)
mStr(P.modeData.ko,80,215)
gc.draw(drawableText.ko,60-drawableText.ko:getWidth(),222)
setFont(20)

View File

@@ -59,7 +59,7 @@ return{
end,
mesDisp=function(P)
setFont(35)
mStr(#PLAYERS.alive.."/49",69,175)
mStr(#PLY_ALIVE.."/49",69,175)
mStr(P.modeData.ko,80,215)
gc.draw(drawableText.ko,60-drawableText.ko:getWidth(),222)
setFont(20)

View File

@@ -59,7 +59,7 @@ return{
end,
mesDisp=function(P)
setFont(35)
mStr(#PLAYERS.alive.."/99",69,175)
mStr(#PLY_ALIVE.."/99",69,175)
mStr(P.modeData.ko,80,215)
gc.draw(drawableText.ko,60-drawableText.ko:getWidth(),222)
setFont(20)

View File

@@ -59,7 +59,7 @@ return{
end,
mesDisp=function(P)
setFont(35)
mStr(#PLAYERS.alive.."/99",69,175)
mStr(#PLY_ALIVE.."/99",69,175)
mStr(P.modeData.ko,80,215)
gc.draw(drawableText.ko,60-drawableText.ko:getWidth(),222)
setFont(20)

View File

@@ -59,7 +59,7 @@ return{
end,
mesDisp=function(P)
setFont(35)
mStr(#PLAYERS.alive.."/99",69,175)
mStr(#PLY_ALIVE.."/99",69,175)
mStr(P.modeData.ko,80,215)
gc.draw(drawableText.ko,60-drawableText.ko:getWidth(),222)
setFont(20)

View File

@@ -75,7 +75,7 @@ end
local function newEmptyPlayer(id,mini)
local P={id=id}
PLAYERS[id]=P
PLAYERS.alive[id]=P
PLY_ALIVE[id]=P
--Inherit functions of Player class
for k,v in next,Player do P[k]=v end

View File

@@ -1333,7 +1333,7 @@ do--Player.drop(self)--Place piece
T=self.atking
self:freshTarget()
end
elseif #PLAYERS.alive>1 then
elseif #PLY_ALIVE>1 then
T=randomTarget(self)
end
if T then
@@ -1753,16 +1753,16 @@ function Player:lose(force)
return
end
self:die()
for i=1,#PLAYERS.alive do
if PLAYERS.alive[i]==self then
rem(PLAYERS.alive,i)
for i=1,#PLY_ALIVE do
if PLY_ALIVE[i]==self then
rem(PLY_ALIVE,i)
break
end
end
self.result="K.O."
if GAME.modeEnv.royaleMode then
self:changeAtk()
self.modeData.place=#PLAYERS.alive+1
self.modeData.place=#PLY_ALIVE+1
self.strength=0
if self.lastRecv then
local A,i=self,0
@@ -1791,7 +1791,7 @@ function Player:lose(force)
freshMostBadge()
freshMostDangerous()
if #PLAYERS.alive==royaleData.stage[GAME.stage]then
if #PLY_ALIVE==royaleData.stage[GAME.stage]then
royaleLevelup()
end
self:showTextF(self.modeData.place,0,120,60,"appear",.26,.9)
@@ -1819,8 +1819,8 @@ function Player:lose(force)
else
self:newTask(tick_lose)
end
if #PLAYERS.alive==1 then
PLAYERS.alive[1]:win()
if #PLY_ALIVE==1 then
PLY_ALIVE[1]:win()
end
end
--------------------------<\Events>--------------------------

View File

@@ -398,7 +398,7 @@ function update.remote_alive(P,dt)
local amount=int(event/0x100)%0x100
local time=int(event/0x10000)%0x10000
local line=int(event/0x100000000)%0x10000
local L=PLAYERS.alive
local L=PLY_ALIVE
for i=1,#L do
if L[i].subID==sid then
P:attack(L[i],amount,time,line,true)
@@ -409,7 +409,7 @@ function update.remote_alive(P,dt)
end
end
elseif event>0x1000000000000 then--Receiving lines
local L=PLAYERS.alive
local L=PLY_ALIVE
local sid=tostring(event%0x100)
for i=1,#L do
if L[i].subID==sid then

View File

@@ -185,9 +185,9 @@ function scene.socketRead(mes)
break
end
end
for i=1,#PLAYERS.alive do
if PLAYERS.alive[i].userID==args[2]then
rem(PLAYERS.alive,i)
for i=1,#PLY_ALIVE do
if PLY_ALIVE[i].userID==args[2]then
rem(PLY_ALIVE,i)
break
end
end
@@ -225,7 +225,7 @@ function scene.socketRead(mes)
end
end
elseif cmd=="R"then
local L=PLAYERS.alive
local L=PLY_ALIVE
for i=1,#L do
if L[i].subID==args[1]then
L[i].ready=true