更新needsToDiscard的相关调用

顺便修复武诸葛亮【智哲】牌ai
This commit is contained in:
157 2023-12-29 15:59:41 +08:00
parent 81385a8fe4
commit c42da2ac0b
13 changed files with 62 additions and 99 deletions

View File

@ -1401,10 +1401,7 @@ game.import('card',function(lib,game,ui,get,ai,_status){
result:{
target:function(player,current){
if(current.hasSkill('gw_qinpendayu')) return 0;
if(current.needsToDiscard()) return -1;
if(current.needsToDiscard(1)) return -0.7;
if(current.needsToDiscard(2)) return -0.4;
return -0.1;
return Math.max(-1,-0.1-0.3*current.needsToDiscard(2));
}
},
order:1.2,

View File

@ -256,9 +256,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
var player=_status.event.player;
var card={name:button.link[2],nature:button.link[3],isCard:true};
if(card.name=='tao'){
if(player.hp==1||(player.hp==2&&!player.hasShan())||player.needsToDiscard()){
return 5;
}
if(player.hp==1||(player.hp==2&&!player.hasShan())||player.needsToDiscard()) return 5;
return 1;
}
if(card.name=='sha'){

View File

@ -5078,12 +5078,8 @@ game.import('character',function(lib,game,ui,get,ai,_status){
if(!target.hasFriend()) return;
var num=1;
if(get.attitude(player,target)>0){
if(player.needsToDiscard()){
num=0.7;
}
else{
num=0.5;
}
if(player.needsToDiscard()) num=0.7;
else num=0.5;
}
if(target.hp>=4) return [1,num*2.5];
if(target.hp==3) return [1,num*1.5];

View File

@ -804,7 +804,9 @@ game.import('character',function(lib,game,ui,get,ai,_status){
return trigger.targets.contains(target);
},
ai1:function(card){
if(!player.needsToDiscard(ui.selected.cards.length)) return 0;
if(!player.needsToDiscard(0,(i,player)=>{
return !ui.selected.cards.includes(i)&&!player.canIgnoreHandcard(i);
})) return 0;
if(ui.selected.cards.length>=num2) return 0;
return Math.max(5,get.value(trigger.card))-get.value(card)-1;
},

View File

@ -5060,12 +5060,8 @@ game.import('character',function(lib,game,ui,get,ai,_status){
if(!moveCard||!target.hasFriend()) return;
var num=1;
if(get.attitude(player,target)>0){
if(player.needsToDiscard()){
num=0.5;
}
else{
num=0.3;
}
if(player.needsToDiscard()) num=0.5;
else num=0.3;
}
if(target.hp>=4) return [1,num*2];
if(target.hp==3) return [1,num*1.5];

View File

@ -4306,7 +4306,9 @@ game.import('character',function(lib,game,ui,get,ai,_status){
selectCard:(player.getStat('skill').buxu||0)+1,
ai1:function(card){
var player=_status.event.player;
if(player.needsToDiscard()>ui.selected.cards.length) return 10/Math.max(0.1,get.value(card));
if(player.needsToDiscard(0,(i,player)=>{
return !ui.selected.cards.includes(i)&&!player.canIgnoreHandcard(i);
})) return 10/Math.max(0.1,get.value(card));
return 5-(player.getStat('skill').buxu||0)-get.value(card);
},
ai2:()=>1,
@ -11316,12 +11318,8 @@ game.import('character',function(lib,game,ui,get,ai,_status){
if(!target.hasFriend()) return;
var num=1;
if(get.attitude(player,target)>0){
if(player.needsToDiscard()){
num=0.7;
}
else{
num=0.5;
}
if(player.needsToDiscard()) num=0.7;
else num=0.5;
}
if(target.hp>=4) return [1,num*2];
if(target.hp==3) return [1,num*1.5];

View File

@ -6510,7 +6510,9 @@ game.import('character',function(lib,game,ui,get,ai,_status){
},
true
)) return 6.5 - get.value(card, player);
if (Math.random() * target.countCards('hs') < 1 || player.needsToDiscard(-ui.selected.cards.length)) return 6 - get.value(card, player);
if (Math.random() * target.countCards('hs') < 1 || player.needsToDiscard(0,(i,player)=>{
return !ui.selected.cards.includes(i)&&!player.canIgnoreHandcard(i);
})) return 6 - get.value(card, player);
return 0;
}
return 6.3 - get.value(card);
@ -11766,12 +11768,8 @@ game.import('character',function(lib,game,ui,get,ai,_status){
if(!target.hasFriend()) return;
var num=1;
if(get.attitude(player,target)>0){
if(player.needsToDiscard()){
num=0.7;
}
else{
num=0.5;
}
if(player.needsToDiscard()) num=0.7;
else num=0.5;
}
if(player.hp>=4) return [1,num*2];
if(target.hp==3) return [1,num*1.5];
@ -12108,7 +12106,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
return player!=target;
},
ai1:function(card){
if(get.attitude(_status.event.player,_status.currentPhase)<0&&_status.currentPhase.needsToDiscard()&&card.name!='du') return -1;
if(card.name!='du'&&get.attitude(_status.event.player,_status.currentPhase)<0&&_status.currentPhase.needsToDiscard()) return -1;
for(var i=0;i<ui.selected.cards.length;i++){
if(get.type(ui.selected.cards[i])==get.type(card)||(ui.selected.cards[i].name=='du'&&card.name!='du')) return -1;
}
@ -13665,12 +13663,8 @@ game.import('character',function(lib,game,ui,get,ai,_status){
if(!target.hasFriend()) return;
var num=1;
if(get.attitude(player,target)>0){
if(player.needsToDiscard()){
num=0.7;
}
else{
num=0.5;
}
if(player.needsToDiscard()) num=0.7;
else num=0.5;
}
if(player.hp>=4) return [1,num*2];
if(target.hp==3) return [1,num*1.5];

View File

@ -15204,17 +15204,13 @@ game.import('character',function(lib,game,ui,get,ai,_status){
return target!=player;
}).set('ai',function(target){
if(target.hasJudge('lebu')) return 0;
var att=get.attitude(_status.event.player,target);
let att=get.attitude(_status.event.player,target),name=_status.event.cards[0].name;
if(att<3) return 0;
if(target.hasSkillTag('nogain')) att/=10;
if(target.hasSha()&&_status.event.sha){
att/=5;
}
if(event.wuxie&&target.needsToDiscard(1)){
att/=5;
}
if(name==='sha'&&target.hasSha()) att/=5;
if(name==='wuxie'&&target.needsToDiscard(_status.event.cards)) att/=5;
return att/(1+get.distance(player,target,'absolute'));
}).set('sha',trigger.cards[0].name=='sha').set('wuxie',trigger.cards[0].name=='wuxie');
}).set('cards',trigger.cards);
'step 1'
if(result.bool){
player.logSkill('yingyuan',result.targets[0]);
@ -15288,19 +15284,21 @@ game.import('character',function(lib,game,ui,get,ai,_status){
if(_status.event.du) return -get.value(card,player,'raw');
else if(_status.event.shuimeng){
if(cardname=='wuzhong'){
if(player.needsToDiscard(2-ui.selected.cards.length)){
return 10-get.value(card,player,'raw');
}
if(player.needsToDiscard(2,(i,player)=>{
return !ui.selected.cards.includes(i)&&!player.canIgnoreHandcard(i);
})) return 10-get.value(card,player,'raw');
}
else if(cardname=='guohe'){
if(player.needsToDiscard(-1-ui.selected.cards.length)){
return 10-get.value(card,player,'raw');
}
if(player.needsToDiscard(-1,(i,player)=>{
return !ui.selected.cards.includes(i)&&!player.canIgnoreHandcard(i);
})) return 10-get.value(card,player,'raw');
}
return 0;
}
else if(cardname=='lebu'){
if(player.needsToDiscard(1-ui.selected.cards.length)){
if(player.needsToDiscard(1,(i,player)=>{
return !ui.selected.cards.includes(i)&&!player.canIgnoreHandcard(i);
})){
return 8-get.value(card,player,'raw');
}
else{
@ -17480,9 +17478,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
return 20-num;
}
else{
if(_status.event.player.needsToDiscard()){
return 7-num;
}
if(_status.event.player.needsToDiscard()) return 7-num;
}
return 0;
},

View File

@ -3334,10 +3334,9 @@ game.import('character',function(lib,game,ui,get,ai,_status){
if(num>0&&!player._dczhizhe_mod&&get.itemtype(card)==='card'&&card.hasGaintag('dczhizhe')){
if(player.canIgnoreHandcard(card)) return Infinity;
player._dczhizhe_mod=true;
if(player.hp<3&&player.needsToDiscard(player.countCards('h',(cardx)=>{
if(player.canIgnoreHandcard(cardx)||get.useful(cardx)>6) return true;
return false;
}))) return num*1.5;
if(player.hp<3&&player.needsToDiscard(0,(i,player)=>{
return !player.canIgnoreHandcard(i)&&get.useful(i)>6;
})) return num*1.5;
return num*10;
}
}
@ -3525,12 +3524,8 @@ game.import('character',function(lib,game,ui,get,ai,_status){
if(!target.hasFriend()) return;
var num=1;
if(get.attitude(player,target)>0){
if(player.needsToDiscard()){
num=0.5;
}
else{
num=0.3;
}
if(player.needsToDiscard()) num=0.5;
else num=0.3;
}
if(target.hp>=4) return [1,num*2];
if(target.hp==3) return [1,num*1.5];
@ -3844,12 +3839,8 @@ game.import('character',function(lib,game,ui,get,ai,_status){
if(!target.hasFriend()) return;
var num=1;
if(get.attitude(player,target)>0){
if(player.needsToDiscard()){
num=0.7;
}
else{
num=0.5;
}
if(player.needsToDiscard()) num=0.7;
else num=0.5;
}
if(target.hp==2&&target.hasFriend()) return [1,num*1.5];
if(target.hp>=2) return [1,num];
@ -8268,7 +8259,9 @@ game.import('character',function(lib,game,ui,get,ai,_status){
if(current==player||current.countCards('he')==0) return false;
return get.effect(current,{name:'guohe_copy2'},player,player)+get.effect(current,{name:'sha'},player,player)>0;
})){
if(get.position(card)=='h'&&player.needsToDiscard()>ui.selected.cards.length) return 7+1/Math.max(1,get.value(card));
if(get.position(card)=='h'&&player.needsToDiscard(0,(i,player)=>{
return !ui.selected.cards.includes(i)&&!player.canIgnoreHandcard(i);
})) return 7+1/Math.max(1,get.value(card));
return 7-get.value(card);
}
return 0;

View File

@ -653,9 +653,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
player.chooseTarget('将'+get.translation(result.links)+'交给一名角色',true).ai=function(target){
var att=get.attitude(player,target)/Math.sqrt(target.countCards('h')+1);
if(result.links.length>1){
if(target==player&&target.needsToDiscard(result.links.length)>1){
return att/5;
}
if(target==player&&target.needsToDiscard(result.links)>1) return att/5;
return att;
}
else{
@ -1241,7 +1239,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
}
return false;
}).ai=function(target){
var num=0,eff=0,damaged=false;
var use=[],eff=0,damaged=false;
for(var i=0;i<hs.length;i++){
if(get.info(hs[i]).multitarget) continue;
var hef;
@ -1252,7 +1250,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
hef=get.effect(target,hs[i],player,player);
}
if(lib.filter.targetEnabled2(hs[i],player,target)&&hef>0){
num++;
use.push(hs[i]);
if(get.attitude(player,target)>0){
hef/=1.5;
if(get.tag(hs[i],'damage')){
@ -1262,9 +1260,9 @@ game.import('character',function(lib,game,ui,get,ai,_status){
eff+=hef;
}
}
if(!player.needsToDiscard(-num)){
return eff;
}
if(!player.needsToDiscard(0,(i,player)=>{
return !use.includes(i)&&!player.canIgnoreHandcard(i);
})) return eff;
return 0;
};
'step 1'

View File

@ -1371,19 +1371,13 @@ game.import('character',function(lib,game,ui,get,ai,_status){
if(target==player) return false;
return target.countCards('h')>player.countCards('h')||Math.max(0,target.hp)>Math.max(0,player.hp);
}).set('ai',function(target){
var att=get.attitude(_status.event.player,target);
let att=get.attitude(_status.event.player,target),name=_status.event.cards[0].name;
if(att<3) return 0;
if(target.hasJudge('lebu')){
att/=5;
}
if(target.hasSha()&&_status.event.sha){
att/=5;
}
if(_status.event.wuxie&&target.needsToDiscard(1)){
att/=5;
}
if(target.hasJudge('lebu')) att/=5;
if(name==='sha'&&target.hasSha()) att/=5;
if(name==='wuxie'&&target.needsToDiscard(_status.event.cards)) att/=5;
return att/(1+get.distance(player,target,'absolute'));
}).set('sha',trigger.cards[0].name=='sha').set('wuxie',trigger.cards[0].name=='wuxie');
}).set('cards',trigger.cards);
'step 1'
if(result.bool){
var list=[];

View File

@ -2101,7 +2101,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
if(num>2) return true;
var card=trigger.card;
if(get.tag(card,'damage')&&player.hp<=trigger.getParent().baseDamage&&(!get.tag(card,'respondShan')||!player.hasShan())&&(!get.tag(card,'respondSha')||!player.hasSha())) return true;
var source=_status.currentPhase,todis=(source.countCards('h')-Math.max(0,source.needsToDiscard()));
var source=_status.currentPhase,todis=source.countCards('h')-source.needsToDiscard();
if(todis<=Math.max(Math.min(2+(source.hp<=1?1:0),player.countCards('he',function(card){
return get.value(card,player)<Math.max(5.5,8-todis)
})),player.countCards('he',function(card){
@ -6980,8 +6980,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
effect:{
player:function(card,player,target){
if(_status.currentPhase!=player) return;
if(card.name=='sha'&&!player.needsToDiscard()&&
!player.getExpansions('chunlao').length&&target.hp>1){
if(card.name=='sha'&&!player.needsToDiscard()&&!player.getExpansions('chunlao').length&&target.hp>1){
return 'zeroplayertarget';
}
}

View File

@ -7721,7 +7721,9 @@ export class Player extends HTMLDivElement {
*/
let cards = this.getCards('h'), num = 0;
if (typeof add === 'number') num = add;
else if (get.itemtype(add) === 'cards') cards.addArray(add);
else if (get.itemtype(add) === 'cards') for (let i of add) {
cards.push(add);
}
else if (get.itemtype(add) === 'card') cards.push(add);
if (typeof filter !== 'function') filter = (card, player) => !player.canIgnoreHandcard(card);
cards = cards.filter(card => {