调整table扩展模块相关代码
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
local next,type=next,type
|
||||
local TABLE={}
|
||||
|
||||
--Copy [1~#] elements
|
||||
--Get a copy of [1~#] elements
|
||||
function TABLE.shift(org)
|
||||
local L={}
|
||||
for i=1,#org do
|
||||
@@ -14,7 +14,7 @@ function TABLE.shift(org)
|
||||
return L
|
||||
end
|
||||
|
||||
--Copy all elements
|
||||
--Get a full copy of a table
|
||||
function TABLE.copy(org)
|
||||
local L={}
|
||||
for k,v in next,org do
|
||||
@@ -28,25 +28,25 @@ function TABLE.copy(org)
|
||||
end
|
||||
|
||||
--For all things in G if same type in base, push to base
|
||||
function TABLE.update(G,base)
|
||||
for k,v in next,G do
|
||||
if type(v)==type(base[k])then
|
||||
function TABLE.update(new,old)
|
||||
for k,v in next,new do
|
||||
if type(v)==type(old[k])then
|
||||
if type(v)=="table"then
|
||||
TABLE.update(v,base[k])
|
||||
TABLE.update(v,old[k])
|
||||
else
|
||||
base[k]=v
|
||||
old[k]=v
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--For all things in G if no val in base, push to base
|
||||
function TABLE.complete(G,base)
|
||||
for k,v in next,G do
|
||||
if base[k]==nil then
|
||||
base[k]=v
|
||||
elseif type(v)=="table"and type(base[k])=="table"then
|
||||
TABLE.complete(v,base[k])
|
||||
function TABLE.complete(new,old)
|
||||
for k,v in next,new do
|
||||
if old[k]==nil then
|
||||
old[k]=v
|
||||
elseif type(v)=="table"and type(old[k])=="table"then
|
||||
TABLE.complete(v,old[k])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -71,7 +71,7 @@ if type(_CC)=="table"then
|
||||
end
|
||||
CC.updateField(P)
|
||||
|
||||
TABLE.clear(P.holdQueue)
|
||||
TABLE.cut(P.holdQueue)
|
||||
P.holdTime=P.gameEnv.holdCount
|
||||
|
||||
P.cur=rem(P.nextQueue,1)
|
||||
|
||||
@@ -180,7 +180,7 @@ function destroyPlayers()--Destroy all player objects, restore freerows and free
|
||||
end
|
||||
PLAYERS[i]=nil
|
||||
end
|
||||
TABLE.clear(PLY_ALIVE)
|
||||
TABLE.cut(PLY_ALIVE)
|
||||
collectgarbage()
|
||||
end
|
||||
function pauseGame()
|
||||
|
||||
@@ -351,7 +351,7 @@ function NET.updateWS_play()
|
||||
elseif res.action==2 then--Player join
|
||||
if res.type=="Self"then
|
||||
--Create room
|
||||
TABLE.clear(PLY_NET)
|
||||
TABLE.cut(PLY_NET)
|
||||
if d.players then
|
||||
for _,p in next,d.players do
|
||||
ins(PLY_NET,p.uid==USER.uid and 1 or #PLY_NET+1,{
|
||||
|
||||
@@ -1748,7 +1748,7 @@ function Player:lose(force)
|
||||
|
||||
if self.AI_mode=="CC"then
|
||||
CC.destroy(self.AI_bot)
|
||||
TABLE.clear(self.holdQueue)
|
||||
TABLE.cut(self.holdQueue)
|
||||
self:loadAI(self.AIdata)
|
||||
end
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ local typeColor={
|
||||
}
|
||||
local function getList()return result[1]and result or dict end
|
||||
local function clearResult()
|
||||
TABLE.clear(result)
|
||||
TABLE.cut(result)
|
||||
selected,scrollPos=1,0
|
||||
waiting,lastSearch=0,false
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user