'use strict'; mode.guozhan={ 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{ game.prepareArena(); game.delay(); game.showChangeLog(); } "step 1" if(_status.connectMode){ game.randomMapOL(); game.broadcastAll(function(){ 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; 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.ban_weak?'开启':'关闭')); uiintro.add('
屏蔽强将:'+(lib.configOL.ban_strong?'开启':'关闭')).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){ 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; if(lib.storage.test&&!_status.connectMode){ console.log(get.translation(game.players[0].identity)+'胜利'); } 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){ 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;iget.population()/2) this.identity='ye'; else this.identity=this.group; // this.node.identity.dataset.color=this.identity; this.setIdentity(this.identity); this.ai.shown=1; 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,'展示了主将'+get.translation(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,'展示了副将'+get.translation(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,'展示了主将'+get.translation(this.name1)+'、副将'+get.translation(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; 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()&&get.config('guozhan_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;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(); } } } } game.tryResult(); }, perfectPair:function(){ if(!get.config('zhulian')) return false; var name1=this.name1; var name2=this.name2; if(lib.character[name1][1]!=lib.character[name2][1]) return false; var list=['re','diy','sp','jsp','shen','jg','xin']; for(var i=0;i0){ 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; }, } }, skill:{ _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=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; }, } }, }