diff --git a/character/collab.js b/character/collab.js index b2739cf66..ccc7cd3dc 100644 --- a/character/collab.js +++ b/character/collab.js @@ -1025,7 +1025,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ content:function(){ var num=lib.skill.ruyijingubang_skill_backup.num; player.storage.ruyijingubang_skill=num; - var card=player.getEquips(1); + var cards=player.getEquips(1); for(var card of cards){ if(card&&card.name=='ruyijingubang'){ card.storage.ruyijingubang_skill=num; @@ -1038,9 +1038,6 @@ game.import('character',function(lib,game,ui,get,ai,_status){ }, }, mod:{ - attackRange:function(player,range){ - if(player.storage.ruyijingubang_skill) return range-3+player.storage.ruyijingubang_skill; - }, cardUsable:function(card,player,num){ if(player.storage.ruyijingubang_skill==1&&card.name=='sha') return Infinity; }, @@ -1516,7 +1513,12 @@ game.import('character',function(lib,game,ui,get,ai,_status){ subtype:'equip1', skills:['ruyijingubang_skill','ruyijingubang_effect'], equipDelay:false, - distance:{attackFrom:-2}, + distance:{ + attackFrom:-2, + attackRange:(card,player)=>{ + return (player.storage.ruyijingubang_skill||3); + } + }, onEquip:function(){ if(!card.storage.ruyijingubang_skill) card.storage.ruyijingubang_skill=3; player.storage.ruyijingubang_skill=card.storage.ruyijingubang_skill; diff --git a/game/game.js b/game/game.js index 0010af9c8..b2b32c011 100644 --- a/game/game.js +++ b/game/game.js @@ -25735,40 +25735,59 @@ return num; }, getAttackRange:function(raw){ - var player=this; - var range=0; + const player=this; + let range=0; if(raw){ range=game.checkMod(player,player,range,'globalFrom',player); range=game.checkMod(player,player,range,'attackFrom',player); - var equips=player.getCards('e',function(card){ + const equips=player.getCards('e',function(card){ return !ui.selected.cards||!ui.selected.cards.contains(card); }); - for(var i=0;i{ + const info=get.info(card,false).distance; + if(ininfo&&info.globalFrom){ range+=info.globalFrom; } - if(info.attackFrom){ - range+=info.attackFrom; + }) + return (equips.reduce((range,card)=>{ + let newRange=1; + const info=get.info(card,false); + if(info.distance){ + //如果存在attackRange 则通过attackRange动态获取攻击范围 + if(typeof info.distance.attackRange=='function'){ + newRange=info.distance.attackRange(card,player); + } + //否则采用祖宗之法 + else if(typeof info.attackFrom=='number'){ + newRange-=info.attackFrom; + } } - } - return (1-range); + return Math.max(range,newRange) + },range)-range); + } + let base=game.checkMod(player,'unchanged','attackRangeBase',player); + if(base!='unchanged'){ + range=base; } - var base=game.checkMod(player,'unchanged','attackRangeBase',player); - if(base!='unchanged') range=base; else{ - range=1; - var equips=player.getCards('e',function(card){ + const equips=player.getCards('e',function(card){ return !ui.selected.cards||!ui.selected.cards.contains(card); }); - for(var i=0;i{ + let newRange=1; + const info=get.info(card,false); + if(info.distance){ + //如果存在attackRange 则通过attackRange动态获取攻击范围 + if(typeof info.distance.attackRange=='function'){ + newRange=info.distance.attackRange(card,player); + } + //否则采用祖宗之法 + else if(typeof info.attackFrom=='number'){ + newRange-=info.attackFrom; + } } - } + return Math.max(range,newRange); + },1); } range=game.checkMod(player,range,'attackRange',player); return range; @@ -56006,8 +56025,7 @@ if(from==to) return 0; if(!game.players.contains(from)&&!game.dead.contains(from)) return Infinity; if(!game.players.contains(to)&&!game.dead.contains(to)) return Infinity; - var player=from,m,n=1,i; - var fxy,txy; + let player=from,m,n=1,i,fxy,txy; if(game.chess){ fxy=from.getXY(); txy=to.getXY(); @@ -56018,9 +56036,9 @@ if(method=='raw'||method=='pure'||method=='absolute') return n; } else{ - var length=game.players.length; - var totalPopulation=game.players.length+game.dead.length+1; - for(var iwhile=0;iwhile{ + let newRange=1; + const info=get.info(card,false); + if(info.distance){ + //如果存在attackRange 则通过attackRange动态获取攻击范围 + if(typeof info.distance.attackRange=='function'){ + newRange=info.distance.attackRange(card,player); + } + //否则采用祖宗之法 + else if(typeof info.attackFrom=='number'){ + newRange-=info.attackFrom; + } + } + return Math.max(range,newRange) + },1); + m+=(1-attakRange) for(i=0;i