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