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