联网推进37,修改ws消息分隔符,登录验证游戏版本,大改进房消息机制,准备开局系统初步
This commit is contained in:
1
main.lua
1
main.lua
@@ -25,6 +25,7 @@ NOGAME=false
|
||||
LOGIN=false
|
||||
EDITING=""
|
||||
WSCONN=false
|
||||
LATEST_VERSION=false
|
||||
FESTIVAL=
|
||||
os.date"%m"=="12"and math.abs(os.date"%d"-25)<4 and"Xmas"or
|
||||
os.date"%m"<"03"and math.abs(({--Spring festival dates, 1.2=2, 2.1=32, etc.
|
||||
|
||||
@@ -71,8 +71,7 @@ return{
|
||||
|
||||
getNoticeFail="Couldn't get announcements",
|
||||
getVersionFail="Unable to detect a new version",
|
||||
versionIsNew="You are now on the latest version.",
|
||||
versionIsOld="Version $1 is available now!",
|
||||
oldVersion="Version $1 is available now!",
|
||||
|
||||
httpCode="Http status code",
|
||||
jsonError="Json error",
|
||||
|
||||
@@ -73,8 +73,7 @@ return{
|
||||
|
||||
getNoticeFail="Echec de l'obtention de la notice",
|
||||
getVersionFail="Echec d'obtention de la dernière version",
|
||||
versionIsNew="Vous êtes sur la dernière version",
|
||||
versionIsOld="La version $1 est disponible !",
|
||||
oldVersion="La version $1 est disponible !",
|
||||
|
||||
-- httpCode="Http status code",
|
||||
jsonError="Erreur json",
|
||||
|
||||
@@ -71,8 +71,7 @@ return{
|
||||
|
||||
getNoticeFail="Não conseguiu ter anúncios",
|
||||
getVersionFail="Falha ao detectar uma versão nova",
|
||||
versionIsNew="Você esta na versão mais nova.",
|
||||
versionIsOld="Versão $1 esta disponível agora!",
|
||||
oldVersion="Versão $1 esta disponível agora!",
|
||||
|
||||
-- httpCode="Http status code",
|
||||
jsonError="Json error",
|
||||
|
||||
@@ -73,8 +73,7 @@ return{
|
||||
|
||||
getNoticeFail="Error al buscar novedades.",
|
||||
getVersionFail="Error al buscar nuevas versiones.",
|
||||
versionIsNew="Esta es la versión más reciente disponible.",
|
||||
versionIsOld="¡Está disponible la nueva versión $1!",
|
||||
oldVersion="¡Está disponible la nueva versión $1!",
|
||||
|
||||
-- httpCode="Http status code",
|
||||
-- jsonError="Json error",
|
||||
|
||||
@@ -72,8 +72,7 @@ return{
|
||||
|
||||
getNoticeFail="拉取公告失败",
|
||||
getVersionFail="检测新版本失败",
|
||||
versionIsNew="游戏已是最新版本",
|
||||
versionIsOld="最新版本$1可以下载了!",
|
||||
oldVersion="最新版本$1可以下载了!",
|
||||
|
||||
httpCode="Http码",
|
||||
jsonError="json错误",
|
||||
|
||||
@@ -370,6 +370,7 @@ function PLY.newRemotePlayer(id,mini,playerData)
|
||||
P.userName=playerData.name
|
||||
P.userID=playerData.id
|
||||
P.subID=playerData.sid
|
||||
P.ready=playerData.ready
|
||||
|
||||
loadRemoteEnv(P,playerData.conf or{})
|
||||
applyGameEnv(P)
|
||||
|
||||
@@ -13,9 +13,9 @@ local function tick_httpREQ_launch(task)
|
||||
if res.message=="OK"and response.code==200 then
|
||||
LOG.print(res.notice,360,COLOR.sky)
|
||||
if VERSION_CODE>=res.version_code then
|
||||
LOG.print(text.versionIsNew,360,COLOR.sky)
|
||||
LATEST_VERSION=true
|
||||
else
|
||||
LOG.print(string.gsub(text.versionIsOld,"$1",res.version_name),"warn")
|
||||
LOG.print(string.gsub(text.oldVersion,"$1",res.version_name),"warn")
|
||||
end
|
||||
else
|
||||
LOG.print(text.httpCode..response.code..": "..res.message,"warn")
|
||||
|
||||
@@ -135,7 +135,7 @@ scene.widgetList={
|
||||
else
|
||||
SCN.go("login")
|
||||
end
|
||||
end},
|
||||
end,hide=function()return not LATEST_VERSION end},
|
||||
WIDGET.newButton{name="qplay", x=590,y=220,w=200,h=140,color="lBlue", font=40,code=function()loadGame(STAT.lastPlay,true)end},
|
||||
WIDGET.newButton{name="setting",x=150,y=380,w=200,h=140,color="lOrange",font=40,code=goScene"setting_game"},
|
||||
WIDGET.newButton{name="stat", x=370,y=380,w=200,h=140,color="lGreen", font=40,code=goScene"stat"},
|
||||
|
||||
@@ -63,7 +63,7 @@ end
|
||||
|
||||
function scene.socketRead(mes)
|
||||
local cmd=mes:sub(1,1)
|
||||
local args=splitStr(mes:sub(2),":")
|
||||
local args=splitStr(mes:sub(2),";")
|
||||
if cmd=="J"or cmd=="L"then
|
||||
textBox:push{
|
||||
COLOR.lR,args[1],
|
||||
|
||||
@@ -50,7 +50,6 @@ function scene.sceneBack()
|
||||
end
|
||||
function scene.sceneInit()
|
||||
love.keyboard.setKeyRepeat(false)
|
||||
wsWrite("C"..dumpBasicConfig())
|
||||
TASK.new(TICK_wsRead)
|
||||
hideChatBox=true
|
||||
textBox:clear()
|
||||
@@ -134,11 +133,9 @@ function scene.keyDown(key)
|
||||
lastBackTime=TIME()
|
||||
LOG.print(text.sureQuit,COLOR.orange)
|
||||
end
|
||||
elseif key=="b"then
|
||||
wsWrite("B")
|
||||
elseif key=="\\"then
|
||||
switchChat()
|
||||
else
|
||||
elseif playing then
|
||||
if noKey then return end
|
||||
local k=keyMap.keyboard[key]
|
||||
if k and k>0 then
|
||||
@@ -146,6 +143,10 @@ function scene.keyDown(key)
|
||||
VK[k].isDown=true
|
||||
VK[k].pressTime=10
|
||||
end
|
||||
elseif key=="space"then
|
||||
if not PLAYERS[1].ready then
|
||||
wsWrite("R")
|
||||
end
|
||||
end
|
||||
end
|
||||
function scene.keyUp(key)
|
||||
@@ -187,7 +188,7 @@ end
|
||||
|
||||
function scene.socketRead(mes)
|
||||
local cmd=mes:sub(1,1)
|
||||
local args=splitStr(mes:sub(2),":")
|
||||
local args=splitStr(mes:sub(2),";")
|
||||
if cmd=="J"or cmd=="L"then
|
||||
textBox:push{
|
||||
COLOR.lR,args[1],
|
||||
@@ -195,13 +196,16 @@ function scene.socketRead(mes)
|
||||
COLOR.Y,text[cmd=="J"and"joinRoom"or"leaveRoom"]
|
||||
}
|
||||
if cmd=="J"then
|
||||
if tostring(USER.id)~=args[2]then
|
||||
wsWrite("C"..dumpBasicConfig())
|
||||
ins(playerData,{name=args[1],id=args[2],sid=tonumber(args[3])})
|
||||
resetGameData("qn",playerData)
|
||||
for i=1,#args do
|
||||
local L=splitStr(args[i],",")
|
||||
L={name=L[1],id=L[2],sid=tonumber(L[3]),conf=L[4],ready=L[5]=="1"}
|
||||
if tostring(USER.id)~=L[2]then
|
||||
ins(playerData,L)
|
||||
else
|
||||
ins(playerData,1,{name=args[1],id=args[2],sid=tonumber(args[3])})
|
||||
ins(playerData,1,L)
|
||||
end
|
||||
end
|
||||
resetGameData("qn",playerData)
|
||||
else
|
||||
for i=1,#playerData do
|
||||
if playerData[i].id==args[2]then
|
||||
@@ -243,13 +247,22 @@ function scene.socketRead(mes)
|
||||
resetGameData("qn",playerData)
|
||||
end
|
||||
elseif cmd=="S"then
|
||||
if args[1]~=tostring(USER.id)then
|
||||
if args[1]~=tostring(PLAYERS[1].sid)then
|
||||
for _,P in next,PLAYERS do
|
||||
if P.userID==args[1]then
|
||||
if P.subID==args[1]then
|
||||
pumpRecording(data.decode("string","base64",args[2]),P.stream)
|
||||
end
|
||||
end
|
||||
end
|
||||
elseif cmd=="R"then
|
||||
local L=PLAYERS.alive
|
||||
for i=1,#L do
|
||||
if L[i].subID==args[1]then
|
||||
L[i].ready=true
|
||||
SFX.play("reach",.6)
|
||||
break
|
||||
end
|
||||
end
|
||||
elseif cmd=="B"then
|
||||
if not playing then
|
||||
playing=true
|
||||
|
||||
@@ -32,7 +32,9 @@ scene.widgetList={
|
||||
WIDGET.newButton{name="chat", x=640, y=540,w=350,h=120,font=40,code=function()
|
||||
wsConnect(
|
||||
tick_goChatRoom,
|
||||
PATH.socket..PATH.onlineChat.."?email="..urlEncode(USER.email).."&access_token="..urlEncode(USER.access_token)
|
||||
PATH.socket..PATH.onlineChat..
|
||||
"?email="..urlEncode(USER.email)..
|
||||
"&token="..urlEncode(USER.access_token)
|
||||
)
|
||||
end},
|
||||
WIDGET.newButton{name="back", x=1140, y=640,w=170,h=80,font=40,code=backScene},
|
||||
|
||||
@@ -145,8 +145,9 @@ function scene.keyDown(k)
|
||||
task_enterRoom,
|
||||
PATH.socket..PATH.onlinePlay..
|
||||
"?email="..urlEncode(USER.email)..
|
||||
"&access_token="..urlEncode(USER.access_token)..
|
||||
"&id="..urlEncode(rooms[selected].id)
|
||||
"&token="..urlEncode(USER.access_token)..
|
||||
"&id="..urlEncode(rooms[selected].id)..
|
||||
"&conf="..urlEncode(dumpBasicConfig())
|
||||
-- "&password="..urlEncode(password),
|
||||
)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user