diff --git a/card/gwent.js b/card/gwent.js index 306af8fac..6d62deca4 100644 --- a/card/gwent.js +++ b/card/gwent.js @@ -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, diff --git a/character/collab.js b/character/collab.js index 72983f488..a434637d9 100644 --- a/character/collab.js +++ b/character/collab.js @@ -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'){ diff --git a/character/ddd.js b/character/ddd.js index fce068fcd..c011ba90d 100644 --- a/character/ddd.js +++ b/character/ddd.js @@ -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]; diff --git a/character/hearth.js b/character/hearth.js index 18c39e264..6dbc3332f 100644 --- a/character/hearth.js +++ b/character/hearth.js @@ -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; }, diff --git a/character/jsrg.js b/character/jsrg.js index 0674bc8dc..51de1d0c9 100644 --- a/character/jsrg.js +++ b/character/jsrg.js @@ -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]; diff --git a/character/mobile.js b/character/mobile.js index eb6a97d6f..5d4fdb48f 100644 --- a/character/mobile.js +++ b/character/mobile.js @@ -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]; diff --git a/character/refresh.js b/character/refresh.js index 91379365a..cc636cbe9 100755 --- a/character/refresh.js +++ b/character/refresh.js @@ -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;i0){ - 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]; diff --git a/character/sp.js b/character/sp.js index 835672f4d..0c5443ad1 100755 --- a/character/sp.js +++ b/character/sp.js @@ -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; }, diff --git a/character/xianding.js b/character/xianding.js index c505ba737..6f79143c1 100644 --- a/character/xianding.js +++ b/character/xianding.js @@ -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; diff --git a/character/xianjian.js b/character/xianjian.js index 8ab1d87df..e09d4a26d 100644 --- a/character/xianjian.js +++ b/character/xianjian.js @@ -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;i0){ - 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' diff --git a/character/xinghuoliaoyuan.js b/character/xinghuoliaoyuan.js index 09ef29831..520c40e6d 100755 --- a/character/xinghuoliaoyuan.js +++ b/character/xinghuoliaoyuan.js @@ -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=[]; diff --git a/character/yijiang.js b/character/yijiang.js index d17ad07d3..36746b68c 100755 --- a/character/yijiang.js +++ b/character/yijiang.js @@ -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)1){ + if(card.name=='sha'&&!player.needsToDiscard()&&!player.getExpansions('chunlao').length&&target.hp>1){ return 'zeroplayertarget'; } } diff --git a/noname/library/element/player.js b/noname/library/element/player.js index 9fbffb4c4..dd1e8c677 100644 --- a/noname/library/element/player.js +++ b/noname/library/element/player.js @@ -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 => {