This commit is contained in:
libccy 2016-04-16 13:10:01 +08:00
parent 8dedb48715
commit 4db1eab700
7 changed files with 493 additions and 140 deletions

View File

@ -107,7 +107,10 @@ card.mingzhong={
useful:4, useful:4,
value:10, value:10,
result:{ result:{
target:1 target:function(player,target){
if(target.num('j','lebu')) return 0;
return Math.max(1,2-target.num('h')/10);
}
} }
} }
}, },

View File

@ -102,7 +102,9 @@ character.refresh={
player.chooseTarget('是否发动突袭?',[1,2],function(card,player,target){ player.chooseTarget('是否发动突袭?',[1,2],function(card,player,target){
return target.num('h')>0&&player!=target&&target.num('h')>=player.num('h'); return target.num('h')>0&&player!=target&&target.num('h')>=player.num('h');
},function(target){ },function(target){
return (1-ai.get.attitude(_status.event.player,target)); var att=ai.get.attitude(_status.event.player,target);
if(target.skills.contains('tuntian')) return att/10;
return 1-att;
}); });
"step 1" "step 1"
if(result.bool){ if(result.bool){

View File

@ -1506,7 +1506,15 @@ character.shenhua={
player.addSkill('haoshi2'); player.addSkill('haoshi2');
}, },
ai:{ ai:{
threaten:2 threaten:2,
ai:{
noh:true,
skillTagFilter:function(player,tag){
if(tag=='noh'){
if(player.num('h')!=2) return false;
}
}
}
} }
}, },
haoshi2:{ haoshi2:{

View File

@ -254,7 +254,9 @@ character.standard={
return target.num('h')>0&&player!=target; return target.num('h')>0&&player!=target;
},function(target){ },function(target){
if(!_status.event.aicheck) return 0; if(!_status.event.aicheck) return 0;
return (1-ai.get.attitude(_status.event.player,target)); var att=ai.get.attitude(_status.event.player,target);
if(target.skills.contains('tuntian')) return att/10;
return 1-att;
}).set('aicheck',check); }).set('aicheck',check);
"step 1" "step 1"
if(result.bool){ if(result.bool){
@ -898,7 +900,15 @@ character.standard={
} }
} }
}, },
group:'kongcheng1' group:'kongcheng1',
ai:{
noh:true,
skillTagFilter:function(player,tag){
if(tag=='noh'){
if(player.num('h')!=1) return false;
}
}
}
}, },
kongcheng1:{ kongcheng1:{
audio:2, audio:2,

View File

@ -2261,6 +2261,12 @@
map.connect_choice_num.hide(); map.connect_choice_num.hide();
map.connect_replace_number.hide(); map.connect_replace_number.hide();
} }
if(config.connect_versus_mode=='2v2'||config.connect_versus_mode=='3v3'){
map.connect_replace_handcard.show();
}
else{
map.connect_replace_handcard.hide();
}
}, },
connect_versus_mode:{ connect_versus_mode:{
name:'游戏模式', name:'游戏模式',
@ -2268,10 +2274,16 @@
item:{ item:{
'1v1':'1v1', '1v1':'1v1',
'2v2':'2v2', '2v2':'2v2',
// '4v4':'4v4', '3v3':'3v3',
'4v4':'4v4',
}, },
frequent:true frequent:true
}, },
connect_replace_handcard:{
name:'末位可换牌',
init:true,
frequent:true,
},
connect_choice_num:{ connect_choice_num:{
name:'侯选武将数', name:'侯选武将数',
init:'20', init:'20',
@ -5115,12 +5127,14 @@
}, },
chooseButtonOL:function(){ chooseButtonOL:function(){
'step 0' 'step 0'
ui.arena.classList.add('markhidden');
for(var i=0;i<event.list.length;i++){ for(var i=0;i<event.list.length;i++){
var current=event.list[i]; var current=event.list[i];
current[0].wait(); current[0].wait();
if(current[0].isOnline()){ if(current[0].isOnline()){
var target=current.shift(); var target=current.shift();
target.send(function(args,callback,switchToAuto,processAI){ target.send(function(args,callback,switchToAuto,processAI){
ui.arena.classList.add('markhidden');
var next=game.me.chooseButton.apply(game.me,args); var next=game.me.chooseButton.apply(game.me,args);
next.callback=callback; next.callback=callback;
next.switchToAuto=switchToAuto; next.switchToAuto=switchToAuto;
@ -5168,6 +5182,9 @@
game.pause(); game.pause();
} }
'step 6' 'step 6'
game.broadcastAll(function(){
ui.arena.classList.remove('markhidden');
});
event.result=event.resultOL; event.result=event.resultOL;
}, },
chooseCard:function(){ chooseCard:function(){
@ -11195,6 +11212,20 @@
} }
}, },
control:{ control:{
open:function(){
ui.control.insertBefore(this,_status.createControl||ui.confirm);
ui.controls.unshift(this);
if(this.childNodes.length){
this.style.transition='opacity 0.5s';
ui.refresh(this);
this.style.transform='translateX(-'+(control.offsetWidth/2)+'px)';
this.style.opacity=1;
ui.refresh(this);
this.style.transition='';
}
ui.updatec();
return this;
},
add:function(item){ add:function(item){
var node=document.createElement('div'); var node=document.createElement('div');
this.appendChild(node); this.appendChild(node);
@ -12296,6 +12327,7 @@
} }
} }
ui.arena.dataset.number=state.number; ui.arena.dataset.number=state.number;
_status.mode=state.mode;
var pos=state.players[observe||game.onlineID].position; var pos=state.players[observe||game.onlineID].position;
for(var i in state.players){ for(var i in state.players){
var info=state.players[i]; var info=state.players[i];
@ -12505,12 +12537,73 @@
var game={ var game={
online:false, online:false,
onlineID:null, onlineID:null,
replaceHandcards:function(){
var next=game.createEvent('replaceHandcards');
if(Array.isArray(arguments[0])){
next.players=arguments[0];
}
else{
next.players=[];
for(var i=0;i<arguments.length;i++){
if(get.itemtype(arguments[i])=='player'){
next.players.push(arguments[i]);
}
}
}
next.content=function(){
'step 0'
var send=function(){
game.me.chooseBool('是否置换手牌?');
game.resume();
};
var sendback=function(result,player){
if(result&&result.bool){
var hs=player.get('h')
game.broadcastAll(function(player,hs){
for(var i=0;i<hs.length;i++){
ui.discardPile.appendChild(hs[i]);
}
},player,hs);
player.directgain(get.cards(hs.length));
}
};
for(var i=0;i<event.players.length;i++){
if(event.players[i].isOnline()){
event.withol=true;
event.players[i].send(send);
event.players[i].wait(sendback);
}
else if(event.players[i]==game.me){
event.withme=true;
game.me.chooseBool('是否置换手牌?');
game.me.wait(sendback);
}
}
'step 1'
if(event.withme){
game.me.unwait(result);
}
'step 2'
if(event.withol&&!event.resultOL){
game.pause();
}
}
},
removeCard:function(name){ removeCard:function(name){
for(var i=0;i<lib.card.list.length;i++){ for(var i=0;i<lib.card.list.length;i++){
if(lib.card.list[i][2]==name){ if(lib.card.list[i][2]==name){
lib.card.list.splice(i--,1); lib.card.list.splice(i--,1);
} }
} }
var list=[];
for(var i=0;i<ui.cardPile.childElementCount;i++){
if(ui.cardPile.childNodes[i].name==name){
list.push(ui.cardPile.childNodes[i]);
}
}
for(var i=0;i<list.length;i++){
list[i].remove();
}
}, },
randomMapOL:function(type){ randomMapOL:function(type){
if(type=='hidden'){ if(type=='hidden'){
@ -20739,11 +20832,14 @@
return ui.create.characterDialog.apply(this,args); return ui.create.characterDialog.apply(this,args);
}, },
characterDialog:function(){ characterDialog:function(){
var filter,str,noclick,thisiscard,seperate; var filter,str,noclick,thisiscard,seperate,expandall;
for(var i=0;i<arguments.length;i++){ for(var i=0;i<arguments.length;i++){
if(arguments[i]==='thisiscard'){ if(arguments[i]==='thisiscard'){
thisiscard=true; thisiscard=true;
} }
else if(arguments[i]==='expandall'){
expandall=true;
}
else if(typeof arguments[i]=='object'&&typeof arguments[i].seperate=='function'){ else if(typeof arguments[i]=='object'&&typeof arguments[i].seperate=='function'){
seperate=arguments[i].seperate; seperate=arguments[i].seperate;
} }
@ -20981,10 +21077,11 @@
dialog.buttons[i].capt=getCapt(dialog.buttons[i].link); dialog.buttons[i].capt=getCapt(dialog.buttons[i].link);
} }
} }
if(!expandall){
if(!thisiscard&&(lib.characterDialogGroup[lib.config.character_dialog_tool]|| if(!thisiscard&&(lib.characterDialogGroup[lib.config.character_dialog_tool]||
lib.config.character_dialog_tool=='自创')){ lib.config.character_dialog_tool=='自创')){
clickCapt.call(node[lib.config.character_dialog_tool]); clickCapt.call(node[lib.config.character_dialog_tool]);
}
} }
return dialog; return dialog;
}, },
@ -24564,6 +24661,7 @@
var state={ var state={
number:ui.arena.dataset.number, number:ui.arena.dataset.number,
players:{}, players:{},
mode:_status.mode
}; };
for(var i in lib.playerOL){ for(var i in lib.playerOL){
state.players[i]=lib.playerOL[i].getState(); state.players[i]=lib.playerOL[i].getState();
@ -24644,21 +24742,21 @@
} }
return num/list.length; return num/list.length;
}, },
rank:function(name){ rank:function(name,num){
if(name==_status.lord) return 'ap'; if(name==_status.lord) return num?8:'ap';
var rank=lib.rank; var rank=lib.rank;
if(rank.s.contains(name)) return 's'; if(rank.s.contains(name)) return num?9:'s';
if(rank.ap.contains(name)) return 'ap'; if(rank.ap.contains(name)) return num?8:'ap';
if(rank.a.contains(name)) return 'a'; if(rank.a.contains(name)) return num?7:'a';
if(rank.am.contains(name)) return 'am'; if(rank.am.contains(name)) return num?6:'am';
if(rank.bp.contains(name)) return 'bp'; if(rank.bp.contains(name)) return num?5:'bp';
if(rank.b.contains(name)) return 'b'; if(rank.b.contains(name)) return num?4:'b';
if(rank.bm.contains(name)) return 'bm'; if(rank.bm.contains(name)) return num?3:'bm';
if(rank.c.contains(name)) return 'c'; if(rank.c.contains(name)) return num?2:'c';
if(rank.d.contains(name)) return 'd'; if(rank.d.contains(name)) return num?1:'d';
if(lib.customCharacters.contains(name)) return 's'; if(lib.customCharacters.contains(name)) return num?9:'s';
if(lib.characterPack.boss&&lib.characterPack.boss[name]) return 'sp'; if(lib.characterPack.boss&&lib.characterPack.boss[name]) return num?10:'sp';
return 'x'; return num?1:'x';
}, },
cardInfo:function(card){ cardInfo:function(card){
return [card.suit,card.number,card.name,card.nature]; return [card.suit,card.number,card.name,card.nature];

View File

@ -188,8 +188,10 @@ table{table-layout: fixed;}
} }
#arena.playerhidden>.player, #arena.playerhidden>.player,
#arena.playerhidden>#mebg{ #arena.playerhidden>#mebg,
#arena.markhidden>.player>.marks{
visibility: hidden; visibility: hidden;
opacity: 0;
} }
#arena.chess>#arenalog{ #arena.chess>#arenalog{
display: none !important; display: none !important;

View File

@ -152,12 +152,28 @@ mode.versus={
game.gameDraw(_status.firstChoose.next); game.gameDraw(_status.firstChoose.next);
game.phaseLoop(_status.firstChoose.next); game.phaseLoop(_status.firstChoose.next);
} }
else if(_status.mode='2v2'){ else if(_status.mode=='2v2'||_status.mode=='3v3'){
_status.first_less=true; _status.first_less=true;
var firstChoose=game.players.randomGet(); var firstChoose=game.players.randomGet();
if(firstChoose.next.side==firstChoose.side){
firstChoose=firstChoose.next;
}
game.gameDraw(firstChoose); game.gameDraw(firstChoose);
if(lib.configOL.replace_handcard){
game.replaceHandcards(firstChoose.previous);
}
game.phaseLoop(firstChoose); game.phaseLoop(firstChoose);
} }
else if(_status.mode=='4v4'){
game.gameDraw(_status.firstAct,function(player){
if(player==_status.firstAct.previousSeat){
return 5;
}
return 4;
});
game.replaceHandcards(_status.firstAct.previous,_status.firstAct.previous.previous);
game.phaseLoop(_status.firstAct);
}
event.finish(); event.finish();
} }
else{ else{
@ -286,6 +302,9 @@ mode.versus={
uiintro.add('<div class="text chat">侯选人数:'+lib.configOL.choice_num+'人'); uiintro.add('<div class="text chat">侯选人数:'+lib.configOL.choice_num+'人');
uiintro.add('<div class="text chat">替补人数:'+lib.configOL.replace_number+'人'); uiintro.add('<div class="text chat">替补人数:'+lib.configOL.replace_number+'人');
} }
else if(lib.configOL.versus_mode=='2v2'||lib.configOL.versus_mode=='3v3'){
uiintro.add('<div class="text chat">四号位换牌:'+(lib.configOL.replace_handcard?'开启':'关闭'));
}
uiintro.add('<div class="text chat">出牌时限:'+lib.configOL.choose_timeout+'秒'); uiintro.add('<div class="text chat">出牌时限:'+lib.configOL.choose_timeout+'秒');
uiintro.add('<div class="text chat">屏蔽弱将:'+(lib.configOL.ban_weak?'开启':'关闭')); uiintro.add('<div class="text chat">屏蔽弱将:'+(lib.configOL.ban_weak?'开启':'关闭'));
uiintro.add('<div class="text chat">屏蔽强将:'+(lib.configOL.ban_strong?'开启':'关闭')).style.paddingBottom='8px'; uiintro.add('<div class="text chat">屏蔽强将:'+(lib.configOL.ban_strong?'开启':'关闭')).style.paddingBottom='8px';
@ -568,7 +587,7 @@ mode.versus={
event.flipassign=true; event.flipassign=true;
"step 1" "step 1"
if(event.current==game.me||(event.four_assign&&event.current.side==game.me.side)){ if(event.current==game.me||(event.four_assign&&event.current.side==game.me.side)){
var dialog=event.xdialog||ui.create.characterDialog(event.filterChoice); var dialog=event.xdialog||ui.create.characterDialog(event.filterChoice,'expandall');
var names=[]; var names=[];
for(var i=0;i<game.players.length;i++){ for(var i=0;i<game.players.length;i++){
if(game.players[i].name){ if(game.players[i].name){
@ -1170,8 +1189,23 @@ mode.versus={
var next=game.createEvent('chooseCharacter',false); var next=game.createEvent('chooseCharacter',false);
next.content=function(){ next.content=function(){
"step 0" "step 0"
var list= var list=['zhu','zhong','zhong','zhong','ezhu','ezhong','ezhong','ezhong'];
event.filterChoice=function(name){ list.randomSort();
var side=Math.random()<0.5;
var map={};
for(var i=0;i<8;i++){
if(list[i][0]=='e'){
game.players[i].side=side;
game.players[i].identity=list[i].slice(1);
}
else{
game.players[i].side=!side;
game.players[i].identity=list[i];
}
map[game.players[i].playerid]=[game.players[i].side,game.players[i].identity];
}
var filterChoice=function(name){
if(name=='zuoci') return true;
if(['yuanshu','re_yuanshu','zhangxingcai','hetaiyou','wenpin','yuji', if(['yuanshu','re_yuanshu','zhangxingcai','hetaiyou','wenpin','yuji',
'xunyu','lusu','guanping','zhangzong','zhoutai','sp_zhangjiao','zhangjiao', 'xunyu','lusu','guanping','zhangzong','zhoutai','sp_zhangjiao','zhangjiao',
'shixie','zhanglu','chenlin','mayunlu','yangxiu','zhugeke','chengyu', 'shixie','zhanglu','chenlin','mayunlu','yangxiu','zhugeke','chengyu',
@ -1181,65 +1215,94 @@ 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]) return false; if(lib.characterPack.refresh[name]){
if(lib.characterPack.standard[name]){ if(!lib.configOL.characterPack.contains('refresh')) return true;
if(lib.characterPack.refresh['re_'+name]) return true; return false;
}
if(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.configOL.characterPack.contains('shenhua')) return true;
return false;
}
if(lib.characterPack.sp[name]){
if(!lib.configOL.characterPack.contains('sp')) return true;
return false;
}
if(lib.characterPack.yijiang[name]){
if(!lib.configOL.characterPack.contains('yijiang')) return true;
return false; return false;
} }
if(lib.characterPack.shenhua[name]) return false;
if(lib.characterPack.sp[name]) return false;
if(lib.characterPack.yijiang[name]) return false;
return true; return true;
} }
event.list.randomSort();
event.list2=list2;
event.current=game.players.randomGet(); event.current=game.players.randomGet();
_status.firstAct=event.current; _status.firstAct=event.current;
event.four_assign=get.config('four_assign');
event.flipassign=true; event.flipassign=true;
event.videoId=lib.status.videoId++;
var func=function(filter,id,selected,map){
var dialog=ui.create.characterDialog(filter,'expandall').open();
dialog.videoId=id;
dialog.groupControl=ui.create.groupControl(dialog);
for(var i in map){
var player=lib.playerOL[i];
if(player){
player.side=map[i][0];
player.identity=map[i][1];
player.setIdentity();
player.node.identity.dataset.color=get.translation(player.side+'Color');
if(player.identity=='zhu'){
game[player.side+'Zhu']=player;
player.isZhu=true;
}
}
}
};
event.map=map;
event.selected=[];
game.broadcastAll(func,filterChoice,event.videoId,event.selected,map);
_status.onreconnect=[func,filterChoice,event.videoId,event.selected,map];
"step 1" "step 1"
if(event.current==game.me||(event.four_assign&&event.current.side==game.me.side)){ game.broadcastAll(function(player){
var dialog=event.xdialog||ui.create.characterDialog(event.filterChoice); player.classList.add('selectedx');
var names=[]; },event.current);
for(var i=0;i<game.players.length;i++){ event.current.chooseButton(true).set('filterButton',function(button){
if(game.players[i].name){ return !_status.event.selected.contains(button.link);
names.push(game.players[i].name); }).set('ai',function(button){
if(_status.event.player.identity=='zhu'){
if(Math.random()<0.8){
var info=lib.character[button.link];
if(!info[4]||!info[4].contains('zhu')){
return 0;
} }
} }
for(var i=0;i<dialog.buttons.length;i++){
if(names.contains(dialog.buttons[i].link)){
dialog.buttons[i].classList.add('unselectable');
dialog.buttons[i].classList.add('noclick');
} }
var seed=_status.event.seed;
var rank=get.rank(button.link,true);
if(seed>0.4){
return (rank>=6)?Math.random():-Math.random();
} }
if(!event.groupControl){ else if(seed>0.1){
event.groupControl=ui.create.groupControl(dialog); return (rank>=4&&rank<6)?Math.random():-Math.random();
}
game.me.chooseButton(dialog,true).closeDialog=false;
event.xdialog=dialog;
dialog.static=true;
event.current.classList.add('selectedx');
} }
else{ else{
event.ai(event.current,event.list.randomGets(3),event.list2); return (rank<4)?Math.random():-Math.random();
if(!event.four_assign){
event.current=event.current.next;
event.redo();
}
} }
}).set('selected',_status.event.selected).set('dialog',event.videoId).set('seed',Math.random());
"step 2" "step 2"
event.current.classList.remove('selectedx'); event.selected.push(result.links[0]);
if(event.current.side==game.me.side){ game.broadcastAll(function(player,name,zhu){
event.current.init(result.buttons[0].link); player.classList.remove('selectedx');
event.list.remove(event.current.name); player.init(name);
event.list2.remove(event.current.name); },event.current,result.links[0]);
if(event.current.identity=='zhu'){ if(event.current.identity=='zhu'){
event.current.hp++; event.current.hp++;
event.current.maxHp++; event.current.maxHp++;
event.current.update(); event.current.update();
} }
} event.current.classList.remove('selectedx');
if(event.four_assign){
for(var i=0;i<game.players.length;i++){ for(var i=0;i<game.players.length;i++){
if(!game.players[i].name) break; if(!game.players[i].name) break;
} }
@ -1265,47 +1328,164 @@ mode.versus={
event.flipassign=!event.flipassign; event.flipassign=!event.flipassign;
event.goto(1); event.goto(1);
} }
"step 3"
_status.onreconnect=[function(){
for(var i=0;i<game.players.length;i++){
var player=game.players[i];
if(player.identity=='zhu'){
game[player.side+'Zhu']=player;
player.isZhu=true;
}
}
}]
game.broadcastAll(function(id){
var dialog=get.idDialog(id);
if(dialog){
dialog.close();
dialog.groupControl.close();
}
},event.videoId);
}
},
chooseCharacterOL3:function(){
var next=game.createEvent('chooseCharacterOL',false);
next.content=function(){
'step 0'
game.additionaldead=[];
game.broadcastAll(function(ref,bool){
for(var i=0;i<6;i++){
ref.side=bool;
ref=ref.next;
bool=!bool;
}
for(var i=0;i<game.players.length;i++){
if(game.players[i].side==game.me.side){
game.players[i].node.identity.firstChild.innerHTML='友';
} }
else{ else{
game.players[i].node.identity.firstChild.innerHTML='敌';
}
game.players[i].node.identity.dataset.color=game.players[i].side+'zhu';
}
},game.me,Math.random()<0.5);
_status.onreconnect=[function(){
var players=game.players.concat(game.dead);
for(var i=0;i<players.length;i++){
if(players[i].side==game.me.side){
players[i].node.identity.firstChild.innerHTML='友';
}
else{
players[i].node.identity.firstChild.innerHTML='敌';
}
}
}];
var list=get.charactersOL();
var choose=[];
event.list=list;
for(var i=0;i<game.players.length;i++){ for(var i=0;i<game.players.length;i++){
if(!game.players[i].name){ choose.push([game.players[i],['选择出场和备用武将',[list.randomRemove(5),'character']],2,true]);
event.ai(game.players[i],event.list.splice(0,3),event.list2); }
game.me.chooseButtonOL(choose,function(player,result){
if(game.online||player==game.me) player.init(result.links[0]);
});
'step 1'
for(var i in result){
if(result[i]=='ai'){
result[i]=event.list.randomRemove(2);
}
else{
result[i]=result[i].links;
} }
} }
game.broadcastAll(function(result,func1,func2){
_status.friendDied=[];
_status.enemyDied=[];
_status.friend=[];
_status.enemy=[];
_status.enemyCount=ui.create.system('杀敌: '+get.cnNumber(0,true),null,true);
_status.friendCount=ui.create.system('阵亡: '+get.cnNumber(0,true),null,true);
lib.setPopped(_status.friendCount,func1);
lib.setPopped(_status.enemyCount,func2);
for(var i in result){
if(!lib.playerOL[i].name){
lib.playerOL[i].init(result[i][0]);
} }
"step 3" if(lib.playerOL[i].side==game.me.side){
if(event.groupControl){ _status.friend.push(result[i][1]);
event.groupControl.close();
} }
if(event.xdialog){ else{
event.xdialog.close(); _status.enemy.push(result[i][1]);
} }
game.addRecentCharacter(game.me.name,game.me.name2); }
},result,game.versusHoverFriend,game.versusHoverEnemy);
_status.onreconnect=[function(list1,list2,list3,list4,side,func1,func2){
if(side!=game.me.side){
var tmp;
tmp=list1;
list1=list2;
list2=tmp;
tmp=list3;
list3=list4;
list4=tmp;
}
_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);
lib.setPopped(_status.friendCount,func1);
lib.setPopped(_status.enemyCount,func2);
for(var i=0;i<game.players.length;i++){
if(game.players[i].side==game.me.side){
game.players[i].node.identity.firstChild.innerHTML='友';
}
else{
game.players[i].node.identity.firstChild.innerHTML='敌';
}
}
},_status.friendDied,_status.enemyDied,
_status.friend,_status.enemy,game.me.side,
game.versusHoverFriend,game.versusHoverEnemy];
} }
}, },
chooseCharacterOL2:function(){ chooseCharacterOL2:function(){
var next=game.createEvent('chooseCharacterOL',false); var next=game.createEvent('chooseCharacterOL',false);
next.content=function(){ next.content=function(){
'step 0' 'step 0'
game.broadcastAll(function(ref,bool){ game.broadcastAll(function(ref,bool,bool2){
game.me.node.identity.firstChild.innerHTML='友';
game.me.next.next.node.identity.firstChild.innerHTML='友';
game.me.next.node.identity.firstChild.innerHTML='敌';
game.me.previous.node.identity.firstChild.innerHTML='敌';
ref.side=bool; ref.side=bool;
ref.next.next.side=bool; ref.next.side=bool2;
ref.next.side=!bool; ref.next.next.side=!bool;
ref.previous.side=!bool; ref.previous.side=!bool2;
for(var i=0;i<game.players.length;i++){ for(var i=0;i<game.players.length;i++){
if(game.players[i].side==game.me.side){
game.players[i].node.identity.firstChild.innerHTML='友';
}
else{
game.players[i].node.identity.firstChild.innerHTML='敌';
}
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.me,Math.random()<0.5,Math.random()<0.5);
_status.onreconnect=[function(){ _status.onreconnect=[function(){
game.me.node.identity.firstChild.innerHTML='友'; var players=game.players.concat(game.dead);
game.me.nextSeat.nextSeat.node.identity.firstChild.innerHTML='友'; for(var i=0;i<players.length;i++){
game.me.nextSeat.node.identity.firstChild.innerHTML='敌'; if(players[i].side==game.me.side){
game.me.previousSeat.node.identity.firstChild.innerHTML='敌'; players[i].node.identity.firstChild.innerHTML='友';
}
else{
players[i].node.identity.firstChild.innerHTML='敌';
}
}
}]; }];
var list=get.charactersOL(); var list=get.charactersOL();
var choose=[]; var choose=[];
@ -1471,8 +1651,8 @@ mode.versus={
_status.friend=list3; _status.friend=list3;
_status.enemy=list4; _status.enemy=list4;
_status.enemyCount=ui.create.system('杀敌: '+get.cnNumber(0,true),null,true); _status.enemyCount=ui.create.system('杀敌: '+get.cnNumber(_status.enemyDied.length,true),null,true);
_status.friendCount=ui.create.system('阵亡: '+get.cnNumber(0,true),null,true); _status.friendCount=ui.create.system('阵亡: '+get.cnNumber(_status.friendDied.length,true),null,true);
lib.setPopped(_status.friendCount,func1); lib.setPopped(_status.friendCount,func1);
lib.setPopped(_status.enemyCount,func2); lib.setPopped(_status.enemyCount,func2);
@ -1583,10 +1763,29 @@ mode.versus={
if(_status.friend.length==1){ if(_status.friend.length==1){
event.directresult=_status.friend[0]; event.directresult=_status.friend[0];
} }
else if(_status.auto){ else if(event.source==game.me){
if(_status.auto){
event.directresult=_status.friend.randomGet(); event.directresult=_status.friend.randomGet();
} }
}
else{ else{
if(!event.source.isOnline()){
event.directresult=_status.friend.randomGet();
}
}
}
else{
if(_status.enemy.length==1){
event.directresult=_status.enemy[0];
}
else{
if(!event.source.isOnline()){
event.directresult=_status.enemy.randomGet();
}
}
}
if(!event.directresult){
if(event.source==game.me){
event.dialog=ui.create.dialog('选择替补角色',[_status.friend,'character']); event.dialog=ui.create.dialog('选择替补角色',[_status.friend,'character']);
event.filterButton=function(){return true}; event.filterButton=function(){return true};
event.player=game.me; event.player=game.me;
@ -1607,16 +1806,8 @@ mode.versus={
game.check(); game.check();
game.pause(); game.pause();
} }
}
else{ else{
if(_status.enemy.length==1){ event.source.send(function(player){
event.directresult=_status.enemy[0];
}
else if(!game.me.nextSeat.isOnline()){
event.directresult=_status.enemy.randomGet();
}
else{
game.me.nextSeat.send(function(player){
if(_status.auto){ if(_status.auto){
_status.event._result=_status.friend.randomGet(); _status.event._result=_status.friend.randomGet();
} }
@ -1646,20 +1837,25 @@ mode.versus={
} }
} }
game.resume(); game.resume();
},game.me.nextSeat); },event.source);
game.me.nextSeat.wait(); event.source.wait();
game.pause(); game.pause();
} }
} }
'step 2' 'step 2'
if(!event.directresult){ if(!event.directresult){
if(event.resultOL){ if(event.resultOL){
event.directresult=event.resultOL[game.me.nextSeat.playerid]; event.directresult=event.resultOL[source.playerid];
} }
if(!event.directresult||event.directresult=='ai'){ if(!event.directresult||event.directresult=='ai'){
if(source.side==game.me.side){
event.directresult=_status.friend.randomGet();
}
else{
event.directresult=_status.enemy.randomGet(); event.directresult=_status.enemy.randomGet();
} }
} }
}
var name=event.directresult; var name=event.directresult;
var color=source.node.identity.dataset.color; var color=source.node.identity.dataset.color;
game.additionaldead.push({ game.additionaldead.push({
@ -1674,6 +1870,9 @@ mode.versus={
source.uninit(); source.uninit();
source.init(name); source.init(name);
source.node.identity.dataset.color=color; source.node.identity.dataset.color=color;
if(source==game.me){
ui.arena.classList.remove('selecting');
}
},source,name,color); },source,name,color);
source.draw(4); source.draw(4);
@ -2123,7 +2322,7 @@ mode.versus={
player:{ player:{
dieAfter:function(source){ dieAfter:function(source){
if(_status.connectMode){ if(_status.connectMode){
if(_status.mode=='1v1'){ if(_status.mode=='1v1'||_status.mode=='3v3'){
game.broadcastAll(function(dead){ game.broadcastAll(function(dead){
if(dead.side==game.me.side){ if(dead.side==game.me.side){
_status.friendDied.push(dead.name); _status.friendDied.push(dead.name);
@ -2134,7 +2333,7 @@ mode.versus={
_status.enemyCount.innerHTML='杀敌: '+get.cnNumber(_status.enemyDied.length,true); _status.enemyCount.innerHTML='杀敌: '+get.cnNumber(_status.enemyDied.length,true);
} }
},this); },this);
if(this==game.me){ if(this.side==game.me.side){
if(_status.friend.length==0){ if(_status.friend.length==0){
game.over(false); game.over(false);
return; return;
@ -2149,7 +2348,13 @@ mode.versus={
game.replacePlayerOL(this); game.replacePlayerOL(this);
} }
else if(_status.mode=='2v2'){ else if(_status.mode=='2v2'){
if(this.nextSeat.nextSeat.isAlive()){ var friend;
for(var i=0;i<game.players.length;i++){
if(game.players[i].side==this.side){
friend=game.players[i];break;
}
}
if(friend){
var next=game.createEvent('versusDraw'); var next=game.createEvent('versusDraw');
next.content=function(){ next.content=function(){
'step 0' 'step 0'
@ -2159,12 +2364,37 @@ mode.versus={
player.draw(); player.draw();
} }
}; };
next.player=this.nextSeat.nextSeat; next.player=friend;
} }
else{ else{
game.over(this.side!=game.me.side); game.over(this.side!=game.me.side);
} }
} }
else if(_status.mode=='4v4'){
if(this.identity=='zhu'){
game.over(this.side!=game.me.side);
}
else if(source){
if(source.side==this.side){
if(source.identity=='zhu'){
source.discard(source.get('he'));
}
}
else{
var num1=0,num2=1;
for(var i=0;i<game.players.length;i++){
if(game.players[i].side==source.side){
num1++;
}
else{
num2++;
}
}
source.draw(2+Math.max(0,num2-num1));
}
}
return;
}
} }
else{ else{
if(_status.mode=='four'){ if(_status.mode=='four'){