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

View File

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

View File

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