2015-05-11 11:57:44 +00:00
|
|
|
'use strict';
|
2015-04-29 03:25:17 +00:00
|
|
|
mode.identity={
|
|
|
|
game:{
|
2015-11-30 13:08:29 +00:00
|
|
|
getIdentityList:function(player){
|
|
|
|
if(player.identityShown) return;
|
|
|
|
if(player==game.me) return;
|
|
|
|
if(get.config('identity_mode')=='zhong'){
|
|
|
|
if(game.zhu&&game.zhu.isZhu){
|
|
|
|
return {
|
|
|
|
fan:'反',
|
|
|
|
zhong:'忠',
|
|
|
|
nei:'内',
|
|
|
|
cai:'猜',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
return {
|
|
|
|
fan:'反',
|
|
|
|
zhong:'忠',
|
|
|
|
nei:'内',
|
|
|
|
zhu:'主',
|
|
|
|
cai:'猜',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
return {
|
|
|
|
fan:'反',
|
|
|
|
zhong:'忠',
|
|
|
|
nei:'内',
|
|
|
|
cai:'猜',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2015-11-04 01:59:00 +00:00
|
|
|
getVideoName:function(){
|
|
|
|
var str=get.translation(game.me.name);
|
|
|
|
if(game.me.name2){
|
|
|
|
str+='/'+get.translation(game.me.name2);
|
|
|
|
}
|
|
|
|
var name=[
|
|
|
|
str,
|
|
|
|
get.cnNumber(parseInt(get.config('player_number')))+'人'+
|
|
|
|
get.translation(lib.config.mode)+' - '+lib.translate[game.me.identity+'2']
|
|
|
|
];
|
|
|
|
return name;
|
|
|
|
},
|
2015-04-29 03:25:17 +00:00
|
|
|
start:function(){
|
|
|
|
var next=game.createEvent('game',false);
|
|
|
|
next.content=function(){
|
|
|
|
"step 0"
|
2015-12-06 15:23:47 +00:00
|
|
|
if(lib.db&&!_status.characterLoaded){
|
|
|
|
_status.waitingForCharacters=true;
|
|
|
|
game.pause();
|
|
|
|
}
|
|
|
|
if(!lib.config.new_tutorial){
|
|
|
|
ui.arena.classList.add('only_dialog');
|
|
|
|
}
|
|
|
|
"step 1"
|
2015-11-04 01:59:00 +00:00
|
|
|
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{
|
2015-11-07 09:20:15 +00:00
|
|
|
if(get.config('identity_mode')=='zhong'){
|
|
|
|
game.prepareArena(8);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
game.prepareArena();
|
|
|
|
}
|
2015-11-25 10:25:18 +00:00
|
|
|
if(!lib.config.new_tutorial){
|
|
|
|
game.delay();
|
|
|
|
}
|
2015-11-04 01:59:00 +00:00
|
|
|
}
|
2015-12-06 15:23:47 +00:00
|
|
|
"step 2"
|
2015-11-25 10:25:18 +00:00
|
|
|
if(!lib.config.new_tutorial){
|
2015-11-30 13:08:29 +00:00
|
|
|
game.saveConfig('version',lib.version);
|
2015-11-25 10:25:18 +00:00
|
|
|
var clear=function(){
|
|
|
|
ui.dialog.close();
|
|
|
|
while(ui.controls.length) ui.controls[0].close();
|
|
|
|
};
|
|
|
|
var clear2=function(){
|
|
|
|
ui.auto.show();
|
|
|
|
ui.arena.classList.remove('only_dialog');
|
|
|
|
};
|
|
|
|
var step1=function(){
|
|
|
|
ui.create.dialog('欢迎来到无名杀,是否进入新手向导?');
|
|
|
|
game.saveConfig('new_tutorial',true);
|
|
|
|
ui.dialog.add('<div class="text center">跳过后,你可以在选项-其它中重置新手向导');
|
|
|
|
ui.auto.hide();
|
|
|
|
ui.create.control('跳过向导',function(){
|
|
|
|
clear();
|
|
|
|
clear2();
|
|
|
|
game.resume();
|
|
|
|
});
|
|
|
|
ui.create.control('继续',step2);
|
|
|
|
}
|
|
|
|
var step2=function(){
|
|
|
|
if(lib.config.layout!='phone'){
|
|
|
|
clear();
|
|
|
|
ui.create.dialog('如果你在使用手机,可能会觉得按钮有点小'+
|
|
|
|
',将布局改成移动可以使按钮变大');
|
|
|
|
ui.dialog.add('<div class="text center">你可以在选项-外观-布局中更改此设置');
|
|
|
|
var lcontrol=ui.create.control('使用移动布局',function(){
|
|
|
|
if(lib.config.layout=='phone'){
|
|
|
|
ui.control.firstChild.firstChild.innerHTML='使用移动布局';
|
|
|
|
lib.init.layout('mobile');
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
ui.control.firstChild.firstChild.innerHTML='使用默认布局';
|
|
|
|
lib.init.layout('phone');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
ui.create.control('继续',step3);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
step3();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
var step3=function(){
|
2015-11-29 11:46:51 +00:00
|
|
|
if(lib.config.touchscreen){
|
2015-11-25 10:25:18 +00:00
|
|
|
clear();
|
2015-11-29 11:46:51 +00:00
|
|
|
ui.create.dialog('触屏模式中,下划可以显示菜单,上划可以切换托管,双指单击可以暂停');
|
|
|
|
ui.dialog.add('<div class="text center">你可以在选项-通用-中更改手势设置');
|
|
|
|
ui.create.control('继续',step4);
|
|
|
|
// var node=ui.create.div('.tutorial_tap',ui.window);
|
|
|
|
// var nodefunc=function(){
|
|
|
|
// setTimeout(function(){
|
|
|
|
// node.style.top='20px';
|
|
|
|
// node.style.left='10%';
|
|
|
|
// setTimeout(function(){
|
|
|
|
// node.style.transition='all 0.2s';
|
|
|
|
// node.style.opacity=0;
|
|
|
|
// setTimeout(function(){
|
|
|
|
// node.style.opacity='';
|
|
|
|
// setTimeout(function(){
|
|
|
|
// node.style.transition='';
|
|
|
|
// },300);
|
|
|
|
// },300);
|
|
|
|
// },1200);
|
|
|
|
// setTimeout(function(){
|
|
|
|
// node.style.left='calc(90% - 30px)';
|
|
|
|
// setTimeout(function(){
|
|
|
|
// node.style.transition='all 0.2s';
|
|
|
|
// node.style.opacity=0;
|
|
|
|
// setTimeout(function(){
|
|
|
|
// node.style.opacity='';
|
|
|
|
// setTimeout(function(){
|
|
|
|
// node.style.transition='';
|
|
|
|
// },300);
|
|
|
|
// },300);
|
|
|
|
// },1200);
|
|
|
|
// setTimeout(function(){
|
|
|
|
// node.style.top='';
|
|
|
|
// node.style.left='';
|
|
|
|
// },2000);
|
|
|
|
// },2000);
|
|
|
|
// },1000);
|
|
|
|
// };
|
|
|
|
// nodefunc();
|
|
|
|
// var interval=setInterval(nodefunc,7000);
|
|
|
|
// var interval2,node2;
|
|
|
|
// var double=true;
|
|
|
|
// ui.create.control('继续',function(){
|
|
|
|
// if(double){
|
|
|
|
// node2=ui.create.div('.tutorial_tap',ui.window);
|
|
|
|
// ui.refresh(node2);
|
|
|
|
// node2.style.top='20px';
|
|
|
|
// node2.style.left='calc(50% - 15px)';
|
|
|
|
// interval2=setInterval(function(){
|
|
|
|
// node2.style.transition='all 0.2s';
|
|
|
|
// node2.style.opacity=0;
|
|
|
|
// setTimeout(function(){
|
|
|
|
// node2.style.opacity='';
|
|
|
|
// setTimeout(function(){
|
|
|
|
// node2.style.opacity=0;
|
|
|
|
// setTimeout(function(){
|
|
|
|
// node2.style.opacity='';
|
|
|
|
// setTimeout(function(){
|
|
|
|
// node2.style.transition='';
|
|
|
|
// },300);
|
|
|
|
// },300);
|
|
|
|
// },300);
|
|
|
|
// },300);
|
|
|
|
// },3000);
|
|
|
|
// clearInterval(interval);
|
|
|
|
// node.delete();
|
|
|
|
// double=false;
|
|
|
|
// ui.dialog.close();
|
|
|
|
// ui.create.dialog('双击顶部可令界面下移,方便进行标身份等操作');
|
|
|
|
// }
|
|
|
|
// else{
|
|
|
|
// clearInterval(interval2);
|
|
|
|
// node2.delete();
|
|
|
|
// step4();
|
|
|
|
// }
|
|
|
|
// });
|
2015-11-25 10:25:18 +00:00
|
|
|
}
|
|
|
|
else{
|
|
|
|
step4();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
var step4=function(){
|
|
|
|
clear();
|
|
|
|
ui.window.classList.add('noclick_important');
|
|
|
|
ui.click.configMenu();
|
|
|
|
ui.control.classList.add('noclick_click_important');
|
|
|
|
ui.control.style.top='calc(100% - 105px)';
|
|
|
|
ui.create.control('在菜单中,可以进行各项设置',function(){
|
|
|
|
ui.click.menuTab('选项');
|
2015-11-30 13:08:29 +00:00
|
|
|
ui.controls[0].replace('如果你感到游戏较卡,可以开启流畅模式',function(){
|
2015-11-25 10:25:18 +00:00
|
|
|
ui.controls[0].replace('在技能一栏中,可以设置自动发动或双将禁配的技能',function(){
|
|
|
|
ui.click.menuTab('武将');
|
|
|
|
ui.controls[0].replace('在武将或卡牌一栏中,单击武将/卡牌可以将其禁用',function(){
|
|
|
|
ui.click.menuTab('战局');
|
|
|
|
ui.controls[0].replace('在战局中可以输入游戏命令,或者管理录像',function(){
|
|
|
|
ui.click.configMenu();
|
|
|
|
ui.window.classList.remove('noclick_important');
|
|
|
|
ui.control.classList.remove('noclick_click_important');
|
|
|
|
ui.control.style.top='';
|
|
|
|
step5();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
})
|
|
|
|
};
|
|
|
|
var step5=function(){
|
|
|
|
clear();
|
|
|
|
ui.create.dialog('如果还有其它问题,欢迎来到百度无名杀吧进行交流');
|
|
|
|
ui.create.control('完成',function(){
|
|
|
|
clear();
|
|
|
|
clear2();
|
|
|
|
game.resume();
|
|
|
|
})
|
|
|
|
};
|
|
|
|
game.pause();
|
|
|
|
step1();
|
|
|
|
}
|
2015-11-30 13:08:29 +00:00
|
|
|
else{
|
|
|
|
game.showChangeLog();
|
|
|
|
}
|
2015-12-06 15:23:47 +00:00
|
|
|
"step 3"
|
2015-04-29 03:25:17 +00:00
|
|
|
if(lib.storage.test){
|
2015-11-05 02:34:35 +00:00
|
|
|
lib.config.game_speed='vfast';
|
2015-04-29 03:25:17 +00:00
|
|
|
_status.auto=true;
|
|
|
|
ui.auto.classList.add('glow');
|
|
|
|
}
|
|
|
|
game.chooseCharacter();
|
2015-12-06 15:23:47 +00:00
|
|
|
"step 4"
|
2015-11-07 09:20:15 +00:00
|
|
|
if(game.players.length==2){
|
2015-04-29 03:25:17 +00:00
|
|
|
game.showIdentity(true);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
for(var i=0;i<game.players.length;i++){
|
|
|
|
game.players[i].ai.shown=0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
game.zhu.ai.shown=1;
|
2015-11-07 09:20:15 +00:00
|
|
|
if(game.zhu2){
|
|
|
|
game.zhong=game.zhu;
|
|
|
|
game.zhu=game.zhu2;
|
|
|
|
delete game.zhu2;
|
|
|
|
}
|
|
|
|
if(get.config('identity_mode')!='zhong'&&get.config('enhance_zhu')&&get.population('fan')>=3){
|
2015-04-29 03:25:17 +00:00
|
|
|
var skill;
|
|
|
|
switch(game.zhu.name){
|
|
|
|
case 'liubei':skill='jizhen';break;
|
|
|
|
case 'dongzhuo':skill='hengzheng';break;
|
|
|
|
case 'sunquan':skill='batu';break;
|
2015-11-28 08:29:42 +00:00
|
|
|
case 'sp_zhangjiao':skill='tiangong';break;
|
2015-04-29 03:25:17 +00:00
|
|
|
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;i<game.players.length;i++){
|
|
|
|
str+=get.translation(game.players[i]);
|
|
|
|
if(game.players[i]==game.zhu) str+='(主)';
|
|
|
|
str+=' ';
|
|
|
|
}
|
|
|
|
console.log(str);
|
|
|
|
game.showIdentity();
|
|
|
|
}
|
|
|
|
lib.config.ai_guess=true;
|
|
|
|
event.trigger('gameStart');
|
2015-11-05 02:34:35 +00:00
|
|
|
|
2015-11-04 01:59:00 +00:00
|
|
|
var players=get.players(lib.sort.position);
|
|
|
|
var info=[];
|
|
|
|
for(var i=0;i<players.length;i++){
|
|
|
|
info.push({
|
|
|
|
name:players[i].name,
|
|
|
|
name2:players[i].name2,
|
|
|
|
identity:players[i].identity
|
|
|
|
});
|
|
|
|
}
|
|
|
|
_status.videoInited=true,
|
|
|
|
game.addVideo('init',null,info);
|
|
|
|
|
2015-11-07 09:20:15 +00:00
|
|
|
game.gameDraw(game.zhong||game.zhu);
|
|
|
|
game.phaseLoop(game.zhong||game.zhu);
|
2015-04-29 03:25:17 +00:00
|
|
|
}
|
|
|
|
},
|
2015-11-01 07:54:42 +00:00
|
|
|
showIdentity:function(me){
|
2015-04-29 03:25:17 +00:00
|
|
|
for(var i=0;i<game.players.length;i++){
|
2015-11-01 07:54:42 +00:00
|
|
|
// if(me===false&&game.players[i]==game.me) continue;
|
2015-04-29 03:25:17 +00:00
|
|
|
game.players[i].identityShown=true;
|
|
|
|
game.players[i].ai.shown=1;
|
|
|
|
game.players[i].setIdentity(game.players[i].identity);
|
2015-11-07 09:20:15 +00:00
|
|
|
if(game.players[i].identity=='zhu'){
|
|
|
|
game.players[i].isZhu=true;
|
|
|
|
}
|
2015-04-29 03:25:17 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
checkResult:function(){
|
|
|
|
if(game.zhu.isAlive()&&get.population('fan')+get.population('nei')>0) return;
|
2015-11-07 09:20:15 +00:00
|
|
|
if(game.zhong){
|
|
|
|
game.zhong.identity='zhong';
|
|
|
|
}
|
2015-04-29 03:25:17 +00:00
|
|
|
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('反贼胜利');
|
|
|
|
}
|
|
|
|
}
|
2015-11-30 13:08:29 +00:00
|
|
|
game.showIdentity();
|
2015-04-29 03:25:17 +00:00
|
|
|
if(game.me.identity=='zhu'||game.me.identity=='zhong'){
|
|
|
|
if(game.zhu.classList.contains('dead')){
|
|
|
|
game.over(false);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
game.over(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(game.me.identity=='nei'){
|
|
|
|
if(get.population('fan')+get.population('zhu')+get.population('zhong')==0){
|
|
|
|
game.over(true);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
game.over(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
if(get.population('fan')+get.population('zhong')>0&&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;i<list.length;i++) list2.remove(list[i]);
|
|
|
|
player.identity=list2[0];
|
|
|
|
player.setIdentity('cai');
|
|
|
|
};
|
|
|
|
next.removePlayer=function(){
|
|
|
|
return game.players.randomGet(game.me,game.zhu);
|
|
|
|
};
|
|
|
|
next.ai=function(player,list,list2){
|
2015-11-07 09:20:15 +00:00
|
|
|
if(_status.event.zhongmode){
|
|
|
|
if(get.config('double_character')){
|
|
|
|
player.init(list[0],list[1]);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
player.init(list[0]);
|
|
|
|
}
|
|
|
|
if(player.identity=='mingzhong'){
|
|
|
|
player.hp++;
|
|
|
|
player.maxHp++;
|
|
|
|
player.update();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(player.identity=='zhu'){
|
2015-05-03 15:17:15 +00:00
|
|
|
list2.randomSort();
|
2015-04-29 03:25:17 +00:00
|
|
|
var choice,choice2;
|
2015-11-07 09:20:15 +00:00
|
|
|
if(!_status.event.zhongmode&&Math.random()-0.8<0&&list2.length){
|
2015-04-29 03:25:17 +00:00
|
|
|
choice=list2[0];
|
|
|
|
choice2=list[0];
|
|
|
|
if(choice2==choice){
|
|
|
|
choice2=list[1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
choice=list[0];
|
|
|
|
choice2=list[1];
|
|
|
|
}
|
|
|
|
if(get.config('double_character')){
|
|
|
|
player.init(choice,choice2);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
player.init(choice);
|
|
|
|
}
|
|
|
|
if(game.players.length>4){
|
|
|
|
player.hp++;
|
|
|
|
player.maxHp++;
|
|
|
|
player.update();
|
|
|
|
}
|
2015-06-10 09:10:24 +00:00
|
|
|
}
|
|
|
|
else if(player.identity=='zhong'&&Math.random()<0.5){
|
2015-04-29 03:25:17 +00:00
|
|
|
var choice=0;
|
|
|
|
for(var i=0;i<list.length;i++){
|
|
|
|
if(lib.character[list[i]][1]==game.zhu.group){
|
|
|
|
choice=i;break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(get.config('double_character')){
|
|
|
|
player.init(list[choice],list[choice==0?choice+1:choice-1]);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
player.init(list[choice]);
|
|
|
|
}
|
2015-06-10 09:10:24 +00:00
|
|
|
}
|
|
|
|
else{
|
2015-04-29 03:25:17 +00:00
|
|
|
if(get.config('double_character')){
|
|
|
|
player.init(list[0],list[1]);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
player.init(list[0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
next.content=function(){
|
|
|
|
"step 0"
|
|
|
|
var i;
|
|
|
|
var list;
|
|
|
|
var list2=[];
|
|
|
|
var list3=[];
|
2015-11-07 09:20:15 +00:00
|
|
|
var identityList;
|
|
|
|
if(get.config('identity_mode')=='zhong'){
|
|
|
|
event.zhongmode=true;
|
|
|
|
identityList=['zhu','zhong','mingzhong','nei','fan','fan','fan','fan'];
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
identityList=lib.config.mode_config.identity.identity[game.players.length-2].slice(0);
|
|
|
|
if(get.config('player_number')=='8'&&get.config('double_nei')){
|
|
|
|
identityList.remove('fan');
|
|
|
|
identityList.push('nei');
|
|
|
|
}
|
2015-11-06 10:05:08 +00:00
|
|
|
}
|
2015-11-07 09:20:15 +00:00
|
|
|
|
2015-04-29 03:25:17 +00:00
|
|
|
var addSetting=function(dialog){
|
2015-05-01 06:16:03 +00:00
|
|
|
dialog.add('选择身份');
|
2015-04-29 03:25:17 +00:00
|
|
|
var table=document.createElement('table');
|
|
|
|
table.style.margin='0 auto';
|
2015-11-25 12:34:54 +00:00
|
|
|
table.style.maxWidth='400px';
|
2015-04-29 03:25:17 +00:00
|
|
|
var tr=document.createElement('tr');
|
|
|
|
table.appendChild(tr);
|
2015-11-07 09:20:15 +00:00
|
|
|
var list;
|
|
|
|
if(event.zhongmode){
|
|
|
|
list=['random','zhu','mingzhong','zhong','nei','fan'];
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
list=['random','zhu','zhong','nei','fan'];
|
|
|
|
}
|
|
|
|
|
|
|
|
for(var i=0;i<list.length;i++){
|
2015-04-29 03:25:17 +00:00
|
|
|
var td=document.createElement('td');
|
|
|
|
tr.appendChild(td);
|
|
|
|
td.link=list[i];
|
2015-11-25 12:34:54 +00:00
|
|
|
td.style.fontSize='25px';
|
|
|
|
td.style.fontFamily='xinwei';
|
2015-05-01 06:16:03 +00:00
|
|
|
if(td.link===game.me.identity){
|
|
|
|
td.classList.add('thundertext');
|
|
|
|
}
|
2015-04-29 03:25:17 +00:00
|
|
|
td.innerHTML=get.translation(list[i]+'2');
|
|
|
|
td.addEventListener(lib.config.touchscreen?'touchend':'click',function(){
|
|
|
|
if(_status.dragged) return;
|
2015-12-12 08:37:15 +00:00
|
|
|
if(_status.justdragged) return;
|
2015-11-14 15:48:04 +00:00
|
|
|
_status.tempNoButton=true;
|
|
|
|
setTimeout(function(){
|
|
|
|
_status.tempNoButton=false;
|
|
|
|
},500);
|
2015-04-29 03:25:17 +00:00
|
|
|
if(game.zhu.name){
|
|
|
|
game.zhu.uninit();
|
2015-11-07 09:20:15 +00:00
|
|
|
delete game.zhu.isZhu;
|
2015-04-29 03:25:17 +00:00
|
|
|
delete game.zhu.identityShown;
|
|
|
|
}
|
|
|
|
dialog.close();
|
|
|
|
_status.event=_status.event.parent;
|
|
|
|
_status.event.step=0;
|
|
|
|
if(this.link!='random'){
|
|
|
|
_status.event.identity=this.link;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
delete _status.event.identity;
|
|
|
|
}
|
|
|
|
game.resume();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
dialog.content.appendChild(table);
|
2015-05-01 06:16:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
dialog.add('选择座位');
|
|
|
|
var seats=document.createElement('table');
|
|
|
|
seats.style.margin='0 auto';
|
2015-11-25 12:34:54 +00:00
|
|
|
seats.style.maxWidth=(60*(parseInt(get.config('player_number'))-1))+'px';
|
2015-05-01 06:16:03 +00:00
|
|
|
var tr=document.createElement('tr');
|
|
|
|
seats.appendChild(tr);
|
|
|
|
for(var i=2;i<=game.players.length;i++){
|
|
|
|
var td=document.createElement('td');
|
|
|
|
tr.appendChild(td);
|
|
|
|
td.style.width='40px';
|
2015-11-25 12:34:54 +00:00
|
|
|
td.style.fontSize='25px';
|
|
|
|
td.style.fontFamily='xinwei';
|
2015-05-01 06:16:03 +00:00
|
|
|
td.innerHTML=get.cnNumber(i,true);
|
|
|
|
td.link=i-1;
|
|
|
|
if(get.distance(game.zhu,game.me,'absolute')===i-1){
|
|
|
|
td.classList.add('thundertext');
|
|
|
|
}
|
|
|
|
td.addEventListener(lib.config.touchscreen?'touchend':'click',function(){
|
|
|
|
if(_status.dragged) return;
|
2015-12-12 08:37:15 +00:00
|
|
|
if(_status.justdragged) return;
|
2015-05-01 06:16:03 +00:00
|
|
|
if(get.distance(game.zhu,game.me,'absolute')==this.link) return;
|
|
|
|
var current=this.parentNode.querySelector('.thundertext');
|
|
|
|
if(current){
|
|
|
|
current.classList.remove('thundertext');
|
|
|
|
}
|
|
|
|
this.classList.add('thundertext');
|
|
|
|
for(var i=0;i<game.players.length;i++){
|
|
|
|
if(get.distance(game.players[i],game.me,'absolute')==this.link){
|
|
|
|
game.swapSeat(game.zhu,game.players[i],false);return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
dialog.content.appendChild(seats);
|
|
|
|
if(game.me==game.zhu){
|
|
|
|
seats.previousSibling.style.display='none';
|
|
|
|
seats.style.display='none';
|
|
|
|
}
|
|
|
|
|
2015-04-29 03:25:17 +00:00
|
|
|
dialog.add(ui.create.div('.placeholder'));
|
|
|
|
dialog.add(ui.create.div('.placeholder'));
|
|
|
|
dialog.add(ui.create.div('.placeholder'));
|
|
|
|
};
|
2015-05-01 06:16:03 +00:00
|
|
|
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').nextSibling.remove();
|
|
|
|
dialog.querySelector('table').nextSibling.remove();
|
|
|
|
dialog.querySelector('table').remove();
|
|
|
|
}
|
|
|
|
};
|
2015-04-29 03:25:17 +00:00
|
|
|
event.addSetting=addSetting;
|
2015-05-01 06:16:03 +00:00
|
|
|
event.removeSetting=removeSetting;
|
2015-04-29 03:25:17 +00:00
|
|
|
event.list=[];
|
2015-05-03 15:17:15 +00:00
|
|
|
identityList.randomSort();
|
2015-04-29 03:25:17 +00:00
|
|
|
if(event.identity){
|
|
|
|
identityList.remove(event.identity);
|
|
|
|
identityList.unshift(event.identity);
|
|
|
|
delete event.identity;
|
|
|
|
}
|
|
|
|
for(i=0;i<game.players.length;i++){
|
|
|
|
game.players[i].identity=identityList[i];
|
|
|
|
game.players[i].setIdentity('cai');
|
2015-11-07 09:20:15 +00:00
|
|
|
if(event.zhongmode){
|
|
|
|
if(identityList[i]=='mingzhong'){
|
|
|
|
game.zhu=game.players[i];
|
|
|
|
}
|
|
|
|
else if(identityList[i]=='zhu'){
|
|
|
|
game.zhu2=game.players[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
if(identityList[i]=='zhu'){
|
|
|
|
game.zhu=game.players[i];
|
|
|
|
}
|
2015-04-29 03:25:17 +00:00
|
|
|
}
|
|
|
|
game.players[i].identityShown=false;
|
|
|
|
}
|
|
|
|
game.zhu.setIdentity();
|
|
|
|
game.zhu.identityShown=true;
|
2015-11-07 09:20:15 +00:00
|
|
|
game.zhu.isZhu=(game.zhu.identity=='zhu');
|
2015-04-29 03:25:17 +00:00
|
|
|
game.me.setIdentity();
|
|
|
|
for(i in lib.character){
|
2015-12-07 11:15:35 +00:00
|
|
|
if(lib.character[i][4]&&lib.character[i][4].contains('forbidai')) continue;
|
2015-04-29 03:25:17 +00:00
|
|
|
if(lib.config.forbidai.contains(i)) continue;
|
|
|
|
if(lib.config.forbidall.contains(i)) continue;
|
2015-12-06 15:23:47 +00:00
|
|
|
if(lib.config.banned.contains(i)) continue;
|
2015-11-18 03:39:14 +00:00
|
|
|
if(!get.config('double_character')&&get.config('ban_weak')&&
|
|
|
|
(lib.config.forbidsingle.contains(i)||lib.rank.c.contains(i)||lib.rank.d.contains(i))) continue;
|
|
|
|
if(get.config('ban_strong')&&(lib.rank.s.contains(i)||lib.rank.ap.contains(i))) continue;
|
2015-04-29 03:25:17 +00:00
|
|
|
if(get.config('double_character')&&lib.config.forbiddouble.contains(i)) continue;
|
|
|
|
event.list.push(i);
|
|
|
|
if(lib.character[i][4]&&lib.character[i][4].contains('zhu')){
|
|
|
|
list2.push(i);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
list3.push(i);
|
|
|
|
}
|
|
|
|
}
|
2015-05-03 15:17:15 +00:00
|
|
|
event.list.randomSort();
|
|
|
|
list3.randomSort();
|
2015-11-28 07:19:04 +00:00
|
|
|
var num=get.config('choice_'+game.me.identity);
|
2015-11-07 09:20:15 +00:00
|
|
|
if(event.zhongmode){
|
|
|
|
num=3;
|
|
|
|
}
|
2015-04-29 03:25:17 +00:00
|
|
|
if(game.zhu!=game.me){
|
|
|
|
event.ai(game.zhu,event.list,list2)
|
|
|
|
event.list.remove(game.zhu.name);
|
|
|
|
event.list.remove(game.zhu.name2);
|
|
|
|
list=event.list.splice(0,num);
|
|
|
|
}
|
|
|
|
else{
|
2015-11-07 09:20:15 +00:00
|
|
|
if(event.zhongmode){
|
|
|
|
list=list3.slice(0,6);
|
|
|
|
}
|
|
|
|
else{
|
2015-11-10 10:13:53 +00:00
|
|
|
list=list2.concat(list3.slice(0,num));
|
2015-11-07 09:20:15 +00:00
|
|
|
}
|
2015-04-29 03:25:17 +00:00
|
|
|
}
|
|
|
|
var dialog=ui.create.dialog('选择角色',[list,'character']);
|
|
|
|
if(get.config('change_identity')){
|
|
|
|
addSetting(dialog);
|
|
|
|
}
|
|
|
|
game.me.chooseButton(dialog,true).selectButton=function(){
|
|
|
|
return get.config('double_character')?2:1
|
|
|
|
};
|
|
|
|
ui.create.cheat=function(){
|
2015-09-03 03:49:14 +00:00
|
|
|
_status.createControl=ui.cheat2;
|
2015-04-29 03:25:17 +00:00
|
|
|
ui.cheat=ui.create.control('更换',function(){
|
2015-05-08 08:07:38 +00:00
|
|
|
if(ui.cheat2&&ui.cheat2.dialog==_status.event.dialog){
|
|
|
|
return;
|
|
|
|
}
|
2015-04-29 03:25:17 +00:00
|
|
|
if(game.zhu!=game.me){
|
|
|
|
event.list=event.list.concat(list);
|
2015-05-03 15:17:15 +00:00
|
|
|
event.list.randomSort();
|
2015-04-29 03:25:17 +00:00
|
|
|
list=event.list.splice(0,num);
|
|
|
|
}
|
|
|
|
else{
|
2015-05-03 15:17:15 +00:00
|
|
|
list3.randomSort();
|
2015-04-29 03:25:17 +00:00
|
|
|
list=list3.slice(0,num).concat(list2);
|
|
|
|
}
|
|
|
|
_status.event.dialog.close();
|
|
|
|
_status.event.dialog=ui.create.dialog('选择角色',[list,'character']);
|
|
|
|
if(get.config('change_identity')){
|
|
|
|
addSetting(_status.event.dialog);
|
|
|
|
}
|
|
|
|
game.uncheck();
|
|
|
|
game.check();
|
|
|
|
});
|
2015-09-03 03:49:14 +00:00
|
|
|
delete _status.createControl;
|
2015-04-29 03:25:17 +00:00
|
|
|
};
|
2015-05-02 09:54:39 +00:00
|
|
|
event.dialogxx=ui.create.characterDialog();
|
2015-04-29 03:25:17 +00:00
|
|
|
ui.create.cheat2=function(){
|
|
|
|
ui.cheat2=ui.create.control('自由选将',function(){
|
|
|
|
if(this.dialog==_status.event.dialog){
|
|
|
|
this.dialog.close();
|
|
|
|
_status.event.dialog=this.backup;
|
|
|
|
this.backup.open();
|
|
|
|
delete this.backup;
|
|
|
|
game.uncheck();
|
|
|
|
game.check();
|
2015-09-03 03:49:14 +00:00
|
|
|
if(ui.cheat){
|
|
|
|
ui.cheat.style.opacity=1;
|
|
|
|
}
|
2015-04-29 03:25:17 +00:00
|
|
|
if(ui.cheat2x){
|
|
|
|
ui.cheat2x.close();
|
|
|
|
delete ui.cheat2x;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
2015-05-02 09:54:39 +00:00
|
|
|
ui.cheat2x=ui.create.groupControl(_status.event.parent.dialogxx);
|
2015-04-29 03:25:17 +00:00
|
|
|
this.backup=_status.event.dialog;
|
|
|
|
_status.event.dialog.close();
|
|
|
|
_status.event.dialog=_status.event.parent.dialogxx;
|
|
|
|
this.dialog=_status.event.dialog;
|
|
|
|
this.dialog.open();
|
|
|
|
game.uncheck();
|
|
|
|
game.check();
|
2015-09-03 03:49:14 +00:00
|
|
|
if(ui.cheat){
|
|
|
|
ui.cheat.style.opacity=0.6;
|
|
|
|
}
|
2015-04-29 03:25:17 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
if(!ui.cheat&&get.config('change_choice'))
|
|
|
|
ui.create.cheat();
|
|
|
|
if(!ui.cheat2&&get.config('free_choose'))
|
|
|
|
ui.create.cheat2();
|
|
|
|
"step 1"
|
|
|
|
if(ui.cheat){
|
|
|
|
ui.cheat.close();
|
|
|
|
delete ui.cheat;
|
|
|
|
}
|
|
|
|
if(ui.cheat2){
|
|
|
|
ui.cheat2.close();
|
|
|
|
delete ui.cheat2;
|
|
|
|
}
|
|
|
|
if(ui.cheat2x){
|
|
|
|
ui.cheat2x.close();
|
|
|
|
delete ui.cheat2x;
|
|
|
|
}
|
|
|
|
if(result.buttons.length==2){
|
|
|
|
game.me.init(result.buttons[0].link,result.buttons[1].link)
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
game.me.init(result.buttons[0].link)
|
|
|
|
}
|
|
|
|
event.list.remove(game.me.name);
|
|
|
|
event.list.remove(game.me.name2);
|
2015-11-07 09:20:15 +00:00
|
|
|
if(game.me==game.zhu&&game.players.length>4){
|
2015-04-29 03:25:17 +00:00
|
|
|
game.me.hp++;
|
|
|
|
game.me.maxHp++;
|
|
|
|
game.me.update();
|
|
|
|
}
|
|
|
|
for(var i=0;i<game.players.length;i++){
|
|
|
|
if(game.players[i]!=game.zhu&&game.players[i]!=game.me){
|
|
|
|
event.ai(game.players[i],
|
2015-11-28 07:19:04 +00:00
|
|
|
event.list.splice(0,get.config('choice_'+game.players[i].identity)))
|
2015-04-29 03:25:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
translate:{
|
|
|
|
zhu:"主",
|
|
|
|
zhong:"忠",
|
2015-11-07 09:20:15 +00:00
|
|
|
mingzhong:"忠",
|
2015-04-29 03:25:17 +00:00
|
|
|
nei:"内",
|
|
|
|
fan:"反",
|
|
|
|
cai:"猜",
|
|
|
|
zhu2:"主公",
|
|
|
|
zhong2:"忠臣",
|
2015-11-07 09:20:15 +00:00
|
|
|
mingzhong2:"明忠",
|
2015-04-29 03:25:17 +00:00
|
|
|
nei2:"内奸",
|
|
|
|
fan2:"反贼",
|
|
|
|
random2:"随机",
|
|
|
|
ai_strategy_1:'均衡',
|
|
|
|
ai_strategy_2:'偏反',
|
|
|
|
ai_strategy_3:'偏主',
|
|
|
|
ai_strategy_4:'酱油',
|
|
|
|
ai_strategy_5:'天使',
|
|
|
|
ai_strategy_6:'仇主',
|
|
|
|
},
|
|
|
|
element:{
|
|
|
|
player:{
|
|
|
|
dieSpeak:function(){
|
|
|
|
switch(this.identity){
|
|
|
|
case 'zhu': this.popup('吾降矣',2000);break;
|
|
|
|
case 'zhong': this.popup('呃啊',2000);break;
|
|
|
|
case 'nei': this.popup('啊,被看穿了',2000);break;
|
|
|
|
case 'fan': this.popup('饶命啊',2000);break;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
dieAfter:function(source){
|
|
|
|
this.dieSpeak();
|
|
|
|
if(get.config('show_identity')&&!this.identityShown){
|
|
|
|
this.setIdentity(this.identity);
|
|
|
|
this.identityShown=true;
|
|
|
|
}
|
|
|
|
game.checkResult();
|
|
|
|
if(this.identity=='fan'&&source) source.draw(3);
|
2015-11-07 09:20:15 +00:00
|
|
|
else if(this.identity=='zhong'&&source&&source.identity=='zhu'&&source.isZhu){
|
2015-04-29 03:25:17 +00:00
|
|
|
source.discard(source.get('he'));
|
|
|
|
}
|
|
|
|
if(game.zhu.storage.enhance_zhu&&get.population('fan')<3){
|
|
|
|
game.zhu.removeSkill(game.zhu.storage.enhance_zhu);
|
|
|
|
delete game.zhu.storage.enhance_zhu;
|
|
|
|
}
|
2015-11-07 09:20:15 +00:00
|
|
|
if(this==game.zhong){
|
|
|
|
game.zhu.identityShown=true;
|
|
|
|
game.zhu.ai.shown=1;
|
|
|
|
game.zhu.setIdentity();
|
|
|
|
game.zhu.isZhu=true;
|
|
|
|
delete game.zhong;
|
2015-11-23 10:59:44 +00:00
|
|
|
if(lib.config.animation&&!lib.config.low_performance) game.zhu.$legend();
|
2015-11-07 09:20:15 +00:00
|
|
|
game.delay(2);
|
2015-11-09 03:15:16 +00:00
|
|
|
game.zhu.playerfocus(1000);
|
2015-11-07 09:20:15 +00:00
|
|
|
}
|
2015-12-07 11:15:35 +00:00
|
|
|
if(!this.node.dieidentity){
|
|
|
|
var node=ui.create.div('.damage.dieidentity',get.translation(this.identity+'2'),this);
|
|
|
|
ui.refresh(node);
|
|
|
|
node.style.opacity=1;
|
|
|
|
this.node.dieidentity=node;
|
|
|
|
}
|
|
|
|
var trans=this.style.transform;
|
|
|
|
if(trans){
|
|
|
|
if(trans.indexOf('rotateY')!=-1){
|
|
|
|
this.node.dieidentity.style.transform='rotateY(180deg)';
|
|
|
|
}
|
2015-12-08 13:54:44 +00:00
|
|
|
else if(trans.indexOf('rotateX')!=-1){
|
2015-12-07 11:15:35 +00:00
|
|
|
this.node.dieidentity.style.transform='rotateX(180deg)';
|
|
|
|
}
|
2015-12-08 13:54:44 +00:00
|
|
|
else{
|
|
|
|
this.node.dieidentity.style.transform='';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
this.node.dieidentity.style.transform='';
|
2015-12-07 11:15:35 +00:00
|
|
|
}
|
2015-04-29 03:25:17 +00:00
|
|
|
},
|
|
|
|
logAi:function(targets,card){
|
|
|
|
if(this.ai.shown==1) 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){
|
2015-12-06 15:23:47 +00:00
|
|
|
this.ai.shown+=info.ai.expose;
|
2015-04-29 03:25:17 +00:00
|
|
|
}
|
|
|
|
if(targets.length>0){
|
|
|
|
for(var i=0;i<targets.length;i++){
|
|
|
|
shown=Math.abs(targets[i].ai.shown);
|
|
|
|
if(shown<0.2||targets[i].identity=='nei') c=0;
|
|
|
|
else if(shown<0.4) c=0.5;
|
|
|
|
else if(shown<0.6) c=0.8;
|
|
|
|
else c=1;
|
|
|
|
effect+=ai.get.effect(targets[i],card,this)*c;
|
|
|
|
}
|
|
|
|
}
|
2015-12-06 15:23:47 +00:00
|
|
|
if(effect>0){
|
2015-04-29 03:25:17 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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();
|
2015-12-06 15:23:47 +00:00
|
|
|
if(get.config('ai_identity')||from==to||!lib.config.ai_guess||(to.identityShown)){
|
2015-04-29 03:25:17 +00:00
|
|
|
return ai.get.realAttitude(from,to)+difficulty*1.5;
|
|
|
|
}
|
|
|
|
else{
|
2015-11-06 10:05:08 +00:00
|
|
|
if(from.identity=='zhong'&&to.ai.shown==0&&from.ai.tempIgnore&&
|
|
|
|
!from.ai.tempIgnore.contains(to)){
|
|
|
|
for(var i=0;i<game.players.length;i++){
|
|
|
|
if(game.players[i].ai.shown==0&&game.players[i].identity=='fan'){
|
|
|
|
return -0.1+difficulty*1.5;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-04-29 03:25:17 +00:00
|
|
|
return ai.get.realAttitude(from,to)*to.ai.shown+difficulty*1.5;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
realAttitude:function(from,to){
|
2015-11-06 10:05:08 +00:00
|
|
|
// if(_status.currentPhase==from&&from.ai.tempIgnore&&from.ai.tempIgnore.contains(to)) return 0;
|
2015-04-29 03:25:17 +00:00
|
|
|
var situation=ai.get.situation();
|
2015-11-07 09:20:15 +00:00
|
|
|
var identity=from.identity;
|
2015-04-29 03:25:17 +00:00
|
|
|
var identity2=to.identity;
|
2015-11-07 09:20:15 +00:00
|
|
|
if(identity2=='zhu'&&!to.isZhu){
|
|
|
|
identity2='zhong';
|
|
|
|
if(from==to) return 10;
|
|
|
|
}
|
|
|
|
var zhongmode=false;
|
|
|
|
if(!game.zhu.isZhu){
|
|
|
|
zhongmode=true;
|
|
|
|
}
|
2015-04-29 03:25:17 +00:00
|
|
|
switch(identity){
|
|
|
|
case 'zhu':
|
|
|
|
switch(identity2){
|
|
|
|
case 'zhu': return 10;
|
2015-11-07 09:20:15 +00:00
|
|
|
case 'zhong':case 'mingzhong': return 6;
|
2015-04-29 03:25:17 +00:00
|
|
|
case 'nei':
|
|
|
|
if(game.players.length==2) return -10;
|
2015-11-06 10:05:08 +00:00
|
|
|
if(get.population('fan')==0) return -0.5;
|
2015-05-11 11:57:44 +00:00
|
|
|
if(situation>1) return 0;
|
2015-04-29 03:25:17 +00:00
|
|
|
return Math.min(3,get.population('fan'));
|
|
|
|
case 'fan': return -4;
|
|
|
|
}
|
2015-05-11 11:57:44 +00:00
|
|
|
break;
|
2015-11-07 09:20:15 +00:00
|
|
|
case 'zhong':case 'mingzhong':
|
2015-04-29 03:25:17 +00:00
|
|
|
switch(identity2){
|
|
|
|
case 'zhu': return 10;
|
2015-11-07 09:20:15 +00:00
|
|
|
case 'zhong':case 'mingzhong': return 4;
|
2015-04-29 03:25:17 +00:00
|
|
|
case 'nei':
|
|
|
|
if(get.population('fan')==0) return -2;
|
2015-05-11 11:57:44 +00:00
|
|
|
return Math.min(3,-situation);
|
2015-04-29 03:25:17 +00:00
|
|
|
case 'fan': return -8;
|
|
|
|
}
|
2015-05-11 11:57:44 +00:00
|
|
|
break;
|
2015-04-29 03:25:17 +00:00
|
|
|
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;
|
2015-12-06 15:23:47 +00:00
|
|
|
if(get.population('fan')==1){
|
|
|
|
var fan;
|
|
|
|
for(var i=0;i<game.players.length;i++){
|
|
|
|
if(game.players[i].identity=='fan'){
|
|
|
|
fan=game.players[i];break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(fan){
|
|
|
|
if(to.hp>1&&to.hp>fan.hp&&to.num('he')>fan.num('he')){
|
|
|
|
return -3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
if(situation>1||get.population('fan')==0) num=0;
|
|
|
|
else num=get.population('fan')+Math.max(0,3-game.zhu.hp);
|
|
|
|
}
|
2015-04-29 03:25:17 +00:00
|
|
|
if(strategy==2) num--;
|
|
|
|
if(strategy==3) num++;
|
|
|
|
return num;
|
|
|
|
case 'zhong':
|
2015-05-11 11:57:44 +00:00
|
|
|
if(strategy==5) return Math.min(0,-situation);
|
|
|
|
if(strategy==6) return Math.max(-1,-situation);
|
2015-04-29 03:25:17 +00:00
|
|
|
if(get.population('fan')==0) num=-5;
|
2015-05-11 11:57:44 +00:00
|
|
|
else if(situation<=0) num=0;
|
2015-04-29 03:25:17 +00:00
|
|
|
else if(game.zhu&&game.zhu.hp<2) num=0;
|
2015-11-06 10:05:08 +00:00
|
|
|
else if(game.zhu&&game.zhu.hp==2) num=-1;
|
|
|
|
else if(game.zhu&&game.zhu.hp<=2&&situation>1) num=-1;
|
2015-04-29 03:25:17 +00:00
|
|
|
else num=-2;
|
2015-11-07 09:20:15 +00:00
|
|
|
if(zhongmode&&situation<2){
|
|
|
|
num=4;
|
|
|
|
}
|
|
|
|
if(strategy==2) num--;
|
|
|
|
if(strategy==3) num++;
|
|
|
|
return num;
|
|
|
|
case 'mingzhong':
|
|
|
|
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 num=-3;
|
2015-04-29 03:25:17 +00:00
|
|
|
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;
|
2015-11-06 10:05:08 +00:00
|
|
|
if(get.population('fan')+get.population('zhong')>0) return 0;
|
2015-04-29 03:25:17 +00:00
|
|
|
return -1;
|
|
|
|
case 'fan':
|
2015-05-11 11:57:44 +00:00
|
|
|
if(strategy==5) return Math.max(-1,situation);
|
|
|
|
if(strategy==6) return Math.min(0,situation);
|
2015-11-06 10:05:08 +00:00
|
|
|
if((game.zhu&&game.zhu.hp<=2&&situation<0)||situation<-1) num=-3;
|
2015-11-07 09:20:15 +00:00
|
|
|
else if(situation<0||get.population('zhong')+get.population('mingzhong')==0) num=-2;
|
2015-11-06 10:05:08 +00:00
|
|
|
else if((game.zhu&&game.zhu.hp>=4&&situation>0)||situation>1) num=1;
|
2015-04-29 03:25:17 +00:00
|
|
|
else num=0;
|
|
|
|
if(strategy==2) num++;
|
|
|
|
if(strategy==3) num--;
|
|
|
|
return num;
|
|
|
|
}
|
2015-05-11 11:57:44 +00:00
|
|
|
break;
|
2015-04-29 03:25:17 +00:00
|
|
|
case 'fan':
|
|
|
|
switch(identity2){
|
|
|
|
case 'zhu':
|
2015-11-07 00:01:37 +00:00
|
|
|
if(get.population('nei')>0){
|
|
|
|
if(situation==1) return -6;
|
|
|
|
if(situation>1) return -5;
|
|
|
|
}
|
2015-04-29 03:25:17 +00:00
|
|
|
return -10;
|
|
|
|
case 'zhong': return -7;
|
2015-11-07 09:20:15 +00:00
|
|
|
case 'mingzhong':return -5;
|
2015-04-29 03:25:17 +00:00
|
|
|
case 'nei':
|
2015-12-06 15:23:47 +00:00
|
|
|
if(get.population('fan')==1) return 0;
|
2015-11-07 09:20:15 +00:00
|
|
|
if(get.population('zhong')+get.population('mingzhong')==0) return -7;
|
2015-04-29 03:25:17 +00:00
|
|
|
if(game.zhu&&game.zhu.hp<=2) return -1;
|
2015-05-11 11:57:44 +00:00
|
|
|
return Math.min(3,situation);
|
2015-04-29 03:25:17 +00:00
|
|
|
case 'fan': return 5;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
situation:function(absolute){
|
|
|
|
var i,j,player;
|
|
|
|
var zhuzhong=0,total=0,zhu,fan=0;
|
|
|
|
for(i=0;i<game.players.length;i++){
|
|
|
|
player=game.players[i];
|
2015-11-06 10:05:08 +00:00
|
|
|
var php=player.hp;
|
|
|
|
if(player.skills.contains('benghuai')&&php>4){
|
|
|
|
php=4;
|
2015-04-29 03:25:17 +00:00
|
|
|
}
|
2015-12-07 11:15:35 +00:00
|
|
|
else if(php>6){
|
|
|
|
php=6;
|
|
|
|
}
|
2015-11-06 10:05:08 +00:00
|
|
|
j=player.get('h').length+player.get('e').length*1.5+php*2;
|
2015-04-29 03:25:17 +00:00
|
|
|
if(player.identity=='zhu'){
|
|
|
|
zhuzhong+=j*1.2+5;
|
|
|
|
total+=j*1.2+5;
|
|
|
|
zhu=j;
|
|
|
|
}
|
2015-11-07 09:20:15 +00:00
|
|
|
else if(player.identity=='zhong'||player.identity=='mingzhong'){
|
2015-04-29 03:25:17 +00:00
|
|
|
zhuzhong+=j*0.8+3;
|
|
|
|
total+=j*0.8+3;
|
|
|
|
}
|
|
|
|
else if(player.identity=='fan'){
|
|
|
|
zhuzhong-=j+4;
|
|
|
|
total+=j+4;
|
|
|
|
fan+=j+4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(absolute) return zhuzhong;
|
|
|
|
var result=parseInt(10*Math.abs(zhuzhong/total));
|
|
|
|
if(zhuzhong<0) result=-result;
|
2015-11-07 09:20:15 +00:00
|
|
|
if(!game.zhong){
|
|
|
|
if(zhu<12&&fan>30) result--;
|
|
|
|
if(zhu<6&&fan>15) result--;
|
|
|
|
if(zhu<4) result--;
|
|
|
|
}
|
2015-04-29 03:25:17 +00:00
|
|
|
return result;
|
|
|
|
},
|
|
|
|
population:function(identity){
|
|
|
|
return get.population(identity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
ui:{
|
|
|
|
click:{
|
2015-11-30 13:08:29 +00:00
|
|
|
// identity:function(){
|
|
|
|
// if(_status.dragged) return;
|
|
|
|
// _status.clicked=true;
|
|
|
|
// if(this.parentNode.identityShown) return;
|
|
|
|
// if(this.parentNode==game.me) return;
|
|
|
|
// if(get.config('identity_mode')=='zhong'){
|
|
|
|
// 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='zhu';break;
|
|
|
|
// case '主':this.firstChild.innerHTML='猜';this.dataset.color='cai';break;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// else{
|
|
|
|
// 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;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
2015-04-29 03:25:17 +00:00
|
|
|
}
|
|
|
|
},
|
2015-05-04 03:17:03 +00:00
|
|
|
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']
|
2015-04-29 03:25:17 +00:00
|
|
|
}
|