'use strict'; mode.versus={ game:{ start:function(){ var next=game.createEvent('game',false); next.content=function(){ "step 0" 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(lib.storage.autoreplaceinnerhtml==undefined) game.save('autoreplaceinnerhtml',true); if(lib.storage.only_zhu==undefined) game.save('only_zhu',true); if(lib.storage.single_control==undefined) game.save('single_control',true); if(lib.storage.control_all==undefined) game.save('control_all',true); if(lib.storage.number==undefined) game.save('number',3); if(lib.storage.replace_number==undefined) game.save('replace_number',3); ui.create.arena(); ui.create.cards(); game.finishCards(); ui.auto.hide(); ui.wuxie.hide(); game.delay(); "step 1" game.chooseCharacter(); "step 2" event.trigger('gameStart'); game.gameDraw(game.players[0]); _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); ui.versushs=ui.create.system('手牌',null,true); lib.setPopped(ui.versusreplace,game.versusHoverReplace); lib.setPopped(ui.versushs,game.versusHoverHandcards); } _status.friendCount=ui.create.system('我方阵亡:'+get.cnNumber(0),null,true); _status.enemyCount=ui.create.system('敌方阵亡:'+get.cnNumber(0),null,true); lib.setPopped(_status.friendCount,game.versusHoverFriend); lib.setPopped(_status.enemyCount,game.versusHoverEnemy); if(lib.storage.zhu){ _status.currentSide=true; game.versusPhaseLoop((_status.currentSide==game.me.side)?game.friendZhu:game.enemyZhu); } else{ game.versusPhaseLoop(game.players[Math.floor(Math.random()*game.players.length)]); } } }, chooseCharacter:function(){ var next=game.createEvent('chooseCharacter',false); next.showConfig=true; next.content=function(){ "step 0" event.check=function(){ this.dialog.classList.add('fullwidth'); this.dialog.classList.add('fullheight'); this.dialog.classList.add('noslide'); 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']); // 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('random_seat',dialog.versus_random_seat.link); game.save('noreplace_end',dialog.versus_noreplace_end.link); game.save('single_control',dialog.versus_single_control.link); 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.save('die_stop',dialog.versus_die_stop.link); game.save('number',dialog.versus_number.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=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); } }, 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 }); source.uninit(); source.init(event.character); source.node.identity.dataset.color=get.translation(source.side+'Color'); source.draw(4); if(lib.storage.die_stop){ _status.event.parent.parent.parent.untrigger(true); } if(lib.storage.single_control&&lib.storage.control_all){ game.onSwapControl(); } } }, 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;i