'use strict'; mode.guozhan={ startBefore:function(){ var playback=localStorage.getItem(lib.configprefix+'playback'); for(var i in lib.characterPack.mode_guozhan){ if(!get.config('onlyguozhan')&&!playback){ if(lib.character[i.slice(3)]) continue; } lib.character[i]=lib.characterPack.mode_guozhan[i]; if(!lib.character[i][4]){ lib.character[i][4]=[]; } if(!lib.translate[i]){ lib.translate[i]=lib.translate[i.slice(3)]; } } }, onreinit:function(){ var pack=lib.characterPack.mode_guozhan; for(var i in pack){ if(!lib.configOL.onlyguozhan){ if(lib.character[i.slice(3)]) continue; } lib.character[i]=pack[i]; if(!lib.character[i][4]){ lib.character[i][4]=[]; } if(!lib.translate[i]){ lib.translate[i]=lib.translate[i.slice(3)]; } } }, start:function(){ "step 0" 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(); } else if(_status.connectMode){ game.waitForPlayer(); } else{ if(get.config('guozhanpile')){ lib.card.list=lib.guozhanPile.slice(0); } game.prepareArena(); game.delay(); game.showChangeLog(); } if(!_status.connectMode){ _status.mode=get.config('guozhan_mode'); if(_status.brawl&&_status.brawl.submode){ _status.mode=_status.brawl.submode; } } "step 1" if(_status.connectMode){ if(lib.configOL.guozhanpile){ lib.card.list=lib.guozhanPile.slice(0); } game.broadcastAll(function(pack){ for(var i=0;i0; }, content:function(){ "step 0" player.chooseCardTarget({ filterCard:function(card){ return get.type(card)=='equip'; }, position:'he', filterTarget:function(card,player,target){ return !target.get('e',get.subtype(card)[5]); }, ai1:function(card){ return 6-ai.get.value(card); }, ai2:function(target){ return ai.get.attitude(_status.event.player,target)-3; }, prompt:get.prompt('yuanhu') }); "step 1" if(result.bool){ var target=result.targets[0]; player.logSkill('yuanhu',target); target.equip(result.cards[0]); if(target!=player){ player.$give(result.cards,target); } player.chooseTarget(true,'弃置一名角色的一张牌',function(card,player,target){ var source=_status.event.source; return get.distance(source,target)<=1&&source!=target&&target.num('he'); }).set('ai',function(target){ return -ai.get.attitude(_status.event.player,target); }).set('source',target); } else{ event.finish(); } "step 2" if(result.targets.length){ player.discardPlayerCard(true,result.targets[0],'he'); } }, }, heyi:{ zhenfa:'inline' }, _heyi:{ mod:{ globalTo:function(from,to,distance){ if(game.hasPlayer(function(current){ return current.hasSkill('heyi')&¤t.inline(to); })){ return distance+1; } } } }, tianfu:{ init:function(player){ player.checkMainSkill('tianfu'); }, inherit:'kanpo', zhenfa:'inline', viewAsFilter:function(player){ return _status.currentPhase.inline(player)&&!player.hasSkill('kanpo')&&player.num('h',{color:'black'})>0; }, }, yizhi:{ init:function(player){ if(player.checkViceSkill('yizhi')){ player.removeMaxHp(); } }, inherit:'guanxing', filter:function(event,player){ return !player.hasSkill('guanxing'); } }, gzshangyi:{ audio:'shangyi', enable:'phaseUse', usable:1, filter:function(event,player){ return player.num('h')>0; }, filterTarget:function(card,player,target){ return player!=target&&(target.num('h')||target.isUnseen(2)); }, content:function(){ "step 0" target.viewCards(player+'的手牌',player.get('h')); "step 1" if(!target.num('h')){ event._result={index:1}; } else if(!target.isUnseen(2)){ event._result={index:0}; } else{ player.chooseControl().set('choiceList',[ '观看'+get.translation(target)+'的手牌并可以弃置其中的一张黑色牌', '观看'+get.translation(target)+'的所有暗置的武将牌', ]); } "step 2" if(result.index==0){ player.discardPlayerCard(target,'h').set('filterButton',function(button){ return get.color(button.link)=='black'; }).set('visible',true); } else{ player.viewCharacter(target,2); } }, ai:{ order:11, result:{ target:function(player,target){ return -target.num('h'); } }, threaten:1.1 }, }, niaoxiang:{ zhenfa:'siege' }, _niaoxiang:{ trigger:{player:'shaBegin'}, filter:function(event,player){ if(game.countPlayer()<4) return false; return player.siege(event.target)&&game.hasPlayer(function(current){ return current.hasSkill('niaoxiang')&¤t.siege(event.target); }); }, forced:true, logTarget:'target', content:function(){ "step 0" var next=trigger.target.chooseToRespond({name:'shan'}); next.autochoose=lib.filter.autoRespondShan; next.set('ai',function(card){ if(_status.event.player.num('h','shan')>1){ return ai.get.unuseful2(card); } return -1; }); "step 1" if(result.bool==false){ trigger.untrigger(); trigger.directHit=true; } } }, fengshi:{ zhenfa:'siege' }, _fengshi:{ trigger:{player:'shaBegin'}, filter:function(event,player){ if(game.countPlayer()<4) return false; return player.siege(event.target)&&game.hasPlayer(function(current){ return current.hasSkill('fengshi')&¤t.siege(event.target); })&&event.target.num('e'); }, logTarget:'target', content:function(){ trigger.target.chooseToDiscard('e',true); } }, chuanxin:{ trigger:{source:'damageBefore'}, filter:function(event,player){ return event.card&&(event.card.name=='sha'||event.card.name=='juedou')&&event.player.identity!='qun'&& !event.player.isUnseen()&&event.player.hasViceCharacter(); }, logTarget:'player', content:function(){ 'step 0' trigger.untrigger(); trigger.finish(); if(trigger.player.num('e')){ trigger.player.chooseControl(function(event,player){ if(player.hp==1) return 1; if(player.hp==2&&player.num('e')>=2) return 1; return 0; }).set('choiceList',['弃置装备区内的所有牌并失去一点体力','移除副将牌']); } else{ event._result={index:1}; } 'step 1' if(result.index==1){ trigger.player.removeCharacter(1); } else{ trigger.player.discard(trigger.player.get('e')); trigger.player.loseHp(); } } }, gzguixiu:{ init2:function(player){ player.logSkill('guixiu'); player.draw(2); }, onremove:function(player){ if(player.isDamaged()){ player.logSkill('guixiu'); player.recover(); } } }, gzcunsi:{ derivation:'gzyongjue', enable:'phaseUse', filter:function(event,player){ return player.checkMainSkill('gzcunsi',false)||player.checkViceSkill('gzcunsi',false); }, unique:true, forceunique:true, filterTarget:true, skillAnimation:true, content:function(){ 'step 0' if(player.checkMainSkill('gzcunsi',false)){ player.removeCharacter(0); } else{ player.removeCharacter(1); } 'step 1' target.addSkill('gzyongjue'); if(target!=player){ target.draw(2); } }, ai:{ order:9, result:{ player:function(player,target){ var num=0; if(player.isDamaged()&&target.isFriendOf(player)){ num++; if(target.hasSkill('kanpo')) num+=0.5; if(target.hasSkill('liegong')) num+=0.5; if(target.hasSkill('tieji')) num+=0.5; if(target.hasSkill('gzrende')) num+=1.2; if(target.hasSkill('longdan')) num+=1.2; if(target.hasSkill('paoxiao')) num+=1.2; if(target!=player) num+=0.5; } return num; } } } }, gzyongjue:{ trigger:{global:'useCardAfter'}, filter:function(event,player){ if(event.gzyongjue==player){ for(var i=0;i0; }, logTarget:'source', content:function(){ var source=trigger.source; if(source.hasSkill('hengjiang2')){ source.storage.hengjiang3+=trigger.num; source.updateMarks(); } else{ source.storage.hengjiang2=player; source.storage.hengjiang3=trigger.num; source.addTempSkill('hengjiang2','phaseAfter'); } } }, hengjiang2:{ mark:'character', intro:{ content:function(storage,player){ return '手牌上限-'+player.storage.hengjiang3; }, markcount:function(storage,player){ return player.storage.hengjiang3; } }, mod:{ maxHandcard:function(player,num){ return num-player.storage.hengjiang3; } }, onremove:function(player){ delete player.storage.hengjiang2; delete player.storage.hengjiang3; }, trigger:{player:'phaseDiscardEnd'}, filter:function(event,player){ return player.storage.hengjiang2.isIn()&&(!event.cards||event.cards.length==0); }, forced:true, popup:false, content:function(){ player.storage.hengjiang2.draw(); } }, baoling:{ trigger:{player:'phaseUseEnd'}, init:function(player){ player.checkMainSkill('baoling'); }, forced:true, filter:function(event,player){ return player.hasViceCharacter(); }, content:function(){ 'step 0' player.removeCharacter(1); 'step 1' player.awakenSkill('baoling'); player.gainMaxHp(3,true); 'step 2' player.recover(3); player.addSkill('benghuai'); }, derivation:'benghuai' }, gzmingshi:{ trigger:{player:'damageBegin'}, forced:true, filter:function(event,player){ return event.num>0&&event.source&&event.source.isUnseen(2); }, content:function(){ trigger.num--; }, ai:{ effect:{ target:function(card,player,target){ if(player.hasSkill('jueqing')) return; if(!player.isUnseen(2)) return; var num=get.tag(card,'damage'); if(num){ if(num>1) return 0.5; return 0; } } } }, }, hunshang:{ init:function(player){ if(player.checkViceSkill('hunshang')){ player.removeMaxHp(); } }, group:['hunshang_yingzi','hunshang_yinghun'], }, hunshang_yingzi:{ inherit:'yingzi', filter:function(event,player){ return player.hp==1&&!player.hasSkill('yingzi'); } }, hunshang_yinghun:{ inherit:'gzyinghun', filter:function(event,player){ return player.hp==1&&player.isDamaged()&&!player.hasSkill('gzyinghun'); } }, yingyang:{ trigger:{player:'compare',target:'compare'}, filter:function(event){ return !event.iwhile; }, content:function(){ if(player==trigger.player){ trigger.num1+=3; } else{ trigger.num2+=3; } } }, gzqianxi:{ audio:'qianxi', trigger:{player:'phaseBegin'}, content:function(){ "step 0" player.judge(); "step 1" event.color=result.color; player.chooseTarget(function(card,player,target){ return player!=target&&get.distance(player,target)<=1; },true).set('ai',function(target){ return -ai.get.attitude(_status.event.player,target); }); "step 2" if(result.bool&&result.targets.length){ result.targets[0].storage.qianxi2=event.color; result.targets[0].addSkill('qianxi2'); player.line(result.targets,'green'); game.addVideo('storage',result.targets[0],['qianxi2',event.color]); } }, }, shuangren:{ trigger:{player:'phaseUseBegin'}, direct:true, priority:15, content:function(){ 'step 0' var goon; if(player.needsToDiscard()>1){ goon=player.hasCard(function(card){ return card.number>10&&ai.get.value(card)<=5; }); } else{ goon=player.hasCard(function(card){ return card.number>=9&&ai.get.value(card)<=5||ai.get.value(card)<=3; }); } player.chooseTarget(get.prompt('shuangren'),function(card,player,target){ return target!=player; }).set('ai',function(target){ var player=_status.event.player; if(_status.event.goon&&ai.get.attitude(player,target)<0){ return ai.get.effect(target,{name:'sha'},player,player); } return 0; }).set('goon',goon); 'step 1' if(result.bool){ var target=result.targets[0]; event.target=target; player.logSkill('shuangren',target); player.chooseToCompare(target); } else{ event.finish(); } 'step 2' if(result.bool){ var target=event.target; if(target.identity!='ye'&&target.identity!='unknown'&&game.hasPlayer(function(current){ return target.identity==current.identity&&target!=current&&player.canUse('sha',current,false); })){ player.chooseTarget('对一名'+get.translation(target.identity)+'势力的角色使用一张杀',true,function(card,player,target){ return target.identity==_status.event.identity; }).set('ai',function(target){ var player=_status.event.player; return ai.get.effect(target,{name:'sha'},player,player); }).set('identity',target.identity); } else{ player.useCard({name:'sha'},target,false); event.finish(); } } else{ trigger.finish(); trigger.untrigger(); event.finish(); } 'step 3' if(result.bool&&result.targets&&result.targets.length){ player.useCard({name:'sha'},result.targets[0],false); } } }, gzduanchang:{ audio:'duanchang', trigger:{player:'dieBegin'}, forced:true, silent:true, filter:function(event,player){ return event.source&&event.source.isIn()&&event.source!=player&& (event.source.hasMainCharacter()||event.source.hasViceCharacter()); }, content:function(){ 'step 0' if(!trigger.source.hasViceCharacter()){ event._result={control:'主将'} } else if(!trigger.source.hasMainCharacter()){ event._result={control:'副将'} } else{ player.chooseControl('主将','副将',function(){ return Math.random()<0.5?'主将':'副将'; }).set('prompt','令'+get.translation(trigger.source)+'失去一张武将牌的所有技能'); } 'step 1' var skills; if(result.control=='主将'){ trigger.source.showCharacter(0); game.broadcastAll(function(player){ player.node.avatar.classList.add('disabled'); },trigger.source); skills=lib.character[trigger.source.name][3]; game.log(trigger.source,'失去了主将技能'); } else{ trigger.source.showCharacter(1); game.broadcastAll(function(player){ player.node.avatar2.classList.add('disabled'); },trigger.source); skills=lib.character[trigger.source.name2][3]; game.log(trigger.source,'失去了副将技能'); } var list=[]; for(var i=0;i2) return 0; if(ui.selected.cards.length&&ui.selected.cards[0].name=='du') return 0; if(!ui.selected.cards.length&&card.name=='du') return 20; var player=get.owner(card); if(player.hp==player.maxHp||player.storage.gzrende<0||player.num('h')+player.storage.gzrende<=2){ if(ui.selected.cards.length){ return -1; } var players=game.filterPlayer(); for(var i=0;i=3&& ai.get.attitude(players[i],player)>=3){ return 11-ai.get.value(card); } } if(player.num('h')>player.hp) return 10-ai.get.value(card); if(player.num('h')>2) return 6-ai.get.value(card); return -1; } return 10-ai.get.value(card); }, content:function(){ target.gain(cards,player); if(typeof player.storage.gzrende!='number'){ player.storage.gzrende=0; } if(player.storage.gzrende>=0){ player.storage.gzrende+=cards.length; if(player.storage.gzrende>=3){ player.recover(); player.storage.gzrende=-1; } } }, ai:{ order:function(skill,player){ if(player.hp==player.maxHp||player.storage.gzrende<0||player.num('h')+player.storage.gzrende<=2){ return 1; } return 10; }, result:{ target:function(player,target){ if(ui.selected.cards.length&&ui.selected.cards[0].name=='du'){ return -10; } if(target.num('j','lebu')) return 0; var nh=target.num('h'); var np=player.num('h'); if(player.hp==player.maxHp||player.storage.gzrende<0||player.num('h')+player.storage.gzrende<=2){ if(nh>=np-1&&np<=player.hp&&!target.get('s').contains('haoshi')) return 0; } return Math.max(1,5-nh); } }, effect:{ target:function(card,player,target){ if(player==target&&get.type(card)=='equip'){ if(player.num('e',{subtype:get.subtype(card)})){ var players=game.filterPlayer(); for(var i=0;i0){ return 0; } } } } } }, threaten:0.8 } }, gzrende1:{ trigger:{player:'phaseUseBegin'}, forced:true, popup:false, silent:true, content:function(){ player.storage.gzrende=0; } }, gzzhiheng:{ inherit:'zhiheng', selectCard:function(){ return [1,_status.event.player.maxHp]; }, prompt:'出牌阶段限一次,你可以弃置至多X张牌(X为你的体力上限),然后摸等量的牌' }, huoshui:{ enable:'phaseUse', unique:true, forceunique:true, filter:function(event,player){ if(player.name1=='gz_zoushi') return player.isUnseen(0); return player.isUnseen(1); }, content:function(){ if(player.name1=='gz_zoushi') player.showCharacter(0); else player.showCharacter(1); } }, _huoshui:{ ai:{ nomingzhi:true, skillTagFilter:function(player){ return _status.currentPhase&&_status.currentPhase!=player&&_status.currentPhase.hasSkill('huoshui'); } } }, qingcheng:{ enable:'phaseUse', filter:function(event,player){ return player.num('he',{type:'equip'})&&game.hasPlayer(function(current){ return current!=player&&!current.isUnseen(2); }); }, filterCard:{type:'equip'}, position:'he', filterTarget:function(card,player,target){ return !target.isUnseen(2); }, check:function(card){ return 6-ai.get.value(card,_status.event.player); }, content:function(){ 'step 0' var choice='主将'; var skills=lib.character[target.name2][3]; for(var i=0;i=0) return 0; if(player.hasCard(function(card){ return get.tag(card,'damage')&&player.canUse(card,target,true,true); })){ if(target.maxHp>3) return -0.5; return -1; } return 0; } } } }, qingcheng_ai:{ ai:{ effect:{ target:function(card){ if(get.tag(card,'damage')) return 2; } } } }, duoshi:{ enable:'chooseToUse', viewAs:{name:'yiyi'}, usable:4, filterCard:{color:'red'}, viewAsFilter:function(player){ return player.num('h',{color:'red'})>0; }, check:function(card){ return 5-ai.get.value(card); } }, gzxiaoguo:{ inherit:'xiaoguo', content:function(){ "step 0" var nono=(Math.abs(ai.get.attitude(player,trigger.player))<3); if(ai.get.damageEffect(trigger.player,player,player)<=0){ nono=true; } var next=player.chooseToDiscard(get.prompt('gzxiaoguo',trigger.player),{type:'basic'}); next.set('ai',function(card){ if(_status.event.nono) return 0; return 8-ai.get.useful(card); }); next.set('logSkill',['gzxiaoguo',trigger.player]); next.set('nono',nono); "step 1" if(result.bool){ var nono=(ai.get.damageEffect(trigger.player,player,trigger.player)>=0); trigger.player.chooseToDiscard('he',{type:'equip'}).set('ai',function(card){ if(_status.event.nono){ return 0; } if(_status.event.player.hp==1) return 10-ai.get.value(card); return 9-ai.get.value(card); }).set('nono',nono); } else{ event.finish(); } "step 2" if(!result.bool){ trigger.player.damage(); } }, }, _mingzhi1:{ trigger:{player:'phaseBegin'}, priority:19, forced:true, popup:false, content:function(){ "step 0" var choice=1; for(var i=0;i=2||(popu==1&&game.players.length<=4)){ return Math.random()<0.5?3:(Math.random()<0.5?2:1); } if(choice==0) return 0; if(get.population(group)>0&&get.totalPopulation(group)+1<=get.population()/2){ return Math.random()<0.2?(Math.random()<0.5?3:(Math.random()<0.5?2:1)):0; } var nming=0; for(var i=0;i=2||(popu==1&&game.players.length<=4)){ return true; } if(get.population(group)>0&&get.totalPopulation(group)+1<=get.population()/2){ return Math.random()<0.2?true:false; } var nming=0; for(var i=0;i=num){ break; } } } else{ if(!map[lib.character[list[i]][1]]){ group=lib.character[list[i]][1]; choice.push(list[i]); list.splice(i--,1); } } } } return choice; }, getState:function(){ var state={}; for(var i in lib.playerOL){ var player=lib.playerOL[i]; state[i]={ identity:player.identity, shown:player.ai.shown, }; } return state; }, updateState:function(state){ for(var i in state){ var player=lib.playerOL[i]; if(player){ player.identity=state[i].identity; player.ai.shown=state[i].shown; } } }, getRoomInfo:function(uiintro){ var num,last; if(lib.configOL.initshow_draw=='0'){ num='关闭' } else{ num=get.cnNumber(parseInt(lib.configOL.initshow_draw))+'张' } uiintro.add('
首亮摸牌:'+num); uiintro.add('
珠联璧合:'+(lib.configOL.zhulian?'开启':'关闭')); uiintro.add('
出牌时限:'+lib.configOL.choose_timeout+'秒'); uiintro.add('
国战牌堆:'+(lib.configOL.guozhanpile?'开启':'关闭')); last=uiintro.add('
国战武将:'+(lib.configOL.onlyguozhan?'开启':'关闭')); if(!lib.configOL.onlyguozhan){ uiintro.add('
屏蔽弱将:'+(lib.configOL.ban_weak?'开启':'关闭')); last=uiintro.add('
屏蔽强将:'+(lib.configOL.ban_strong?'开启':'关闭')); if(lib.configOL.banned.length){ last=uiintro.add('
禁用武将:'+get.translation(lib.configOL.banned)); } if(lib.configOL.bannedcards.length){ last=uiintro.add('
禁用卡牌:'+get.translation(lib.configOL.bannedcards)); } } last.style.paddingBottom='8px'; }, addRecord:function(bool){ if(typeof bool=='boolean'){ var data=lib.config.gameRecord.guozhan.data; var identity=game.me.identity; if(!data[identity]){ data[identity]=[0,0]; } if(bool){ data[identity][0]++; } else{ data[identity][1]++; } var list=['wei','shu','wu','qun','ye']; var str=''; for(var i=0;i'; } } lib.config.gameRecord.guozhan.str=str; game.saveConfig('gameRecord',lib.config.gameRecord); } }, getIdentityList:function(player){ if(!player.isUnseen()) return; if(player==game.me) return; var list={ wei:'魏', shu:'蜀', wu:'吴', qun:'群', ye:'野', unknown:'猜' } var num=Math.floor((game.players.length+game.dead.length)/2); var noye=true; if(get.population('wei')>=num){ delete list.wei; noye=false; } if(get.population('shu')>=num){ delete list.shu; noye=false; } if(get.population('wu')>=num){ delete list.wu; noye=false; } if(get.population('qun')>=num){ delete list.qun; noye=false; } if(noye){ delete list.ye; } return list; }, getVideoName:function(){ var str=get.translation(game.me.name1)+'/'+get.translation(game.me.name2); var str2=get.cnNumber(parseInt(get.config('player_number')))+'人'+ get.translation(lib.config.mode); if(game.me.identity=='ye'){ str2+=' - 野心家'; } var name=[str,str2]; return name; }, showIdentity:function(started){ if(game.phaseNumber==0&&!started) return; for(var i=0;i1){ check=false; } } else{ if(hasunknown&&!get.zhu()){ var players=game.players.concat(game.dead); var num=0; for(var i=0;iplayers.length/2){ check=false; } } } } if(check){ game.checkResult(); } else if(!hasunknown){ var ids=[]; var idmap={}; var idp={}; for(var i=0;i1&&idmap[id2]>1) return; if(idmap[id1]>1&&id1=='ye') return; if(idmap[id2]>1&&id2=='ye') return; if(idmap[id1]==1){ idp[id1].showGiveup(); } if(idmap[id2]==1){ idp[id2].showGiveup(); } } }, checkResult:function(){ _status.overing=true; for(var i=0;i0; }, chooseCharacter:function(){ var next=game.createEvent('chooseCharacter',false); next.showConfig=true; next.addPlayer=true; next.ai=function(player,list,back){ if(_status.brawl&&_status.brawl.chooseCharacterAi){ if(_status.brawl.chooseCharacterAi(player,list,back)!==false){ return; } } for(var i=0;i'; td.link=i-1; td.addEventListener(lib.config.touchscreen?'touchend':'click',function(){ if(_status.dragged) return; if(_status.justdragged) return; if(_status.cheat_seat){ _status.cheat_seat.classList.remove('thundertext'); if(_status.cheat_seat==this){ delete _status.cheat_seat; return; } } this.classList.add('thundertext'); _status.cheat_seat=this; }); } dialog.content.appendChild(seats); if(game.me==game.zhu){ seats.previousSibling.style.display='none'; seats.style.display='none'; } dialog.add(ui.create.div('.placeholder')); dialog.add(ui.create.div('.placeholder')); dialog.add(ui.create.div('.placeholder')); }; var removeSetting=function(){ var dialog=_status.event.dialog; if(dialog.querySelector('table')&&!get.config('change_identity')){ dialog.querySelector('table').previousSibling.remove(); dialog.querySelector('table').nextSibling.remove(); dialog.querySelector('table').nextSibling.remove(); dialog.querySelector('table').nextSibling.remove(); dialog.querySelector('table').remove(); } }; event.addSetting=addSetting; event.removeSetting=removeSetting; var chosen=lib.config.continue_name||[]; game.saveConfig('continue_name'); event.chosen=chosen; var i; event.list=[]; for(i in lib.character){ if(i.indexOf('gz_shibing')==0) continue; if(chosen.contains(i)) continue; if(lib.filter.characterDisabled(i)) continue; if(get.config('onlyguozhan')){ if(!lib.characterPack.mode_guozhan[i]) continue; if(get.config('junzhu')){ if(lib.junList.contains(i.slice(3))) continue; } else{ if(lib.junList.contains(i.slice(7))) continue; } } if(lib.character[i][2]==3||lib.character[i][2]==4||lib.character[i][2]==5) event.list.push(i); } _status.characterlist=event.list.slice(0); if(_status.brawl&&_status.brawl.chooseCharacterFilter){ event.list=_status.brawl.chooseCharacterFilter(event.list); } event.list.randomSort(); // var list=event.list.splice(0,parseInt(get.config('choice_num'))); var list; if(_status.brawl&&_status.brawl.chooseCharacter){ list=_status.brawl.chooseCharacter(event.list,game.me); } else{ list=game.getCharacterChoice(event.list,parseInt(get.config('choice_num'))); } if(_status.auto){ event.ai(game.me,list); } else if(chosen.length){ game.me.init(chosen[0],chosen[1],false); } else{ var dialog=ui.create.dialog('选择角色','hidden',[list,'character']); if(!_status.brawl||!_status.brawl.noAddSetting){ if(get.config('change_identity')){ addSetting(dialog); } } var next=game.me.chooseButton(dialog,true,2); next.filterButton=function(button){ if(ui.dialog.buttons.length<=10){ for(var i=0;ilist.length){ num=5; } else if(lib.configOL.number*7>list.length){ num=6; } else{ num=7; } var filterButton=function(button){ if(ui.dialog){ if(ui.dialog.buttons.length<=10){ for(var i=0;i=2||player.hp>=player.maxHp-1) return 'draw_card'; if(player.hp==2&&player.num('h')==0) return 'draw_card'; return 'recover_hp'; },ui.create.dialog('hidden','珠联璧合:选择一项奖励')); } "step 1" if(result.control=='draw_card'){ player.draw(2); } else{ player.recover(); } } }, player:{ getModeState:function(){ return { unseen:this.isUnseen(0), unseen2:this.isUnseen(1), } }, setModeState:function(info){ if(info.mode.unseen) this.classList.add('unseen'); if(info.mode.unseen2) this.classList.add('unseen2'); if(!info.name) return; // if(info.name.indexOf('unknown')==0){ // if(this==game.me){ // lib.translate[info.name]+='(你)'; // } // } this.init(info.name1,info.name2,false); this.name1=info.name1; this.name=info.name; this.node.name_seat=ui.create.div('.name.name_seat',get.verticalStr(lib.translate[this.name].slice(0,3)),this); if(info.identityShown){ this.setIdentity(info.identity); this.node.identity.classList.remove('guessing'); } else if(this!=game.me){ this.node.identity.firstChild.innerHTML='猜'; this.node.identity.dataset.color='unknown'; this.node.identity.classList.add('guessing'); } }, dieAfter:function(source){ this.showCharacter(2); if(source&&source.identity!='unknown'){ if(this.identity=='ye') source.draw(1); else if(this.identity!=source.identity) source.draw(get.population(this.identity)+1); else source.discard(source.get('he')); } game.tryResult(); }, viewCharacter:function(target,num){ if(num!=0&&num!=1){ num=2; } if(!target.isUnseen(num)){ return; } var next=game.createEvent('viewCharacter'); next.player=this; next.target=target; next.num=num; next.setContent(function(){ var content,str=get.translation(target)+'的'; if(event.num==0||!target.isUnseen(1)){ content=[str+'主将',[[target.name1],'character']]; game.log(player,'观看了',target,'的主将'); } else if(event.num==1||!target.isUnseen(0)){ content=[str+'副将',[[target.name2],'character']]; game.log(player,'观看了',target,'的副将'); } else{ content=[str+'主将和副将',[[target.name1,target.name2],'character']]; game.log(player,'观看了',target,'的主将和副将'); } player.chooseControl('ok').set('dialog',content); }) }, checkShow:function(skill){ var sourceSkill=get.info(skill); if(sourceSkill&&sourceSkill.sourceSkill){ skill=sourceSkill.sourceSkill; } if(game.expandSkills(this.get('s')).contains(skill)) return false; if(lib.skill.global.contains(skill)) return false; if(this.isUnseen(0)){ var skills=game.expandSkills(lib.character[this.name1][3].slice(0)); if(skills.contains(skill)){ this.showCharacter(0); return true; } } if(this.isUnseen(1)){ var skills=game.expandSkills(lib.character[this.name2][3].slice(0)); if(skills.contains(skill)){ this.showCharacter(1); return true; } } return false; }, checkViceSkill:function(skill,disable){ if(game.expandSkills(lib.character[this.name2][3].slice(0)).contains(skill)){ return true; } else{ if(disable!==false){ this.awakenSkill(skill); } return false; } }, checkMainSkill:function(skill,disable){ if(game.expandSkills(lib.character[this.name1][3].slice(0)).contains(skill)){ return true; } else{ if(disable!==false){ this.awakenSkill(skill); } return false; } }, removeMaxHp:function(){ if(game.online) return; if(typeof this.singleHp=='boolean'){ if(this.singleHp){ this.singleHp=false; } else{ this.singleHp=true; this.maxHp--; } } else{ this.maxHp--; } }, hideCharacter:function(num,log){ if(this.isUnseen(2)){ return; } game.addVideo('hideCharacter',this,num); var skills; switch(num){ case 0: if(log!==false) game.log(this,'暗置了主将'+get.translation(this.name1)); skills=lib.character[this.name][3]; this.name=this.name2; this.sex=lib.character[this.name2][0]; this.classList.add('unseen'); break; case 1: if(log!==false) game.log(this,'暗置了副将'+get.translation(this.name2)); skills=lib.character[this.name2][3]; this.classList.add('unseen2'); break; } game.broadcast(function(player,name,sex,num,skills){ player.name=name; player.sex=sex; switch(num){ case 0:player.classList.add('unseen');break; case 1:player.classList.add('unseen2');break; } for(var i=0;iget.population()/2) this.identity='ye'; else this.identity=this.group; this.setIdentity(this.identity); this.ai.shown=1; this.node.identity.classList.remove('guessing'); if(_status.clickingidentity&&_status.clickingidentity[0]==this){ for(var i=0;i<_status.clickingidentity[1].length;i++){ _status.clickingidentity[1][i].delete(); _status.clickingidentity[1][i].style.transform=''; } delete _status.clickingidentity; } game.addVideo('setIdentity',this,this.identity); } var skills; switch(num){ case 0: if(log!==false) game.log(this,'展示了主将','#b'+this.name1); this.name=this.name1; skills=lib.character[this.name][3]; this.sex=lib.character[this.name][0]; this.classList.remove('unseen'); break; case 1: if(log!==false) game.log(this,'展示了副将','#b'+this.name2); skills=lib.character[this.name2][3]; if(this.sex=='unknown') this.sex=lib.character[this.name2][0]; if(this.name.indexOf('unknown')==0) this.name=this.name2; this.classList.remove('unseen2'); break; case 2: if(log!==false) game.log(this,'展示了主将','#b'+this.name1,'、副将','#b'+this.name2); this.name=this.name1; skills=lib.character[this.name][3].concat(lib.character[this.name2][3]); this.sex=lib.character[this.name][0]; this.classList.remove('unseen'); this.classList.remove('unseen2'); break; } game.broadcast(function(player,name,sex,num,identity){ player.identityShown=true; player.name=name; player.sex=sex; player.node.identity.classList.remove('guessing'); switch(num){ case 0:player.classList.remove('unseen');break; case 1:player.classList.remove('unseen2');break; case 2:player.classList.remove('unseen');player.classList.remove('unseen2');break; } player.ai.shown=1; player.identity=identity; player.setIdentity(identity); if(_status.clickingidentity&&_status.clickingidentity[0]==player){ for(var i=0;i<_status.clickingidentity[1].length;i++){ _status.clickingidentity[1][i].delete(); _status.clickingidentity[1][i].style.transform=''; } delete _status.clickingidentity; } },this,this.name,this.sex,num,this.identity); this.identityShown=true; var initdraw=parseInt(get.config('initshow_draw')); if(!_status.initshown&&!_status.overing&&initdraw&&this.isAlive()&&_status.mode!='mingjiang'){ this.popup('首亮'); game.log(this,'首先明置武将,得到奖励'); game.log(this,'摸了'+get.cnNumber(initdraw)+'张牌'); this.draw(initdraw).log=false; _status.initshown=true; } for(var i=0;i0){ min=Math.min(min,num); } } return get.population(this.identity)==min; }, logAi:function(targets,card){ if(this.ai.shown==1||this.isMad()) return; if(typeof targets=='number'){ this.ai.shown+=targets; } else{ var effect=0,c,shown; var info=get.info(card); if(info.ai&&info.ai.expose){ if(_status.event.name=='_wuxie'){ if(_status.event.source&&_status.event.source.ai.shown){ this.ai.shown+=0.2; } } else{ this.ai.shown+=info.ai.expose; } } if(targets.length>0){ for(var i=0;i0){ if(effect<1) c=0.5; else c=1; if(targets.length==1&&targets[0]==this); else if(targets.length==1) this.ai.shown+=0.2*c; else this.ai.shown+=0.1*c; } } if(this.ai.shown>0.95) this.ai.shown=0.95; if(this.ai.shown<-0.5) this.ai.shown=-0.5; }, } }, ai:{ get:{ realAttitude:function(from,toidentity,difficulty){ if(from.identity==toidentity&&toidentity!='ye'){ return 4+difficulty; } if(from.identity=='unknown'&&lib.character[from.name1][1]==toidentity){ if(get.totalPopulation(toidentity)+1<=get.population()/2) return 4+difficulty; } var groups=[]; for(var i=0;i=game.players.length/2){ if(to_p<=from_p){ return 0.5; } return 0; } if(to_p=get.population()-2){ toidentity='ye'; } } var att=ai.get.realAttitude(from,toidentity,difficulty); if(from.storage.zhibi&&from.storage.zhibi.contains(to)){ return att; } if(to.ai.shown>=0.5) return att*to.ai.shown; var nshown=0; for(var i=0;i=game.players.length/2&&att>=0){ return 0; } return Math.min(0,Math.random()-0.5)+difficulty; } if(to.ai.shown>=0.2){ if(att>2){ return Math.max(0,Math.random()-0.5)+difficulty; } if(att>=0){ return 0; } return Math.min(0,Math.random()-0.7)+difficulty; } if(att>2){ return Math.max(0,Math.random()-0.7)+difficulty; } if(att>=0){ return Math.min(0,Math.random()-0.3)+difficulty; } return Math.min(0,Math.random()-0.5)+difficulty; }, } }, }