This commit is contained in:
libccy 2016-04-18 13:13:47 +08:00
parent 3ade3bab99
commit 68454bb5e4
5 changed files with 95 additions and 51 deletions

View File

@ -6766,10 +6766,7 @@
} }
if(game.online&&player==game.me&&!_status.over&&!game.controlOver&&!ui.exit){ if(game.online&&player==game.me&&!_status.over&&!game.controlOver&&!ui.exit){
if(lib.mode[lib.configOL.mode].config.dierestart){ if(lib.mode[lib.configOL.mode].config.dierestart){
ui.exit=ui.create.control('退出联机',function(){ ui.exit=ui.create.control('退出联机',ui.click.exit);
game.saveConfig('reconnect_info');
game.reload();
});
} }
} }
@ -7175,22 +7172,7 @@
else{ else{
this.roomempty=false; this.roomempty=false;
var config=info[2]; var config=info[2];
var modetrans; this.initOL(get.modetrans(config),info[1]);
if(config.mode=='versus'){
switch(config.versus_mode){
case '1v1':modetrans='单人对决';break;
case '2v2':modetrans='欢乐成双';break;
case '3v3':modetrans='血战到底';break;
case '4v4':modetrans='四人对决';break;
}
}
else if(config.mode=='identity'&&config.identity_mode=='zhong'){
modetrans='忠胆英杰';
}
else{
modetrans=get.cnNumber(parseInt(config.number))+'人'+get.translation(config.mode);
}
this.initOL(modetrans,info[1]);
if(config.gameStarted){ if(config.gameStarted){
this.node.gaming.show(); this.node.gaming.show();
} }
@ -12086,6 +12068,9 @@
for(var i in config){ for(var i in config){
lib.configOL[i]=config[i]; lib.configOL[i]=config[i];
} }
if(ui.connectStartBar){
ui.connectStartBar.firstChild.innerHTML=get.modetrans(lib.configOL,true);
}
},config); },config);
if(lib.configOL.mode=='identity'&&lib.configOL.identity_mode=='zhong'&&game.connectPlayers){ if(lib.configOL.mode=='identity'&&lib.configOL.identity_mode=='zhong'&&game.connectPlayers){
for(var i=0;i<game.connectPlayers.length;i++){ for(var i=0;i<game.connectPlayers.length;i++){
@ -12214,8 +12199,8 @@
lib.wsOL[id].onclose(); lib.wsOL[id].onclose();
} }
}, },
reloadroom:function(){ reloadroom:function(forced){
if(window.isNonameServer&&!_status.protectingroom){ if(window.isNonameServer&&(forced||!_status.protectingroom)){
game.reload(); game.reload();
} }
}, },
@ -12225,6 +12210,9 @@
game.roomId=index; game.roomId=index;
lib.node={}; lib.node={};
if(config&&mode&&window.isNonameServer){ if(config&&mode&&window.isNonameServer){
if(mode=='auto'){
mode=lib.configOL.mode;
}
game.switchMode(mode,config); game.switchMode(mode,config);
} }
else{ else{
@ -12240,7 +12228,7 @@
lib.config.recentIP.remove(_status.ip); lib.config.recentIP.remove(_status.ip);
lib.config.recentIP.unshift(_status.ip); lib.config.recentIP.unshift(_status.ip);
lib.config.recentIP.splice(5); lib.config.recentIP.splice(5);
game.saveConfig('reconnect_info',[_status.ip]); game.saveConfig('reconnect_info',[_status.ip,null]);
game.saveConfig('recentIP',lib.config.recentIP); game.saveConfig('recentIP',lib.config.recentIP);
_status.connectMode=true; _status.connectMode=true;
@ -12269,10 +12257,11 @@
},true); },true);
if(window.isNonameServer){ if(window.isNonameServer){
var cfg='pagecfg'+game.roomId; var cfg='pagecfg'+lib.config.pageId;
if(lib.config[cfg]){ if(lib.config[cfg]){
lib.configOL=lib.config[cfg][0]; lib.configOL=lib.config[cfg][0];
game.send('server','enter',lib.config[cfg][1],lib.config[cfg][2],lib.config[cfg][3]); game.send('server','server',lib.config[cfg].slice(1));
game.saveConfig(cfg);
_status.protectingroom=true; _status.protectingroom=true;
setTimeout(function(){ setTimeout(function(){
_status.protectingroom=false; _status.protectingroom=false;
@ -12285,6 +12274,9 @@
game.send('server','server'); game.send('server','server');
} }
} }
else if(typeof game.roomId=='number'){
game.send('server','enter',game.roomId,lib.config.connect_nickname,lib.config.connect_avatar);
}
} }
if(_status.event.getParent()){ if(_status.event.getParent()){
game.forceOver('noover',proceed); game.forceOver('noover',proceed);
@ -12326,7 +12318,7 @@
game.ip=ip; game.ip=ip;
game.servermode=servermode; game.servermode=servermode;
game.roomId=roomId; game.roomId=roomId;
game.saveConfig('reconnect_info',[_status.ip,id]); game.saveConfig('reconnect_info',[_status.ip,id,game.roomId]);
lib.config.recentIP.remove(_status.ip); lib.config.recentIP.remove(_status.ip);
lib.config.recentIP.unshift(_status.ip); lib.config.recentIP.unshift(_status.ip);
lib.config.recentIP.splice(5); lib.config.recentIP.splice(5);
@ -12340,7 +12332,12 @@
game.finishCards(); game.finishCards();
ui.create.roomInfo(); ui.create.roomInfo();
ui.create.chat(); ui.create.chat();
ui.create.connectPlayers(ip); if(game.servermode){
ui.create.connectPlayers(get.modetrans(config,true));
}
else{
ui.create.connectPlayers(ip);
}
ui.pause.hide(); ui.pause.hide();
ui.auto.hide(); ui.auto.hide();
game.clearConnect(); game.clearConnect();
@ -12410,8 +12407,9 @@
game.roomId=state.roomId; game.roomId=state.roomId;
if(observe){ if(observe){
game.onlineID=null; game.onlineID=null;
game.roomId=null;
} }
game.saveConfig('reconnect_info',[_status.ip,game.onlineID]); game.saveConfig('reconnect_info',[_status.ip,game.onlineID,game.roomId]);
_status.connectMode=true; _status.connectMode=true;
lib.configOL=config; lib.configOL=config;
lib.playerOL={}; lib.playerOL={};
@ -12567,10 +12565,7 @@
game.send('reinited'); game.send('reinited');
_status.gameStarted=true; _status.gameStarted=true;
if(!observe&&game.me&&game.me.isDead()){ if(!observe&&game.me&&game.me.isDead()){
ui.exit=ui.create.control('退出联机',function(){ ui.exit=ui.create.control('退出联机',ui.click.exit);
game.saveConfig('reconnect_info');
game.reload();
});
} }
}); });
}, },
@ -15351,10 +15346,10 @@
} }
} }
if(!ui.exit){ if(!ui.exit){
ui.exit=ui.create.control('退出联机',function(){ ui.exit=ui.create.control('退出联机',ui.click.exit);
game.saveConfig('reconnect_info'); }
game.reload(); if(game.servermode){
}); ui.exit.firstChild.innerHTML='返回房间';
} }
if(ui.tempnowuxie){ if(ui.tempnowuxie){
ui.tempnowuxie.close(); ui.tempnowuxie.close();
@ -15775,7 +15770,8 @@
game.addRecord(resultbool); game.addRecord(resultbool);
} }
if(window.isNonameServer){ if(window.isNonameServer){
game.saveConfig('pagecfg'+game.pageId,[lib.configOL,game.roomId,_status.onlinenickname,_status.onlineavatar]); lib.configOL.gameStarted=false;
game.saveConfig('pagecfg'+lib.config.pageId,[lib.configOL,game.roomId,_status.onlinenickname,_status.onlineavatar]);
game.reload(); game.reload();
} }
}, },
@ -22399,6 +22395,16 @@
}, },
}, },
click:{ click:{
exit:function(){
if(game.servermode&&lib.config.reconnect_info&&_status.over){
lib.config.reconnect_info[2]=game.roomId;
game.saveConfig('reconnect_info',lib.config.reconnect_info);
}
else{
game.saveConfig('reconnect_info');
}
game.reload();
},
shortcut:function(show){ shortcut:function(show){
if(show===false){ if(show===false){
ui.shortcut.classList.add('hidden'); ui.shortcut.classList.add('hidden');
@ -24871,6 +24877,27 @@
}, },
}; };
var get={ var get={
modetrans:function(config,server){
if(config.mode=='versus'){
switch(config.versus_mode){
case '1v1':return '单人对决';
case '2v2':return '欢乐成双';
case '3v3':return '血战到底';
case '4v4':return '四人对决';
}
}
else if(config.mode=='identity'&&config.identity_mode=='zhong'){
return '忠胆英杰';
}
else{
if(server){
return get.translation(config.mode)+'模式';
}
else{
return get.cnNumber(parseInt(config.number))+'人'+get.translation(config.mode);
}
}
},
charactersOL:function(){ charactersOL:function(){
var list=[]; var list=[];
for(var i=0;i<lib.configOL.characterPack.length;i++){ for(var i=0;i<lib.configOL.characterPack.length;i++){

View File

@ -6,7 +6,7 @@ page1.open('http://localhost/index.html?server=true', function(status) {
} }
else{ else{
page.evaluate(function(){ page.evaluate(function(){
game.pageId=1; game.saveConfig('pageId',1);
}); });
} }
}); });
@ -19,7 +19,7 @@ page2.open('http://localhost/index.html?server=true', function(status) {
} }
else{ else{
page.evaluate(function(){ page.evaluate(function(){
game.pageId=2; game.saveConfig('pageId',2);
}); });
} }
}); });
@ -32,7 +32,7 @@ page3.open('http://localhost/index.html?server=true', function(status) {
} }
else{ else{
page.evaluate(function(){ page.evaluate(function(){
game.pageId=3; game.saveConfig('pageId',3);
}); });
} }
}); });

