'use strict'; mode.identity={ game:{ start:function(){ var next=game.createEvent('game',false); next.content=function(){ "step 0" game.prepareArena(); game.delay(); "step 1" if(lib.storage.test){ _status.auto=true; // ui.auto.innerHTML='手动'; ui.auto.classList.add('glow'); } game.chooseCharacter(); "step 2" if(get.config('ai_identity')||game.players.length==2){ game.showIdentity(true); } else{ for(var i=0;i=3){ var skill; switch(game.zhu.name){ case 'liubei':skill='jizhen';break; case 'dongzhuo':skill='hengzheng';break; case 'sunquan':skill='batu';break; case 'diy_zhangjiao':skill='tiangong';break; case 'liushan':skill='shengxi';break; case 'sunce':skill='ciqiu';break; case 'yuanshao':skill='geju';break; case 're_caocao':skill='dangping';break; case 'caopi':skill='junxing';break; case 'liuxie':skill='moukui';break; default:skill='tianming';break; } game.zhu.addSkill(skill); game.zhu.storage.enhance_zhu=skill; } if(lib.storage.test){ var str=''; for(var i=0;i0) return; if(lib.storage.test){ if(game.zhu.isAlive()){ console.log('主忠胜利'); } else if(game.players[0].identity=='nei'&&game.players.length==1){ console.log('内奸胜利'); } else{ console.log('反贼胜利'); } } for(var i=0;i0&&game.zhu.classList.contains('dead')){ game.over(true); } else{ game.over(false); } } }, chooseCharacter:function(){ var next=game.createEvent('chooseCharacter',false); next.showConfig=true; next.addPlayer=function(player){ var list=lib.config.mode_config.identity.identity[game.players.length-3].slice(0); var list2=lib.config.mode_config.identity.identity[game.players.length-2].slice(0); for(var i=0;i4){ player.hp++; player.maxHp++; player.update(); } } else if(player.identity=='zhong'&&Math.random()<0.5){ var choice=0; for(var i=0;i4){ game.me.hp++; game.me.maxHp++; game.me.update(); } for(var i=0;i0){ for(var i=0;i0&&!this.spy){ 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; } else if(effect<0&&this==game.me&&game.me.identity!='nei'){ if(targets.length==1&&targets[0]==this); else if(targets.length==1) this.ai.shown-=0.2; else this.ai.shown-=0.1; } else if(this.spy){ if(this.ai.shown>0.5) this.ai.shown=0.5; if(targets.length==1&&targets[0]!=this) this.ai.shown-=0.2; else this.ai.shown-=0.1; } } if(this!=game.me) this.ai.shown*=2; if(this.ai.shown>0.95) this.ai.shown=0.95; if(this.ai.shown<-0.5) this.ai.shown=-0.5; }, } }, ai:{ get:{ attitude:function(from,to){ var x=0,num=0,temp,i; if(_status.ai.customAttitude){ for(i=0;i<_status.ai.customAttitude.length;i++){ temp=_status.ai.customAttitude[i](from,to); if(temp!=undefined){ x+=temp; num++; } } } if(num){ return x/num; } var difficulty=0; if(to==game.me) difficulty=2-get.difficulty(); if(get.config('ai_identity')||from==to||!lib.config.ai_guess||(to.identityShown&&!to.spy)){ return ai.get.realAttitude(from,to)+difficulty*1.5; } else{ return ai.get.realAttitude(from,to)*to.ai.shown+difficulty*1.5; } }, realAttitude:function(from,to){ if(_status.currentPhase==from&&from.ai.tempIgnore&&from.ai.tempIgnore.contains(to)) return 0; var situation=ai.get.situation(); var identity=from.spy||from.identity; var identity2=to.identity; if(from==to&&from.spy) identity2=from.spy; switch(identity){ case 'zhu': switch(identity2){ case 'zhu': return 10; case 'zhong': return 6; case 'nei': if(game.players.length==2) return -10; if(situation>1) return 0; return Math.min(3,get.population('fan')); case 'fan': return -4; } break; case 'zhong': switch(identity2){ case 'zhu': return 10; case 'zhong': return get.population('fan')>0?4:0.1; case 'nei': if(get.population('fan')==0) return -2; return Math.min(3,-situation); case 'fan': return -8; } break; case 'nei': if(identity2=='zhu'&&game.players.length==2) return -10; var strategy=get.aiStrategy(); if(strategy==4){ if(from==to) return 10; return 0; } var num; switch(identity2){ case 'zhu': if(strategy==6) return -1; if(strategy==5) return 10; if(to.hp<=0) return 10; if(situation>1) num=0; else num=get.population('fan')+Math.max(0,3-game.zhu.hp); if(strategy==2) num--; if(strategy==3) num++; return num; case 'zhong': if(strategy==5) return Math.min(0,-situation); if(strategy==6) return Math.max(-1,-situation); if(get.population('fan')==0) num=-5; else if(situation<=0) num=0; else if(game.zhu&&game.zhu.hp<2) num=0; else if(game.zhu&&game.zhu.hp==2) num=-0.5 else num=-2; if(strategy==2) num--; if(strategy==3) num++; return num; case 'nei': if(from==to) return 10; if(from.ai.friend.contains(to)) return 5; return -1; case 'fan': if(strategy==5) return Math.max(-1,situation); if(strategy==6) return Math.min(0,situation); if((game.zhu&&game.zhu.hp<=2&&situation<=0)||situation<-1) num=-3; else if(situation<0||get.population('zhong')==0) num=-2; else if((game.zhu&&game.zhu.hp>4&&situation>0)||situation>1) num=1; else num=0; if(strategy==2) num++; if(strategy==3) num--; return num; } break; case 'fan': switch(identity2){ case 'zhu': if(situation==1) return -6; if(situation>1) return -5; return -10; case 'zhong': return -7; case 'nei': if(get.population('zhong')==0) return -7; if(game.zhu&&game.zhu.hp<=2) return -1; return Math.min(3,situation); case 'fan': return 5; } } }, situation:function(absolute){ var i,j,player; var zhuzhong=0,total=0,zhu,fan=0; for(i=0;i30) result--; if(zhu<6&&fan>15) result--; if(zhu<4) result--; return result; }, population:function(identity){ return get.population(identity); } } }, ui:{ click:{ identity:function(){ if(_status.dragged) return; _status.clicked=true; if(this.parentNode.identityShown) return; if(this.parentNode==game.me) return; switch(this.firstChild.innerHTML){ case '猜':this.firstChild.innerHTML='反';this.dataset.color='fan';break; case '反':this.firstChild.innerHTML='忠';this.dataset.color='zhong';break; case '忠':this.firstChild.innerHTML='内';this.dataset.color='nei';break; case '内':this.firstChild.innerHTML='猜';this.dataset.color='cai';break; } } } }, config:['player_number','double_character','double_hp', 'ban_weak','enhance_zhu','free_choose','change_identity', 'change_choice','change_card','dierestart','swap','revive', 'auto_identity','ai_strategy','ai_identity','difficulty'] }