更新开房api,为未来加入新功能做准备

This commit is contained in:
MrZ626
2021-05-14 00:10:32 +08:00
parent 45948b9d94
commit e674457e6f
2 changed files with 26 additions and 15 deletions

View File

@@ -201,17 +201,18 @@ function NET.fetchRoom()
})
end
end
function NET.createRoom(roomType,roomName,password)
function NET.createRoom(roomName,capacity,roomType,password)
if NET.lock('enterRoom',1.26)then
NET.roomInfo.name=roomName or"?"
NET.roomInfo.type=roomType or"?"
NET.roomInfo.name=roomName
NET.roomInfo.type=roomType
NET.roomInfo.private=not not password
NET.roomInfo.capacity="?"
NET.roomInfo.capacity=capacity
WS.send('play',JSON.encode{
action=1,
data={
type=roomType,
name=roomName,
capacity=capacity,
roomData={type=roomType},
password=password,
config=dumpBasicConfig(),
}
@@ -221,10 +222,10 @@ end
function NET.enterRoom(room,password)
if NET.lock('enterRoom',1.26)then
SFX.play('reach',.6)
NET.roomInfo.name=room.name or"?"
NET.roomInfo.type=room.type or"?"
NET.roomInfo.name=room.name
NET.roomInfo.type=room.type
NET.roomInfo.private=not not password
NET.roomInfo.capacity=room.capacity or"?"
NET.roomInfo.capacity=room.capacity
NET.roomInfo.start=room.start
WS.send('play',JSON.encode{
action=2,
@@ -410,6 +411,7 @@ function NET.updateWS_play()
}
end
end
--TODO: d.roomData (json)
loadGame('netBattle',true,true)
else
--Load other players

View File

@@ -36,14 +36,23 @@ function scene.keyDown(k)
SCN.go('setting_game')
elseif k=="m"or k=="n"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(
k=="m"and"classic"or
tonumber(USER.uid)<100 and(
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"
(USERS.getUsername(USER.uid)or"???").."'s room",
cap,roomType
)
lastCreateRoomTime=TIME()
else