View File

@ -40,17 +40,33 @@
this.avatar=avatar; this.avatar=avatar;
util.updaterooms(); util.updaterooms();
}, },
server:function(){ server:function(cfg){
for(var i=0;i<rooms.length;i++){ if(cfg){
if(!rooms[i].owner){ this.servermode=true;
rooms[i].owner=this; var room=rooms[cfg[0]];
rooms[i].servermode=true; if(!room||room.owner){
this.room=rooms[i]; this.sendl('reloadroom',true);
this.servermode=true; }
break; else{
room.owner=this;
this.room=room;
this.nickname=cfg[1];
this.avatar=cfg[2];
this.sendl('createroom',cfg[0],{},'auto')
} }
} }
util.updaterooms(); else{
for(var i=0;i<rooms.length;i++){
if(!rooms[i].owner){
rooms[i].owner=this;
rooms[i].servermode=true;
this.room=rooms[i];
this.servermode=true;
break;
}
}
util.updaterooms();
}
}, },
config:function(config){ config:function(config){
var room=this.room; var room=this.room;

View File

@ -1,6 +1,6 @@
window.noname_update={ window.noname_update={
version:'1.8.8', version:'1.8.8.0',
changeLog:[ changeLog:[
'联机改进' '联机大厅改进'
] ]
} }

View File

@ -115,6 +115,7 @@ mode.connect={
else if(lib.config.reconnect_info){ else if(lib.config.reconnect_info){
var info=lib.config.reconnect_info; var info=lib.config.reconnect_info;
game.onlineID=info[1]; game.onlineID=info[1];
game.roomId=info[2];
var n=5; var n=5;
var connect=function(){ var connect=function(){
game.connect(info[0],function(success){ game.connect(info[0],function(success){