dcweiwan ai减少复杂度
This commit is contained in:
parent
4690e51b32
commit
75021b08eb
|
@ -171,10 +171,13 @@ game.import('character',function(lib,game,ui,get,ai,_status){
|
||||||
},
|
},
|
||||||
position:'h',
|
position:'h',
|
||||||
check:(card)=>{
|
check:(card)=>{
|
||||||
let player=_status.event.player;
|
const player=_status.event.player;
|
||||||
let targets=game.filterPlayer(target=>target!=player&&lib.skill.dcweiwan.ai.result.target(player,target)!=0);
|
const target = game.players.reduce((result, current) => {
|
||||||
targets.sort((a,b)=>Math.abs(lib.skill.dcweiwan.ai.result.target(player,b))-Math.abs(lib.skill.dcweiwan.ai.result.target(player,a)));
|
if (current === player) return result;
|
||||||
return lib.skill.dcweiwan.getWeiWanEffect(player,card,targets[0]);
|
const effect = Math.abs(lib.skill.dcweiwan.ai.result.target(player, current));
|
||||||
|
return effect > result[1] ? [current, effect] : result;
|
||||||
|
}, [null, 0])[0];
|
||||||
|
return target?lib.skill.dcweiwan.getWeiWanEffect(player,card,target):0;
|
||||||
},
|
},
|
||||||
usable:1,
|
usable:1,
|
||||||
content:function*(event,map){
|
content:function*(event,map){
|
||||||
|
@ -218,35 +221,29 @@ game.import('character',function(lib,game,ui,get,ai,_status){
|
||||||
order:9,
|
order:9,
|
||||||
result:{
|
result:{
|
||||||
target:(player,target)=>{
|
target:(player,target)=>{
|
||||||
let att=get.sgn(get.attitude(player,target))-1;
|
const att=get.sgn(get.attitude(player,target))-1;
|
||||||
let cards=player.getCards(lib.skill.dcweiwan.position,card=>{
|
const cards=player.getCards(lib.skill.dcweiwan.position,card=>lib.skill.dcweiwan.filterCard(card,player));
|
||||||
return lib.skill.dcweiwan.filterCard(card,player);
|
return att * cards.reduce((result, card) => {
|
||||||
});
|
const effect = lib.skill.dcweiwan.getWeiWanEffect(player, card, target);
|
||||||
cards.sort((a,b)=>lib.skill.dcweiwan.getWeiWanEffect(player,b,target)-lib.skill.dcweiwan.getWeiWanEffect(player,a,target));
|
return effect > result ? effect : result;
|
||||||
return att*lib.skill.dcweiwan.getWeiWanEffect(player,cards[0],target);
|
},0);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
getWeiWanEffect:(player,cardx,target)=>{
|
getWeiWanEffect:(player,cardx,target)=>{
|
||||||
let suit=get.suit(cardx,player);
|
const suit=get.suit(cardx,player);
|
||||||
let cards=target.getCards('hej',card=>get.suit(card,target)!=suit&&lib.filter.canBeGained(card,player,target));
|
const cards=target.getCards('hej',card=>get.suit(card,target)!==suit&&lib.filter.canBeGained(card,player,target));
|
||||||
if(!cards.length) return 0;
|
const num=lib.suits.filter(suit=>cards.some(card=>get.suit(card,target)===suit)).length;
|
||||||
let suits=lib.suit.slice();
|
|
||||||
suits.reverse();
|
|
||||||
suits.add('none');
|
|
||||||
let num=suits.filter(suit2=>cards.some(card=>get.suit(card,target)==suit2)).length;
|
|
||||||
switch(num){
|
switch(num){
|
||||||
case 1:
|
case 1:
|
||||||
num+=Math.max(0,get.sgn(get.effect(target,{name:'losehp'},player,player)));
|
return num+Math.max(0,get.sgn(get.effect(target,{name:'losehp'},player,player)));
|
||||||
break;
|
|
||||||
case 2:
|
case 2:
|
||||||
num+=player.countCards('he',card=>player.canUse(card,target,false)&&get.effect(target,card,player,player)>0);
|
return num+player.countCards('he',card=>player.canUse(card,target,false)&&get.effect(target,card,player,player)>0);
|
||||||
break;
|
|
||||||
case 3:
|
case 3:
|
||||||
num=Math.ceil(num/2);
|
return Math.ceil(num / 2);
|
||||||
break;
|
default:
|
||||||
|
return num;
|
||||||
}
|
}
|
||||||
return num;
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
//董昭
|
//董昭
|
||||||
|
|
Loading…
Reference in New Issue