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(lib.mode[lib.configOL.mode].config.dierestart){
ui.exit=ui.create.control('退出联机',function(){
game.saveConfig('reconnect_info');
game.reload();
});
ui.exit=ui.create.control('退出联机',ui.click.exit);
}
}
@ -7175,22 +7172,7 @@
else{
this.roomempty=false;
var config=info[2];
var modetrans;
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]);
this.initOL(get.modetrans(config),info[1]);
if(config.gameStarted){
this.node.gaming.show();
}
@ -12086,6 +12068,9 @@
for(var i in config){
lib.configOL[i]=config[i];
}
if(ui.connectStartBar){
ui.connectStartBar.firstChild.innerHTML=get.modetrans(lib.configOL,true);
}
},config);
if(lib.configOL.mode=='identity'&&lib.configOL.identity_mode=='zhong'&&game.connectPlayers){
for(var i=0;i<game.connectPlayers.length;i++){
@ -12214,8 +12199,8 @@
lib.wsOL[id].onclose();
}
},
reloadroom:function(){
if(window.isNonameServer&&!_status.protectingroom){
reloadroom:function(forced){
if(window.isNonameServer&&(forced||!_status.protectingroom)){
game.reload();
}
},
@ -12225,6 +12210,9 @@
game.roomId=index;
lib.node={};
if(config&&mode&&window.isNonameServer){
if(mode=='auto'){
mode=lib.configOL.mode;
}
game.switchMode(mode,config);
}
else{
@ -12240,7 +12228,7 @@
lib.config.recentIP.remove(_status.ip);
lib.config.recentIP.unshift(_status.ip);
lib.config.recentIP.splice(5);
game.saveConfig('reconnect_info',[_status.ip]);
game.saveConfig('reconnect_info',[_status.ip,null]);
game.saveConfig('recentIP',lib.config.recentIP);
_status.connectMode=true;
@ -12269,10 +12257,11 @@
},true);
if(window.isNonameServer){
var cfg='pagecfg'+game.roomId;
var cfg='pagecfg'+lib.config.pageId;
if(lib.config[cfg]){
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;
setTimeout(function(){
_status.protectingroom=false;
@ -12285,6 +12274,9 @@
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()){
game.forceOver('noover',proceed);
@ -12326,7 +12318,7 @@
game.ip=ip;
game.servermode=servermode;
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.unshift(_status.ip);
lib.config.recentIP.splice(5);
@ -12340,7 +12332,12 @@
game.finishCards();
ui.create.roomInfo();
ui.create.chat();
if(game.servermode){
ui.create.connectPlayers(get.modetrans(config,true));
}
else{
ui.create.connectPlayers(ip);
}
ui.pause.hide();
ui.auto.hide();
game.clearConnect();
@ -12410,8 +12407,9 @@
game.roomId=state.roomId;
if(observe){
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;
lib.configOL=config;
lib.playerOL={};
@ -12567,10 +12565,7 @@
game.send('reinited');
_status.gameStarted=true;
if(!observe&&game.me&&game.me.isDead()){
ui.exit=ui.create.control('退出联机',function(){
game.saveConfig('reconnect_info');
game.reload();
});
ui.exit=ui.create.control('退出联机',ui.click.exit);
}
});
},
@ -15351,10 +15346,10 @@
}
}
if(!ui.exit){
ui.exit=ui.create.control('退出联机',function(){
game.saveConfig('reconnect_info');
game.reload();
});
ui.exit=ui.create.control('退出联机',ui.click.exit);
}
if(game.servermode){
ui.exit.firstChild.innerHTML='返回房间';
}
if(ui.tempnowuxie){
ui.tempnowuxie.close();
@ -15775,7 +15770,8 @@
game.addRecord(resultbool);
}
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();
}
},
@ -22399,6 +22395,16 @@
},
},
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){
if(show===false){
ui.shortcut.classList.add('hidden');
@ -24871,6 +24877,27 @@
},
};
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(){
var list=[];
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{
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{
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{
page.evaluate(function(){
game.pageId=3;
game.saveConfig('pageId',3);
});
}
});

View File

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

View File

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

View File

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