From 322b7ec991a71fb9e90cc2688c6722219aa2f294 Mon Sep 17 00:00:00 2001 From: Spmario233 Date: Sun, 13 Aug 2023 00:47:44 +0800 Subject: [PATCH] rename Disabled to DisabledSlot, removed isEmpty --- character/diy.js | 22 +++--- character/extra.js | 15 ++-- character/huicui.js | 70 +++++++++-------- character/mobile.js | 173 +++++++++++++++++++++--------------------- character/offline.js | 10 +-- character/old.js | 2 +- character/refresh.js | 46 +++++------ character/shenhua.js | 7 +- character/shiji.js | 35 +++++---- character/sp.js | 24 +++--- character/sp2.js | 6 +- character/tw.js | 10 +-- character/xianding.js | 2 +- character/yijiang.js | 4 +- game/game.js | 40 +++++++--- mode/boss.js | 8 +- mode/guozhan.js | 10 +-- 17 files changed, 253 insertions(+), 231 deletions(-) diff --git a/character/diy.js b/character/diy.js index d75785510..6932bae7e 100755 --- a/character/diy.js +++ b/character/diy.js @@ -3447,10 +3447,10 @@ game.import('character',function(lib,game,ui,get,ai,_status){ forced:true, charlotte:true, filter:function(event,player){ - return !player.isDisabled(1); + return player.hasEnabledSlot(1); }, content:function(){ - if(player.isEmpty(1)){ + if(player.hasEmptySlot(1)){ var card=get.cardPile2(function(card){ return get.subtype(card)=='equip1'&&!get.cardtag(card,'gifts')&&player.canUse(card,player); }); @@ -4176,12 +4176,12 @@ game.import('character',function(lib,game,ui,get,ai,_status){ filterCard:function(card,player){ if(!player) player=_status.event.player; return game.hasPlayer(function(current){ - return current!=player&¤t.isEmpty(get.subtype(card,false)); + return current!=player&¤t.canEquip(card); }); }, position:'e', filterTarget:function(card,player,target){ - return target!=player&&target.isEmpty(get.subtype(ui.selected.cards[0],false)); + return target!=player&&target.canEquip(ui.selected.cards[0]); }, check:function(card){ if(get.value(card)<=0) return 10; @@ -6536,7 +6536,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ if(player==target) return false; var card=ui.selected.cards[0]; if(get.type(card,false)=='delay') return target.canAddJudge({name:card.name}); - return target.isEmpty(get.subtype(card,false)); + return target.canEquip(card); }, discard:false, lose:false, @@ -10200,16 +10200,16 @@ game.import('character',function(lib,game,ui,get,ai,_status){ 'step 0' var list=['equip1','equip2','equip3','equip4','equip5']; for(var i=0;i0 })) return 'equip1'; - if(list.contains('equip3')&&player.isEmpty('equip3')) return 'equip3'; - if(list.contains('equip4')&&player.isEmpty('equip4')) return 'equip4'; - if(list.contains('equip5')&&player.isEmpty('equip5')) return 'equip5'; - if(list.contains('equip2')&&player.isEmpty('equip2')) return 'equip2'; + if(list.contains('equip3')&&player.hasEmptySlot('equip3')) return 'equip3'; + if(list.contains('equip4')&&player.hasEmptySlot('equip4')) return 'equip4'; + if(list.contains('equip5')&&player.hasEmptySlot('equip5')) return 'equip5'; + if(list.contains('equip2')&&player.hasEmptySlot('equip2')) return 'equip2'; return list.randomGet(); }; 'step 1' diff --git a/character/extra.js b/character/extra.js index 629cf8aa9..dae836289 100755 --- a/character/extra.js +++ b/character/extra.js @@ -3734,7 +3734,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ else{ event.target2=result.targets[0]; var list=['手牌区']; - if(lib.card[card.name].type=='equip'&&event.target2.isEmpty(lib.card[card.name].subtype)) list.push('装备区'); + if(lib.card[card.name].type=='equip'&&event.target2.canEquip(card)) list.push('装备区'); if(lib.card[card.name].type=='delay'&&!event.target2.storage._disableJudge&&!event.target2.hasJudge(card.name)) list.push('判定区'); if(list.length==1) event._result={control:list[0]}; else{ @@ -4011,7 +4011,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ filter:function(event,player){ var num=event.name=='phase'?5:3; if(num==3?event.numFixed:!game.hasPlayer(function(current){ - return current.countDisabled()<5; + return current.hasEnabledSlot(); })) return false; return game.countPlayer(function(current){ return current.isDamaged(); @@ -4027,7 +4027,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ } else{ player.chooseTarget(get.prompt('olzhiti'),'废除一名角色的一个随机装备栏',function(card,player,target){ - return target.countDisabled()<5; + return target.hasEnabledSlot(); }).set('ai',function(target){ return -get.attitude(_status.event.player,target)*(target.countCards('e')+1) }); @@ -4038,13 +4038,12 @@ game.import('character',function(lib,game,ui,get,ai,_status){ player.logSkill('olzhiti',target); var list=[]; for(var i=1;i<6;i++){ - if(!target.isDisabled(i)) list.add((i==3||i==4)?6:i); + if(target.hasEnabledSlot(i)) list.add((i==3||i==4)?6:i); } var num=list.randomGet(); if(num!=6) target.disableEquip(num); else{ - target.disableEquip(3); - target.disableEquip(4); + target.disableEquip(3,4); } } }, @@ -6401,7 +6400,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ return player!=event.player&&event.player.isIn()&&_status.currentPhase==player; }, check:function(event,player){ - if(player.countDisabled()<5&&player.isDisabled(5)) return false; + if(player.hasEnabledSlot()&&!player.hasEnabledSlot(5)) return false; return true; }, bannedList:[ @@ -6425,7 +6424,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ if(func(listm[i])) list.add(listm[i]); } event.skills=list; - if(player.countDisabled()<5){ + if(player.hasEnabledSlot()){ player.chooseToDisable().ai=function(event,player,list){ if(list.contains('equip5')) return 'equip5'; return list.randomGet(); diff --git a/character/huicui.js b/character/huicui.js index 784f861c7..a81258f9f 100644 --- a/character/huicui.js +++ b/character/huicui.js @@ -4704,9 +4704,6 @@ game.import('character',function(lib,game,ui,get,ai,_status){ audio:2, enable:'phaseUse', usable:1, - isDisabled:function(player,pos){ - return pos>0?player.isDisabled(pos):player.storage._disableJudge; - }, chooseButton:{ dialog:function(event,player){ var dialog=ui.create.dialog('弥笃:选择要废除或恢复的装备栏或判定区','hidden'); @@ -4714,10 +4711,13 @@ game.import('character',function(lib,game,ui,get,ai,_status){ dialog.noforcebutton=true; var list1=[],list2=[]; for(var i=1;i<6;i++){ - (player.isDisabled(i)?list2:list1).push(i); + for(var j=0;j0?get.translation('equip'+i)+'栏':'判定区')+''; - td.link=i; + td.link=[i,bool]; td.addEventListener(lib.config.touchscreen?'touchend':'click',ui.click.button); for(var j in lib.element.button){ td[j]=lib.element.button[j]; @@ -4738,43 +4738,43 @@ game.import('character',function(lib,game,ui,get,ai,_status){ } if(list1.length){ dialog.addText('未废除'); - addTable(list1); + addTable(list1,true); } if(list2.length){ dialog.addText('已废除'); - addTable(list2); + addTable(list2,false); } return dialog; }, filter:function(button,player){ if(!ui.selected.buttons.length) return true; - if(lib.skill.midu.isDisabled(player,ui.selected.buttons[0].link)) return false; - return !player.isDisabled(button.link); + if(!ui.selected.buttons[0].link[1]) return false; + return button.link[1] }, check:function(button){ var player=_status.event.player; - if(lib.skill.midu.isDisabled(player,button.link)){ - if(button.link<=0) return -10; + if(!button.link[1]){ + if(button.link[0]<=0) return -10; if(player.hasCard(function(card){ - return get.subtype(card)==('equip'+button.link); + return get.subtype(card)==('equip'+button.link[0]); },'hs')) return 15; return 10; } - if(button.link<=0||player.isEmpty(button.link)&&!player.hasCard(function(card){ - return get.subtype(card)==('equip'+button.link)&&player.canUse(card,player)&&get.effect(player,card,player,player)>0; + if(button.link[0]<=0||player.hasEmptySlot(button.link[0])&&!player.hasCard(function(card){ + return get.subtype(card)==('equip'+button.link[0])&&player.canUse(card,player)&&get.effect(player,card,player,player)>0; },'hs')) return 5; return 0; }, - select:[1,6], + select:[1,Infinity], backup:function(links,player){ - if(lib.skill.midu.isDisabled(player,links[0])){ + if(!links[0][1]){ return { audio:'midu', selectCard:-1, selectTarget:-1, filterCard:()=>false, filterTarget:()=>false, - equip:links[0], + equip:links[0][0], content:function(){ var pos=lib.skill.midu_backup.equip; if(pos<=0) player.enableJudge(); @@ -4789,15 +4789,16 @@ game.import('character',function(lib,game,ui,get,ai,_status){ selectCard:-1, filterCard:()=>false, filterTarget:true, - equip:links.sort(), + equip:links.map(i=>i[0]).sort(), content:function(){ - var list=lib.skill.midu_backup.equip,bool=false; - for(var i of list){ - if(i<=0) bool=true; - else player.disableEquip(i); + var list=lib.skill.midu_backup.equip,num=list.length,bool=false; + if(list.contains(-1)){ + list.remove(-1); + bool=true; } + if(list.length>0) player.disableEquip(list); if(bool) player.disableJudge(); - target.draw(list.length) + target.draw(num) }, ai:{ tag:{ @@ -4811,7 +4812,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ } }, prompt:function(links,player){ - if(lib.skill.midu.isDisabled(player,links[0])){ + if(!links[0][1]){ return '恢复一个装备栏或判定区并获得〖活墨〗'; } var numc=get.cnNumber(links.length); @@ -4828,11 +4829,11 @@ game.import('character',function(lib,game,ui,get,ai,_status){ xianwang:{ mod:{ globalTo:function(source,player,distance){ - var num=player.countDisabled(); + var num=player.countDisabledSlot(); if(num>0) return distance+(num>2?2:1); }, globalFrom:function(source,player,distance){ - var num=source.countDisabled(); + var num=source.countDisabledSlot(); if(num>0) return distance-(num>2?2:1); }, }, @@ -5513,7 +5514,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ var info=get.info(i); return info&&!get.is.locked(i)&&!info.limited&&!info.juexingji&&!info.zhuSkill&&!info.charlotte; }); - if(!skills.length&&target.isEmpty(2)) return 1; + if(!skills.length&&target.hasEmptySlot(2)) return 1; return -0.5*skills.length; }, }, @@ -6458,7 +6459,10 @@ game.import('character',function(lib,game,ui,get,ai,_status){ }, mod:{ targetInRange:function(card,player,target){ - if(player.countDisabled()>=5) return true; + for(var i=1;i<=5;i++){ + if(!player.hasDisabledSlot(i)) return false; + } + return true; }, }, marktext:'萍', @@ -6469,7 +6473,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ trigger:{global:'useCardAfter'}, filter:function(event,player){ return player!=event.player&&event.targets.contains(player)&& - player.countDisabled()<5&&!player.getStorage('fuping').contains(event.card.name); + player.hasEnabledSlot()&&!player.getStorage('fuping').contains(event.card.name); }, logTarget:'player', prompt2:(event)=>('废除一个装备栏并记录【'+get.translation(event.card.name)+'】'), @@ -7273,14 +7277,14 @@ game.import('character',function(lib,game,ui,get,ai,_status){ if(num>=5) return false; var num2=0; for(var i=1;i<=5;i++){ - if(event.player.isEmpty(i)) num2++; + num2+=event.player.countEmptySlot(i); } return num1) continue; - if(target.isEmpty(get.subtype(es[i]))) return true; - } + for(var i=0;i1) continue; + if(target.canEquip(es[i])) return true; + } + return false; + } + else{ + if(!event.ingame){ + if(target.getEquip(2)) return true; return false; } - else{ - if(!event.ingame){ - if(target.getEquip(2)) return true; - return false; - } - return target.countCards('e')>0; - } - }); - next.set('ingame',event.ingame) - next.set('ai',function(target){ - var player=_status.event.player; - var att=get.attitude(player,target); - if(ui.selected.targets.length==0){ - if(att<0){ - if(game.hasPlayer(function(current){ - if(get.attitude(player,current)>0){ - var es=target.getCards('e'); - for(var i=0;i1) continue; - else if(current.isEmpty(get.subtype(es[i]))) return true; - } - return false; + return target.countCards('e')>0; + } + }); + next.set('ingame',event.ingame) + next.set('ai',function(target){ + var player=_status.event.player; + var att=get.attitude(player,target); + if(ui.selected.targets.length==0){ + if(att<0){ + if(game.hasPlayer(function(current){ + if(get.attitude(player,current)>0){ + var es=target.getCards('e'); + for(var i=0;i1) continue; + else if(current.canEquip(es[i])) return true; } - })) return -att; - } - return 0; + return false; + } + })) return -att; } - if(att>0){ - var es=ui.selected.targets[0].getCards('e'); - var i; - for(i=0;i1) continue; - if(target.isEmpty(get.subtype(es[i]))) break; - } - if(i==es.length) return 0; + return 0; + } + if(att>0){ + var es=ui.selected.targets[0].getCards('e'); + var i; + for(i=0;i1) continue; + if(target.canEquip(es[i])) break; } - return -att*get.attitude(player,ui.selected.targets[0]); + if(i==es.length) return 0; + } + return -att*get.attitude(player,ui.selected.targets[0]); + }); + next.set('multitarget',true); + next.set('targetprompt',['被移走','移动目标']); + next.set('prompt',prompt); + 'step 1' + if(result.bool){ + player.line2(result.targets,'green'); + event.targets=result.targets; + } + else event.finish(); + 'step 2' + game.delay(); + 'step 3' + if(targets.length==2){ + if(!event.ingame){ + event._result={ + bool:true, + links:[targets[0].getEquip(2)], + }; + } + else{ + player.choosePlayerCard('e',true,function(button){ + return get.equipValue(button.link); + },targets[0]).set('targets0',targets[0]).set('targets1',targets[1]).set('filterButton',function(button){ + var targets1=_status.event.targets1; + if(['equip3','equip4'].contains(get.subtype(button.link))&&targets1.getEquip('liulongcanjia')) return false; + if(button.link.name=='liulongcanjia'&&targets1.countCards('e',{subtype:['equip3','equip4']})>1) return false; + return !targets1.countCards('e',{subtype:get.subtype(button.link)}); + }); - next.set('multitarget',true); - next.set('targetprompt',['被移走','移动目标']); - next.set('prompt',prompt); - 'step 1' - if(result.bool){ - player.line2(result.targets,'green'); - event.targets=result.targets; } - else event.finish(); - 'step 2' + } + else event.finish(); + 'step 4' + if(result.bool&&result.links.length){ + var link=result.links[0]; + if(get.position(link)=='e') event.targets[1].equip(link); + else if(link.viewAs) event.targets[1].addJudge({name:link.viewAs},[link]); + else event.targets[1].addJudge(link); + event.targets[0].$give(link,event.targets[1],false) game.delay(); - 'step 3' - if(targets.length==2){ - if(!event.ingame){ - event._result={ - bool:true, - links:[targets[0].getEquip(2)], - }; - } - else{ - player.choosePlayerCard('e',true,function(button){ - return get.equipValue(button.link); - },targets[0]).set('targets0',targets[0]).set('targets1',targets[1]).set('filterButton',function(button){ - var targets1=_status.event.targets1; - if(['equip3','equip4'].contains(get.subtype(button.link))&&targets1.getEquip('liulongcanjia')) return false; - if(button.link.name=='liulongcanjia'&&targets1.countCards('e',{subtype:['equip3','equip4']})>1) return false; - return !targets1.countCards('e',{subtype:get.subtype(button.link)}); - - }); - } - } - else event.finish(); - 'step 4' - if(result.bool&&result.links.length){ - var link=result.links[0]; - if(get.position(link)=='e') event.targets[1].equip(link); - else if(link.viewAs) event.targets[1].addJudge({name:link.viewAs},[link]); - else event.targets[1].addJudge(link); - event.targets[0].$give(link,event.targets[1],false) - game.delay(); - } + } }, audio:true, enable:"phaseUse", @@ -12440,7 +12441,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ if(target.isMin()) return false; var es=from.getCards('e'); for(var i=0;i0) return 9; } @@ -12473,7 +12474,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ if(current!=target&&get.attitude(player,current)>0){ var es=target.getCards('e'); for(var i=0;i0&¤t.isEmpty(get.subtype(es[i]))&&get.value(es[i],current)>0) return true; + if(get.value(es[i],target)>0&¤t.canEquip(es[i])&&get.value(es[i],current)>0) return true; } } })){ @@ -12489,7 +12490,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ if(sgnatt!=0&&att2!=0&& get.sgn(get.value(es[i],ui.selected.targets[0]))==-att2&& get.sgn(get.value(es[i],target))==sgnatt&& - target.isEmpty(get.subtype(es[i]))){ + target.canEquip(es[i])){ return Math.abs(att); } } @@ -12538,7 +12539,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ return targets1.canAddJudge(button.link); } else{ - return targets1.isEmpty(get.subtype(button.link)); + return targets1.canEquip(button.link); } }); } diff --git a/character/offline.js b/character/offline.js index 81b804dc6..95b6fb02f 100644 --- a/character/offline.js +++ b/character/offline.js @@ -1666,7 +1666,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ if(current.isMin()) return false; var es=target.getCards('e'); for(var i=0;i=target.countCards('h')&&target.isEmpty(2)) return false; + if((card.name=='juedou'||card.name=='sha'||card.name=='huogong')&&player!=target&&player.countCards('h')>=target.countCards('h')&&target.hasEmptySlot(2)) return false; }, }, }, diff --git a/character/refresh.js b/character/refresh.js index 4d1e8b8b7..20b1607fa 100755 --- a/character/refresh.js +++ b/character/refresh.js @@ -3057,7 +3057,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ if(get.sgn(get.value(es[i],current))!=-att||get.value(es[i],current)<5) return false; var att2=get.sgn(get.attitude(player,current2)); if(att==att2||att2!=get.sgn(get.effect(current2,es[i],player,current2))) return false; - return current!=current2&&!current2.isMin()&¤t2.isEmpty(get.subtype(es[i])); + return current!=current2&&!current2.isMin()&¤t2.canEquip(es[i]); })){ return true; } @@ -5083,7 +5083,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ if(!target.getHistory('sourceDamage').length){ var cards=target.getCards('e'); for(var i of cards){ - if(player.isEmpty(get.subtype(i))) return true; + if(player.canEquip(i)) return true; } } return target.getHistory('useCard',function(evt){ @@ -5102,7 +5102,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ if(!target.getHistory('sourceDamage').length){ var cards=target.getCards('e'); for(var i of cards){ - if(player.isEmpty(get.subtype(i))) list.push(i); + if(player.canEquip(i)) list.push(i); } } if(list.length){ @@ -6735,7 +6735,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ }); for(var i=0;i0) return 18; return 7; @@ -6787,7 +6787,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ else if(att>0){ if(target.countCards('e',function(card){ return get.value(card,target)<0&&!_status.event.cards.contains(card)&&game.hasPlayer(function(current){ - return current!=target&¤t.isEmpty(get.subtype(card))&&get.effect(current,card,player,player)<0; + return current!=target&¤t.canEquip(card)&&get.effect(current,card,player,player)<0; }); })>0) return 9; } @@ -6798,7 +6798,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ return !_status.event.cards.contains(card); }); for(var i=0;i0&¤t.isEmpty(get.subtype(es[i]))&&get.effect(current,es[i],player,current)>0) return true; + if(get.value(es[i],target)>0&¤t.canEquip(card)&&get.effect(current,es[i],player,current)>0) return true; } } })){ @@ -6818,7 +6818,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ return get.attitude(player,current)<0&¤t.countDiscardableCards(player,'he')>0&&get.damageEffect(current,player,player)>0; }); if(bool&&player.countCards('e',function(card){ - return !_status.event.cards.contains(card)&&target.isEmpty(get.subtype(card))&&get.effect(target,card,player,player)>0; + return !_status.event.cards.contains(card)&&target.canEquip(card)&&get.effect(target,card,player,player)>0; })) return 2.5*Math.abs(att); else if(bool) return 1/Math.max(1,Math.abs(att)); else return get.damageEffect(target,player,player); @@ -6826,7 +6826,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ if(sgnatt!=0&&att2!=0&&sgnatt!=att2&& get.sgn(get.value(es[i],ui.selected.targets[0]))==-att2&& get.sgn(get.effect(target,es[i],player,target))==sgnatt&& - target.isEmpty(get.subtype(es[i]))){ + target.canEquip(es[i])){ return Math.abs(att); } } @@ -6865,7 +6865,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ },targets[0]).set('nojudge',event.nojudge||false).set('targets0',targets[0]).set('targets1',targets[1]).set('filterButton',function(button){ if(_status.event.cards.contains(button.link)) return false; var targets1=_status.event.targets1; - return targets1.isEmpty(get.subtype(button.link)); + return targets1.canEquip(button.link); }).set('cards',cards); } else{ @@ -6900,7 +6900,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ }; for(var i=0;i0&&!target.hasSkillTag('noe')) return 0; var num=0; target.countCards('e',function(card){ - if(player.isEmpty(get.subtype(card))){ + if(player.canEquip(card)){ var eff=get.effect(player,card,player,player); if(eff>num) num=eff; } @@ -7594,7 +7594,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ event.target=target; player.logSkill('rezishou',target); player.choosePlayerCard(target,'e','将一张装备牌移至你的装备区').set('filterButton',function(button){ - return _status.event.player.isEmpty(get.subtype(button.link)); + return _status.event.player.canEquip(button.link); }); } else event.finish(); @@ -8325,7 +8325,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ if(target.isMin()) return false; var es=from.getCards('e'); for(var i=0;i0){ if(target.countCards('e',function(card){ return get.value(card,target)<0&&game.hasPlayer(function(current){ - return current!=player&¤t!=target&&get.attitude(player,current)<0&¤t.isEmpty(get.subtype(card))&&get.effect(current,card,player,player)>0; + return current!=player&¤t!=target&&get.attitude(player,current)<0&¤t.canEquip(card)&&get.effect(current,card,player,player)>0; }); })>0) return 9; } @@ -8350,7 +8350,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ if(current!=target&¤t!=player&&get.attitude(player,current)>0){ var es=target.getCards('e'); for(var i=0;i0&¤t.isEmpty(get.subtype(es[i]))&&get.effect(current,es[i],player,player)>0) return true; + if(get.value(es[i],target)>0&¤t.canEquip(es[i])&&get.effect(current,es[i],player,player)>0) return true; } } })){ @@ -8366,7 +8366,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ if(sgnatt!=0&&att2!=0&&sgnatt!=att2&& get.sgn(get.value(es[i],ui.selected.targets[0]))==-att2&& get.sgn(get.value(es[i],target))==sgnatt&& - target.isEmpty(get.subtype(es[i]))){ + target.canEquip(es[i])){ return Math.abs(att); } } @@ -8404,7 +8404,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ } },targets[0]).set('targets0',targets[0]).set('targets1',targets[1]).set('filterButton',function(button){ var targets1=_status.event.targets1; - return targets1.isEmpty(get.subtype(button.link)); + return targets1.canEquip(button.link); }); } else{ @@ -8433,7 +8433,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ var att2=get.sgn(get.attitude(player,current2)); if(att==att2||att2!=get.sgn(get.value(es[i],current2))) return false; } - return current!=current2&&!current2.isMin()&¤t2.isEmpty(get.subtype(es[i])); + return current!=current2&&!current2.isMin()&¤t2.canEquip(es[i]); })){ return true; } @@ -11709,7 +11709,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ if(!target.hasSex('male')) return false; var card=ui.selected.cards[0]; if(!card) return false; - if(get.position(card)=='e'&&!target.isEmpty(get.subtype(card))) return false; + if(get.position(card)=='e'&&!target.canEquip(card)) return false; return true; }, discard:false, @@ -11718,7 +11718,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ content:function(){ 'step 0' if(get.position(cards[0])=='e') event._result={index:0}; - else if(get.type(cards[0])!='equip'||!target.isEmpty(get.subtype(cards[0]))) event._result={index:1}; + else if(get.type(cards[0])!='equip'||!target.canEquip(cards[0])) event._result={index:1}; else player.chooseControl().set('choiceList',[ '将'+get.translation(cards[0])+'置入'+get.translation(target)+'的装备区', '弃置'+get.translation(cards[0]), diff --git a/character/shenhua.js b/character/shenhua.js index 92e630b65..08a3a6da1 100755 --- a/character/shenhua.js +++ b/character/shenhua.js @@ -3976,8 +3976,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ }, filterTarget:function(card,player,target){ if(target.isMin()) return false; - var type=get.subtype(card); - return player!=target&&target.isEmpty(type); + return player!=target&&target.canEquip(card); }, content:function(){ target.equip(cards[0]); @@ -5418,7 +5417,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ inherit:'bagua_skill', filter:function(event,player){ if(!lib.skill.bagua_skill.filter(event,player)) return false; - if(!player.isEmpty(2)) return false; + if(!player.hasEmptySlot(2)) return false; return true; }, ai:{ @@ -5428,7 +5427,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ if(player==target&&get.subtype(card)=='equip2'){ if(get.equipValue(card)<=7.5) return 0; } - if(!target.isEmpty(2)) return; + if(!target.hasEmptySlot(2)) return; return lib.skill.bagua_skill.ai.effect.target.apply(this,arguments); } } diff --git a/character/shiji.js b/character/shiji.js index 7b5e48219..be75dc3bd 100644 --- a/character/shiji.js +++ b/character/shiji.js @@ -1,4 +1,5 @@ 'use strict'; + game.import('character',function(lib,game,ui,get,ai,_status){ return { name:'shiji', @@ -402,21 +403,20 @@ game.import('character',function(lib,game,ui,get,ai,_status){ if(att>0){ if(target.hasCard(function(card){ if(get.value(card,target)<=0&&game.hasPlayer(function(current){ - return current!=target&¤t.isEmpty(get.subtype(card,false))&&get.effect(current,card,player,player)>0; + return current!=target&¤t.canEquip(card,false)&&get.effect(current,card,player,player)>0; })) return true; return false; },'e')) return 2*att; if(!target.hasCard(function(card){ - var sub=get.subtype(card,false); return game.hasPlayer(function(current){ - return current!=target&¤t.isEmpty(sub); + return current!=target&¤t.canEquip(card); }) },'e')) return 1; } else if(att<0){ if(target.hasCard(function(card){ if(get.value(card,target)>=4.5&&game.hasPlayer(function(current){ - return current!=target&¤t.isEmpty(get.subtype(card,false))&&get.effect(current,card,player,player)>0; + return current!=target&¤t.canEquip(card)&&get.effect(current,card,player,player)>0; })) return true; return false; },'e')) return -att; @@ -433,9 +433,8 @@ game.import('character',function(lib,game,ui,get,ai,_status){ else event.finish(); 'step 2' var es=target.getCards('e',function(card){ - var sub=get.subtype(card,false); return game.hasPlayer(function(current){ - return current!=target&¤t.isEmpty(sub); + return current!=target&¤t.canEquip(card); }) }); if(es.length){ @@ -443,7 +442,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ else player.chooseButton(['移动'+get.translation(target)+'的一张装备牌',es],true).set('ai',function(button){ var player=_status.event.player,target=_status.event.getParent().target,card=button.link; if(game.hasPlayer(function(current){ - return current!=target&¤t.isEmpty(get.subtype(card,false))&&get.effect(current,card,player,player)>0; + return current!=target&¤t.canEquip(card)&&get.effect(current,card,player,player)>0; })) return -get.value(card,target)*get.attitude(player,target); return 0; }); @@ -453,8 +452,8 @@ game.import('character',function(lib,game,ui,get,ai,_status){ if(result.bool){ event.card=result.links[0]; player.chooseTarget(true,'选择'+get.translation(event.card)+'的移动目标',function(card,player,target){ - return target.isEmpty(_status.event.subtype); - }).set('subtype',get.subtype(event.card)).set('ai',function(target){ + return target.canEquip(_status.event.card); + }).set('card',event.card).set('ai',function(target){ var evt=_status.event; return get.effect(target,evt.getParent().card,evt.player,evt.player); }); @@ -1999,15 +1998,15 @@ game.import('character',function(lib,game,ui,get,ai,_status){ filter:function(event,player){ if(event.player!=player.storage.chuhai2) return false; for(var i=1;i<6;i++){ - if(player.isEmpty(i)) return true; + if(player.hasEmptySlot(i)) return true; } return false; }, content:function(){ for(var i=1;i<7;i++){ - if(player.isEmpty(i)){ + if(player.hasEmptySlot(i)){ var sub='equip'+i,card=get.cardPile(function(card){ - return get.subtype(card,false)==sub&&!get.cardtag(card,'gifts'); + return get.subtype(card,false)==sub&&!get.cardtag(card,'gifts')&&player.canEquip(card); }); if(card){ player.$gain2(card); @@ -2994,16 +2993,16 @@ game.import('character',function(lib,game,ui,get,ai,_status){ }, filterTarget:function(card,player,target){ for(var i=1;i<6;i++){ - if(target.isEmpty(i)) return true; + if(target.hasEmptySlot(i)) return true; } return false; }, content:function(){ 'step 0' - event.num=0; + event.num=1; player.awakenSkill('rongbei'); 'step 1' - while(!target.isEmpty(event.num)){ + while(!target.hasEmptySlot(event.num)){ event.num++; if(event.num>5){ event.finish(); @@ -4602,7 +4601,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ audio:'muzhen', filterTarget:[ function(card,player,target){ - return target.countCards('h')>0&&target.isEmpty(ui.selected.cards[0]); + return target.countCards('h')>0&&target.canEquip(ui.selected.cards[0]); }, function(card,player,target){ return target.countCards('e')>0; @@ -4610,9 +4609,9 @@ game.import('character',function(lib,game,ui,get,ai,_status){ ][links[0]], filterCard:[ function(card,player){ - if(ui.selected.targets.length) return ui.selected.targets[0].isEmpty(card); + if(ui.selected.targets.length) return ui.selected.targets[0].canEquip(card); return game.hasPlayer(function(current){ - return current.countCards('h')>0&¤t.isEmpty(card); + return current.countCards('h')>0&¤t.canEquip(card); }) }, true, diff --git a/character/sp.js b/character/sp.js index 293f4630c..c00c40207 100755 --- a/character/sp.js +++ b/character/sp.js @@ -5901,16 +5901,16 @@ game.import('character',function(lib,game,ui,get,ai,_status){ return !event.numFixed&&event.num>0; }, check:function(event,player){ - if(player.isEmpty(2)||player.isEmpty(5)||player.isEmpty(1)) return true; + if(player.hasEmptySlot(2)||player.hasEmptySlot(5)||player.hasEmptySlot(1)) return true; return false; }, prompt2:'摸牌阶段开始时,你可以少摸一张牌并声明一种装备牌的副类别,然后从牌堆或弃牌堆中获得一张该副类别的牌。', content:function(){ 'step 0' player.chooseControl('equip1','equip2','equip6','equip5').set('prompt','选择获得一种副类别的装备牌').set('ai',function(card){ - if(player.isEmpty(2)) return 'equip2'; - if(player.isEmpty(5)) return 'equip5'; - if(player.isEmpty(1)) return 'equip1'; + if(player.hasEmptySlot(2)) return 'equip2'; + if(player.hasEmptySlot(5)) return 'equip5'; + if(player.hasEmptySlot(1)) return 'equip1'; return 'equip6'; }); 'step 1' @@ -7818,7 +7818,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ trigger:{global:'phaseBegin'}, direct:true, filter:function(event,player){ - return event.player.isIn()&&event.player.isEmpty(5)&&player.hasCard(lib.skill.zhuangshu.filterCard,'he'); + return event.player.isIn()&&event.player.hasEmptySlot(5)&&player.hasCard(lib.skill.zhuangshu.filterCard,'he'); }, filterCard:function(card){ if(_status.connectMode) return true; @@ -7842,7 +7842,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ 'step 1' if(result.bool){ var name='zhuangshu_'+get.type2(result.cards[0],result.cards[0].original=='h'?player:false); - if(lib.card[name]&&trigger.player.isIn&&trigger.player.isEmpty(5)){ + if(lib.card[name]&&trigger.player.isIn&&trigger.player.hasEmptySlot(5)){ var target=game.findPlayer(function(current){ var equip=current.getEquip(5); return equip&&equip.name==name; @@ -11880,7 +11880,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ }).set('ai',function(target){ var player=_status.event.player; var att=get.attitude(player,target) - if(target.getEquip(2)&&player.isEmpty(2)){ + if(target.getEquip(2)&&player.hasEmptySlot(2)){ return -2*att; } return -att; @@ -16154,7 +16154,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ inherit:'bagua_skill', filter:function(event,player){ if(!lib.skill.bagua_skill.filter(event,player)) return false; - if(!player.isEmpty(2)) return false; + if(!player.hasEmptySlot(2)) return false; return true; }, ai:{ @@ -20901,7 +20901,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ }, position:'he', filterTarget:function(card,player,target){ - return target.isEmpty(get.subtype(card)); + return target.canEquip(card); }, ai1:function(card){ return 6-get.value(card); @@ -21160,7 +21160,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ "step 1" if(result.bool){ event.card=result.links[0]; - if(player.isEmpty(get.subtype(event.card))){ + if(player.canEquip(event.card)){ player.chooseBool('是否将'+get.translation(event.card)+'置入自己的装备区?').ai=function(){ return true; }; @@ -21870,7 +21870,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ //priority:15, filter:function (event,player){ if(player.hasSkill('smh_huoji')||player.hasSkill('smh_lianhuan')) return false; - if(!player.isEmpty(2)) return false; + if(!player.hasEmptySlot(2)) return false; if(event.nature) return true; return get.type(event.card,'trick')=='trick'; }, @@ -21887,7 +21887,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ if(player==target&&get.subtype(card)=='equip2'){ if(get.equipValue(card)<=8) return 0; } - if(!target.isEmpty(2)) return; + if(!target.hasEmptySlot(2)) return; if(get.tag(card,'natureDamage')) return 'zerotarget'; if(get.type(card)=='trick'&&get.tag(card,'damage')){ return 'zeroplayertarget'; diff --git a/character/sp2.js b/character/sp2.js index c75cfe33e..b37a5ed1e 100644 --- a/character/sp2.js +++ b/character/sp2.js @@ -1139,7 +1139,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ event.num=target.countCards('e'); var subtypes=[]; for(var i=1;i<7;i++){ - if(target.isEmpty(i)) subtypes.push('equip'+i); + if(target.hasEmptySlot(i)) subtypes.push('equip'+i); } if(subtypes.length){ subtypes.randomSort(); @@ -5890,7 +5890,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ }, check:function(event,player){ for(var i=5;i>0;i--){ - if(player.isEmpty(i)) return ('equip'+i); + if(player.hasEmptySlot(i)) return ('equip'+i); } return 'cancel2'; }, @@ -8986,7 +8986,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ for(var i=0;i0){ if(val<=Math.min(0,equip)&&game.hasPlayer(function(current){ - return current!=target&¤t.isEmpty(get.subtype(i))&&get.effect(current,i,player,player)>0; + return current!=target&¤t.canEquip(i)&&get.effect(current,i,player,player)>0; })) equip=val; } else{ if(val>Math.max(0,equip)&&game.hasPlayer(function(current){ - return current!=target&¤t.isEmpty(get.subtype(i))&&get.effect(current,i,player,player)>0; + return current!=target&¤t.canEquip(i)&&get.effect(current,i,player,player)>0; })) equip=val; } } @@ -9121,7 +9121,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ return targets1.canAddJudge(button.link); } else{ - return targets1.isEmpty(get.subtype(button.link)); + return targets1.canEquip(button.link); } }).set('ai',function(button){ var player=_status.event.player,target=_status.event.targets1,source=_status.event.targets0; @@ -11538,7 +11538,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ filterCard:{type:'equip'}, filterTarget:function(card,player,target){ var card=ui.selected.cards[0]; - return target.isEmpty(get.subtype(card)); + return target.canEquip(card); }, discard:false, lose:false, diff --git a/character/xianding.js b/character/xianding.js index 9d9a2bfcf..75c39f6d9 100644 --- a/character/xianding.js +++ b/character/xianding.js @@ -8645,7 +8645,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ event.num=1; 'step 1' var type='equip'+num; - if(!player.isEmpty(type)) return; + if(!player.hasEmptySlot(type)) return; var card=get.cardPile2(function(card){ return get.subtype(card,false)==type&&player.canUse(card,player); }); diff --git a/character/yijiang.js b/character/yijiang.js index c9d857f12..b876f2ed2 100755 --- a/character/yijiang.js +++ b/character/yijiang.js @@ -10835,7 +10835,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ "step 0" var next; if(trigger.player.hasCard(function(card){ - return player.isEmpty(get.subtype(card)); + return player.canEquip(card); },'e')){ next=player.chooseControl('移动装备','draw_card','cancel2',function(event,player){ var source=_status.event.sourcex; @@ -10865,7 +10865,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ if(result.control=='移动装备'){ player.logSkill('qieting',trigger.player); player.choosePlayerCard(trigger.player,'e','将一张装备牌移至你的装备区',true).set('filterButton',function(button){ - return _status.event.player.isEmpty(get.subtype(button.link)); + return _status.event.player.canEquip(button.link); }).set('ai',function(button){ return get.effect(player,button.link,player,player); }); diff --git a/game/game.js b/game/game.js index b59e1f5a1..5937df88c 100644 --- a/game/game.js +++ b/game/game.js @@ -10761,7 +10761,7 @@ if(!event.slots.length) return; var slotsx=[...new Set(event.slots)].sort(); for(var slot of slotsx){ - var lost=player.countDisabled(slot),gain=Math.min(lost,get.numOf(event.slots,slot)); + var lost=player.countDisabledSlot(slot),gain=Math.min(lost,get.numOf(event.slots,slot)); if(lost<=0) continue; else{ game.log(player,'恢复了'+get.cnNumber(gain)+'个','#g'+get.translation(slot)+'栏'); @@ -11827,7 +11827,7 @@ 'step 0' var list=[]; for(var i=1;i<=5;i++){ - if(player.hasDisabled(i)) list.push('equip'+i); + if(player.hasDisabledSlot(i)) list.push('equip'+i); } if(!list.length) event.finish(); else if(list.length==1){ @@ -18133,20 +18133,20 @@ //装备栏相关 //判断一名角色的某个区域是否被废除 //type为要判断的区域 若为空 则判断玩家是否有任意一个被废除的区域 - hasDisabled:function(type){ + hasDisabledSlot:function(type){ var player=this; - if(type=='horse') return player.hasDisabled(3)&&player.hasDisabled(4); - return player.countDisabled(type)>0; + if(type=='horse') return player.hasDisabledSlot(3)&&player.hasDisabledSlot(4); + return player.countDisabledSlot(type)>0; }, //判断一名角色的某个区域被废除的数量 //用法同上 - countDisabled:function(type){ + countDisabledSlot:function(type){ var player=this; var map=(player.disabledSlots||{}); if(type==undefined){ num=0; for(var i=1;i<=5;i++){ - num+=player.countDisabled(i); + num+=player.countDisabledSlot(i); } return num; } @@ -18157,11 +18157,28 @@ return 0; } }, + //判断一名角色是否有某个装备栏空着 + hasEmptySlot:function(type){ + var player=this; + if(type=='horse') return player.hasEmptySlot(3)&&player.hasEmptySlot(4); + return player.countEmptySlot(type)>0; + }, + //判断一名角色的某个装备栏空位的数量 + countEmptySlot:function(type){ + if(!type) return 0; + var player=this; + if(typeof type=='number') type=('equip'+type); + return Math.max(0,player.countEnabledSlot(type)-player.getEquips(type).reduce(function(num,card){ + var types=get.subtypes(card,false); + return num+get.numOf(types,type); + },0)) + }, //判断一名角色是否有可以用于装备牌的区域(考虑金箍棒等“不可被替换装备”) //用法同下 countEquipableSlot:function(type){ - if(!type) return false; + if(!type) return 0; var player=this; + if(typeof type=='number') type=('equip'+type); return Math.max(0,player.countEnabledSlot(type)-player.getEquips(type).reduce(function(num,card){ var types=get.subtypes(card,false); if(!lib.filter.canBeReplaced(card,player)) num+=get.numOf(types,type); @@ -18192,7 +18209,7 @@ var slots=1; var num=map[type]; if(typeof num=='number'&&num>0) slots+=num; - slots-=player.countDisabled(type); + slots-=player.countDisabledSlot(type); return slots; } }, @@ -18396,8 +18413,11 @@ return true; }, //以下函数将不再进行后续维护 + countDisabled:function(){ + return this.countDisabledSlot.apply(this,arguments) + }, isDisabled:function(arg){ - return this.hasDisabled(arg)&&!this.hasEnabledSlot(arg); + return this.hasDisabledSlot(arg)&&!this.hasEnabledSlot(arg); }, isEmpty:function(num){ return this.countEnabledSlot(num)>this.getEquips(num); diff --git a/mode/boss.js b/mode/boss.js index dd5d7a734..9f7dd71b9 100644 --- a/mode/boss.js +++ b/mode/boss.js @@ -1890,7 +1890,7 @@ game.import('mode',function(lib,game,ui,get,ai,_status){ event.num=1.5; 'step 1' var card=cards.shift(); - if(player.isEmpty(get.subtype(card))&&Math.random()