'use strict'; mode.versus={ start:function(){ "step 0" _status.mode=get.config('versus_mode'); "step 1" var playback=localStorage.getItem(lib.configprefix+'playback'); if(playback){ ui.create.me(); ui.arena.style.display='none'; ui.system.style.display='none'; _status.playback=playback; localStorage.removeItem(lib.configprefix+'playback'); var store=lib.db.transaction(['video'],'readwrite').objectStore('video'); store.get(parseInt(playback)).onsuccess=function(e){ if(e.target.result){ game.playVideoContent(e.target.result.video); } else{ alert('播放失败:找不到录像'); game.reload(); } } event.finish(); return; } if(_status.mode=='jiange'||_status.mode=='four'){ game.prepareArena(8); // game.pause(); } else{ if(lib.storage.choice==undefined) game.save('choice',20); if(lib.storage.zhu==undefined) game.save('zhu',true); if(lib.storage.noreplace_end==undefined) game.save('noreplace_end',true); if(get.config('first_less')==undefined) game.saveConfig('first_less',true,true); if(lib.storage.autoreplaceinnerhtml==undefined) game.save('autoreplaceinnerhtml',true); if(lib.storage.single_control==undefined) game.save('single_control',true); if(lib.storage.number==undefined) game.save('number',3); if(lib.storage.versus_reward==undefined) game.save('versus_reward',3); if(lib.storage.versus_punish==undefined) game.save('versus_punish','弃牌'); if(lib.storage.replace_number==undefined) game.save('replace_number',3); switch(lib.storage.seat_order){ case '交叉':lib.storage.cross_seat=true;lib.storage.random_seat=false;break; case '随机':lib.storage.cross_seat=false;lib.storage.random_seat=true;break; default:lib.storage.cross_seat=false;lib.storage.random_seat=false; } game.save('only_zhu',true); game.save('control_all',true); ui.wuxie.hide(); ui.create.cards(); game.finishCards(); } game.delay(); "step 2" if(_status.mode=='four'){ var list=['zhu','zhong','zhong','zhong','ezhu','ezhong','ezhong','ezhong']; list.randomSort(); var side=Math.random()<0.5; 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]; } if(game.players[i].identity=='zhu'){ game[game.players[i].side+'Zhu']=game.players[i]; game.players[i].isZhu=true; } game.players[i].setIdentity(game.players[i].identity); game.players[i].node.identity.dataset.color=get.translation(game.players[i].side+'Color'); } game.chooseCharacterFour(); } else if(_status.mode=='jiange'){ var list=['shumech','shu','shuboss','shu','wei','weiboss','wei','weimech']; var pos=Math.floor(Math.random()*8); for(var i=0;i<8;i++){ var j=pos+i; if(j>=8){ j-=8; } if(list[i][0]=='w'){ game.players[j].side=true; game.players[j].setIdentity('wei'); game.players[j].identity='wei'; } else{ game.players[j].side=false; game.players[j].setIdentity('shu'); game.players[j].identity='shu'; } if(list[i].indexOf('mech')!=-1){ game.players[j].type='mech'; } else if(list[i].indexOf('boss')!=-1){ game.players[j].type='boss'; } else{ game.players[j].type='human'; } } game.chooseCharacterJiange(); } else{ game.chooseCharacter(); } "step 3" var players=get.players(lib.sort.position); var info=[]; for(var i=0;i=4); } game.addVideo('init',null,info); event.trigger('gameStart'); if(_status.mode=='four'){ game.gameDraw(_status.firstAct,function(player){ if(player==_status.firstAct.previousSeat){ return 5; } return 4; }); if(game.me==_status.firstAct.previous||game.me==_status.firstAct.previous.previous){ game.me.chooseBool('是否置换手牌?'); event.replaceCard=true; } } else if(_status.mode=='jiange'){ var firstAct; for(var i=0;i1){ for(var i=0;i=lib.storage.number){ actcount=i-lib.storage.number; } else{ actcount=i+lib.storage.number; } } if(actcount>0){ actcount--; } else{ actcount=game.players.length-1; } firstAct=game.players[actcount]; break; } } } else{ firstAct=game.players[Math.floor(Math.random()*game.players.length)]; } } game.gameDraw(firstAct,4); _status.first_less=true; _status.round=0; if(lib.storage.single_control){ lib.skill.global.push('versus_swap'); ui.autoreplace=ui.create.div('.caption.normal'); ui.autoreplace.innerHTML='
自动换人
'; ui.autoreplace.style.textAlign='center'; if(lib.storage.autoreplaceinnerhtml){ ui.autoreplace.classList.add('on') } ui.autoreplace.listen(game.switchAutoreplace); // ui.versusreplace=ui.create.system('换人',null,true); // lib.setPopped(ui.versusreplace,game.versusHoverReplace); if(game.players.length>2){ ui.versushs=ui.create.system('手牌',null,true); lib.setPopped(ui.versushs,game.versusHoverHandcards,220); } } _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('友方',null,true); // _status.enemyCount=ui.create.system('敌方',null,true); lib.setPopped(_status.friendCount,game.versusHoverFriend); lib.setPopped(_status.enemyCount,game.versusHoverEnemy); if(lib.storage.zhu){ _status.currentSide=true; game.versusPhaseLoop(firstAct); } else{ game.versusPhaseLoop(firstAct); } } if(_status.mode!='four'){ event.finish(); } "step 4" if(event.replaceCard&&result.bool){ var hs=game.me.get('h'); for(var i=0;i'; } } lib.config.gameRecord.versus.str=str; game.saveConfig('gameRecord',lib.config.gameRecord); } }, chooseCharacterJiange:function(){ var next=game.createEvent('chooseCharacter',false); next.showConfig=true; next.content=function(){ 'step 0' if(lib.config.hiddenCharacterPack.contains('boss')){ game.loadPackage('character/boss'); } 'step 1' for(var i in lib.skill){ if(lib.skill[i].changeSeat){ lib.skill[i]={}; if(lib.translate[i+'_info']){ lib.translate[i+'_info']='此模式下不可用'; } } } var list={ weilist:[],shulist:[], weimech:[],shumech:[], weiboss:[],shuboss:[], } event.list=list; if(lib.characterPack.boss){ for(var i in lib.characterPack.boss){ if(!lib.character[i]&&lib.characterPack.boss[i][4]){ if(lib.characterPack.boss[i][4].contains('jiangeboss')|| lib.characterPack.boss[i][4].contains('jiangemech')){ lib.character[i]=lib.characterPack.boss[i]; } } } } for(var i in lib.character){ if(lib.character[i][4]){ if(lib.character[i][4].contains('jiangeboss')){ list[lib.character[i][1]+'boss'].push(i);continue; } else if(lib.character[i][4].contains('jiangemech')){ list[lib.character[i][1]+'mech'].push(i);continue; } } if(lib.filter.characterDisabled(i)) continue; if(lib.character[i][1]=='wei'){ list.weilist.push(i); } else if(lib.character[i][1]=='shu'){ list.shulist.push(i); } } if(!list.weiboss.length){ alert('剑阁模式不可隐藏boss武将包,请在选项-其它中选择“重置隐藏扩展包”'); event.finish(); _status.over=true; return; } var dialog; switch(game.me.type){ case 'human': for(var i=0;ib?1:-1; } if(lib.storage.choice=='∞'){ list.sort(sortByGroup); } else{ list.randomSort(); } _status.list=list; var choice=(lib.storage.choice=='∞')?list.length:lib.storage.choice; event.dialog=ui.create.dialog('选择角色',[list.slice(0,choice),'character']); event.dialog.classList.add('fixed'); // for(var i=0;i=dialog.versus_number.link+dialog.replace_number.link){ event.fill.firstChild.innerHTML='开始'; _status.choosefinished=true; } game.save('zhu',dialog.versus_zhu.link); if(lib.storage.zhu){ // dialog.versus_only_zhu.parentNode.classList.remove('disabled'); dialog.versus_main_zhu.parentNode.classList.remove('disabled'); } else{ // dialog.versus_only_zhu.parentNode.classList.add('disabled'); dialog.versus_main_zhu.parentNode.classList.add('disabled'); } // game.save('only_zhu',dialog.versus_only_zhu.link); game.save('main_zhu',dialog.versus_main_zhu.link); game.save('assign_enemy',dialog.versus_assign_enemy.link); game.save('seat_order',dialog.versus_seat_order.link); // game.save('cross_seat',dialog.versus_cross_seat.link); game.save('noreplace_end',dialog.versus_noreplace_end.link); game.save('single_control',dialog.versus_single_control.link); // if(lib.storage.cross_seat){ // dialog.versus_random_seat.parentNode.classList.add('disabled'); // } // else{ // dialog.versus_random_seat.parentNode.classList.remove('disabled'); // if(lib.storage.random_seat){ // dialog.versus_cross_seat.parentNode.classList.add('disabled'); // } // else{ // dialog.versus_cross_seat.parentNode.classList.remove('disabled'); // } // } switch(lib.storage.seat_order){ case '交叉':lib.storage.cross_seat=true;lib.storage.random_seat=false;break; case '随机':lib.storage.cross_seat=false;lib.storage.random_seat=true;break; default:lib.storage.cross_seat=false;lib.storage.random_seat=false; } // if(lib.storage.single_control){ // dialog.versus_control_all.parentNode.classList.remove('disabled'); // } // else{ // dialog.versus_control_all.parentNode.classList.add('disabled'); // } // game.save('control_all',dialog.versus_control_all.link); game.saveConfig('first_less',dialog.versus_first_less.link,true); game.save('number',dialog.versus_number.link); game.save('versus_reward',dialog.versus_reward.link); game.save('versus_punish',dialog.versus_punish.link); game.save('replace_number',dialog.replace_number.link); game.save('choice',dialog.choice.link); var count,i; if(dialog.buttons.length>lib.storage.choice){ count=dialog.buttons.length-lib.storage.choice; var removed=[]; for(i=dialog.buttons.length-1;i>=0&&count>0;i--){ if(dialog.buttons[i].classList.contains('target')==false&& dialog.buttons[i].classList.contains('glow')==false){ dialog.buttons[i].remove(); _status.list.remove(dialog.buttons[i].link); removed.push(dialog.buttons[i].link) dialog.buttons.splice(i,1); count--; } } for(i=0;i=4){ ui.arena.dataset.number=parseInt(ui.arena.dataset.number)+1; for(var i=0;i=4){ // ui.fakemebg.show(); game.onSwapControl(); } } }, versusPhaseLoop:function(player){ var next=game.createEvent('phaseLoop'); next.player=player; next.content=function(){ "step 0" if(lib.storage.zhu){ player.classList.add('acted'); } player.phase(); "step 1" if(lib.storage.zhu){ _status.currentSide=!_status.currentSide; _status.round++; if(_status.round>=2*Math.max(game.friend.length,game.enemy.length)){ _status.round=0; for(var i=0;ib.num('j')) return 1; return a.hp-b.hp; }) event.player=list[0]; event.goto(0); } else{ game.me.chooseTarget('选择要行动的角色',true,function(card,player,target){ return (target.classList.contains('acted')==false&&target.side==game.me.side); }) } } else{ event.player=event.player.next; event.goto(0); } "step 2" event.player=result.targets[0]; event.goto(0); } }, phaseLoopJiange:function(){ var next=game.createEvent('phaseLoop'); next.num=0; next.content=function(){ if(event.num>=8){ event.num-=8; } var player=_status.actlist[event.num]; if(player.isAlive()){ player.phase(); } event.num++; event.redo(); } }, replacePlayer:function(player){ var next=game.createEvent('replacePlayer'); next.source=player; next.content=function(){ "step 0" var list=(source.side==game.me.side)?_status.friend:_status.enemy; if(list.length==0){ // if(game.friend.contains(source)){ // game.over(false); // } // else{ // game.over(true); // } game.friend.remove(source); game.enemy.remove(source); if(game.friend.length==0) game.over(false); else if(game.enemy.length==0) game.over(true); if(game.friendZhu&&game.friendZhu.classList.contains('dead')&&game.friend.length){ game.friendZhu=game.friend[0]; game.friendZhu.setIdentity(_status.color+'Zhu'); } if(game.enemyZhu&&game.enemyZhu.classList.contains('dead')&&game.enemy.length){ game.enemyZhu=game.enemy[0]; game.enemyZhu.setIdentity(!_status.color+'Zhu'); } event.finish(); return; } if(source.side==game.me.side&&list.length>1&&(game.me==game.friendZhu||(lib.storage.zhu&&lib.storage.single_control))&& !_status.auto){ event.dialog=ui.create.dialog('选择替补角色',[list,'character']); event.filterButton=function(){return true;}; event.player=game.me; event.forced=true; event.custom.replace.confirm=function(){ event.character=ui.selected.buttons[0].link; event.dialog.close(); if(ui.confirm) ui.confirm.close(); delete event.player; game.resume(); } game.check(); game.pause(); } else{ event.character=list[Math.floor(Math.random()*list.length)]; } "step 1" _status.friend.remove(event.character); _status.enemy.remove(event.character); source.revive(); game.additionaldead.push({ name:source.name, stat:source.stat }); game.addVideo('reinit',source,[event.character,get.translation(source.side+'Color')]); source.uninit(); source.init(event.character); source.node.identity.dataset.color=get.translation(source.side+'Color'); source.draw(4); _status.event.parent.parent.parent.untrigger(false,source); if(lib.storage.single_control&&lib.storage.control_all){ game.onSwapControl(); } "step 2" // if(_status.currentPhase==source){ // source.skip('phase'); // } } }, versusClickToSwap:function(e){ if(_status.dragged) return; if(this.link==game.me){ if(!this.classList.contains('buttonclick')){ this.animate('buttonclick'); } } else if(_status.event.player==game.me&&!_status.auto){ game.me.popup('请稍后再换人'); e.stopPropagation(); } else{ game.modeSwapPlayer(this.link); } }, versusCheckHandcards:function(){ _status.clicked=true; if(ui.intro){ ui.intro.close(); if(ui.intro.source=='versusCheckHandcards'){ delete ui.intro; ui.control.show(); game.resume2(); return; } } game.pause2(); ui.control.hide(); ui.intro=ui.create.dialog(); ui.intro.source='versusCheckHandcards'; ui.intro.add(ui.autoreplace); var players=[]; for(var i=0;i2)){ if(game.friend.contains(this)){ game.over(false); } else{ game.over(true); } } else if(game.friend.length==1&&this==game.friend[0]&&_status.friend.length==0){ game.over(false); } else if(game.enemy.length==1&&this==game.enemy[0]&&_status.enemy.length==0){ game.over(true); } else{ if(source){ if(source.side!=this.side){ if(lib.storage.versus_reward){ source.draw(lib.storage.versus_reward); } } else{ if(lib.storage.versus_punish=='弃牌'){ source.discard(source.get('he')); } else if(lib.storage.versus_punish=='摸牌'&&lib.storage.versus_reward){ source.draw(lib.storage.versus_reward); } } } else{ game.delay(); } game.replacePlayer(this); } } } }, ai:{ get:{ attitude:function(from,to){ if(from.side==to.side){ if(to.identity=='zhu'&&(lib.storage.main_zhu||_status.mode=='four')) return 10; return 6; } if(to.identity=='zhu'&&(lib.storage.main_zhu||_status.mode=='four')) return -10; return -6; }, } }, help:{ '对决模式':'
4v4
  • 双方各有一名主公和三名忠臣,杀死对方主公获胜
  • '+ '8号位游戏开始时额外摸一张牌,7、8号位可在游戏开始时置换一次手牌
  • '+ '杀死对方忠臣摸2+x张牌,x为对方(含刚被杀的忠臣)与己方的存活人数之差;主公杀死己方忠臣须弃置所有牌', } }