整理代码,修复房间里的各就各位/预备标记显示时机问题

This commit is contained in:
MrZ626
2021-05-09 02:26:03 +08:00
parent b4be31361e
commit 46b3ad8a70
3 changed files with 16 additions and 15 deletions

View File

@@ -16,8 +16,8 @@ local NET={
capacity=false,
},
allReady=false,
streamRoomID=false,
connectingStream=false,
streamRoomID=false,
serverGaming=false,
}
@@ -389,12 +389,11 @@ function NET.updateWS_play()
ready=d.ready,
config=d.config,
}
if SCN.socketRead then SCN.socketRead('Join',d)end
if SCN.socketRead then SCN.socketRead('join',d)end
NET.allReady=false
end
elseif res.action==3 then--Player leave
if not d.uid then
NET.allReady=false
NET.wsclose_stream()
NET.unlock('quit')
SCN.back()
@@ -412,10 +411,10 @@ function NET.updateWS_play()
break
end
end
if SCN.socketRead then SCN.socketRead('Leave',d)end
if SCN.socketRead then SCN.socketRead('leave',d)end
end
elseif res.action==4 then--Player talk
if SCN.socketRead then SCN.socketRead('Talk',d)end
if SCN.socketRead then SCN.socketRead('talk',d)end
elseif res.action==5 then--Player change settings
netPLY.setConf(d.uid,d.config)
elseif res.action==6 then--One ready
@@ -425,12 +424,12 @@ function NET.updateWS_play()
NET.allReady=true
elseif res.action==8 then--Set
NET.streamRoomID=d.rid
NET.allReady=false
NET.connectingStream=true
NET.wsconn_stream()
elseif res.action==9 then--Game finished
NET.allReady=false
NET.wsclose_stream()
if SCN.socketRead then SCN.socketRead('Finish',d)end
if SCN.socketRead then SCN.socketRead('finish',d)end
end
else
WS.alert('play')
@@ -460,7 +459,7 @@ function NET.updateWS_stream()
NET.unlock('wsc_stream')
elseif res.action==0 then--Game start
NET.connectingStream=false
SCN.socketRead('Go',d)
SCN.socketRead('go',d)
elseif res.action==1 then--Game finished
--?
elseif res.action==2 then--Player join
@@ -475,7 +474,7 @@ function NET.updateWS_stream()
end
end
elseif res.action==5 then--Receive stream
SCN.socketRead('Stream',d)
SCN.socketRead('stream',d)
end
else
WS.alert('stream')

View File

@@ -136,26 +136,26 @@ function scene.gamepadUp(key)
end
function scene.socketRead(cmd,d)
if cmd=="Join"then
if cmd=='join'then
textBox:push{
COLOR.lR,d.username,
COLOR.dY,"#"..d.uid.." ",
COLOR.Y,text.joinRoom,
}
SFX.play('click')
elseif cmd=="Leave"then
elseif cmd=='leave'then
textBox:push{
COLOR.lR,d.username,
COLOR.dY,"#"..d.uid.." ",
COLOR.Y,text.leaveRoom,
}
elseif cmd=="Talk"then
elseif cmd=='talk'then
textBox:push{
COLOR.Z,d.username,
COLOR.dY,"#"..d.uid.." ",
COLOR.N,d.message or"[_]",
}
elseif cmd=="Go"then
elseif cmd=='go'then
if not playing then
playing=true
netPLY.resetReady()
@@ -166,7 +166,7 @@ function scene.socketRead(cmd,d)
else
LOG.print("Redundant [Go]",30,COLOR.G)
end
elseif cmd=="Finish"then
elseif cmd=='finish'then
playing=false
local winnerUID
for _,p in next,d.result do
@@ -178,7 +178,7 @@ function scene.socketRead(cmd,d)
if winnerUID then
TEXT.show(text.champion:gsub("$1",netPLY.getUsername(winnerUID)),640,260,80,'zoomout',.26)
end
elseif cmd=="Stream"then
elseif cmd=='stream'then
if d.uid~=USER.uid and playing then
for _,P in next,PLAYERS do
if P.uid==d.uid then

View File

@@ -17,6 +17,8 @@ local scene={}
function scene.sceneInit()
BG.set()
NET.allReady=false
NET.connectingStream=false
scrollPos=0
selected=1
fetchRoom()