From ee02013fa5b2348688ffbbf2239cf009baf2e319 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Mon, 29 Mar 2021 11:40:36 +0800 Subject: [PATCH] =?UTF-8?q?PLAYERS.alive=E6=8B=BF=E5=87=BA=E6=9D=A5?= =?UTF-8?q?=E4=BD=9C=E4=B8=BA=E5=8D=95=E7=8B=AC=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zframework/init.lua | 2 +- parts/gametoolfunc.lua | 48 ++++++++++++++++++------------------ parts/globalTables.lua | 3 ++- parts/modes/custom_clear.lua | 2 +- parts/modes/round_e.lua | 2 +- parts/modes/round_h.lua | 2 +- parts/modes/round_l.lua | 2 +- parts/modes/round_n.lua | 2 +- parts/modes/round_u.lua | 2 +- parts/modes/techmino49_e.lua | 2 +- parts/modes/techmino49_h.lua | 2 +- parts/modes/techmino49_u.lua | 2 +- parts/modes/techmino99_e.lua | 2 +- parts/modes/techmino99_h.lua | 2 +- parts/modes/techmino99_u.lua | 2 +- parts/player/init.lua | 2 +- parts/player/player.lua | 16 ++++++------ parts/player/update.lua | 4 +-- parts/scenes/net_game.lua | 8 +++--- 19 files changed, 54 insertions(+), 53 deletions(-) diff --git a/Zframework/init.lua b/Zframework/init.lua index 8058fe6b..faf26cfe 100644 --- a/Zframework/init.lua +++ b/Zframework/init.lua @@ -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() diff --git a/parts/gametoolfunc.lua b/parts/gametoolfunc.lua index 3bc0fd2a..aa461149 100644 --- a/parts/gametoolfunc.lua +++ b/parts/gametoolfunc.lua @@ -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) diff --git a/parts/globalTables.lua b/parts/globalTables.lua index 93439ce4..3aae2007 100644 --- a/parts/globalTables.lua +++ b/parts/globalTables.lua @@ -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 diff --git a/parts/modes/custom_clear.lua b/parts/modes/custom_clear.lua index 5809db7b..4dbbb590 100644 --- a/parts/modes/custom_clear.lua +++ b/parts/modes/custom_clear.lua @@ -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, diff --git a/parts/modes/round_e.lua b/parts/modes/round_e.lua index 2b3ef740..d565c152 100644 --- a/parts/modes/round_e.lua +++ b/parts/modes/round_e.lua @@ -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 diff --git a/parts/modes/round_h.lua b/parts/modes/round_h.lua index 54d17ae3..3ccce225 100644 --- a/parts/modes/round_h.lua +++ b/parts/modes/round_h.lua @@ -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 diff --git a/parts/modes/round_l.lua b/parts/modes/round_l.lua index a9ab94d7..69a21cd4 100644 --- a/parts/modes/round_l.lua +++ b/parts/modes/round_l.lua @@ -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 diff --git a/parts/modes/round_n.lua b/parts/modes/round_n.lua index b790fa84..6619e14e 100644 --- a/parts/modes/round_n.lua +++ b/parts/modes/round_n.lua @@ -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 diff --git a/parts/modes/round_u.lua b/parts/modes/round_u.lua index d8675c26..15ddef4d 100644 --- a/parts/modes/round_u.lua +++ b/parts/modes/round_u.lua @@ -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 diff --git a/parts/modes/techmino49_e.lua b/parts/modes/techmino49_e.lua index e1083665..05caf981 100644 --- a/parts/modes/techmino49_e.lua +++ b/parts/modes/techmino49_e.lua @@ -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) diff --git a/parts/modes/techmino49_h.lua b/parts/modes/techmino49_h.lua index 9643673f..8f2efa53 100644 --- a/parts/modes/techmino49_h.lua +++ b/parts/modes/techmino49_h.lua @@ -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) diff --git a/parts/modes/techmino49_u.lua b/parts/modes/techmino49_u.lua index d10655b9..fdc11d4a 100644 --- a/parts/modes/techmino49_u.lua +++ b/parts/modes/techmino49_u.lua @@ -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) diff --git a/parts/modes/techmino99_e.lua b/parts/modes/techmino99_e.lua index c35700ac..9ef69fe9 100644 --- a/parts/modes/techmino99_e.lua +++ b/parts/modes/techmino99_e.lua @@ -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) diff --git a/parts/modes/techmino99_h.lua b/parts/modes/techmino99_h.lua index 713030b3..6479e695 100644 --- a/parts/modes/techmino99_h.lua +++ b/parts/modes/techmino99_h.lua @@ -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) diff --git a/parts/modes/techmino99_u.lua b/parts/modes/techmino99_u.lua index 3ca05a56..a6440694 100644 --- a/parts/modes/techmino99_u.lua +++ b/parts/modes/techmino99_u.lua @@ -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) diff --git a/parts/player/init.lua b/parts/player/init.lua index ede6222e..04fcf48d 100644 --- a/parts/player/init.lua +++ b/parts/player/init.lua @@ -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 diff --git a/parts/player/player.lua b/parts/player/player.lua index 1cd56cf6..ebc30661 100644 --- a/parts/player/player.lua +++ b/parts/player/player.lua @@ -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>-------------------------- diff --git a/parts/player/update.lua b/parts/player/update.lua index 9b99af5d..d04ef910 100644 --- a/parts/player/update.lua +++ b/parts/player/update.lua @@ -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 diff --git a/parts/scenes/net_game.lua b/parts/scenes/net_game.lua index 7ea561f9..de4f162c 100644 --- a/parts/scenes/net_game.lua +++ b/parts/scenes/net_game.lua @@ -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