This commit is contained in:
libccy 2016-04-17 17:02:46 +08:00
parent af9fa6d3b8
commit 6445b51f21
4 changed files with 129 additions and 61 deletions

View File

@ -27,8 +27,9 @@
break;
}
}
if(window.location.href.indexOf('index.html?server')!=-1){
window.isNonameServer=true;
var index=window.location.href.indexOf('index.html?server=');
if(index!=-1){
window.isNonameServer=window.location.href.slice(index+18);
window.indexedDB=null;
}
}());
@ -11458,7 +11459,7 @@
if(lib.character[i][4]&&lib.character[i][4].contains('forbidai')) return true;
if(lib.config.forbidai.contains(i)) return true;
if(_status.connectMode){
if(lib.config['connect_'+lib.config.mode+'_banned'].contains(i)) return true;
if(lib.configOL.banned.contains(i)) return true;
var double_character=false;
if(lib.configOL.mode=='guozhan'){
double_character=true;
@ -12228,7 +12229,12 @@
},true);
if(window.isNonameServer){
game.send('server','server');
switch(window.isNonameServer){
case 'identity':lib.configOL.mode='identity';game.send('server','enter','auto','服务器','xunyu');break;
case 'guozhan':lib.configOL.mode='guozhan';game.send('server','enter','auto','服务器','yuanshao');break;
case 'versus':lib.configOL.mode='versus';lib.config.mode_config.versus.connect_versus_mode='2v2';game.send('server','enter','auto','服务器','diaochan');break;
default:game.send('server','server');
}
}
}
if(_status.event.getParent()){
@ -12243,13 +12249,14 @@
var list2=['re_caocao','liubei','sunquan','sp_zhangjiao','yuanshao','dongzhuo'];
var more_room=false;
for(var i=0;i<ui.rooms.length;i++){
if(list[i]&&i>=3){
if(list[i]&&list[i]!='server'&&i>=3){
more_room=true;
}
ui.rooms[i].initRoom(list[i],list2[i]);
}
if(!more_room){
if(list[0]&&list[1]&&list[2]){
if(list[0]&&list[1]&&list[2]&&
list[0]!='server'&&list[1]!='server'&&list[2]!='server'){
more_room=true;
}
}
@ -15709,7 +15716,7 @@
game.addRecord(resultbool);
}
if(window.isNonameServer){
setTimeout(game.reload,5000);
setTimeout(game.reload,7000);
}
},
loop:function(){
@ -16472,6 +16479,7 @@
if(_status.connectMode&&lib.mode[name].connect){
game.saveConfig('connect_mode',name);
game.clearConnect();
lib.configOL.mode=name;
if(configx){
for(var i in configx){
lib.configOL[i]=configx[i];
@ -16482,8 +16490,6 @@
if(i=='update') continue;
lib.configOL[i.slice(8)]=get.config(i);
}
}
lib.configOL.mode=name;
lib.configOL.characterPack=lib.connectCharacterPack.slice(0);
lib.configOL.cardPack=lib.connectCardPack.slice(0);
for(var i=0;i<lib.config.connect_characters.length;i++){
@ -16493,13 +16499,12 @@
lib.configOL.cardPack.remove(lib.config.connect_cards[i]);
}
lib.configOL.banned=lib.config['connect_'+name+'_banned'];
}
for(var i in lib.cardPackList){
if(lib.configOL.cardPack.contains(i)){
lib.card.list=lib.card.list.concat(lib.cardPackList[i]);
}
}
for(i=0;i<lib.card.list.length;i++){
if(lib.card.list[i][2]=='huosha'){
lib.card.list[i]=lib.card.list[i].slice(0);
@ -17885,11 +17890,23 @@
else if(_status.enteringroom){
lib.configOL.mode=active.mode;
if(_status.enteringroomserver){
game.saveConfig('connect_mode',lib.configOL.mode);
var config={};
for(var i in lib.mode[lib.configOL.mode].connect){
if(i=='update') continue;
config[i.slice(8)]=get.config(i,lib.configOL.mode);
}
config.characterPack=lib.connectCharacterPack.slice(0);
config.cardPack=lib.connectCardPack.slice(0);
for(var i=0;i<lib.config.connect_characters.length;i++){
config.characterPack.remove(lib.config.connect_characters[i]);
}
for(var i=0;i<lib.config.connect_cards.length;i++){
config.cardPack.remove(lib.config.connect_cards[i]);
}
config.banned=lib.config['connect_'+active.mode+'_banned'];
game.send('server','enter',_status.roomindex,lib.config.connect_nickname,lib.config.connect_avatar,config,active.mode);
}
else{

View File

@ -6,6 +6,15 @@
var clients={};
var messages={
enter:function(index,nickname,avatar,config,mode){
if(index=='auto'){
index=0;
this.servermode='auto';
for(var i=rooms.length-1;i>=0;i--){
if(!rooms[i].owner){
index=i;break;
}
}
}
this.nickname=nickname;
this.avatar=avatar;
var room=rooms[index];
@ -36,7 +45,7 @@
}
},
server:function(){
for(var i=0;i<rooms.length;i++){
for(var i=rooms.length-1;i>=0;i--){
if(!rooms[i].owner){
rooms[i].owner=this;
rooms[i].servermode=true;
@ -112,8 +121,10 @@
}
else if(rooms[i].owner&&rooms[i].config){
if(rooms[i]._num==0){
if(rooms[i].owner.servermode!='auto'||rooms[i].config.gameStarted){
rooms[i].owner.sendl('reloadroom');
}
}
roomlist[i]=[rooms[i].owner.nickname,rooms[i].owner.avatar,
rooms[i].config,rooms[i]._num];
}

View File

@ -176,11 +176,17 @@ mode.identity={
}
if(game.players.length==2){
game.showIdentity(true);
if(game.me.next.isOnline){
game.me.next.send(function(identity){
game.me.next.setIdentity(identity);
},game.me.identity);
var map={};
for(var i in lib.playerOL){
map[i]=lib.playerOL[i].identity;
}
game.broadcast(function(map){
for(var i in map){
lib.playerOL[i].identity=map[i];
lib.playerOL[i].setIdentity();
lib.playerOL[i].ai.shown=1;
}
},map);
}
else{
for(var i=0;i<game.players.length;i++){

View File

@ -1215,24 +1215,24 @@ mode.versus={
'sp_ganning','sp_zhangfei','sp_xiahoudun'].contains(name)){
return true;
}
if(lib.characterPack.refresh[name]){
if(lib.characterPack.refresh&&lib.characterPack.refresh[name]){
if(!lib.configOL.characterPack.contains('refresh')) return true;
return false;
}
if(lib.characterPack.standard[name]){
if(lib.characterPack.standard&&lib.characterPack.standard[name]){
if(!lib.configOL.characterPack.contains('standard')) return true;
if(lib.configOL.characterPack.contains('refresh')&&lib.characterPack.refresh['re_'+name]) return true;
return false;
}
if(lib.characterPack.shenhua[name]){
if(lib.characterPack.shenhua&&lib.characterPack.shenhua[name]){
if(!lib.configOL.characterPack.contains('shenhua')) return true;
return false;
}
if(lib.characterPack.sp[name]){
if(lib.characterPack.sp&&lib.characterPack.sp[name]){
if(!lib.configOL.characterPack.contains('sp')) return true;
return false;
}
if(lib.characterPack.yijiang[name]){
if(lib.characterPack.yijiang&&lib.characterPack.yijiang[name]){
if(!lib.configOL.characterPack.contains('yijiang')) return true;
return false;
}
@ -1367,7 +1367,10 @@ mode.versus={
}
game.players[i].node.identity.dataset.color=game.players[i].side+'zhu';
}
},game.me,Math.random()<0.5);
},game.players[0],Math.random()<0.5);
if(game.me.side==undefined){
game.me.side=game.players[0].side;
}
_status.onreconnect=[function(){
var players=game.players.concat(game.dead);
for(var i=0;i<players.length;i++){
@ -1475,7 +1478,7 @@ mode.versus={
}
game.players[i].node.identity.dataset.color=game.players[i].side+'zhu';
}
},game.me,Math.random()<0.5,Math.random()<0.5);
},game.players[0],Math.random()<0.5,Math.random()<0.5);
_status.onreconnect=[function(){
var players=game.players.concat(game.dead);
for(var i=0;i<players.length;i++){
@ -1529,10 +1532,10 @@ mode.versus={
list.remove('sunquan');
event.videoId=lib.status.videoId++;
if(Math.random()<0.5){
event.choosing=game.me;
event.choosing=game.players[0];
}
else{
event.choosing=game.me.next;
event.choosing=game.players[1];
}
var createDialog=function(list,id,list1,list2){
var dialog=ui.create.dialog('选择角色',[list,'character']);
@ -1560,8 +1563,8 @@ mode.versus={
}
};
game.broadcastAll(createDialog,list,event.videoId,event.choosing);
game.me.storage.versuslist=[];
game.me.next.storage.versuslist=[];
game.players[0].storage.versuslist=[];
game.players[1].storage.versuslist=[];
event.selected=[];
_status.firstChoose=event.choosing;
event.num=(parseInt(lib.configOL.replace_number)+1)*2;
@ -1626,11 +1629,11 @@ mode.versus={
_status.friendDied=[];
_status.enemyDied=[];
_status.friend=game.me.storage.versuslist;
_status.enemy=game.me.next.storage.versuslist;
_status.friend=game.players[0].storage.versuslist;
_status.enemy=game.players[1].storage.versuslist;
delete game.me.storage.versuslist;
delete game.me.next.storage.versuslist;
delete game.players[0].storage.versuslist;
delete game.players[1].versuslist;
_status.enemyCount=ui.create.system('杀敌: '+get.cnNumber(0,true),null,true);
_status.friendCount=ui.create.system('阵亡: '+get.cnNumber(0,true),null,true);
@ -1638,18 +1641,34 @@ mode.versus={
lib.setPopped(_status.friendCount,game.versusHoverFriend);
lib.setPopped(_status.enemyCount,game.versusHoverEnemy);
game.me.side=true;
game.players[0].side=true;
game.players[1].side=false;
var func=function(list1,list2,list3,list4,func1,func2,playerid){
if(game.me.playerid==playerid){
game.me.side=true;
game.me.next.side=false;
var func=function(list1,list2,list3,list4,func1,func2){
}
else{
game.me.side=false;
game.me.nextSeat.side=true;
game.me.next.side=true;
}
if(game.me.side){
_status.enemyDied=list1;
_status.friendDied=list2;
_status.enemy=list3;
_status.friend=list4;
}
else{
_status.friendDied=list1;
_status.enemyDied=list2;
_status.friend=list3;
_status.enemy=list4;
}
_status.enemyCount=ui.create.system('杀敌: '+get.cnNumber(_status.enemyDied.length,true),null,true);
_status.friendCount=ui.create.system('阵亡: '+get.cnNumber(_status.friendDied.length,true),null,true);
@ -1658,33 +1677,48 @@ mode.versus={
lib.setPopped(_status.enemyCount,func2);
};
_status.onreconnect=[func,_status.enemyDied,_status.friendDied,
_status.enemy,_status.friend,game.versusHoverFriend,game.versusHoverEnemy];
game.me.next.send.apply(game.me.next,_status.onreconnect);
_status.enemy,_status.friend,game.versusHoverFriend,game.versusHoverEnemy,game.players[0].playerid];
game.broadcast(func,_status.enemyDied,_status.friendDied,
_status.enemy,_status.friend,game.versusHoverFriend,game.versusHoverEnemy,game.players[0].playerid);
var list=[[game.me,['选择出场角色',[_status.friend,'character']]],[game.me.next,['选择出场角色',[_status.enemy,'character']]]];
var list=[[game.players[0],['选择出场角色',[_status.friend,'character']]],[game.players[1],['选择出场角色',[_status.enemy,'character']]]];
game.me.chooseButtonOL(list,function(player,result){
if(game.online||player==game.me) player.init(result.links[0]);
});
'step 5'
var result1=result[game.me.playerid].links[0];
var result1;
var friend=result[game.players[0].playerid];
if(friend&&friend.links&&friend.links.length){
result1=friend.links[0];
}
else{
result1=_status.friend.randomGet();
}
var result2;
var enemy=result[game.me.next.playerid];
var enemy=result[game.players[1].playerid];
if(enemy&&enemy.links&&enemy.links.length){
result2=enemy.links[0];
}
else{
result2=_status.enemy.randomGet();
}
game.me.next.init(result2);
_status.enemy.remove(result2);
if(!game.players[0].name) game.players[0].init(result1);
if(!game.players[1].name) game.players[1].init(result2);
_status.friend.remove(result1);
game.me.next.send(function(result1,result2){
if(!game.me.name){
game.me.init(result2);
_status.enemy.remove(result2);
game.broadcast(function(result1,result2){
if(game.me.side){
if(!game.me.name) game.me.init(result1);
if(!game.me.next.name) game.me.next.init(result2);
_status.friend.remove(result1);
_status.enemy.remove(result2);
}
game.me.next.init(result1);
else{
if(!game.me.name) game.me.init(result2);
if(!game.me.next.name) game.me.next.init(result1);
_status.friend.remove(result2);
_status.enemy.remove(result1);
}
},result1,result2);
}
},