更新开房api,为未来加入新功能做准备
This commit is contained in:
@@ -201,17 +201,18 @@ function NET.fetchRoom()
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function NET.createRoom(roomType,roomName,password)
|
function NET.createRoom(roomName,capacity,roomType,password)
|
||||||
if NET.lock('enterRoom',1.26)then
|
if NET.lock('enterRoom',1.26)then
|
||||||
NET.roomInfo.name=roomName or"?"
|
NET.roomInfo.name=roomName
|
||||||
NET.roomInfo.type=roomType or"?"
|
NET.roomInfo.type=roomType
|
||||||
NET.roomInfo.private=not not password
|
NET.roomInfo.private=not not password
|
||||||
NET.roomInfo.capacity="?"
|
NET.roomInfo.capacity=capacity
|
||||||
WS.send('play',JSON.encode{
|
WS.send('play',JSON.encode{
|
||||||
action=1,
|
action=1,
|
||||||
data={
|
data={
|
||||||
type=roomType,
|
|
||||||
name=roomName,
|
name=roomName,
|
||||||
|
capacity=capacity,
|
||||||
|
roomData={type=roomType},
|
||||||
password=password,
|
password=password,
|
||||||
config=dumpBasicConfig(),
|
config=dumpBasicConfig(),
|
||||||
}
|
}
|
||||||
@@ -221,10 +222,10 @@ end
|
|||||||
function NET.enterRoom(room,password)
|
function NET.enterRoom(room,password)
|
||||||
if NET.lock('enterRoom',1.26)then
|
if NET.lock('enterRoom',1.26)then
|
||||||
SFX.play('reach',.6)
|
SFX.play('reach',.6)
|
||||||
NET.roomInfo.name=room.name or"?"
|
NET.roomInfo.name=room.name
|
||||||
NET.roomInfo.type=room.type or"?"
|
NET.roomInfo.type=room.type
|
||||||
NET.roomInfo.private=not not password
|
NET.roomInfo.private=not not password
|
||||||
NET.roomInfo.capacity=room.capacity or"?"
|
NET.roomInfo.capacity=room.capacity
|
||||||
NET.roomInfo.start=room.start
|
NET.roomInfo.start=room.start
|
||||||
WS.send('play',JSON.encode{
|
WS.send('play',JSON.encode{
|
||||||
action=2,
|
action=2,
|
||||||
@@ -410,6 +411,7 @@ function NET.updateWS_play()
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
--TODO: d.roomData (json)
|
||||||
loadGame('netBattle',true,true)
|
loadGame('netBattle',true,true)
|
||||||
else
|
else
|
||||||
--Load other players
|
--Load other players
|
||||||
|
|||||||
@@ -36,14 +36,23 @@ function scene.keyDown(k)
|
|||||||
SCN.go('setting_game')
|
SCN.go('setting_game')
|
||||||
elseif k=="m"or k=="n"then
|
elseif k=="m"or k=="n"then
|
||||||
if TIME()-lastCreateRoomTime>6.26 then
|
if TIME()-lastCreateRoomTime>6.26 then
|
||||||
|
local cap,roomType
|
||||||
|
if k=="n"then
|
||||||
|
cap,roomType=2,"solo"
|
||||||
|
elseif kb.isDown("q")and tonumber(USER.uid)<100 then
|
||||||
|
cap,roomType=17,"big"
|
||||||
|
elseif kb.isDown("w")and tonumber(USER.uid)<100 then
|
||||||
|
cap,roomType=31,"huge"
|
||||||
|
elseif kb.isDown("e")and tonumber(USER.uid)<100 then
|
||||||
|
cap,roomType=49,"T49"
|
||||||
|
elseif kb.isDown("r")and tonumber(USER.uid)<100 then
|
||||||
|
cap,roomType=99,"T99"
|
||||||
|
else
|
||||||
|
cap,roomType=5,"normal"
|
||||||
|
end
|
||||||
NET.createRoom(
|
NET.createRoom(
|
||||||
k=="m"and"classic"or
|
(USERS.getUsername(USER.uid)or"???").."'s room",
|
||||||
tonumber(USER.uid)<100 and(
|
cap,roomType
|
||||||
kb.isDown"q"and"r49"or
|
|
||||||
kb.isDown"w"and"r99"or
|
|
||||||
kb.isDown"e"and"unlimited"
|
|
||||||
)or"solo",
|
|
||||||
(USERS.getUsername(USER.uid)or"???").."'s room"
|
|
||||||
)
|
)
|
||||||
lastCreateRoomTime=TIME()
|
lastCreateRoomTime=TIME()
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user