diff --git a/CHANGELOG.md b/CHANGELOG.md index a676306..45860a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.37.1 + +- added compatibility with the `Disable Game Canvas` setting + # 0.37.0 - added a new `Conditional Icons Size` client setting which offers the possibility to change the size in pixel for the conditional icons shown on mouse over diff --git a/module.json b/module.json index 80c35f5..4e9d808 100644 --- a/module.json +++ b/module.json @@ -19,12 +19,12 @@ "minimum": "11.315", "verified": "11" }, - "version": "0.37.0", + "version": "0.37.1", "manifestPlusVersion": "1.2.0", "url": "https://github.com/reonZ/pf2e-perception", "readme": "https://github.com/reonZ/pf2e-perception/blob/master/README.md", "manifest": "https://raw.githubusercontent.com/reonZ/pf2e-perception/master/module.json", - "download": "https://github.com/reonZ/pf2e-perception/releases/download/0.37.0/module.zip", + "download": "https://github.com/reonZ/pf2e-perception/releases/download/0.37.1/module.zip", "changelog": "https://github.com/reonZ/pf2e-perception/blob/master/CHANGELOG.md", "bugs": "https://github.com/reonZ/pf2e-perception/issues", "styles": [ diff --git a/scripts/main.js b/scripts/main.js index a8205f8..c138896 100644 --- a/scripts/main.js +++ b/scripts/main.js @@ -1,8 +1,8 @@ -(()=>{var It=Object.defineProperty;var wi=(t,e,i)=>e in t?It(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i;var a=(t,e)=>It(t,"name",{value:e,configurable:!0});var Oe=(t,e,i)=>(wi(t,typeof e!="symbol"?e+"":e,i),i),At=(t,e,i)=>{if(!e.has(t))throw TypeError("Cannot "+i)};var Wt=(t,e,i)=>(At(t,e,"read from private field"),i?i.call(t):e.get(t)),ue=(t,e,i)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,i)};var q=(t,e,i)=>(At(t,e,"access private method"),i);var Pe="Compendium.pf2e.other-effects.Item.I9lfZUiCwMiGogVi",P={[void 0]:0,observed:0,concealed:1,hidden:2,undetected:3,unnoticed:4},de=["observed","concealed","hidden","undetected","unnoticed"],U=["none","lesser","standard","greater","greater-prone"],x={[void 0]:0,none:0,lesser:1,standard:2,greater:3,"greater-prone":4},V={cover:"none",visibility:"observed"},ke=["attack-roll","spell-attack-roll"],Dt=[...ke,"skill-check","perception-check"],Ge={cover:"modules/pf2e-perception/images/cover.webp",concealed:"systems/pf2e/icons/conditions/concealed.webp",hidden:"systems/pf2e/icons/conditions/hidden.webp",undetected:"systems/pf2e/icons/conditions/undetected.webp",unnoticed:"systems/pf2e/icons/conditions/unnoticed.webp"};var yt="#000000",ht="#656665",wt="#809e71",$t=["darkness","dance-of-darkness","ravenous-darkness"],Mt=["obscuring-mist","stinking-cloud","noxious-vapors"];var f="pf2e-perception";function X(t){return`modules/${f}/templates/${t}.hbs`}a(X,"templatePath");function h(...t){let e=t.at(-1),i=typeof e=="object",n=i?t.slice(0,-1):t;return n.unshift(f),game.i18n[i?"format":"localize"](n.join("."),e)}a(h,"localize");function w(t,e){return t.getFlag(f,e)}a(w,"getFlag");function vt(t,e,i){return t.setFlag(f,e,i)}a(vt,"setFlag");function _t(t,e){return t.unsetFlag(f,e,!0)}a(_t,"unsetFlag");function zt(t){return getProperty(t,`flags.${f}`)??{}}a(zt,"getFlags");function O(t){return game.settings.get(f,t)}a(O,"getSetting");function Ue(t,e){return game.settings.set(f,t,e)}a(Ue,"setSetting");function Lt(){return game.user.role>=O("permission")}a(Lt,"hasPermission");function pe(t){return game.i18n.localize(`PF2E.Actions.${t}.Title`)}a(pe,"getActionName");function Vt(t){let i=game.pf2e.ConditionManager.getCondition("off-guard").toObject();return i.name+=` (${game.i18n.localize(`PF2E.condition.${t}.name`)})`,i}a(Vt,"createFlatFootedSource");function Se(t,e){return e??=x[t]===3?4:x[t],{_id:"I9lfZUiCwMiGogVi",img:"systems/pf2e/icons/conditions-2/status_acup.webp",name:h("cover",t),system:{description:{gm:"",value:"

When you're behind an obstacle that could block weapons, guard you against explosions, and make you harder to detect, you're behind cover. Standard cover gives you a +2 circumstance bonus to AC, to Reflex saves against area effects, and to Stealth checks to Hide, Sneak, or otherwise avoid detection. You can increase this to greater cover using the Take Cover basic action, increasing the circumstance bonus to +4. If cover is especially light, typically when it's provided by a creature, you have lesser cover, which grants a +1 circumstance bonus to AC. A creature with standard cover or greater cover can attempt to use Stealth to Hide, but lesser cover isn't sufficient.

"},rules:[{domain:"all",key:"RollOption",option:`self:cover-bonus:${e}`},{domain:"all",key:"RollOption",option:`self:cover-level:${t}`},{key:"FlatModifier",predicate:[{or:[{and:["self:condition:prone","item:ranged"]},{not:"self:cover-level:greater-prone"}]}],selector:"ac",type:"circumstance",value:e},{key:"FlatModifier",predicate:["area-effect",{not:"self:cover-level:greater-prone"}],selector:"reflex",type:"circumstance",value:e},{key:"FlatModifier",predicate:[{or:["action:hide","action:sneak","avoid-detection"]},{not:"self:cover-level:greater-prone"}],selector:"stealth",type:"circumstance",value:e},{key:"FlatModifier",predicate:["action:avoid-notice",{not:"self:cover-level:greater-prone"}],selector:"initiative",type:"circumstance",value:e}],slug:"effect-cover"},type:"effect",flags:{core:{sourceId:Pe},[f]:{level:t,bonus:e}}}}a(Se,"createCoverSource");function Be(t,e=void 0){if(t)return t.system.rules.find(i=>i.key==="ChoiceSet"&&(!e||i.flag===e))}a(Be,"findChoiceSetRule");function Ie(t,e=!1){if(!t)return;let i=t.id,n=t.isToken;return(e?game.user.targets:canvas.tokens.controlled).find(r=>n?r.actor===t:r.actor.id===i)??t.getActiveTokens().shift()??null}a(Ie,"getActorToken");function Z(t){return t.itemTypes.condition.some(e=>e.slug==="prone")}a(Z,"isProne");function te(t,e=!1){let i=t.itemTypes.effect.find(n=>n.sourceId===Pe);return e?Be(i)?.selection.level:i}a(te,"getCoverEffect");function jt(t,e){return!t||!e||!t.system.perception?.senses?!1:(e=e.toLowerCase(),!!t.system.perception.senses.find(({type:i})=>i===e))}a(jt,"hasSense");function He(t){return jt(t,"greater-darkvision")}a(He,"hasGreaterDarkvision");function Ke(t){return jt(t,"see-invisibility")}a(Ke,"seeInvisibility");var qe={LOWER_BY_TWO:-2,LOWER:-1,INCREASE:1,INCREASE_BY_TWO:2,TO_CRITICAL_FAILURE:"criticalFailure",TO_FAILURE:"failure",TO_SUCCESS:"success",TO_CRITICAL_SUCCESS:"criticalSuccess"},Gt=["criticalFailure","failure","success","criticalSuccess"],Qe,Ut,be,Ye,ge,Ae,Xe,Bt,ie=class{constructor(e,i,n=null){ue(this,Qe);ue(this,be);ue(this,ge);ue(this,Xe);e instanceof Roll?(this.dieResult=(e.isDeterministic?e.terms.find(o=>o instanceof NumericTerm):e.dice.find(o=>o instanceof Die&&o.faces===20))?.total??1,this.rollTotal=e.total):(this.dieResult=e.dieValue,this.rollTotal=e.dieValue+e.modifier),this.dc=typeof i=="number"?{value:i}:i,this.unadjusted=q(this,Xe,Bt).call(this),this.adjustment=q(this,Qe,Ut).call(this,this.unadjusted,n),this.value=this.adjustment?q(this,be,Ye).call(this,this.adjustment.amount,this.unadjusted):this.unadjusted}},M=ie;a(M,"DegreeOfSuccess"),Qe=new WeakSet,Ut=a(function(e,i){if(!i)return null;for(let n of["all",...Gt]){let{label:o,amount:r}=i[n]??{};if(r&&o&&!(e===ie.CRITICAL_SUCCESS&&r===qe.INCREASE)&&!(e===ie.CRITICAL_FAILURE&&r===qe.LOWER)&&(n==="all"||Gt.indexOf(n)===e))return{label:o,amount:r}}return null},"#getDegreeAdjustment"),be=new WeakSet,Ye=a(function(e,i){switch(e){case"criticalFailure":return 0;case"failure":return 1;case"success":return 2;case"criticalSuccess":return 3;default:return Math.clamped(i+e,0,3)}},"#adjustDegreeOfSuccess"),ge=new WeakSet,Ae=a(function(e){return this.dieResult===20?q(this,be,Ye).call(this,qe.INCREASE,e):this.dieResult===1?q(this,be,Ye).call(this,qe.LOWER,e):e},"#adjustDegreeByDieValue"),Xe=new WeakSet,Bt=a(function(){let e=this.dc.value;return this.rollTotal-e>=10?q(this,ge,Ae).call(this,ie.CRITICAL_SUCCESS):e-this.rollTotal>=10?q(this,ge,Ae).call(this,ie.CRITICAL_FAILURE):this.rollTotal>=e?q(this,ge,Ae).call(this,ie.SUCCESS):q(this,ge,Ae).call(this,ie.FAILURE)},"#calculateDegreeOfSuccess"),Oe(M,"CRITICAL_FAILURE",0),Oe(M,"FAILURE",1),Oe(M,"SUCCESS",2),Oe(M,"CRITICAL_SUCCESS",3);function Ht(t,e){let i="",n=["standard","npc-vision"];for(let r of n){let s=Ee(t.object,r);i+=`
+(()=>{var It=Object.defineProperty;var wi=(t,e,i)=>e in t?It(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i;var a=(t,e)=>It(t,"name",{value:e,configurable:!0});var Oe=(t,e,i)=>(wi(t,typeof e!="symbol"?e+"":e,i),i),At=(t,e,i)=>{if(!e.has(t))throw TypeError("Cannot "+i)};var Wt=(t,e,i)=>(At(t,e,"read from private field"),i?i.call(t):e.get(t)),ue=(t,e,i)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,i)};var q=(t,e,i)=>(At(t,e,"access private method"),i);var Pe="Compendium.pf2e.other-effects.Item.I9lfZUiCwMiGogVi",P={[void 0]:0,observed:0,concealed:1,hidden:2,undetected:3,unnoticed:4},de=["observed","concealed","hidden","undetected","unnoticed"],U=["none","lesser","standard","greater","greater-prone"],x={[void 0]:0,none:0,lesser:1,standard:2,greater:3,"greater-prone":4},V={cover:"none",visibility:"observed"},ke=["attack-roll","spell-attack-roll"],Dt=[...ke,"skill-check","perception-check"],Ge={cover:"modules/pf2e-perception/images/cover.webp",concealed:"systems/pf2e/icons/conditions/concealed.webp",hidden:"systems/pf2e/icons/conditions/hidden.webp",undetected:"systems/pf2e/icons/conditions/undetected.webp",unnoticed:"systems/pf2e/icons/conditions/unnoticed.webp"};var yt="#000000",ht="#656665",wt="#809e71",$t=["darkness","dance-of-darkness","ravenous-darkness"],Mt=["obscuring-mist","stinking-cloud","noxious-vapors"];var f="pf2e-perception";function X(t){return`modules/${f}/templates/${t}.hbs`}a(X,"templatePath");function h(...t){let e=t.at(-1),i=typeof e=="object",n=i?t.slice(0,-1):t;return n.unshift(f),game.i18n[i?"format":"localize"](n.join("."),e)}a(h,"localize");function w(t,e){return t.getFlag(f,e)}a(w,"getFlag");function vt(t,e,i){return t.setFlag(f,e,i)}a(vt,"setFlag");function _t(t,e){return t.unsetFlag(f,e,!0)}a(_t,"unsetFlag");function zt(t){return getProperty(t,`flags.${f}`)??{}}a(zt,"getFlags");function O(t){return game.settings.get(f,t)}a(O,"getSetting");function Ue(t,e){return game.settings.set(f,t,e)}a(Ue,"setSetting");function Lt(){return game.user.role>=O("permission")}a(Lt,"hasPermission");function pe(t){return game.i18n.localize(`PF2E.Actions.${t}.Title`)}a(pe,"getActionName");function Vt(t){let i=game.pf2e.ConditionManager.getCondition("off-guard").toObject();return i.name+=` (${game.i18n.localize(`PF2E.condition.${t}.name`)})`,i}a(Vt,"createFlatFootedSource");function be(t,e){return e??=x[t]===3?4:x[t],{_id:"I9lfZUiCwMiGogVi",img:"systems/pf2e/icons/conditions-2/status_acup.webp",name:h("cover",t),system:{description:{gm:"",value:"

When you're behind an obstacle that could block weapons, guard you against explosions, and make you harder to detect, you're behind cover. Standard cover gives you a +2 circumstance bonus to AC, to Reflex saves against area effects, and to Stealth checks to Hide, Sneak, or otherwise avoid detection. You can increase this to greater cover using the Take Cover basic action, increasing the circumstance bonus to +4. If cover is especially light, typically when it's provided by a creature, you have lesser cover, which grants a +1 circumstance bonus to AC. A creature with standard cover or greater cover can attempt to use Stealth to Hide, but lesser cover isn't sufficient.

"},rules:[{domain:"all",key:"RollOption",option:`self:cover-bonus:${e}`},{domain:"all",key:"RollOption",option:`self:cover-level:${t}`},{key:"FlatModifier",predicate:[{or:[{and:["self:condition:prone","item:ranged"]},{not:"self:cover-level:greater-prone"}]}],selector:"ac",type:"circumstance",value:e},{key:"FlatModifier",predicate:["area-effect",{not:"self:cover-level:greater-prone"}],selector:"reflex",type:"circumstance",value:e},{key:"FlatModifier",predicate:[{or:["action:hide","action:sneak","avoid-detection"]},{not:"self:cover-level:greater-prone"}],selector:"stealth",type:"circumstance",value:e},{key:"FlatModifier",predicate:["action:avoid-notice",{not:"self:cover-level:greater-prone"}],selector:"initiative",type:"circumstance",value:e}],slug:"effect-cover"},type:"effect",flags:{core:{sourceId:Pe},[f]:{level:t,bonus:e}}}}a(be,"createCoverSource");function Be(t,e=void 0){if(t)return t.system.rules.find(i=>i.key==="ChoiceSet"&&(!e||i.flag===e))}a(Be,"findChoiceSetRule");function Ie(t,e=!1){if(!t)return;let i=t.id,n=t.isToken;return(e?game.user.targets:canvas.tokens?.controlled??[]).find(r=>n?r.actor===t:r.actor.id===i)??t.getActiveTokens().shift()??null}a(Ie,"getActorToken");function Z(t){return t.itemTypes.condition.some(e=>e.slug==="prone")}a(Z,"isProne");function te(t,e=!1){let i=t.itemTypes.effect.find(n=>n.sourceId===Pe);return e?Be(i)?.selection.level:i}a(te,"getCoverEffect");function jt(t,e){return!t||!e||!t.system.perception?.senses?!1:(e=e.toLowerCase(),!!t.system.perception.senses.find(({type:i})=>i===e))}a(jt,"hasSense");function He(t){return jt(t,"greater-darkvision")}a(He,"hasGreaterDarkvision");function Ke(t){return jt(t,"see-invisibility")}a(Ke,"seeInvisibility");var qe={LOWER_BY_TWO:-2,LOWER:-1,INCREASE:1,INCREASE_BY_TWO:2,TO_CRITICAL_FAILURE:"criticalFailure",TO_FAILURE:"failure",TO_SUCCESS:"success",TO_CRITICAL_SUCCESS:"criticalSuccess"},Gt=["criticalFailure","failure","success","criticalSuccess"],Qe,Ut,Se,Ye,ge,Ae,Xe,Bt,ie=class{constructor(e,i,n=null){ue(this,Qe);ue(this,Se);ue(this,ge);ue(this,Xe);e instanceof Roll?(this.dieResult=(e.isDeterministic?e.terms.find(o=>o instanceof NumericTerm):e.dice.find(o=>o instanceof Die&&o.faces===20))?.total??1,this.rollTotal=e.total):(this.dieResult=e.dieValue,this.rollTotal=e.dieValue+e.modifier),this.dc=typeof i=="number"?{value:i}:i,this.unadjusted=q(this,Xe,Bt).call(this),this.adjustment=q(this,Qe,Ut).call(this,this.unadjusted,n),this.value=this.adjustment?q(this,Se,Ye).call(this,this.adjustment.amount,this.unadjusted):this.unadjusted}},M=ie;a(M,"DegreeOfSuccess"),Qe=new WeakSet,Ut=a(function(e,i){if(!i)return null;for(let n of["all",...Gt]){let{label:o,amount:r}=i[n]??{};if(r&&o&&!(e===ie.CRITICAL_SUCCESS&&r===qe.INCREASE)&&!(e===ie.CRITICAL_FAILURE&&r===qe.LOWER)&&(n==="all"||Gt.indexOf(n)===e))return{label:o,amount:r}}return null},"#getDegreeAdjustment"),Se=new WeakSet,Ye=a(function(e,i){switch(e){case"criticalFailure":return 0;case"failure":return 1;case"success":return 2;case"criticalSuccess":return 3;default:return Math.clamped(i+e,0,3)}},"#adjustDegreeOfSuccess"),ge=new WeakSet,Ae=a(function(e){return this.dieResult===20?q(this,Se,Ye).call(this,qe.INCREASE,e):this.dieResult===1?q(this,Se,Ye).call(this,qe.LOWER,e):e},"#adjustDegreeByDieValue"),Xe=new WeakSet,Bt=a(function(){let e=this.dc.value;return this.rollTotal-e>=10?q(this,ge,Ae).call(this,ie.CRITICAL_SUCCESS):e-this.rollTotal>=10?q(this,ge,Ae).call(this,ie.CRITICAL_FAILURE):this.rollTotal>=e?q(this,ge,Ae).call(this,ie.SUCCESS):q(this,ge,Ae).call(this,ie.FAILURE)},"#calculateDegreeOfSuccess"),Oe(M,"CRITICAL_FAILURE",0),Oe(M,"FAILURE",1),Oe(M,"SUCCESS",2),Oe(M,"CRITICAL_SUCCESS",3);function Ht(t,e){let i="",n=["standard","npc-vision"];for(let r of n){let s=Ee(t.object,r);i+=`

${h(`settings.${r}.short`)}

-
`}i+="
",e.find('.tab[data-tab="basic"] hr').first().after(i);let o=e.find(".pf2e-perception-injected").toArray().reduce((r,s)=>(r+=s.clientHeight,r),0);t.setPosition({top:t.position.top-o/2})}a(Ht,"renderSceneConfig");function j(t){if(t=t instanceof Token?t.document:t,!(t instanceof TokenDocument))return[];let e=t.scene.tokens.filter(i=>i!==t&&i.actor?.isOfType("creature"));if(O("encounter")){let i=game.combats.active;return i?e.filter(n=>{let o=n.actor,r=o.traits;return o.type==="familiar"||r.has("minion")||r.has("eidolon")||i.getCombatantByToken(n.id)}):e}return e}a(j,"getValidTokens");function ne(t,e){let i=j(t).map(n=>n.id);return e.filter(n=>{let o=n instanceof Token||n instanceof TokenDocument?n.id:n;return i.includes(o)})}a(ne,"validateTokens");function Ee(t,e){return w(t,e)??O(e)}a(Ee,"getSceneSetting");async function Pt({affects:t,origin:e,target:i,item:n,domains:o,options:r}){if(!(e&&i))return[];let[s,c]=t==="target"?[e,i]:[i,e],l=[...r,s.getRollOptions(o),c.getSelfRollOptions(t)].flat(),p=n?n.isOfType("spell")?{spell:n}:{weapon:n}:{};return(await Promise.all(o.flatMap(d=>s.synthetics.ephemeralEffects[d]?.[t]??[]).map(d=>d({test:l,resolvables:p})))).flatMap(d=>d??[])}a(Pt,"extractEphemeralEffects");function Kt(t,e){if(!t.isOfType("action","melee","weapon"))return null;let{increment:i}=t.range??{};return i&&typeof e=="number"?Math.max(Math.ceil(e/i),1):null}a(Kt,"getRangeIncrement");function qt(t,e){if(!t?.isOfType("creature"))return!1;let{flanking:i}=t.attributes;return i.flankable?typeof i.offGuardable=="number"?e.level>i.offGuardable:i.offGuardable:!1}a(qt,"isOffGuardFromFlanking");function kt(t){return typeof t=="object"&&t!==null}a(kt,"isObject");function Yt(t,e){return t.includes(e)}a(Yt,"tupleHasValue");function $i(t,e){return canvas.dimensions?canvas.grid.type!==CONST.GRID_TYPES.SQUARE?canvas.grid.measureDistance(t,e):Mi(new Ray(t,e)):NaN}a($i,"measureDistance");function Mi(t,{reach:e=null}={}){if(!canvas.dimensions)return NaN;let i=canvas.dimensions.size,n=canvas.dimensions.distance,o=Math.ceil(Math.abs(t.dx/i)),r=Math.ceil(Math.abs(t.dy/i)),s=Math.ceil(Math.abs((t.dz||0)/i)),c=[o,r,s].sort((u,g)=>u-g),l={doubleDiagonal:c[0],diagonal:c[1]-c[0],straight:c[2]-c[1]},p=l.diagonal+l.doubleDiagonal>1&&e===10?1:0;return(Math.floor(l.doubleDiagonal*1.75+l.diagonal*1.5+l.straight)-p)*n}a(Mi,"measureDistanceOnGrid");function Qt({areaType:t,object:e,colors:i,document:n,collisionType:o="move",preview:r=!1,collisionOrigin:s}){if(!e.id&&!r)return;let{grid:c,dimensions:l}=canvas;if(!(c&&l))return;let p=n.angle??0,d=n.direction??45,u=c.getHighlightLayer(e.highlightId)?.clear();if(!u)return;let[g,m]=c.getCenter(n.x,n.y),[y,k]=c.grid.getGridPositionFromPixels(g,m),R=(360+(d-p*.5)%360)%360,E=(360+(d+p*.5)%360)%360,S=canvas.grid.getSnappedPosition(n.x,n.y,e.layer.gridPrecision),F=a((W,_,D)=>(W=(360+W%360)%360,_=(360+_%360)%360,D=(360+D%360)%360,W<_?D>=W&&D<=_:D>=W||D<=_),"withinAngle"),T=(()=>{if(t!=="cone")return{x:0,y:0};let W=(d>=0?360-d:-d)%360,_=S.x%l.size!==0?Math.sign(1*Math.round(Math.cos(Math.toRadians(W))*100)/100)/2:0,D=S.y%l.size!==0?-Math.sign(1*Math.round(Math.sin(Math.toRadians(W))*100)/100)/2:0;return{x:_*l.size,y:D*l.size}})(),A=Math.clamped(n.width??0,1.5,2),b=n.distance??0,N=b*A/l.distance,G=Math.ceil(N/(l.size/c.h)),ce=Math.ceil(N/(l.size/c.w)),Ce=a(W=>{if(!(t==="emanation"&&e instanceof Token))return{x:0,y:0};if(e.w<=l.size)return{x:0,y:0};let _=(e.w-l.size)/2,D=a((v,C)=>C===v?0:C>v?_:-_,"getCoordinate");return{x:D(e.center.x,W.x),y:D(e.center.y,W.y)}},"offsetEmanationOrigin");for(let W=-ce;W0&&!F(R,E,Di))continue}if($i(C,ve)>b)continue;canvas.ready&&CONFIG.Canvas.polygonBackends[o].testCollision(s??ve,C,{type:o,mode:"any"})?(c.grid.highlightGridPosition(u,{x:D,y:v,border:1,color:0}),u.beginFill(0,.5).moveTo(D,v).lineTo(D+l.size,v+l.size).endFill()):c.grid.highlightGridPosition(u,{x:D,y:v,border:i.border,color:i.fill})}}a(Qt,"highlightGrid");var _i={burst:"circle",emanation:"circle",line:"ray",cone:"cone",rect:"rect",cube:"rect",square:"rect"};function Ze({type:t="burst",token:e,distance:i}){St(e)&&(i??=t==="cone"?30:15,bt({type:t,distance:i,traits:["concentrate","secret"],flags:{type:"seek",tokenId:e.id,collisionType:"sight",collisionOrigin:e.center}}))}a(Ze,"createSeekTemplate");function Xt({type:t="burst",distance:e=20,conceal:i=!1}={}){bt({type:t,distance:e,fillColor:yt,flags:{type:"darkness",conceal:i}})}a(Xt,"createDarknessTemplate");function Zt({type:t="burst",distance:e=20}={}){bt({type:t,distance:e,fillColor:ht,flags:{type:"mist"}})}a(Zt,"createMistTemplate");function Jt(t,e){return e&&!St(e)?null:canvas.scene.templates.filter(i=>w(i,"type")===t)??[]}a(Jt,"getTemplates");function Je(t){return Jt("darkness",t)}a(Je,"getDarknessTemplates");function et(t){return Jt("mist",t)}a(et,"getMistTemplates");function tt(t){if(!St(t))return null;let e=canvas.scene.templates.find(n=>w(n,"type")==="seek");if(!e)return null;let i=t instanceof Token?t.document:t;return Te(e,{collisionType:"sight",collisionOrigin:i.center})}a(tt,"getSeekTemplateTokens");async function J(t){let e=t.scene.templates.filter(i=>w(i,"type")==="seek"&&w(i,"tokenId")===t.id);for(let i of e)await i.delete()}a(J,"deleteSeekTemplate");function St(t){return canvas.scene===t.scene?!0:(ui.notifications.error(h("template.scene")),!1)}a(St,"checkScene");function bt({type:t,distance:e,traits:i,fillColor:n,width:o,flags:r}){let s=_i[t],c={distance:e,t:s,fillColor:n||game.user.color,flags:{[f]:r}};switch(s){case"ray":c.width=o||CONFIG.MeasuredTemplate.defaults.width*(canvas.dimensions?.distance??1);break;case"cone":c.angle=CONFIG.MeasuredTemplate.defaults.angle;break;case"rect":{let l=c.distance??0;c.distance=Math.hypot(l,l),c.width=l,c.direction=45;break}}i&&setProperty(c,"flags.pf2e.origin.traits",i),canvas.templates.createPreview(c)}a(bt,"createTemplate");function Te(t,{collisionOrigin:e,collisionType:i="move"}={}){let n=t instanceof MeasuredTemplateDocument?t.object:t;if(!canvas.scene)return[];let{grid:o,dimensions:r}=canvas;if(!(o&&r))return[];let s=o.getHighlightLayer(n.highlightId);if(!s||o.type!==CONST.GRID_TYPES.SQUARE)return[];let c=e??n.center,l=canvas.tokens.quadtree.getObjects(s.getLocalBounds(void 0,!0)),p=[];for(let d of l){let u=d.document,g=[];for(let m=0;m1)for(let k=1;kNumber(S)),R={x:y+r.size*.5,y:k+r.size*.5};if(R.x<0||R.y<0)continue;if(!(canvas.ready&&i&&CONFIG.Canvas.polygonBackends[i].testCollision(c,R,{type:i,mode:"any"}))){p.push(d);break}}}return p}a(Te,"getTemplateTokens");function ei(){let t=["circle","cone"].includes(this.document.t),e=canvas.grid.type===CONST.GRID_TYPES.SQUARE;if(!t||!e)return MeasuredTemplate.prototype.highlightGrid.call(this);if(!this.isVisible){canvas.grid.getHighlightLayer(this.highlightId)?.clear();return}let i=w(this.document,"collisionType"),n=w(this.document,"collisionOrigin");this.snapForShape(),Qt({areaType:Yt(["burst","cone","emanation"],this.areaType)?this.areaType:"burst",object:this,document:this.document,colors:{border:this.borderColor,fill:this.fillColor},preview:!0,collisionType:i,collisionOrigin:n})}a(ei,"highlightTemplateGrid");function ti(t){let{type:e,slug:i,castLevel:n=0}=t.getFlag("pf2e","origin")??{};e==="spell"&&($t.includes(i)?t.updateSource({fillColor:yt,[`flags.${f}`]:{type:"darkness",conceal:n>=4}}):Mt.includes(i)?t.updateSource({fillColor:ht,[`flags.${f}`]:{type:"mist"}}):i==="cloudkill"&&t.updateSource({fillColor:wt,[`flags.${f}`]:{type:"mist"}}))}a(ti,"preCreateMeasuredTemplate");function it(t){w(t,"type")==="darkness"&&canvas.perception.update({initializeVision:!0})}a(it,"onMeasuredTemplate");function Re(t,e=1){let i=Object.getPrototypeOf(t);return e>1?Re(i,e-1):i}a(Re,"getPrototype");function nt(t,e){return t.name.localeCompare(e.name)}a(nt,"sortByName");function rt(t){return t=Number(t),isNaN(t)?void 0:t}a(rt,"asNumberOnly");var Y=class extends Application{#e;#i;#t;#n;#r;constructor({token:e,resolve:i,selected:n=[]},o={}){super(o),this.#e=e,this.#i=i,this.#t=n,this.#r=(r,s)=>{let c=r.id,l=this.element.find("[data-token-id]");l.removeClass("hover"),s&&l.filter(`[data-token-id=${c}]`).addClass("hover")},Hooks.on("hoverToken",this.#r)}async close(e={}){Hooks.off("hoverToken",this.#r),this.#i?.(e.resolve??!1),super.close(e)}static get defaultOptions(){return mergeObject(Application.defaultOptions,{minimizable:!1})}static async openMenu(e,i={}){if(e.token instanceof TokenDocument&&(e.token=e.token.object),!e.token){ui.notifications.error(h("menu.no-token"));return}i.id=`${f}-${e.token.document.uuid}`;let n=Object.values(ui.windows).find(o=>o.id===i.id);return n&&n.close(),new Promise(o=>{e.resolve=o,new this(e,i).render(!0)})}static createPropertyData(e,i,n){let o=V[n],r=e[n]??o,s=i[n]??o;return{original:r,current:s,changed:r!==s,custom:s!==o,originalCustom:r!==o}}get token(){return this.#e}get document(){return this.#e.document}get actor(){return this.#e.actor}get scene(){return this.#e.scene}get selected(){return this.#t.length?ne(this.token,this.#t):[]}get currentData(){return deepClone(this.#o)}get#o(){return this.#n||(this.#n=this.getSavedData()),this.#n}getSavedData(){let e=z(this.document)??{};return deepClone(e)}reset(){this.#n=this.getSavedData(),this.#t=[],this.render()}isSelected(e){let i=typeof e=="object"?e.id:e;return this.#t.includes(i)}getData(e){return{i18n:h,covers:U.map(i=>({value:i,label:h(`cover.${i}`)})),visibilities:de.map(i=>({value:i,label:h(`visibility.${i}`)}))}}activateListeners(e){e.find("[data-token-id]").on("mouseenter",i=>{let{tokenId:n}=i.currentTarget.dataset,o=this.scene.tokens.get(n)?.object;!o||o.controlled||o._onHoverIn(i,{hoverOutOthers:!0})}),e.find("[data-action=close]").on("click",()=>{this.close({resolve:!0})}),e.find("select[name=visibility], select[name=cover]").on("change",i=>{let n=i.currentTarget,o=n.name,r=V[o],s=n.value||r,c=n.closest(".token")?.dataset.tokenId,l=c?[c]:this.#t;for(let p of l)setProperty(this.#o,`${p}.${o}`,s);c?(n.classList.toggle("changed",s!==n.dataset.original),n.classList.toggle("custom",s!==r)):this.render()}),e.find("[data-action=accept]").on("click",i=>{this._saveData(this.#o),this.close({resolve:!0})})}_saveData(e){ot(this.document,e)}_setSelected(e){this.#t=e??this.element.find("[data-token-id].ui-selected").toArray().map(i=>i.dataset.tokenId)}_spliIntoAlliances(e){let i=[],n=[],o=[],r=this.actor.alliance,s=r==="party"?"opposition":r==="opposition"?"party":null;for(let c of e)if(s){let l=c.actor?c.actor.alliance:c.alliance;l===r?i.push(c):l===s?n.push(c):l===null&&o.push(c)}else o.push(c);return{allies:i.sort(nt),neutral:o.sort(nt),enemies:n.sort(nt),hasTokens:i.length||n.length||o.length}}};a(Y,"BaseMenu");var We=class extends Y{get title(){return h("menu.perception.title",{name:this.token.name})}get template(){return X("perception")}getData(e){let i=this.selected,n=this.currentData,o=this.getSavedData(),r=j(this.token).map(({id:s,name:c,actor:l})=>{let p=n[s]??{},d=o[s]??{};return{id:s,name:c,alliance:l.alliance,cover:Y.createPropertyData(d,p,"cover"),visibility:Y.createPropertyData(d,p,"visibility"),selected:i.includes(s)}});return{...super.getData(e),...this._spliIntoAlliances(r)}}activateListeners(e){super.activateListeners(e),e.filter(".tokens").selectable({autoRefresh:!1,filter:".token",cancel:"header,select",stop:()=>this._setSelected()}),e.find("[data-action=select-all]").on("click",i=>{let n=$(i.currentTarget).closest("section"),o=(n.length?n:e).find("[data-token-id]"),r=o.filter(":not(.ui-selected)").length===0;o.toggleClass("ui-selected",!r),this._setSelected()}),e.find("[data-action=use-selection]").on("click",i=>{this._setSelected(canvas.tokens.controlled.map(n=>n.id)),this.render()}),e.find("[data-action=reset]").on("click",i=>this.reset())}};a(We,"PerceptionMenu");var zi=[{x:.25,y:.25},{x:.5,y:.25},{x:.75,y:.25},{x:.25,y:.5},{x:.5,y:.5},{x:.75,y:.5},{x:.25,y:.75},{x:.5,y:.75},{x:.75,y:.75}];function at(t,e){let i=1-e;return{top:{A:ee({x:e,y:e},t),B:ee({x:i,y:e},t)},right:{A:ee({x:i,y:e},t),B:ee({x:i,y:i},t)},bottom:{A:ee({x:i,y:i},t),B:ee({x:e,y:i},t)},left:{A:ee({x:e,y:i},t),B:ee({x:e,y:e},t)}}}a(at,"getRectEdges");function De(t,e,i=!1){return i&&Q(t,e),CONFIG.Canvas.polygonBackends.move.testCollision(t,e,{type:"move",mode:"any"})}a(De,"lineIntersectWall");function st(t,e,i=!1){for(let n of Li(e.bounds))if(De(t,n,i))return!0;return!1}a(st,"pointToTokenIntersectWall");function ee(t,e){return{x:e.x+e.width*t.x,y:e.y+e.height*t.y}}a(ee,"getRectPoint");function me(){canvas.controls.debug.clear()}a(me,"clearDebug");function Q(t,e,i="blue"){let n=i==="blue"?26316:i==="red"?16711680:1483011;canvas.controls.debug.lineStyle(4,n).moveTo(t.x,t.y).lineTo(e.x,e.y)}a(Q,"drawDebugLine");function*Li(t){for(let e of zi)yield ee(e,t)}a(Li,"rectSpread");function ct(t,e=!1){if(t=t instanceof Token?t:t.object,t.document.hasStatusEffect(CONFIG.specialStatusEffects.INVISIBLE))return;let i=t.scene;if(i!==canvas.scene||!i.tokenVision||i.darkness{let{name:m,uuid:y}=this.item;console.warn(`PF2e System | PF2ePerception rules element on item ${m} (${y}) simple warning: ${g}`)},"selectorWarn"),d=Array.isArray(l.targets)?[...l.targets,"all"]:l.targets,u=Array.isArray(d)?d.join(", "):null;if(!d&&r.targets?.length){p(`The selector "${r.selector}" doesn't accept any targets property.`);return}if(r.selector==="ignore"&&!r.targets?.length){let g=`The selector "${r.selector}" requires a targets property with the ids of the tokens on the scene that should not give cover.`;this.failValidation(g);return}if(u&&r.targets?.some(g=>!d.includes(g))){let g=`The targets property of selector "${r.selector}" only accepts the following: ${u}.`;this.failValidation(g);return}else if(!u&&d&&r.targets?.some(g=>typeof g!==d)){let g=`The targets property of selector "${r.selector}" needs to be of type "${d}".`;this.failValidation(g);return}if(!l.value&&r.value){p(`The selector "${r.selector}" doesn't accept any value property.`);return}if(r.selector==="set"){if(!l.value.includes(r.value)){let g=l.value.join(", "),m=`The selector "${r.selector}" only accepts the following: ${g}.`;this.failValidation(m)}}else{let g=typeof r.value;if(l.value&&!l.value.includes(g)){let m=`The selector "${r.selector}" does not accept a value property of type ${g}.`;this.failValidation(m)}}}static defineSchema(){let{fields:r}=foundry.data;return{...super.defineSchema(),type:new r.StringField({required:!0,nullable:!1,blank:!1,choices:["visibility","cover"]}),affects:new r.StringField({required:!0,nullable:!1,blank:!1,initial:"self",choices:["self","other"]}),selector:new r.StringField({required:!0,nullable:!1,blank:!1}),targets:new r.ArrayField(new r.StringField({required:!0,nullable:!1,blank:!1,initial:void 0}),{required:!0,nullable:!1,initial:["all"]}),predicate:new e({required:!1,nullable:!1}),value:new i({required:!1,initial:void 0})}}test(r,s){return s?super.test(r):!1}addToPerception(r,s,c){if(!this.test(c,!0))return;let p=`${this.affects==="self"?r:r==="origin"?"target":"origin"}.${this.type}.${this.selector}`,d=xe[this.type][this.selector];if(!d.targets){setProperty(s,p,!0);return}let u=this.targets.includes("all")?d.targets:this.targets;if(!d.value){for(let g of u){let m=`${p}.${g}`;setProperty(s,m,!0)}return}for(let g of u){let m=`${p}.${g}`,y=getProperty(s,m);y?y.add(this.value):y=new Set([this.value]),setProperty(s,m,y)}}}a(n,"PF2ePerceptionRuleElement"),game.pf2e.RuleElements.custom.PF2ePerception=n}a(ii,"setupRuleElement");function re(t,e,{distance:i,extraOptions:n=[]}={}){let o=t.actor,r=e.actor;if(!o||!r)return{};let s={origin:o.rules.filter(u=>!u.ignored&&u.key==="PF2ePerception")??[],target:r.rules.filter(u=>!u.ignored&&u.key==="PF2ePerception")??[]};if(!s.origin.length&&!s.target.length)return{};let c={origin:o.getRollOptions(),target:r.getRollOptions()},l={origin:r.getSelfRollOptions("target"),target:o.getSelfRollOptions("origin")};t=t instanceof Token?t:t.object,e=e instanceof Token?e:e.object,i??=t.distanceTo(e);let p=[`origin:distance:${i}`,`target:distance:${i}`],d={};for(let u of["origin","target"]){let g=[...n,...c[u],...l[u],...p];for(let m of s[u])m.addToPerception(u,d,g)}return d}a(re,"perceptionRules");function ni(t){let e=t.actor;return e?(e.rules.filter(n=>!n.ignored&&n.key==="PF2ePerception"&&n.type==="cover"&&n.selector==="ignored")??[]).flatMap(n=>n.targets):[]}a(ni,"getIgnoredPerception");function B(t,e,i,n,o){let r=t[e]?.[i]?.[n];return o?r?.[o]:r}a(B,"getPerception");function Fe(t,e,i,n){n===void 0&&(n=i==="cover"?"none":"observed");let o=i==="cover"?U:de;if(n&&B(t,e,i,"cancel",n))return;let r=B(t,e,i,"set",n)?.first();if(r&&o.includes(r))n=r;else if(n&&B(t,e,i,"reduce",n)){let s=o.indexOf(n);n=o[Math.max(0,s-1)]}return n===o[0]?void 0:n}a(Fe,"updateFromPerceptionRules");function ri(t,e){!Lt()||!t.object.actor?.isOfType("creature")||(e.find(".col.left").append('
'),e.find("[data-action=pf2e-perception]").on("click",i=>Et(t.object)))}a(ri,"renderTokenHUD");function Et(t){return We.openMenu({token:t})}a(Et,"openHUD");function oi(t,e){for(let i of e)delete i.flags?.[f]}a(oi,"pasteToken");function z(t,...e){return e.unshift("data"),t=t instanceof Token?t.document:t,w(t,e.join("."))}a(z,"getTokenData");async function ai(t){return t=t instanceof Token?t.document:t,_t(t,"data")}a(ai,"clearTokenData");async function ot(t,e){let i=j(t).map(o=>o.id),n={};for(let o in e){if(!i.includes(o)){n[`flags.${f}.data.-=${o}`]=!0;continue}let r=e[o],s=z(t,o)??{};if(r.visibility===V.visibility&&delete r.visibility,r.cover===V.cover&&delete r.cover,!(s.cover===r.cover&&s.visibility===r.visibility))if(!r.visibility&&!r.cover)n[`flags.${f}.data.-=${o}`]=!0;else for(let c of["cover","visibility"])s[c]!==r[c]&&(r[c]?n[`flags.${f}.data.${o}.${c}`]=r[c]:n[`flags.${f}.data.${o}.-=${c}`]=!0)}return t=t instanceof Token?t.document:t,t.update(n)}a(ot,"setTokenData");function lt(t,e,i=!1){let n=t.scene;return Ee(n,"standard")?(i&&me(),(O("standard-type")==="points"?st(t.center,e,i):De(t.center,e.center,i))?"standard":void 0):void 0}a(lt,"getWallCover");var fe={tiny:0,sm:1,med:2,lg:3,huge:4,grg:5};function dt(t,e,{perception:i={},options:n=[],affects:o="origin",debug:r=!1}={}){let s=n.includes("item:ranged")?Z(e.actor):!1,c=a(d=>Fe(i,o,"cover",d),"returnValue"),l=te(e.actor,!0);if(s&&x[l]>x.lesser)return c("greater-prone");!s&&l==="greater-prone"&&(l=void 0);let p=z(e,t.id,"cover");if(s&&x[p]>x.lesser)return c("greater-prone");if(!s&&p==="greater-prone"&&(p=void 0),x[l]x[p]&&(p=g)}if(x[p]5){let u=d.getCreatureCover,g;if(typeof u=="function"){let m=u(t,e,{perception:i,debug:r});g=U.includes(m)?m:ut(t,e,{perception:i,debug:r})}else g=ut(t,e,{perception:i,debug:r});x[g]>x[p]&&(p=g)}}return s&&x[p]>x.lesser?c("greater-prone"):c(x[p]>x[l]?p:void 0)}a(dt,"getCover");function ut(t,e,{perception:i={},debug:n=!1}={}){let o=O("lesser");if(o==="none")return;t=t instanceof Token?t.document:t,e=e instanceof Token?e.document:e;let r=(()=>{let b=Object.keys(i.origin?.cover?.ignore??{}),N=Object.keys(i.target?.cover?.ignore??{});return new Set([...b,...N])})(),s,c=t.center,l=e.center,p=t.actor,d=e.actor;n&&(me(),Q(c,l));let u=a(b=>{let N=fe[b.actor.size];return N-g>=2&&N-m>=2},"isExtraLarge"),g=fe[p.size],m=fe[d.size],y=p.alliance,k=O("dead-cover"),R=O("prone-cover"),E=t.scene.tokens.contents.filter(b=>{let N=b.actor,G=ni(b);return N&&!b.hidden&&b!==t&&b!==e&&(R||!Z(N))&&(k||N.hitPoints?.value!==0)&&!r.has(b.id)&&!(G.includes("all")||G.includes(N.alliance===y?"allies":"enemies"))}).sort((b,N)=>fe[N.actor.size]-fe[b.actor.size]),S=g(n&&Q(b.A,b.B,"red"),lineSegmentIntersects(c,l,b.A,b.B)),"intersectsEdge"),A=o==="cross"?b=>T(b.top)&&T(b.bottom)||T(b.left)&&T(b.right):b=>Object.values(b).some(N=>T(N));for(let b of E){let N=b.object,G=at(N.bounds,F);if(A(G))return S?"standard":"lesser";u(b)&&S--}return s}a(ut,"getCreatureCover");function oe(t,e,{perception:i={},affects:n="origin",debug:o=!1}={}){t=t instanceof Token?t:t.object,e=e instanceof Token?e:e.object;let r=t.actor,s=e.actor,c=(()=>{if(!r||!s)return;let S;s.hasCondition("blinded")?S="hidden":s.hasCondition("dazzled")&&(S="concealed");for(let F of["unnoticed","undetected","hidden","concealed"])P[F]>P[S]&&r.hasCondition(F)&&(S=F);return S})(),l=a(S=>p?(P[S]P[d]?c:d;if(P[u]>=P.hidden||p)return l(u);let g=s?.hasLowLightVision,m=s?.hasDarkvision,y=s&&He(s);if(y&&u==="concealed")return l(u);let k;if(!y){let S=Je(t);if(S?.length){let F;for(let T of S){let A=Te(T);if(!A.length)continue;if(A.includes(t)||A.includes(e))k=!0;else continue;if(!m)return l("hidden");w(T,"conceal")&&(F="concealed")}if(F==="concealed"&&(u="concealed"),k&&u==="concealed")return l(u)}}if(u!=="concealed"){let S=et(t);if(S?.length)for(let F of S){let T=Te(F);if(!T.length)continue;if(T.includes(t)||T.includes(e))return l("concealed")}}if(k||y)return l(u);let R=ct(t,o),E=R==="dim"?"concealed":R===null?"hidden":void 0;return(E==="concealed"&&g||E==="hidden"&&m)&&(E=void 0),P[E]>P[u]&&(u=E),l(u)}a(oe,"getVisibility");function si(t,e,i,n){let o=e.flags?.["pf2e-perception"];if(o&&(o.data||o["-=data"]!==void 0)){if(t.object.renderFlags.set({refreshVisibility:!0}),game.user.isGM)return;let r=Hooks.on("refreshToken",s=>{!t.object!==s&&(Hooks.off("refreshToken",r),game.combat?.getCombatantByToken(t.id)&&ui.combat.render())})}}a(si,"updateToken");function ci(t,e){e?pt(t):ye(t)}a(ci,"hoverToken");function li(t){ye(t),game.user.isGM||ui.combat.render()}a(li,"deleteToken");function di(t,e){e&&(ye(),Hooks.once("sightRefresh",()=>t.hover&&pt(t)))}a(di,"controlToken");function ye(t){if(!t?.id)return $(".pf2e-conditionals").remove();$(`.pf2e-conditionals[data-hover-id=${t.id}]`).remove(),$(`.pf2e-conditionals[data-token-id=${t.id}]`).remove()}a(ye,"clearConditionals");function pt(t){let e=j(t);for(let i of e)Tt(i,t)}a(pt,"showAllConditionals");async function Tt(t,e){if(t=t instanceof Token?t:t.object,!t.visible||!t.actor?.isOfType("creature"))return;let i=z(t,e.id);if(isEmpty(i))return;if(!game.user.isGM&&!e.document.hasPlayerOwner&&P[i.visibility]>=P.hidden){if(!i.cover)return;i={cover:i.cover}}let n=t.worldTransform.a,o=canvas.clientCoordinatesFromCanvas(t.document._source),r=O("icon-size"),s=[`top: ${o.y}px`,`left: ${o.x+t.hitArea.width*n/2}px`,`--icon-size: ${r}px`].join("; "),c=`
`;let l=O("icon-path");Object.entries(i).map(([p,d])=>{let u=p==="cover"?"cover":d,g=l[u]||Ge[u];(g.startsWith("systems")||g.startsWith("modules"))&&(g=`../../../${g}`),c+=`
`}),c+="
",$(document.body).append(c)}a(Tt,"showConditionals");function pi(){return!!(this.sight.enabled&&this.actor?.isOfType("creature")&&this.scene?.rulesBasedVision)}a(pi,"rulesBasedVision");function gi(t){let e=t.actor;if(e?.isOfType("creature")&&(e.isOfType("npc")&&Ee(t.scene,"npc-vision")&&t.updateSource({"sight.enabled":!0}),game.user.isGM&&t.hidden)){let i=game.user.targets,n={};for(let o of i)n[o.id]={visibility:"unnoticed"};i.size&&t.updateSource({[`flags.${f}.data`]:n})}}a(gi,"preCreateToken");var we=class extends Y{static async openMenu(e,i){let n=await super.openMenu(e,i);return n&&e.message&&mi(e.message),n}get title(){return h("menu.validation.title",{name:this.token.name})}get template(){return X("validation")}get selected(){let e=super.selected;return e.length?e:this.globalSelection}get globalSelection(){let e=this.token,i=e.actor.alliance;return j(e).filter(n=>n.actor.alliance!==i).map(n=>n.id)}getSavedData(e=!0){let i=super.getSavedData();return e?this._convertData(i):i}_convertData(e){let i=this.property,n=this.scene,o=this.selected,r=V[i],s=i==="cover"?U:de;for(let c of o){let l=n.tokens.get(c),p=`${c}.${i}`,d=getProperty(e,p)??r,u=this.processValue({token:l,value:d});s.includes(u)||(u=d),d!==u&&setProperty(e,p,u)}return e}processValue(e){throw new Error(`${this.constructor.name} doesn't have a 'processValue' method defined`)}getData(e){let{covers:i,visibilities:n,i18n:o}=super.getData(e),r=this.currentData,s=this.getSavedData(!1),c=this.property,l=this.selected,p=j(this.token);p=p.map(({id:u,name:g,actor:m})=>{let y=r[u]??{},k=s[u]??{};return{id:u,name:g,alliance:m.alliance,selected:l.includes(u),...Y.createPropertyData(k,y,c)}});let d=O("validation");return d==="selected"?p=p.filter(u=>u.selected):d==="changed"&&(p=p.filter(u=>u.changed)),{...this._spliIntoAlliances(p),i18n:o,property:c,options:c==="cover"?i:n,showSelected:l.length!==p.length&&d==="all",showChanges:d!=="changed"}}activateListeners(e){super.activateListeners(e),e.find("[data-action=cancel]").on("click",i=>{this.close()})}};a(we,"ValidationMenu");var $e=class extends we{#e;constructor(e,i={}){super(e,i),this.#e=e.value}get property(){return"cover"}processValue(){return this.#e}};a($e,"CoverValidationMenu");var ae=class extends we{#e;constructor(e,i={}){super(e,i),this.#e=e.roll}get property(){return"visibility"}get roll(){return this.#e}};a(ae,"VisibilityValidationMenu");var Me=class extends ae{processValue({token:e,value:i}){let n=this.roll,o=e.actor.perception.dc.value,r=P[i],s=new M(n,o).value;return s>=M.SUCCESS&&r=P.hidden?"observed":i}};a(Me,"HideValidationMenu");var _e=class extends ae{processValue({token:e,value:i}){let n=this.roll,o=e.actor.perception.dc.value,r=P[i];return new M(n,o).value>=M.SUCCESS&&re.id)}processValue({token:e,value:i}){return P[i]>=P.hidden?"observed":i}};a(ze,"UnHideValidationMenu");var Le=class extends ae{#e;constructor(e,i={}){super(e,i),this.#e=e.originator}get selected(){let e=this.token,i=e.actor.alliance,n=this.#e.id,o=z(e)??{};return j(e).filter(r=>{if(r.id===n||r.actor.alliance===i)return!1;let s=getProperty(o,`${r.id}.visibility`);return P[s]>=P.undetected}).map(r=>r.id)}processValue({token:e,value:i}){return P[i]>=P.undetected?"hidden":i}};a(Le,"PointOutValidationMenu");var gt=class extends ae{getSavedData(e=!0){let i=this.token.id,n=j(this.token),o={};for(let r of n){let s=z(r,i);s&&(o[r.id]=deepClone(s))}return e?this._convertData(o):o}getData(){let e=super.getData();return e.isReversed=!0,e.options=de.map(i=>({value:i,label:h(`visibility.reversed.${i}`)})),e}_saveData(e){let i=this.scene,n=this.token.id,o=[];for(let[r,s]of Object.entries(e)){let c={_id:r},l=i.tokens.get(r);if(l){s.visibility===V.visibility&&delete s.visibility;let p=z(l,n)??{};if(p?.visibility===s.visibility)continue;!p.cover&&!s.visibility?c[`flags.${f}.data.-=${n}`]=!0:s.visibility?c[`flags.${f}.data.${n}.visibility`]=s.visibility:c[`flags.${f}.data.${n}.-=visibility`]=!0}else c[`flags.${f}.data.-=${n}`]=!0;o.push(c)}i.updateEmbeddedDocuments("Token",o)}};a(gt,"ReverseVisibilityValidationMenu");var Ve=class extends gt{#e;constructor(e,i={}){super(e,i),this.#e=e.fromTemplate}get globalSelection(){return[]}static async openMenu(e,i){await super.openMenu(e,i)&&J(e.token)}processValue({token:e,value:i}){let n=this.roll,o=e.actor.skills.stealth.dc.value,r=P[i],s=new M(n,o).value;return s>=M.CRITICAL_SUCCESS&&r>=P.hidden||s>=M.SUCCESS&&r===P.hidden?"observed":s>=M.SUCCESS&&r>=P.undetected?"hidden":i}};a(Ve,"SeekValidationMenu");function xt(t,e){let i=t.token;if(!i)return;let n=game.user.isGM,o=i.hasPlayerOwner,{cover:r,selected:s,skipWait:c,validated:l,pointOut:p}=zt(t),d=t.getFlag("pf2e","context");if(r){if(n){let u=mt({property:"cover",skipWait:c,validated:l});e.find(".message-content").append(u),e.find("[data-action=validate-cover]").on("click",()=>{$e.openMenu({token:i,selected:s,value:r,message:t})})}else if(!c){let u=Rt("cover",l);e.find(".message-content").append(u)}}else if(d?.pf2ePerception?.visibility){l||e.find(".message-buttons").remove();let u=e.find(".flavor-text");!n&&o&&(e.find(".message-sender").text(i.name),u.empty());let g=h(`message.flat-check.${l===void 0?"blind":l?"success":"failure"}`),m=vi(g,l);if(u.append(m),n)for(let y of["success","failure"])u.append(Ft({action:`${y}-message`,icon:"fa-solid fa-message",label:h("message.flat-check.button",y)})),e.find(`[data-action=${y}-message]`).on("click",()=>{vt(t,"validated",y==="success")})}else if(d?.type==="skill-check"&&d.pf2ePerception)if(n){if(d.options.includes("action:hide")){let u=mt({property:"visibility",skipWait:c,validated:l});e.find(".flavor-text").append(u),e.find("[data-action=validate-visibility]").on("click",()=>{Me.openMenu({token:i,message:t,roll:t.rolls[0],selected:d.pf2ePerception.selected})})}else if(d.options.includes("action:create-a-diversion")){let u=mt({property:"visibility",skipWait:c,validated:l});e.find(".flavor-text").append(u),e.find("[data-action=validate-visibility]").on("click",()=>{_e.openMenu({token:i,message:t,roll:t.rolls[0],selected:d.pf2ePerception.selected})})}}else o&&(d.options.includes("action:hide")?yi({token:i,message:t,html:e,validated:l,action:"Hide"}):d.options.includes("action:create-a-diversion")&&hi(e,l));else if(d?.type==="perception-check"&&d.pf2ePerception)if(n){if(d.options.includes("action:seek")){let u=fi({skipWait:c,validated:l,smallAction:"delete-template",smallIcon:"fa-thin fa-cubes",smallSlashed:!0});e.find(".flavor-text").append(u),e.find("[data-action=validate-visibility]").on("click",()=>{Ve.openMenu({token:i,message:t,roll:t.rolls[0],selected:d.pf2ePerception.selected,fromTemplate:d.pf2ePerception.fromTemplate})}),e.find("[data-action=delete-template").on("click",()=>{J(i)})}}else o&&d.options.includes("action:seek")&&yi({token:i,message:t,html:e,validated:l,action:"Seek"});else if(p){let u=i.scene.tokens.get(p);if(!u)return;if(n){let g=fi({skipWait:c,validated:l,smallAction:"ping-token",smallIcon:"fa-solid fa-signal-stream"});e.find(".message-content").append(g),e.find("[data-action=validate-visibility]").on("click",()=>{Le.openMenu({message:t,token:u,originator:i,selected:canvas.tokens.controlled.map(m=>m.id)})}),e.find("[data-action=ping-token]").on("click",()=>{canvas.ping(u.center)})}else if(o){let g=Rt("visibility",l);e.find(".message-content").append(g)}}if(n&&ke.includes(d?.type)){let g=` +
`}i+="
",e.find('.tab[data-tab="basic"] hr').first().after(i);let o=e.find(".pf2e-perception-injected").toArray().reduce((r,s)=>(r+=s.clientHeight,r),0);t.setPosition({top:t.position.top-o/2})}a(Ht,"renderSceneConfig");function j(t){if(t=t instanceof Token?t.document:t,!(t instanceof TokenDocument))return[];let e=t.scene.tokens.filter(i=>i!==t&&i.actor?.isOfType("creature"));if(O("encounter")){let i=game.combats.active;return i?e.filter(n=>{let o=n.actor,r=o.traits;return o.type==="familiar"||r.has("minion")||r.has("eidolon")||i.getCombatantByToken(n.id)}):e}return e}a(j,"getValidTokens");function ne(t,e){let i=j(t).map(n=>n.id);return e.filter(n=>{let o=n instanceof Token||n instanceof TokenDocument?n.id:n;return i.includes(o)})}a(ne,"validateTokens");function Ee(t,e){return w(t,e)??O(e)}a(Ee,"getSceneSetting");async function Pt({affects:t,origin:e,target:i,item:n,domains:o,options:r}){if(!(e&&i))return[];let[s,c]=t==="target"?[e,i]:[i,e],l=[...r,s.getRollOptions(o),c.getSelfRollOptions(t)].flat(),p=n?n.isOfType("spell")?{spell:n}:{weapon:n}:{};return(await Promise.all(o.flatMap(d=>s.synthetics.ephemeralEffects[d]?.[t]??[]).map(d=>d({test:l,resolvables:p})))).flatMap(d=>d??[])}a(Pt,"extractEphemeralEffects");function Kt(t,e){if(!t.isOfType("action","melee","weapon"))return null;let{increment:i}=t.range??{};return i&&typeof e=="number"?Math.max(Math.ceil(e/i),1):null}a(Kt,"getRangeIncrement");function qt(t,e){if(!t?.isOfType("creature"))return!1;let{flanking:i}=t.attributes;return i.flankable?typeof i.offGuardable=="number"?e.level>i.offGuardable:i.offGuardable:!1}a(qt,"isOffGuardFromFlanking");function kt(t){return typeof t=="object"&&t!==null}a(kt,"isObject");function Yt(t,e){return t.includes(e)}a(Yt,"tupleHasValue");function $i(t,e){return canvas.dimensions?canvas.grid.type!==CONST.GRID_TYPES.SQUARE?canvas.grid.measureDistance(t,e):Mi(new Ray(t,e)):NaN}a($i,"measureDistance");function Mi(t,{reach:e=null}={}){if(!canvas.dimensions)return NaN;let i=canvas.dimensions.size,n=canvas.dimensions.distance,o=Math.ceil(Math.abs(t.dx/i)),r=Math.ceil(Math.abs(t.dy/i)),s=Math.ceil(Math.abs((t.dz||0)/i)),c=[o,r,s].sort((u,g)=>u-g),l={doubleDiagonal:c[0],diagonal:c[1]-c[0],straight:c[2]-c[1]},p=l.diagonal+l.doubleDiagonal>1&&e===10?1:0;return(Math.floor(l.doubleDiagonal*1.75+l.diagonal*1.5+l.straight)-p)*n}a(Mi,"measureDistanceOnGrid");function Qt({areaType:t,object:e,colors:i,document:n,collisionType:o="move",preview:r=!1,collisionOrigin:s}){if(!e.id&&!r)return;let{grid:c,dimensions:l}=canvas;if(!(c&&l))return;let p=n.angle??0,d=n.direction??45,u=c.getHighlightLayer(e.highlightId)?.clear();if(!u)return;let[g,m]=c.getCenter(n.x,n.y),[y,k]=c.grid.getGridPositionFromPixels(g,m),R=(360+(d-p*.5)%360)%360,E=(360+(d+p*.5)%360)%360,b=canvas.grid.getSnappedPosition(n.x,n.y,e.layer.gridPrecision),F=a((W,_,D)=>(W=(360+W%360)%360,_=(360+_%360)%360,D=(360+D%360)%360,W<_?D>=W&&D<=_:D>=W||D<=_),"withinAngle"),T=(()=>{if(t!=="cone")return{x:0,y:0};let W=(d>=0?360-d:-d)%360,_=b.x%l.size!==0?Math.sign(1*Math.round(Math.cos(Math.toRadians(W))*100)/100)/2:0,D=b.y%l.size!==0?-Math.sign(1*Math.round(Math.sin(Math.toRadians(W))*100)/100)/2:0;return{x:_*l.size,y:D*l.size}})(),A=Math.clamped(n.width??0,1.5,2),S=n.distance??0,N=S*A/l.distance,G=Math.ceil(N/(l.size/c.h)),ce=Math.ceil(N/(l.size/c.w)),Ce=a(W=>{if(!(t==="emanation"&&e instanceof Token))return{x:0,y:0};if(e.w<=l.size)return{x:0,y:0};let _=(e.w-l.size)/2,D=a((v,C)=>C===v?0:C>v?_:-_,"getCoordinate");return{x:D(e.center.x,W.x),y:D(e.center.y,W.y)}},"offsetEmanationOrigin");for(let W=-ce;W0&&!F(R,E,Di))continue}if($i(C,ve)>S)continue;canvas.ready&&CONFIG.Canvas.polygonBackends[o].testCollision(s??ve,C,{type:o,mode:"any"})?(c.grid.highlightGridPosition(u,{x:D,y:v,border:1,color:0}),u.beginFill(0,.5).moveTo(D,v).lineTo(D+l.size,v+l.size).endFill()):c.grid.highlightGridPosition(u,{x:D,y:v,border:i.border,color:i.fill})}}a(Qt,"highlightGrid");var _i={burst:"circle",emanation:"circle",line:"ray",cone:"cone",rect:"rect",cube:"rect",square:"rect"};function Ze({type:t="burst",token:e,distance:i}){bt(e)&&(i??=t==="cone"?30:15,St({type:t,distance:i,traits:["concentrate","secret"],flags:{type:"seek",tokenId:e.id,collisionType:"sight",collisionOrigin:e.center}}))}a(Ze,"createSeekTemplate");function Xt({type:t="burst",distance:e=20,conceal:i=!1}={}){St({type:t,distance:e,fillColor:yt,flags:{type:"darkness",conceal:i}})}a(Xt,"createDarknessTemplate");function Zt({type:t="burst",distance:e=20}={}){St({type:t,distance:e,fillColor:ht,flags:{type:"mist"}})}a(Zt,"createMistTemplate");function Jt(t,e){return e&&!bt(e)?null:canvas.scene.templates.filter(i=>w(i,"type")===t)??[]}a(Jt,"getTemplates");function Je(t){return Jt("darkness",t)}a(Je,"getDarknessTemplates");function et(t){return Jt("mist",t)}a(et,"getMistTemplates");function tt(t){if(!bt(t))return null;let e=canvas.scene.templates.find(n=>w(n,"type")==="seek");if(!e)return null;let i=t instanceof Token?t.document:t;return Te(e,{collisionType:"sight",collisionOrigin:i.center})}a(tt,"getSeekTemplateTokens");async function J(t){let e=t.scene.templates.filter(i=>w(i,"type")==="seek"&&w(i,"tokenId")===t.id);for(let i of e)await i.delete()}a(J,"deleteSeekTemplate");function bt(t){return canvas.scene===t.scene?!0:(ui.notifications.error(h("template.scene")),!1)}a(bt,"checkScene");function St({type:t,distance:e,traits:i,fillColor:n,width:o,flags:r}){let s=_i[t],c={distance:e,t:s,fillColor:n||game.user.color,flags:{[f]:r}};switch(s){case"ray":c.width=o||CONFIG.MeasuredTemplate.defaults.width*(canvas.dimensions?.distance??1);break;case"cone":c.angle=CONFIG.MeasuredTemplate.defaults.angle;break;case"rect":{let l=c.distance??0;c.distance=Math.hypot(l,l),c.width=l,c.direction=45;break}}i&&setProperty(c,"flags.pf2e.origin.traits",i),canvas.templates.createPreview(c)}a(St,"createTemplate");function Te(t,{collisionOrigin:e,collisionType:i="move"}={}){let n=t instanceof MeasuredTemplateDocument?t.object:t;if(!canvas.scene)return[];let{grid:o,dimensions:r}=canvas;if(!(o&&r))return[];let s=o.getHighlightLayer(n.highlightId);if(!s||o.type!==CONST.GRID_TYPES.SQUARE)return[];let c=e??n.center,l=canvas.tokens.quadtree.getObjects(s.getLocalBounds(void 0,!0)),p=[];for(let d of l){let u=d.document,g=[];for(let m=0;m1)for(let k=1;kNumber(b)),R={x:y+r.size*.5,y:k+r.size*.5};if(R.x<0||R.y<0)continue;if(!(canvas.ready&&i&&CONFIG.Canvas.polygonBackends[i].testCollision(c,R,{type:i,mode:"any"}))){p.push(d);break}}}return p}a(Te,"getTemplateTokens");function ei(){let t=["circle","cone"].includes(this.document.t),e=canvas.grid.type===CONST.GRID_TYPES.SQUARE;if(!t||!e)return MeasuredTemplate.prototype.highlightGrid.call(this);if(!this.isVisible){canvas.grid.getHighlightLayer(this.highlightId)?.clear();return}let i=w(this.document,"collisionType"),n=w(this.document,"collisionOrigin");this.snapForShape(),Qt({areaType:Yt(["burst","cone","emanation"],this.areaType)?this.areaType:"burst",object:this,document:this.document,colors:{border:this.borderColor,fill:this.fillColor},preview:!0,collisionType:i,collisionOrigin:n})}a(ei,"highlightTemplateGrid");function ti(t){let{type:e,slug:i,castLevel:n=0}=t.getFlag("pf2e","origin")??{};e==="spell"&&($t.includes(i)?t.updateSource({fillColor:yt,[`flags.${f}`]:{type:"darkness",conceal:n>=4}}):Mt.includes(i)?t.updateSource({fillColor:ht,[`flags.${f}`]:{type:"mist"}}):i==="cloudkill"&&t.updateSource({fillColor:wt,[`flags.${f}`]:{type:"mist"}}))}a(ti,"preCreateMeasuredTemplate");function it(t){w(t,"type")==="darkness"&&canvas.perception.update({initializeVision:!0})}a(it,"onMeasuredTemplate");function Re(t,e=1){let i=Object.getPrototypeOf(t);return e>1?Re(i,e-1):i}a(Re,"getPrototype");function nt(t,e){return t.name.localeCompare(e.name)}a(nt,"sortByName");function rt(t){return t=Number(t),isNaN(t)?void 0:t}a(rt,"asNumberOnly");var Y=class extends Application{#e;#i;#t;#n;#r;constructor({token:e,resolve:i,selected:n=[]},o={}){super(o),this.#e=e,this.#i=i,this.#t=n,this.#r=(r,s)=>{let c=r.id,l=this.element.find("[data-token-id]");l.removeClass("hover"),s&&l.filter(`[data-token-id=${c}]`).addClass("hover")},Hooks.on("hoverToken",this.#r)}async close(e={}){Hooks.off("hoverToken",this.#r),this.#i?.(e.resolve??!1),super.close(e)}static get defaultOptions(){return mergeObject(Application.defaultOptions,{minimizable:!1})}static async openMenu(e,i={}){if(e.token instanceof TokenDocument&&(e.token=e.token.object),!e.token){ui.notifications.error(h("menu.no-token"));return}i.id=`${f}-${e.token.document.uuid}`;let n=Object.values(ui.windows).find(o=>o.id===i.id);return n&&n.close(),new Promise(o=>{e.resolve=o,new this(e,i).render(!0)})}static createPropertyData(e,i,n){let o=V[n],r=e[n]??o,s=i[n]??o;return{original:r,current:s,changed:r!==s,custom:s!==o,originalCustom:r!==o}}get token(){return this.#e}get document(){return this.#e.document}get actor(){return this.#e.actor}get scene(){return this.#e.scene}get selected(){return this.#t.length?ne(this.token,this.#t):[]}get currentData(){return deepClone(this.#o)}get#o(){return this.#n||(this.#n=this.getSavedData()),this.#n}getSavedData(){let e=z(this.document)??{};return deepClone(e)}reset(){this.#n=this.getSavedData(),this.#t=[],this.render()}isSelected(e){let i=typeof e=="object"?e.id:e;return this.#t.includes(i)}getData(e){return{i18n:h,covers:U.map(i=>({value:i,label:h(`cover.${i}`)})),visibilities:de.map(i=>({value:i,label:h(`visibility.${i}`)}))}}activateListeners(e){e.find("[data-token-id]").on("mouseenter",i=>{let{tokenId:n}=i.currentTarget.dataset,o=this.scene.tokens.get(n)?.object;!o||o.controlled||o._onHoverIn(i,{hoverOutOthers:!0})}),e.find("[data-action=close]").on("click",()=>{this.close({resolve:!0})}),e.find("select[name=visibility], select[name=cover]").on("change",i=>{let n=i.currentTarget,o=n.name,r=V[o],s=n.value||r,c=n.closest(".token")?.dataset.tokenId,l=c?[c]:this.#t;for(let p of l)setProperty(this.#o,`${p}.${o}`,s);c?(n.classList.toggle("changed",s!==n.dataset.original),n.classList.toggle("custom",s!==r)):this.render()}),e.find("[data-action=accept]").on("click",i=>{this._saveData(this.#o),this.close({resolve:!0})})}_saveData(e){ot(this.document,e)}_setSelected(e){this.#t=e??this.element.find("[data-token-id].ui-selected").toArray().map(i=>i.dataset.tokenId)}_spliIntoAlliances(e){let i=[],n=[],o=[],r=this.actor.alliance,s=r==="party"?"opposition":r==="opposition"?"party":null;for(let c of e)if(s){let l=c.actor?c.actor.alliance:c.alliance;l===r?i.push(c):l===s?n.push(c):l===null&&o.push(c)}else o.push(c);return{allies:i.sort(nt),neutral:o.sort(nt),enemies:n.sort(nt),hasTokens:i.length||n.length||o.length}}};a(Y,"BaseMenu");var We=class extends Y{get title(){return h("menu.perception.title",{name:this.token.name})}get template(){return X("perception")}getData(e){let i=this.selected,n=this.currentData,o=this.getSavedData(),r=j(this.token).map(({id:s,name:c,actor:l})=>{let p=n[s]??{},d=o[s]??{};return{id:s,name:c,alliance:l.alliance,cover:Y.createPropertyData(d,p,"cover"),visibility:Y.createPropertyData(d,p,"visibility"),selected:i.includes(s)}});return{...super.getData(e),...this._spliIntoAlliances(r)}}activateListeners(e){super.activateListeners(e),e.filter(".tokens").selectable({autoRefresh:!1,filter:".token",cancel:"header,select",stop:()=>this._setSelected()}),e.find("[data-action=select-all]").on("click",i=>{let n=$(i.currentTarget).closest("section"),o=(n.length?n:e).find("[data-token-id]"),r=o.filter(":not(.ui-selected)").length===0;o.toggleClass("ui-selected",!r),this._setSelected()}),e.find("[data-action=use-selection]").on("click",i=>{this._setSelected(canvas.tokens.controlled.map(n=>n.id)),this.render()}),e.find("[data-action=reset]").on("click",i=>this.reset())}};a(We,"PerceptionMenu");var zi=[{x:.25,y:.25},{x:.5,y:.25},{x:.75,y:.25},{x:.25,y:.5},{x:.5,y:.5},{x:.75,y:.5},{x:.25,y:.75},{x:.5,y:.75},{x:.75,y:.75}];function at(t,e){let i=1-e;return{top:{A:ee({x:e,y:e},t),B:ee({x:i,y:e},t)},right:{A:ee({x:i,y:e},t),B:ee({x:i,y:i},t)},bottom:{A:ee({x:i,y:i},t),B:ee({x:e,y:i},t)},left:{A:ee({x:e,y:i},t),B:ee({x:e,y:e},t)}}}a(at,"getRectEdges");function De(t,e,i=!1){return i&&Q(t,e),CONFIG.Canvas.polygonBackends.move.testCollision(t,e,{type:"move",mode:"any"})}a(De,"lineIntersectWall");function st(t,e,i=!1){for(let n of Li(e.bounds))if(De(t,n,i))return!0;return!1}a(st,"pointToTokenIntersectWall");function ee(t,e){return{x:e.x+e.width*t.x,y:e.y+e.height*t.y}}a(ee,"getRectPoint");function me(){canvas.controls.debug.clear()}a(me,"clearDebug");function Q(t,e,i="blue"){let n=i==="blue"?26316:i==="red"?16711680:1483011;canvas.controls.debug.lineStyle(4,n).moveTo(t.x,t.y).lineTo(e.x,e.y)}a(Q,"drawDebugLine");function*Li(t){for(let e of zi)yield ee(e,t)}a(Li,"rectSpread");function ct(t,e=!1){if(t=t instanceof Token?t:t.object,t.document.hasStatusEffect(CONFIG.specialStatusEffects.INVISIBLE))return;let i=t.scene;if(i!==canvas.scene||!i.tokenVision||i.darkness{let{name:m,uuid:y}=this.item;console.warn(`PF2e System | PF2ePerception rules element on item ${m} (${y}) simple warning: ${g}`)},"selectorWarn"),d=Array.isArray(l.targets)?[...l.targets,"all"]:l.targets,u=Array.isArray(d)?d.join(", "):null;if(!d&&r.targets?.length){p(`The selector "${r.selector}" doesn't accept any targets property.`);return}if(r.selector==="ignore"&&!r.targets?.length){let g=`The selector "${r.selector}" requires a targets property with the ids of the tokens on the scene that should not give cover.`;this.failValidation(g);return}if(u&&r.targets?.some(g=>!d.includes(g))){let g=`The targets property of selector "${r.selector}" only accepts the following: ${u}.`;this.failValidation(g);return}else if(!u&&d&&r.targets?.some(g=>typeof g!==d)){let g=`The targets property of selector "${r.selector}" needs to be of type "${d}".`;this.failValidation(g);return}if(!l.value&&r.value){p(`The selector "${r.selector}" doesn't accept any value property.`);return}if(r.selector==="set"){if(!l.value.includes(r.value)){let g=l.value.join(", "),m=`The selector "${r.selector}" only accepts the following: ${g}.`;this.failValidation(m)}}else{let g=typeof r.value;if(l.value&&!l.value.includes(g)){let m=`The selector "${r.selector}" does not accept a value property of type ${g}.`;this.failValidation(m)}}}static defineSchema(){let{fields:r}=foundry.data;return{...super.defineSchema(),type:new r.StringField({required:!0,nullable:!1,blank:!1,choices:["visibility","cover"]}),affects:new r.StringField({required:!0,nullable:!1,blank:!1,initial:"self",choices:["self","other"]}),selector:new r.StringField({required:!0,nullable:!1,blank:!1}),targets:new r.ArrayField(new r.StringField({required:!0,nullable:!1,blank:!1,initial:void 0}),{required:!0,nullable:!1,initial:["all"]}),predicate:new e({required:!1,nullable:!1}),value:new i({required:!1,initial:void 0})}}test(r,s){return s?super.test(r):!1}addToPerception(r,s,c){if(!this.test(c,!0))return;let p=`${this.affects==="self"?r:r==="origin"?"target":"origin"}.${this.type}.${this.selector}`,d=xe[this.type][this.selector];if(!d.targets){setProperty(s,p,!0);return}let u=this.targets.includes("all")?d.targets:this.targets;if(!d.value){for(let g of u){let m=`${p}.${g}`;setProperty(s,m,!0)}return}for(let g of u){let m=`${p}.${g}`,y=getProperty(s,m);y?y.add(this.value):y=new Set([this.value]),setProperty(s,m,y)}}}a(n,"PF2ePerceptionRuleElement"),game.pf2e.RuleElements.custom.PF2ePerception=n}a(ii,"setupRuleElement");function re(t,e,{distance:i,extraOptions:n=[]}={}){let o=t.actor,r=e.actor;if(!o||!r)return{};let s={origin:o.rules.filter(u=>!u.ignored&&u.key==="PF2ePerception")??[],target:r.rules.filter(u=>!u.ignored&&u.key==="PF2ePerception")??[]};if(!s.origin.length&&!s.target.length)return{};let c={origin:o.getRollOptions(),target:r.getRollOptions()},l={origin:r.getSelfRollOptions("target"),target:o.getSelfRollOptions("origin")};t=t instanceof Token?t:t.object,e=e instanceof Token?e:e.object,i??=t.distanceTo(e);let p=[`origin:distance:${i}`,`target:distance:${i}`],d={};for(let u of["origin","target"]){let g=[...n,...c[u],...l[u],...p];for(let m of s[u])m.addToPerception(u,d,g)}return d}a(re,"perceptionRules");function ni(t){let e=t.actor;return e?(e.rules.filter(n=>!n.ignored&&n.key==="PF2ePerception"&&n.type==="cover"&&n.selector==="ignored")??[]).flatMap(n=>n.targets):[]}a(ni,"getIgnoredPerception");function B(t,e,i,n,o){let r=t[e]?.[i]?.[n];return o?r?.[o]:r}a(B,"getPerception");function Fe(t,e,i,n){n===void 0&&(n=i==="cover"?"none":"observed");let o=i==="cover"?U:de;if(n&&B(t,e,i,"cancel",n))return;let r=B(t,e,i,"set",n)?.first();if(r&&o.includes(r))n=r;else if(n&&B(t,e,i,"reduce",n)){let s=o.indexOf(n);n=o[Math.max(0,s-1)]}return n===o[0]?void 0:n}a(Fe,"updateFromPerceptionRules");function ri(t,e){!Lt()||!t.object.actor?.isOfType("creature")||(e.find(".col.left").append('
'),e.find("[data-action=pf2e-perception]").on("click",i=>Et(t.object)))}a(ri,"renderTokenHUD");function Et(t){return We.openMenu({token:t})}a(Et,"openHUD");function oi(t,e){for(let i of e)delete i.flags?.[f]}a(oi,"pasteToken");function z(t,...e){return e.unshift("data"),t=t instanceof Token?t.document:t,w(t,e.join("."))}a(z,"getTokenData");async function ai(t){return t=t instanceof Token?t.document:t,_t(t,"data")}a(ai,"clearTokenData");async function ot(t,e){let i=j(t).map(o=>o.id),n={};for(let o in e){if(!i.includes(o)){n[`flags.${f}.data.-=${o}`]=!0;continue}let r=e[o],s=z(t,o)??{};if(r.visibility===V.visibility&&delete r.visibility,r.cover===V.cover&&delete r.cover,!(s.cover===r.cover&&s.visibility===r.visibility))if(!r.visibility&&!r.cover)n[`flags.${f}.data.-=${o}`]=!0;else for(let c of["cover","visibility"])s[c]!==r[c]&&(r[c]?n[`flags.${f}.data.${o}.${c}`]=r[c]:n[`flags.${f}.data.${o}.-=${c}`]=!0)}return t=t instanceof Token?t.document:t,t.update(n)}a(ot,"setTokenData");function lt(t,e,i=!1){let n=t.scene;return Ee(n,"standard")?(i&&me(),(O("standard-type")==="points"?st(t.center,e,i):De(t.center,e.center,i))?"standard":void 0):void 0}a(lt,"getWallCover");var fe={tiny:0,sm:1,med:2,lg:3,huge:4,grg:5};function dt(t,e,{perception:i={},options:n=[],affects:o="origin",debug:r=!1}={}){let s=n.includes("item:ranged")?Z(e.actor):!1,c=a(d=>Fe(i,o,"cover",d),"returnValue"),l=te(e.actor,!0);if(s&&x[l]>x.lesser)return c("greater-prone");!s&&l==="greater-prone"&&(l=void 0);let p=z(e,t.id,"cover");if(s&&x[p]>x.lesser)return c("greater-prone");if(!s&&p==="greater-prone"&&(p=void 0),x[l]x[p]&&(p=g)}if(x[p]5){let u=d.getCreatureCover,g;if(typeof u=="function"){let m=u(t,e,{perception:i,debug:r});g=U.includes(m)?m:ut(t,e,{perception:i,debug:r})}else g=ut(t,e,{perception:i,debug:r});x[g]>x[p]&&(p=g)}}return s&&x[p]>x.lesser?c("greater-prone"):c(x[p]>x[l]?p:void 0)}a(dt,"getCover");function ut(t,e,{perception:i={},debug:n=!1}={}){let o=O("lesser");if(o==="none")return;t=t instanceof Token?t.document:t,e=e instanceof Token?e.document:e;let r=(()=>{let S=Object.keys(i.origin?.cover?.ignore??{}),N=Object.keys(i.target?.cover?.ignore??{});return new Set([...S,...N])})(),s,c=t.center,l=e.center,p=t.actor,d=e.actor;n&&(me(),Q(c,l));let u=a(S=>{let N=fe[S.actor.size];return N-g>=2&&N-m>=2},"isExtraLarge"),g=fe[p.size],m=fe[d.size],y=p.alliance,k=O("dead-cover"),R=O("prone-cover"),E=t.scene.tokens.contents.filter(S=>{let N=S.actor,G=ni(S);return N&&!S.hidden&&S!==t&&S!==e&&(R||!Z(N))&&(k||N.hitPoints?.value!==0)&&!r.has(S.id)&&!(G.includes("all")||G.includes(N.alliance===y?"allies":"enemies"))}).sort((S,N)=>fe[N.actor.size]-fe[S.actor.size]),b=g(n&&Q(S.A,S.B,"red"),lineSegmentIntersects(c,l,S.A,S.B)),"intersectsEdge"),A=o==="cross"?S=>T(S.top)&&T(S.bottom)||T(S.left)&&T(S.right):S=>Object.values(S).some(N=>T(N));for(let S of E){let N=S.object,G=at(N.bounds,F);if(A(G))return b?"standard":"lesser";u(S)&&b--}return s}a(ut,"getCreatureCover");function oe(t,e,{perception:i={},affects:n="origin",debug:o=!1}={}){t=t instanceof Token?t:t.object,e=e instanceof Token?e:e.object;let r=t.actor,s=e.actor,c=(()=>{if(!r||!s)return;let b;s.hasCondition("blinded")?b="hidden":s.hasCondition("dazzled")&&(b="concealed");for(let F of["unnoticed","undetected","hidden","concealed"])P[F]>P[b]&&r.hasCondition(F)&&(b=F);return b})(),l=a(b=>p?(P[b]P[d]?c:d;if(P[u]>=P.hidden||p)return l(u);let g=s?.hasLowLightVision,m=s?.hasDarkvision,y=s&&He(s);if(y&&u==="concealed")return l(u);let k;if(!y){let b=Je(t);if(b?.length){let F;for(let T of b){let A=Te(T);if(!A.length)continue;if(A.includes(t)||A.includes(e))k=!0;else continue;if(!m)return l("hidden");w(T,"conceal")&&(F="concealed")}if(F==="concealed"&&(u="concealed"),k&&u==="concealed")return l(u)}}if(u!=="concealed"){let b=et(t);if(b?.length)for(let F of b){let T=Te(F);if(!T.length)continue;if(T.includes(t)||T.includes(e))return l("concealed")}}if(k||y)return l(u);let R=ct(t,o),E=R==="dim"?"concealed":R===null?"hidden":void 0;return(E==="concealed"&&g||E==="hidden"&&m)&&(E=void 0),P[E]>P[u]&&(u=E),l(u)}a(oe,"getVisibility");function si(t,e,i,n){let o=e.flags?.["pf2e-perception"];if(o&&(o.data||o["-=data"]!==void 0)){if(t.object.renderFlags.set({refreshVisibility:!0}),game.user.isGM)return;let r=Hooks.on("refreshToken",s=>{!t.object!==s&&(Hooks.off("refreshToken",r),game.combat?.getCombatantByToken(t.id)&&ui.combat.render())})}}a(si,"updateToken");function ci(t,e){e?pt(t):ye(t)}a(ci,"hoverToken");function li(t){ye(t),game.user.isGM||ui.combat.render()}a(li,"deleteToken");function di(t,e){e&&(ye(),Hooks.once("sightRefresh",()=>t.hover&&pt(t)))}a(di,"controlToken");function ye(t){if(!t?.id)return $(".pf2e-conditionals").remove();$(`.pf2e-conditionals[data-hover-id=${t.id}]`).remove(),$(`.pf2e-conditionals[data-token-id=${t.id}]`).remove()}a(ye,"clearConditionals");function pt(t){let e=j(t);for(let i of e)Tt(i,t)}a(pt,"showAllConditionals");async function Tt(t,e){if(t=t instanceof Token?t:t.object,!t.visible||!t.actor?.isOfType("creature"))return;let i=z(t,e.id);if(isEmpty(i))return;if(!game.user.isGM&&!e.document.hasPlayerOwner&&P[i.visibility]>=P.hidden){if(!i.cover)return;i={cover:i.cover}}let n=t.worldTransform.a,o=canvas.clientCoordinatesFromCanvas(t.document._source),r=O("icon-size"),s=[`top: ${o.y}px`,`left: ${o.x+t.hitArea.width*n/2}px`,`--icon-size: ${r}px`].join("; "),c=`
`;let l=O("icon-path");Object.entries(i).map(([p,d])=>{let u=p==="cover"?"cover":d,g=l[u]||Ge[u];(g.startsWith("systems")||g.startsWith("modules"))&&(g=`../../../${g}`),c+=`
`}),c+="
",$(document.body).append(c)}a(Tt,"showConditionals");function pi(){return!!(this.sight.enabled&&this.actor?.isOfType("creature")&&this.scene?.rulesBasedVision)}a(pi,"rulesBasedVision");function gi(t){let e=t.actor;if(e?.isOfType("creature")&&(e.isOfType("npc")&&Ee(t.scene,"npc-vision")&&t.updateSource({"sight.enabled":!0}),game.user.isGM&&t.hidden)){let i=game.user.targets,n={};for(let o of i)n[o.id]={visibility:"unnoticed"};i.size&&t.updateSource({[`flags.${f}.data`]:n})}}a(gi,"preCreateToken");var we=class extends Y{static async openMenu(e,i){let n=await super.openMenu(e,i);return n&&e.message&&mi(e.message),n}get title(){return h("menu.validation.title",{name:this.token.name})}get template(){return X("validation")}get selected(){let e=super.selected;return e.length?e:this.globalSelection}get globalSelection(){let e=this.token,i=e.actor.alliance;return j(e).filter(n=>n.actor.alliance!==i).map(n=>n.id)}getSavedData(e=!0){let i=super.getSavedData();return e?this._convertData(i):i}_convertData(e){let i=this.property,n=this.scene,o=this.selected,r=V[i],s=i==="cover"?U:de;for(let c of o){let l=n.tokens.get(c),p=`${c}.${i}`,d=getProperty(e,p)??r,u=this.processValue({token:l,value:d});s.includes(u)||(u=d),d!==u&&setProperty(e,p,u)}return e}processValue(e){throw new Error(`${this.constructor.name} doesn't have a 'processValue' method defined`)}getData(e){let{covers:i,visibilities:n,i18n:o}=super.getData(e),r=this.currentData,s=this.getSavedData(!1),c=this.property,l=this.selected,p=j(this.token);p=p.map(({id:u,name:g,actor:m})=>{let y=r[u]??{},k=s[u]??{};return{id:u,name:g,alliance:m.alliance,selected:l.includes(u),...Y.createPropertyData(k,y,c)}});let d=O("validation");return d==="selected"?p=p.filter(u=>u.selected):d==="changed"&&(p=p.filter(u=>u.changed)),{...this._spliIntoAlliances(p),i18n:o,property:c,options:c==="cover"?i:n,showSelected:l.length!==p.length&&d==="all",showChanges:d!=="changed"}}activateListeners(e){super.activateListeners(e),e.find("[data-action=cancel]").on("click",i=>{this.close()})}};a(we,"ValidationMenu");var $e=class extends we{#e;constructor(e,i={}){super(e,i),this.#e=e.value}get property(){return"cover"}processValue(){return this.#e}};a($e,"CoverValidationMenu");var ae=class extends we{#e;constructor(e,i={}){super(e,i),this.#e=e.roll}get property(){return"visibility"}get roll(){return this.#e}};a(ae,"VisibilityValidationMenu");var Me=class extends ae{processValue({token:e,value:i}){let n=this.roll,o=e.actor.perception.dc.value,r=P[i],s=new M(n,o).value;return s>=M.SUCCESS&&r=P.hidden?"observed":i}};a(Me,"HideValidationMenu");var _e=class extends ae{processValue({token:e,value:i}){let n=this.roll,o=e.actor.perception.dc.value,r=P[i];return new M(n,o).value>=M.SUCCESS&&re.id)}processValue({token:e,value:i}){return P[i]>=P.hidden?"observed":i}};a(ze,"UnHideValidationMenu");var Le=class extends ae{#e;constructor(e,i={}){super(e,i),this.#e=e.originator}get selected(){let e=this.token,i=e.actor.alliance,n=this.#e.id,o=z(e)??{};return j(e).filter(r=>{if(r.id===n||r.actor.alliance===i)return!1;let s=getProperty(o,`${r.id}.visibility`);return P[s]>=P.undetected}).map(r=>r.id)}processValue({token:e,value:i}){return P[i]>=P.undetected?"hidden":i}};a(Le,"PointOutValidationMenu");var gt=class extends ae{getSavedData(e=!0){let i=this.token.id,n=j(this.token),o={};for(let r of n){let s=z(r,i);s&&(o[r.id]=deepClone(s))}return e?this._convertData(o):o}getData(){let e=super.getData();return e.isReversed=!0,e.options=de.map(i=>({value:i,label:h(`visibility.reversed.${i}`)})),e}_saveData(e){let i=this.scene,n=this.token.id,o=[];for(let[r,s]of Object.entries(e)){let c={_id:r},l=i.tokens.get(r);if(l){s.visibility===V.visibility&&delete s.visibility;let p=z(l,n)??{};if(p?.visibility===s.visibility)continue;!p.cover&&!s.visibility?c[`flags.${f}.data.-=${n}`]=!0:s.visibility?c[`flags.${f}.data.${n}.visibility`]=s.visibility:c[`flags.${f}.data.${n}.-=visibility`]=!0}else c[`flags.${f}.data.-=${n}`]=!0;o.push(c)}i.updateEmbeddedDocuments("Token",o)}};a(gt,"ReverseVisibilityValidationMenu");var Ve=class extends gt{#e;constructor(e,i={}){super(e,i),this.#e=e.fromTemplate}get globalSelection(){return[]}static async openMenu(e,i){await super.openMenu(e,i)&&J(e.token)}processValue({token:e,value:i}){let n=this.roll,o=e.actor.skills.stealth.dc.value,r=P[i],s=new M(n,o).value;return s>=M.CRITICAL_SUCCESS&&r>=P.hidden||s>=M.SUCCESS&&r===P.hidden?"observed":s>=M.SUCCESS&&r>=P.undetected?"hidden":i}};a(Ve,"SeekValidationMenu");function xt(t,e){let i=t.token;if(!i)return;let n=game.user.isGM,o=i.hasPlayerOwner,{cover:r,selected:s,skipWait:c,validated:l,pointOut:p}=zt(t),d=t.getFlag("pf2e","context");if(r){if(n){let u=mt({property:"cover",skipWait:c,validated:l});e.find(".message-content").append(u),e.find("[data-action=validate-cover]").on("click",()=>{$e.openMenu({token:i,selected:s,value:r,message:t})})}else if(!c){let u=Rt("cover",l);e.find(".message-content").append(u)}}else if(d?.pf2ePerception?.visibility){l||e.find(".message-buttons").remove();let u=e.find(".flavor-text");!n&&o&&(e.find(".message-sender").text(i.name),u.empty());let g=h(`message.flat-check.${l===void 0?"blind":l?"success":"failure"}`),m=vi(g,l);if(u.append(m),n)for(let y of["success","failure"])u.append(Ft({action:`${y}-message`,icon:"fa-solid fa-message",label:h("message.flat-check.button",y)})),e.find(`[data-action=${y}-message]`).on("click",()=>{vt(t,"validated",y==="success")})}else if(d?.type==="skill-check"&&d.pf2ePerception)if(n){if(d.options.includes("action:hide")){let u=mt({property:"visibility",skipWait:c,validated:l});e.find(".flavor-text").append(u),e.find("[data-action=validate-visibility]").on("click",()=>{Me.openMenu({token:i,message:t,roll:t.rolls[0],selected:d.pf2ePerception.selected})})}else if(d.options.includes("action:create-a-diversion")){let u=mt({property:"visibility",skipWait:c,validated:l});e.find(".flavor-text").append(u),e.find("[data-action=validate-visibility]").on("click",()=>{_e.openMenu({token:i,message:t,roll:t.rolls[0],selected:d.pf2ePerception.selected})})}}else o&&(d.options.includes("action:hide")?yi({token:i,message:t,html:e,validated:l,action:"Hide"}):d.options.includes("action:create-a-diversion")&&hi(e,l));else if(d?.type==="perception-check"&&d.pf2ePerception)if(n){if(d.options.includes("action:seek")){let u=fi({skipWait:c,validated:l,smallAction:"delete-template",smallIcon:"fa-thin fa-cubes",smallSlashed:!0});e.find(".flavor-text").append(u),e.find("[data-action=validate-visibility]").on("click",()=>{Ve.openMenu({token:i,message:t,roll:t.rolls[0],selected:d.pf2ePerception.selected,fromTemplate:d.pf2ePerception.fromTemplate})}),e.find("[data-action=delete-template").on("click",()=>{J(i)})}}else o&&d.options.includes("action:seek")&&yi({token:i,message:t,html:e,validated:l,action:"Seek"});else if(p){let u=i.scene.tokens.get(p);if(!u)return;if(n){let g=fi({skipWait:c,validated:l,smallAction:"ping-token",smallIcon:"fa-solid fa-signal-stream"});e.find(".message-content").append(g),e.find("[data-action=validate-visibility]").on("click",()=>{Le.openMenu({message:t,token:u,originator:i,selected:canvas.tokens.controlled.map(m=>m.id)})}),e.find("[data-action=ping-token]").on("click",()=>{canvas.ping(u.center)})}else if(o){let g=Rt("visibility",l);e.find(".message-content").append(g)}}if(n&&ke.includes(d?.type)){let g=` @@ -10,11 +10,11 @@ ${pe(t)} 1 (${i} ${n}) -`}a(ji,"actionTitle");function hi(t,e){let i=Rt("visibility",e);t.find(".flavor-text").append(i)}a(hi,"addSkillCheckFlavor");function yi({html:t,token:e,message:i,validated:n,action:o}){let r=i.getFlag("pf2e","modifierName"),s=ji(o,r);t.find(".message-sender").text(e.name),t.find(".flavor-text").html(s),hi(t,n)}a(yi,"addBlindSkillCheckFlavor");function Rt(t,e){let i=h(`message.${t}.player.${e?"validated":"wait"}`);return vi(i,e)}a(Rt,"createWaitHint");function vi(t,e){return`${e===!0?` ${t}`:e===!1?` ${t}`:t}`}a(vi,"createHint");function mt({skipWait:t,validated:e,property:i}){let n=h(`message.${i}.gm.${t?"check":e?"validated":"validate"}`);return!t&&e&&(n+=''),Ft({action:`validate-${i}`,icon:"fa-solid fa-list",label:n})}a(mt,"createValidateButton");function Ft({action:t,icon:e,label:i,tooltip:n,slashed:o=!1}){let r=`",r}a(Ft,"createChatButton");async function Nt({content:t,token:e,flags:i,secret:n}){let o={content:t,speaker:ChatMessage.getSpeaker({token:e instanceof Token?e.document:e})};return i&&setProperty(o,`flags.${f}`,i),n&&(o.type=CONST.CHAT_MESSAGE_TYPES.WHISPER,o.whisper=ChatMessage.getWhisperRecipients("gm")),ChatMessage.create(o)}a(Nt,"createTokenMessage");function ki(){let t=game.pf2e.actions.get("hide"),e=Re(t,2).constructor,i=Re(t.toActionVariant(),2).constructor,n=Re(t,1).constructor,o=Re(t.toActionVariant(),1).constructor;Qi(e,i),Yi(n,o),qi(n,o),Ki(n,o),Bi(n,o),Gi(e,i)}a(ki,"setupActions");function Gi(t,e){class i extends e{async use(r={}){let s=h("action.point-out"),c=Ne(r,s);c&&Ui(this,c)}}a(i,"PointOutVariant");class n extends t{constructor(){super({cost:1,name:`${f}.action.point-out`,description:`${f}.action.point-out.description`,rollOptions:["action:point-out"],slug:"point-out",traits:["auditory","manipulate","visual"]})}toActionVariant(r={}){return r.name??=this.name,new i(this,r)}}a(n,"PointOut"),game.pf2e.actions.set("point-out",new n)}a(Gi,"setupPointOut");async function Ui({name:t,traits:e},i){let n=game.user.targets.filter(p=>p.actor).first(),o=n?z(n,i.id,"visibility"):void 0,r=n&&P[o]({slug:p,tooltip:CONFIG.PF2E.traitsDescriptions[p],name:CONFIG.PF2E.actionTraits[p]}))}),l={pointOut:r?n.id:void 0};Nt({content:c,token:i,flags:l})}a(Ui,"pointOut");function Bi(t,e){class i extends e{async use(r={}){let s=pe("Seek"),c=Ne(r,s);if(c)return O("seek-template")&&!await Hi(c)?J(c):(r.actors=[c.actor],super.use(r))}}a(i,"SeekVariant");class n extends t{constructor(){super({cost:1,description:"PF2E.Actions.Seek.Description",name:"PF2E.Actions.Seek.Title",notes:[{outcome:["criticalSuccess"],text:"PF2E.Actions.Seek.Notes.criticalSuccess"},{outcome:["success"],text:"PF2E.Actions.Seek.Notes.success"}],rollOptions:["action:seek"],slug:"seek",statistic:"perception",traits:["concentrate","secret"]})}toActionVariant(r){return new i(this,r)}}a(n,"Seek"),game.pf2e.actions.set("seek",new n)}a(Bi,"setupSeek");async function Hi(t){let e=game.i18n.localize("PF2E.Foot"),i='

';return i+=`${h("dialog.seek.hint")}

`,i+=Pi("create-cone","fa-thin fa-cubes",game.i18n.format("PF2E.TemplateLabel",{size:30,unit:e,shape:game.i18n.localize(CONFIG.PF2E.areaTypes.cone)})),i+=Pi("create-burst","fa-thin fa-cubes",game.i18n.format("PF2E.TemplateLabel",{size:15,unit:e,shape:game.i18n.localize(CONFIG.PF2E.areaTypes.burst)})),i+="

",Dialog.wait({title:`${t.name} - ${game.i18n.localize("PF2E.Actions.Seek.Title")}`,content:i,buttons:{ok:{icon:'',label:h("dialog.seek.accept"),callback:()=>!0},no:{icon:'',label:h("dialog.seek.cancel"),callback:n=>!1}},close:()=>!1,render:n=>{n.filter(".dialog-content").find("[data-action=create-cone], [data-action=create-burst]").on("click",r=>{let{action:s}=r.currentTarget.dataset;J(t),Ze({type:s==="create-cone"?"cone":"burst",token:t})})}},{width:300,left:10})}a(Hi,"seek");function Ki(t,e){class i extends e{async use(r={}){let s=pe("Sneak"),c=Ne(r,s);if(c)return r.actors=[c.actor],super.use(r)}}a(i,"SneakVariant");class n extends t{constructor(){super({cost:1,description:"PF2E.Actions.Sneak.Description",name:"PF2E.Actions.Sneak.Title",notes:[{outcome:["success","criticalSuccess"],text:"PF2E.Actions.Sneak.Notes.success"},{outcome:["failure"],text:"PF2E.Actions.Sneak.Notes.failure"},{outcome:["criticalFailure"],text:"PF2E.Actions.Sneak.Notes.criticalFailure"}],rollOptions:["action:sneak"],slug:"sneak",traits:["move","secret"]})}toActionVariant(r){return new i(this,r)}}a(n,"Sneak")}a(Ki,"setupSneak");function qi(t,e){class i extends e{async use(r={}){let s=pe("CreateADiversion"),c=Ne(r,s);if(c)return r.actors=[c.actor],super.use(r)}}a(i,"CreateADiversionVariant");class n extends t{constructor(){super({cost:1,description:"PF2E.Actions.CreateADiversion.Description",name:"PF2E.Actions.CreateADiversion.Title",notes:[{outcome:["criticalSuccess","success"],text:"PF2E.Actions.CreateADiversion.Notes.success"},{outcome:["criticalFailure","failure"],text:"PF2E.Actions.CreateADiversion.Notes.failure"}],section:"skill",slug:"create-a-diversion",statistic:"deception",traits:["mental"],variants:[{name:"PF2E.Actions.CreateADiversion.DistractingWords.Title",rollOptions:["action:create-a-diversion","action:create-a-diversion:distracting-words"],slug:"distracting-words",traits:["auditory","linguistic","mental"]},{name:"PF2E.Actions.CreateADiversion.Gesture.Title",rollOptions:["action:create-a-diversion","action:create-a-diversion:gesture"],slug:"gesture",traits:["manipulate","mental"]},{name:"PF2E.Actions.CreateADiversion.Trick.Title",rollOptions:["action:create-a-diversion","action:create-a-diversion:trick"],slug:"trick",traits:["manipulate","mental"]}]})}toActionVariant(r){return new i(this,r)}}a(n,"CreateADiversion"),game.pf2e.actions.set("create-a-diversion",new n)}a(qi,"setupCreateADiversion");function Yi(t,e){class i extends e{async use(r={}){let s=pe("Hide"),c=Ne(r,s);if(c)return r.actors=[c.actor],super.use(r)}}a(i,"HideVariant");class n extends t{constructor(){super({cost:1,description:"PF2E.Actions.Hide.Description",name:"PF2E.Actions.Hide.Title",rollOptions:["action:hide"],slug:"hide",statistic:"stealth",traits:["secret"],notes:[{outcome:["success","criticalSuccess"],text:"PF2E.Actions.Hide.Notes.success"}]})}toActionVariant(r){return new i(this,r)}}a(n,"Hide"),game.pf2e.actions.set("hide",new n)}a(Yi,"setupHide");function Qi(t,e){class i extends e{async use(r={}){let s=h("action.take-cover"),c=Ne(r,s);c&&Xi(c)}}a(i,"TakeCoverVariant");class n extends t{constructor(){super({cost:1,description:"PF2E.Actions.TakeCover.Description",img:"systems/pf2e/icons/conditions-2/status_acup.webp",name:"PF2E.Actions.TakeCover.Title",slug:"take-cover"})}toActionVariant(r){return new i(this,r)}}a(n,"TakeCover"),game.pf2e.actions.set("take-cover",new n)}a(Qi,"setupCover");async function Xi(t){let e=t.actor,i=te(e),n=ne(t,game.user.targets.ids);if(i&&!n.length)return i.delete();let o=z(t)??{},r=Object.entries(o).reduce((l,[p,{cover:d}])=>(d&&(l[p]=d),l),{}),s=await renderTemplate(X("covers-dialog"),{i18n:h,hasTargets:!!n.length,hasCovers:!isEmpty(r),hasTargetCover:n.some(l=>l in r),isProne:Z(e)}),c=new Dialog({title:`${t.name} - ${h("action.take-cover")}`,content:s,buttons:{},render:l=>{l.find("button").on("click",async p=>{let{level:d}=p.currentTarget.dataset,u=O("skip-cover"),g=a(async(m,y)=>{let k=y?n:void 0,R=m===V.cover?k?"remove":"remove-all":"take";if(await Nt({content:h(`message.cover.${R}`,{cover:h(`cover.${m}`)}),flags:{selected:k,cover:m,skipWait:u},token:t}),u){if(m===V.cover&&!k)return ai(t);let E=deepClone(z(t))??{};for(let S of n)setProperty(E,`${S}.cover`,m);return ot(t,E)}},"process");if(d==="remove-all")g(V.cover);else if(d==="remove")g(V.cover,!0);else if(n.length)g(d,!0);else{let m=Se(d);e.createEmbeddedDocuments("Item",[m])}c.close()})}}).render(!0)}a(Xi,"takeCover");function Ne(t,e){let i=t.tokens?.filter(r=>r.actor)??[];Array.isArray(i)||(i=[i]);let n=t.actors??[];if(Array.isArray(n)||(n=[n]),!i.length&&n.length===1&&(i=[Ie(n[0])].filter(Boolean)),i.length||(i=canvas.tokens.controlled.filter(r=>r.actor)),i.length||(i=[Ie(game.user.character)].filter(Boolean)),i.length>1){ui.notifications.warn(h("action.only-one",{action:e}));return}if(!i.length){ui.notifications.warn(h("action.must-one",{action:e}));return}let o=i[0];if(!o?.actor?.isOfType("creature")){ui.notifications.warn(h("action.must-creature",{action:e}));return}return o}a(Ne,"getSelectedToken");function Pi(t,e,i){return`",r}a(Ft,"createChatButton");async function Nt({content:t,token:e,flags:i,secret:n}){let o={content:t,speaker:ChatMessage.getSpeaker({token:e instanceof Token?e.document:e})};return i&&setProperty(o,`flags.${f}`,i),n&&(o.type=CONST.CHAT_MESSAGE_TYPES.WHISPER,o.whisper=ChatMessage.getWhisperRecipients("gm")),ChatMessage.create(o)}a(Nt,"createTokenMessage");function ki(){let t=game.pf2e.actions.get("hide"),e=Re(t,2).constructor,i=Re(t.toActionVariant(),2).constructor,n=Re(t,1).constructor,o=Re(t.toActionVariant(),1).constructor;Qi(e,i),Yi(n,o),qi(n,o),Ki(n,o),Bi(n,o),Gi(e,i)}a(ki,"setupActions");function Gi(t,e){class i extends e{async use(r={}){let s=h("action.point-out"),c=Ne(r,s);c&&Ui(this,c)}}a(i,"PointOutVariant");class n extends t{constructor(){super({cost:1,name:`${f}.action.point-out`,description:`${f}.action.point-out.description`,rollOptions:["action:point-out"],slug:"point-out",traits:["auditory","manipulate","visual"]})}toActionVariant(r={}){return r.name??=this.name,new i(this,r)}}a(n,"PointOut"),game.pf2e.actions.set("point-out",new n)}a(Gi,"setupPointOut");async function Ui({name:t,traits:e},i){let n=game.user.targets.filter(p=>p.actor).first(),o=n?z(n,i.id,"visibility"):void 0,r=n&&P[o]({slug:p,tooltip:CONFIG.PF2E.traitsDescriptions[p],name:CONFIG.PF2E.actionTraits[p]}))}),l={pointOut:r?n.id:void 0};Nt({content:c,token:i,flags:l})}a(Ui,"pointOut");function Bi(t,e){class i extends e{async use(r={}){let s=pe("Seek"),c=Ne(r,s);if(c)return O("seek-template")&&!await Hi(c)?J(c):(r.actors=[c.actor],super.use(r))}}a(i,"SeekVariant");class n extends t{constructor(){super({cost:1,description:"PF2E.Actions.Seek.Description",name:"PF2E.Actions.Seek.Title",notes:[{outcome:["criticalSuccess"],text:"PF2E.Actions.Seek.Notes.criticalSuccess"},{outcome:["success"],text:"PF2E.Actions.Seek.Notes.success"}],rollOptions:["action:seek"],slug:"seek",statistic:"perception",traits:["concentrate","secret"]})}toActionVariant(r){return new i(this,r)}}a(n,"Seek"),game.pf2e.actions.set("seek",new n)}a(Bi,"setupSeek");async function Hi(t){let e=game.i18n.localize("PF2E.Foot"),i='

';return i+=`${h("dialog.seek.hint")}

`,i+=Pi("create-cone","fa-thin fa-cubes",game.i18n.format("PF2E.TemplateLabel",{size:30,unit:e,shape:game.i18n.localize(CONFIG.PF2E.areaTypes.cone)})),i+=Pi("create-burst","fa-thin fa-cubes",game.i18n.format("PF2E.TemplateLabel",{size:15,unit:e,shape:game.i18n.localize(CONFIG.PF2E.areaTypes.burst)})),i+="

",Dialog.wait({title:`${t.name} - ${game.i18n.localize("PF2E.Actions.Seek.Title")}`,content:i,buttons:{ok:{icon:'',label:h("dialog.seek.accept"),callback:()=>!0},no:{icon:'',label:h("dialog.seek.cancel"),callback:n=>!1}},close:()=>!1,render:n=>{n.filter(".dialog-content").find("[data-action=create-cone], [data-action=create-burst]").on("click",r=>{let{action:s}=r.currentTarget.dataset;J(t),Ze({type:s==="create-cone"?"cone":"burst",token:t})})}},{width:300,left:10})}a(Hi,"seek");function Ki(t,e){class i extends e{async use(r={}){let s=pe("Sneak"),c=Ne(r,s);if(c)return r.actors=[c.actor],super.use(r)}}a(i,"SneakVariant");class n extends t{constructor(){super({cost:1,description:"PF2E.Actions.Sneak.Description",name:"PF2E.Actions.Sneak.Title",notes:[{outcome:["success","criticalSuccess"],text:"PF2E.Actions.Sneak.Notes.success"},{outcome:["failure"],text:"PF2E.Actions.Sneak.Notes.failure"},{outcome:["criticalFailure"],text:"PF2E.Actions.Sneak.Notes.criticalFailure"}],rollOptions:["action:sneak"],slug:"sneak",traits:["move","secret"]})}toActionVariant(r){return new i(this,r)}}a(n,"Sneak")}a(Ki,"setupSneak");function qi(t,e){class i extends e{async use(r={}){let s=pe("CreateADiversion"),c=Ne(r,s);if(c)return r.actors=[c.actor],super.use(r)}}a(i,"CreateADiversionVariant");class n extends t{constructor(){super({cost:1,description:"PF2E.Actions.CreateADiversion.Description",name:"PF2E.Actions.CreateADiversion.Title",notes:[{outcome:["criticalSuccess","success"],text:"PF2E.Actions.CreateADiversion.Notes.success"},{outcome:["criticalFailure","failure"],text:"PF2E.Actions.CreateADiversion.Notes.failure"}],section:"skill",slug:"create-a-diversion",statistic:"deception",traits:["mental"],variants:[{name:"PF2E.Actions.CreateADiversion.DistractingWords.Title",rollOptions:["action:create-a-diversion","action:create-a-diversion:distracting-words"],slug:"distracting-words",traits:["auditory","linguistic","mental"]},{name:"PF2E.Actions.CreateADiversion.Gesture.Title",rollOptions:["action:create-a-diversion","action:create-a-diversion:gesture"],slug:"gesture",traits:["manipulate","mental"]},{name:"PF2E.Actions.CreateADiversion.Trick.Title",rollOptions:["action:create-a-diversion","action:create-a-diversion:trick"],slug:"trick",traits:["manipulate","mental"]}]})}toActionVariant(r){return new i(this,r)}}a(n,"CreateADiversion"),game.pf2e.actions.set("create-a-diversion",new n)}a(qi,"setupCreateADiversion");function Yi(t,e){class i extends e{async use(r={}){let s=pe("Hide"),c=Ne(r,s);if(c)return r.actors=[c.actor],super.use(r)}}a(i,"HideVariant");class n extends t{constructor(){super({cost:1,description:"PF2E.Actions.Hide.Description",name:"PF2E.Actions.Hide.Title",rollOptions:["action:hide"],slug:"hide",statistic:"stealth",traits:["secret"],notes:[{outcome:["success","criticalSuccess"],text:"PF2E.Actions.Hide.Notes.success"}]})}toActionVariant(r){return new i(this,r)}}a(n,"Hide"),game.pf2e.actions.set("hide",new n)}a(Yi,"setupHide");function Qi(t,e){class i extends e{async use(r={}){let s=h("action.take-cover"),c=Ne(r,s);c&&Xi(c)}}a(i,"TakeCoverVariant");class n extends t{constructor(){super({cost:1,description:"PF2E.Actions.TakeCover.Description",img:"systems/pf2e/icons/conditions-2/status_acup.webp",name:"PF2E.Actions.TakeCover.Title",slug:"take-cover"})}toActionVariant(r){return new i(this,r)}}a(n,"TakeCover"),game.pf2e.actions.set("take-cover",new n)}a(Qi,"setupCover");async function Xi(t){let e=t.actor,i=te(e),n=ne(t,game.user.targets.ids);if(i&&!n.length)return i.delete();let o=z(t)??{},r=Object.entries(o).reduce((l,[p,{cover:d}])=>(d&&(l[p]=d),l),{}),s=await renderTemplate(X("covers-dialog"),{i18n:h,hasTargets:!!n.length,hasCovers:!isEmpty(r),hasTargetCover:n.some(l=>l in r),isProne:Z(e)}),c=new Dialog({title:`${t.name} - ${h("action.take-cover")}`,content:s,buttons:{},render:l=>{l.find("button").on("click",async p=>{let{level:d}=p.currentTarget.dataset,u=O("skip-cover"),g=a(async(m,y)=>{let k=y?n:void 0,R=m===V.cover?k?"remove":"remove-all":"take";if(await Nt({content:h(`message.cover.${R}`,{cover:h(`cover.${m}`)}),flags:{selected:k,cover:m,skipWait:u},token:t}),u){if(m===V.cover&&!k)return ai(t);let E=deepClone(z(t))??{};for(let b of n)setProperty(E,`${b}.cover`,m);return ot(t,E)}},"process");if(d==="remove-all")g(V.cover);else if(d==="remove")g(V.cover,!0);else if(n.length)g(d,!0);else{let m=be(d);e.createEmbeddedDocuments("Item",[m])}c.close()})}}).render(!0)}a(Xi,"takeCover");function Ne(t,e){let i=t.tokens?.filter(r=>r.actor)??[];Array.isArray(i)||(i=[i]);let n=t.actors??[];if(Array.isArray(n)||(n=[n]),!i.length&&n.length===1&&(i=[Ie(n[0])].filter(Boolean)),i.length||(i=canvas.tokens.controlled.filter(r=>r.actor)),i.length||(i=[Ie(game.user.character)].filter(Boolean)),i.length>1){ui.notifications.warn(h("action.only-one",{action:e}));return}if(!i.length){ui.notifications.warn(h("action.must-one",{action:e}));return}let o=i[0];if(!o?.actor?.isOfType("creature")){ui.notifications.warn(h("action.must-creature",{action:e}));return}return o}a(Ne,"getSelectedToken");function Pi(t,e,i){return` -`}a(Pi,"createButton");var Si={geometry:{clearDebug:me,getRectEdges:at,lineIntersectWall:De,pointToTokenIntersectWall:st},token:{getCreatureCover:ut,getWallCover:lt,getVisibility:oe,clearConditionals:ye,showConditionals:Tt,showAllConditionals:pt,getTokenData:z,getCover:dt,openHUD:Et},lighting:{getLightExposure:ct},actor:{isProne:Z,getCoverEffect:te,seeInvisibility:Ke,hasGreaterDarkvision:He},scene:{getValidTokens:j,validateTokens:ne,getSceneSetting:Ee},template:{createSeekTemplate:Ze,createDarknessTemplate:Xt,createMistTemplate:Zt,getDarknessTemplates:Je,getMistTemplates:et,getSeekTemplateTokens:tt,deleteSeekTemplate:J,getTemplateTokens:Te},ruleElement:{perceptionRules:re,getPerception:B,updateFromPerceptionRules:Fe}};async function bi(t,...e){let i=e[1];if(!i)return t(...e);Array.isArray(i.options)&&(i.options=new Set(i.options));let{actor:n,createMessage:o="true",type:r,token:s,target:c,isReroll:l}=i,p=s??Ie(n),d=c?.token,u=ke.includes(r),g=O("flat-check");if(l||!o||!p||n.isOfType("hazard")||!Dt.includes(r)||u&&(!d||g==="none"))return t(...e);if(u&&d.actor){let m=e[2],y=re(p,d,{extraOptions:i.options.filter(A=>A.startsWith("item:"))}),k=oe(d,p,{perception:y,affects:"target"});if(!k)return t(...e);let R=(()=>{let A=B(y,"target","visibility","dc",k)?.first(),b=rt(A);if(!b)return b;let N=A[0];return["-","+"].includes(N)?(k==="concealed"?5:11)+b:b})();if(R===0)return t(...e);let E=P[k]>=P.undetected,S=m?.ctrlKey||m?.metaKey,T=(await new p.actor.saves.reflex.constructor(p.actor,{slug:"visibility-check",label:`${game.i18n.localize("PF2E.FlatCheck")}: ${game.i18n.localize(`PF2E.condition.${k}.name`)}`,check:{type:"flat-check"}}).roll({dc:{value:R??(k==="concealed"?5:11)},target:d.actor,rollMode:E||S?game.user.isGM?"gmroll":"blindroll":"roll"})).degreeOfSuccess>1;if(E&&(i.options.add("secret"),i.pf2ePerception={isSuccess:T,visibility:k}),g!=="roll"&&!E&&!T)return}else if(i.options.has("action:hide"))setProperty(i,"pf2ePerception.selected",game.user.targets.ids);else if(i.options.has("action:create-a-diversion"))setProperty(i,"pf2ePerception.selected",game.user.targets.ids);else if(i.options.has("action:seek")){let m=tt(p),y=m??Array.from(game.user.targets),k=ne(p,y).filter(R=>!R.document.hidden).map(R=>R.id);setProperty(i,"pf2ePerception.selected",k),setProperty(i,"pf2ePerception.fromTemplate",!!m)}return t(...e)}a(bi,"checkRoll");function Ei(t,e){let{createMessage:i="true",type:n,token:o,target:r,isReroll:s,options:c,dc:l}=t.context,p=o,d=r?.token,u=r?.actor;if(s||!i||!p||!d||!u||!ke.includes(n))return;let g=te(u),m=g?Be(g)?.selection.level??w(g,"level"):void 0,y=t[f]?.coverOverride??m,k='
';k+=`
${h("dice-checks.cover.label")}
`,k+=`
",k+="
",e.find(".roll-mode-panel").before(k),e.find("select[name=overrideCover]").on("change",E=>{let S=E.currentTarget.value||void 0;setProperty(t,`${f}.coverOverride`,S),y=S}),e.find("button.roll")[0].addEventListener("click",E=>{E.preventDefault(),E.stopPropagation(),E.stopImmediatePropagation();let S=!1,F=deepClone(u._source.items);if(y!==m){S=!0;let T=F.findIndex(A=>getProperty(A,"flags.core.sourceId")===Pe);if(T!==-1&&F.splice(T,1),y){let A=Se(y);F.push(A)}}if(S&&(r.actor=u.clone({items:F},{keepId:!0}),l?.slug)){let T=r.actor.getStatistic(l.slug)?.dc;T&&(l.value=T.value,l.statistic=T)}t.resolve(!0),t.isResolved=!0,t.close()},!0),t.setPosition()}a(Ei,"renderCheckModifiersDialog");function Ti(t,e){O("target")&&Zi(e)}a(Ti,"renderCombatTracker");function Zi(t){t.find("[data-control=toggleTarget]").each((e,i)=>{i.addEventListener("click",n=>{n.preventDefault(),n.stopPropagation(),n.stopImmediatePropagation();let{combatantId:o}=n.currentTarget.closest(".combatant").dataset,s=game.combats.viewed.combatants.get(o??"")?.token;if(!s)return;let c=Array.from(game.user.targets).some(l=>l.document===s);s.object.setTarget(!c,{releaseOthers:!n.shiftKey})},!0)})}a(Zi,"setupToggleTarget");function Ri(t,e){let i=O("encounter");e.find(".form-group").last().after(`
+`}a(Pi,"createButton");var bi={geometry:{clearDebug:me,getRectEdges:at,lineIntersectWall:De,pointToTokenIntersectWall:st},token:{getCreatureCover:ut,getWallCover:lt,getVisibility:oe,clearConditionals:ye,showConditionals:Tt,showAllConditionals:pt,getTokenData:z,getCover:dt,openHUD:Et},lighting:{getLightExposure:ct},actor:{isProne:Z,getCoverEffect:te,seeInvisibility:Ke,hasGreaterDarkvision:He},scene:{getValidTokens:j,validateTokens:ne,getSceneSetting:Ee},template:{createSeekTemplate:Ze,createDarknessTemplate:Xt,createMistTemplate:Zt,getDarknessTemplates:Je,getMistTemplates:et,getSeekTemplateTokens:tt,deleteSeekTemplate:J,getTemplateTokens:Te},ruleElement:{perceptionRules:re,getPerception:B,updateFromPerceptionRules:Fe}};async function Si(t,...e){let i=e[1];if(!i)return t(...e);Array.isArray(i.options)&&(i.options=new Set(i.options));let{actor:n,createMessage:o="true",type:r,token:s,target:c,isReroll:l}=i,p=s??Ie(n),d=c?.token,u=ke.includes(r),g=O("flat-check");if(l||!o||!p||n.isOfType("hazard")||!Dt.includes(r)||u&&(!d||g==="none"))return t(...e);if(u&&d.actor){let m=e[2],y=re(p,d,{extraOptions:i.options.filter(A=>A.startsWith("item:"))}),k=oe(d,p,{perception:y,affects:"target"});if(!k)return t(...e);let R=(()=>{let A=B(y,"target","visibility","dc",k)?.first(),S=rt(A);if(!S)return S;let N=A[0];return["-","+"].includes(N)?(k==="concealed"?5:11)+S:S})();if(R===0)return t(...e);let E=P[k]>=P.undetected,b=m?.ctrlKey||m?.metaKey,T=(await new p.actor.saves.reflex.constructor(p.actor,{slug:"visibility-check",label:`${game.i18n.localize("PF2E.FlatCheck")}: ${game.i18n.localize(`PF2E.condition.${k}.name`)}`,check:{type:"flat-check"}}).roll({dc:{value:R??(k==="concealed"?5:11)},target:d.actor,rollMode:E||b?game.user.isGM?"gmroll":"blindroll":"roll"})).degreeOfSuccess>1;if(E&&(i.options.add("secret"),i.pf2ePerception={isSuccess:T,visibility:k}),g!=="roll"&&!E&&!T)return}else if(i.options.has("action:hide"))setProperty(i,"pf2ePerception.selected",game.user.targets.ids);else if(i.options.has("action:create-a-diversion"))setProperty(i,"pf2ePerception.selected",game.user.targets.ids);else if(i.options.has("action:seek")){let m=tt(p),y=m??Array.from(game.user.targets),k=ne(p,y).filter(R=>!R.document.hidden).map(R=>R.id);setProperty(i,"pf2ePerception.selected",k),setProperty(i,"pf2ePerception.fromTemplate",!!m)}return t(...e)}a(Si,"checkRoll");function Ei(t,e){let{createMessage:i="true",type:n,token:o,target:r,isReroll:s,options:c,dc:l}=t.context,p=o,d=r?.token,u=r?.actor;if(s||!i||!p||!d||!u||!ke.includes(n))return;let g=te(u),m=g?Be(g)?.selection.level??w(g,"level"):void 0,y=t[f]?.coverOverride??m,k='
';k+=`
${h("dice-checks.cover.label")}
`,k+=`
",k+="
",e.find(".roll-mode-panel").before(k),e.find("select[name=overrideCover]").on("change",E=>{let b=E.currentTarget.value||void 0;setProperty(t,`${f}.coverOverride`,b),y=b}),e.find("button.roll")[0].addEventListener("click",E=>{E.preventDefault(),E.stopPropagation(),E.stopImmediatePropagation();let b=!1,F=deepClone(u._source.items);if(y!==m){b=!0;let T=F.findIndex(A=>getProperty(A,"flags.core.sourceId")===Pe);if(T!==-1&&F.splice(T,1),y){let A=be(y);F.push(A)}}if(b&&(r.actor=u.clone({items:F},{keepId:!0}),l?.slug)){let T=r.actor.getStatistic(l.slug)?.dc;T&&(l.value=T.value,l.statistic=T)}t.resolve(!0),t.isResolved=!0,t.close()},!0),t.setPosition()}a(Ei,"renderCheckModifiersDialog");function Ti(t,e){O("target")&&Zi(e)}a(Ti,"renderCombatTracker");function Zi(t){t.find("[data-control=toggleTarget]").each((e,i)=>{i.addEventListener("click",n=>{n.preventDefault(),n.stopPropagation(),n.stopImmediatePropagation();let{combatantId:o}=n.currentTarget.closest(".combatant").dataset,s=game.combats.viewed.combatants.get(o??"")?.token;if(!s)return;let c=Array.from(game.user.targets).some(l=>l.document===s);s.object.setTarget(!c,{releaseOthers:!n.shiftKey})},!0)})}a(Zi,"setupToggleTarget");function Ri(t,e){let i=O("encounter");e.find(".form-group").last().after(`

${h("settings.encounter.short")}

-
`),e.find('input[name="pf2e-perception.encounter"]').on("change",n=>{let o=n.currentTarget.checked;Ue("encounter",o)})}a(Ri,"renderCombatTrackerConfig");function xi(t,e,i={}){return!e.enabled||!this._canDetect(t,i.object,i)?!1:i.tests.some(n=>this._testPoint(t,e,i.object,n))}a(xi,"detectionModeTestVisibility");function Fi(t,e,i){if(e instanceof PlaceableObject&&e.document.hidden)return!1;if(!(e instanceof Token))return!0;let n=t.object,o=n.document;return o instanceof TokenDocument&&o.hasStatusEffect(CONFIG.specialStatusEffects.BLIND)?!1:n instanceof Token?!Ct(n,e,P.hidden,i):!e.document?.hasStatusEffect(CONFIG.specialStatusEffects.INVISIBLE)&&!e.actor?.hasCondition("hidden","undetected","unnoticed")}a(Fi,"basicSightCanDetect");function Ni(t,e,i){if(e.document.hidden||!(e instanceof Token)||!e.actor?.emitsSound)return!1;if(!game.settings.get("pf2e","automation.rulesBasedVision"))return!0;let n=t.object;return n.actor?.hasCondition("deafened")?!1:n instanceof Token?!Ct(n,e,P.undetected,i):!e.actor?.hasCondition("undetected","unnoticed")}a(Ni,"hearingCanDetect");function Ci(t,e,i){if(e.document.hidden||!(e instanceof Token)||e.document.elevation>canvas.primary.background.elevation||e.actor?.isOfType("loot"))return!1;let n=t.object;return n instanceof Token?!Ct(n,e,P.undetected,i):!e.actor?.hasCondition("undetected","unnoticed")}a(Ci,"feelTremorCanDetect");function Ct(t,e,i,n={}){if(!n.visibility){let o=re(t,e);n.visibility=oe(e,t,{perception:o,affects:"target"})}return P[n.visibility]>=i}a(Ct,"reachesThreshold");function Ji(t,e,i){let n=t.length-e.length,o=Array.from(e);if(n===0)return t(...o);if(n===1){let r=a(s=>t(s,...o),"ret");return(i||t.lazy)&&(r.lazy=i||t.lazy,r.lazyArgs=e),r}throw new Error("Wrong number of arguments")}a(Ji,"purry");function en(t,e,i){let n=[];for(let o=0;ot.has(e)?{done:!1,hasNext:!1}:(t.add(e),{done:!1,hasNext:!0,next:e})}a(Oi,"uniqLazy");function tn(t){return en(t,Oi())}a(tn,"_uniq");var se={compact:t=>t.filter(Boolean),uniq:function(){return Ji(tn,arguments,Oi)}};var H=class extends Array{constructor(...e){super(...Array.isArray(e[0])?e[0]:e),this.isValid=H.isValid(this)}static isValid(e){return this.isArray(e)}static isArray(e){return super.isArray(e)&&e.every(i=>he.isStatement(i))}static test(e=[],i){return e instanceof H?e.test(i):new H(...e).test(i)}test(e){if(this.length===0)return!0;if(!this.isValid)return console.warn("PF2e System | The provided predicate set is malformed."),!1;let i=e instanceof Set?e:new Set(e);return this.every(n=>this.#e(n,i))}toObject(){return deepClone([...this])}clone(){return new H(this.toObject())}#e(e,i){return typeof e=="string"&&i.has(e)||he.isBinaryOp(e)&&this.#i(e,i)||he.isCompound(e)&&this.#t(e,i)}#i(e,i){if("eq"in e)return i.has(`${e.eq[0]}:${e.eq[1]}`);{let n=Object.keys(e)[0],[o,r]=Object.values(e)[0],s=Array.from(i),c=a(d=>{let u=Number(d);if(!Number.isNaN(u))return[u];let g=new RegExp(String.raw`^${d}:([^:]+)$`),m=s.map(y=>Number(g.exec(y)?.[1]||NaN)).filter(y=>!Number.isNaN(y));return m.length>0?m:[NaN]},"getValues"),l=c(o),p=c(r);switch(n){case"gt":return l.some(d=>p.every(u=>d>u));case"gte":return l.some(d=>p.every(u=>d>=u));case"lt":return l.some(d=>p.every(u=>dp.every(u=>d<=u));default:return console.warn("PF2e System | Malformed binary operation encountered"),!1}}}#t(e,i){return"and"in e&&e.and.every(n=>this.#e(n,i))||"nand"in e&&!e.nand.every(n=>this.#e(n,i))||"or"in e&&e.or.some(n=>this.#e(n,i))||"xor"in e&&e.xor.filter(n=>this.#e(n,i)).length===1||"nor"in e&&!e.nor.some(n=>this.#e(n,i))||"not"in e&&!this.#e(e.not,i)||"if"in e&&!(this.#e(e.if,i)&&!this.#e(e.then,i))}};a(H,"PredicatePF2e");var ft,he=class{static isStatement(e){return e instanceof Object?this.isCompound(e)||this.isBinaryOp(e):typeof e=="string"?this.isAtomic(e):!1}static isAtomic(e){return typeof e=="string"&&e.length>0||this.isBinaryOp(e)}static isBinaryOp(e){if(!kt(e))return!1;let i=Object.entries(e);if(i.length>1)return!1;let[n,o]=i[0];return Wt(this,ft).has(n)&&Array.isArray(o)&&o.length===2&&typeof o[0]=="string"&&["string","number"].includes(typeof o[1])}static isCompound(e){return kt(e)&&(this.isAnd(e)||this.isOr(e)||this.isNand(e)||this.isXor(e)||this.isNor(e)||this.isNot(e)||this.isIf(e))}static isAnd(e){return Object.keys(e).length===1&&Array.isArray(e.and)&&e.and.every(i=>this.isStatement(i))}static isNand(e){return Object.keys(e).length===1&&Array.isArray(e.nand)&&e.nand.every(i=>this.isStatement(i))}static isOr(e){return Object.keys(e).length===1&&Array.isArray(e.or)&&e.or.every(i=>this.isStatement(i))}static isXor(e){return Object.keys(e).length===1&&Array.isArray(e.xor)&&e.xor.every(i=>this.isStatement(i))}static isNor(e){return Object.keys(e).length===1&&Array.isArray(e.nor)&&e.nor.every(i=>this.isStatement(i))}static isNot(e){return Object.keys(e).length===1&&!!e.not&&this.isStatement(e.not)}static isIf(e){return Object.keys(e).length===2&&this.isStatement(e.if)&&this.isStatement(e.then)}};a(he,"StatementValidator"),ft=new WeakMap,ue(he,ft,new Set(["eq","gt","gte","lt","lte"]));var nn={ancestralEchoing:{level:15,name:"PF2E.WeaponPropertyRune.ancestralEchoing.Name",price:9500,rarity:"rare",slug:"ancestralEchoing",traits:["dwarf","magical","saggorak"]},anchoring:{damage:{notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.anchoring.Name",text:"PF2E.WeaponPropertyRune.anchoring.Note.criticalSuccess"}]},level:10,name:"PF2E.WeaponPropertyRune.anchoring.Name",price:900,rarity:"uncommon",slug:"anchoring",traits:["magical"]},ashen:{damage:{dice:[{damageType:"fire",category:"persistent",diceNumber:1,dieSize:"d4"}],notes:[{outcome:["success"],title:"PF2E.WeaponPropertyRune.ashen.Name",text:"PF2E.WeaponPropertyRune.ashen.Note.success"}]},level:9,name:"PF2E.WeaponPropertyRune.ashen.Name",price:700,rarity:"common",slug:"ashen",traits:["magical"]},astral:{level:8,name:"PF2E.WeaponPropertyRune.astral.Name",price:450,rarity:"common",slug:"astral",traits:["magical","spirit"],damage:{dice:[{damageType:"spirit",diceNumber:1,dieSize:"d6"}]}},authorized:{level:3,name:"PF2E.WeaponPropertyRune.authorized.Name",price:50,rarity:"common",slug:"authorized",traits:["magical"]},bane:{level:4,name:"PF2E.WeaponPropertyRune.bane.Name",price:100,rarity:"uncommon",slug:"bane",traits:["magical"]},bloodbane:{level:8,name:"PF2E.WeaponPropertyRune.bloodbane.Name",price:475,rarity:"uncommon",slug:"bloodbane",traits:["dwarf","magical"]},bloodthirsty:{damage:{notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.bloodbane.Name",text:"PF2E.WeaponPropertyRune.bloodthirsty.Note.criticalSuccess"}]},level:16,name:"PF2E.WeaponPropertyRune.bloodthirsty.Name",price:8500,rarity:"uncommon",slug:"bloodthirsty",traits:["magical"]},brilliant:{damage:{dice:[{damageType:"fire",diceNumber:1,dieSize:"d4"},{damageType:"spirit",diceNumber:1,dieSize:"d4",predicate:["target:trait:fiend"]},{damageType:"vitality",diceNumber:1,dieSize:"d4",predicate:["target:negative-healing"]}],notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.brilliant.Name",text:"PF2E.WeaponPropertyRune.brilliant.Note.criticalSuccess"}]},level:12,name:"PF2E.WeaponPropertyRune.brilliant.Name",price:2e3,rarity:"common",slug:"brilliant",traits:["magical"]},called:{level:7,name:"PF2E.WeaponPropertyRune.called.Name",price:350,rarity:"common",slug:"called",traits:["magical"]},coating:{level:9,name:"PF2E.WeaponPropertyRune.coating.Name",price:700,rarity:"common",slug:"coating",traits:["extradimensional","magical"]},conducting:{level:7,name:"PF2E.WeaponPropertyRune.conducting.Name",price:300,rarity:"common",slug:"conducting",traits:["magical"]},corrosive:{damage:{dice:[{damageType:"acid",diceNumber:1,dieSize:"d6"}],notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.corrosive.Name",text:"PF2E.WeaponPropertyRune.corrosive.Note.criticalSuccess"}]},level:8,name:"PF2E.WeaponPropertyRune.corrosive.Name",price:500,rarity:"common",slug:"corrosive",traits:["acid","magical"]},crushing:{damage:{notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.crushing.Name",text:"PF2E.WeaponPropertyRune.crushing.Note.criticalSuccess"}]},level:3,name:"PF2E.WeaponPropertyRune.crushing.Name",price:50,rarity:"uncommon",slug:"crushing",traits:["magical"]},cunning:{level:5,name:"PF2E.WeaponPropertyRune.cunning.Name",price:140,rarity:"common",slug:"cunning",traits:["magical"]},dancing:{level:13,name:"PF2E.WeaponPropertyRune.dancing.Name",price:2700,rarity:"uncommon",slug:"dancing",traits:["magical"]},decaying:{damage:{dice:[{slug:"decaying",damageType:"void",diceNumber:1,dieSize:"d4"},{slug:"decaying-persistent",category:"persistent",damageType:"void",diceNumber:2,dieSize:"d4",critical:!0}]},level:8,name:"PF2E.WeaponPropertyRune.decaying.Name",price:500,rarity:"common",slug:"decaying",traits:["acid","magical","void"]},deathdrinking:{damage:{dice:[{slug:"deathdrinking-negative",damageType:"void",diceNumber:1,dieSize:"d6",critical:!0,predicate:["target:mode:living",{not:"target:negative-healing"}]},{slug:"deathdrinking-positive",damageType:"vitality",diceNumber:1,dieSize:"d6",critical:!0,predicate:["target:negative-healing"]}]},level:7,name:"PF2E.WeaponPropertyRune.deathdrinking.Name",price:360,rarity:"rare",slug:"deathdrinking",traits:["magical"]},demolishing:{damage:{dice:[{damageType:"force",category:"persistent",diceNumber:1,dieSize:"d6",predicate:["target:trait:construct"]}]},level:6,name:"PF2E.WeaponPropertyRune.demolishing.Name",price:225,rarity:"rare",slug:"demolishing",traits:["magical"]},disrupting:{damage:{dice:[{category:"persistent",damageType:"vitality",diceNumber:1,dieSize:"d6",predicate:["target:negative-healing"]}],notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.disrupting.Name",text:"PF2E.WeaponPropertyRune.disrupting.Note.criticalSuccess",predicate:["target:negative-healing"]}]},level:5,name:"PF2E.WeaponPropertyRune.disrupting.Name",price:150,rarity:"common",slug:"disrupting",traits:["magical"]},earthbinding:{level:5,name:"PF2E.WeaponPropertyRune.earthbinding.Name",price:125,rarity:"common",slug:"earthbinding",traits:["magical"]},energizing:{level:6,name:"PF2E.WeaponPropertyRune.energizing.Name",price:250,rarity:"uncommon",slug:"energizing",traits:["magical"]},extending:{level:7,name:"PF2E.WeaponPropertyRune.extending.Name",price:700,rarity:"common",slug:"extending",traits:["magical"]},fanged:{level:2,name:"PF2E.WeaponPropertyRune.fanged.Name",price:30,rarity:"uncommon",slug:"fanged",traits:["magical"]},fearsome:{damage:{notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.fearsome.Name",text:"PF2E.WeaponPropertyRune.fearsome.Note.criticalSuccess"}]},level:5,name:"PF2E.WeaponPropertyRune.fearsome.Name",price:160,rarity:"common",slug:"fearsome",traits:["emotion","fear","magical","mental"]},flaming:{damage:{dice:[{damageType:"fire",diceNumber:1,dieSize:"d6"},{damageType:"fire",category:"persistent",diceNumber:1,dieSize:"d10",critical:!0}]},level:8,name:"PF2E.WeaponPropertyRune.flaming.Name",price:500,rarity:"common",slug:"flaming",traits:["fire","magical"]},flurrying:{level:7,name:"PF2E.WeaponPropertyRune.flurrying.Name",price:360,rarity:"common",slug:"flurrying",traits:["magical"]},frost:{damage:{dice:[{damageType:"cold",diceNumber:1,dieSize:"d6"}],notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.frost.Name",text:"PF2E.WeaponPropertyRune.frost.Note.criticalSuccess"}]},level:8,name:"PF2E.WeaponPropertyRune.frost.Name",price:500,rarity:"common",slug:"frost",traits:["cold","magical"]},ghostTouch:{level:4,name:"PF2E.WeaponPropertyRune.ghostTouch.Name",price:75,rarity:"common",slug:"ghostTouch",traits:["magical"]},giantKilling:{damage:{dice:[{slug:"giantKilling",damageType:"mental",diceNumber:1,dieSize:"d6",predicate:["target:trait:giant"]}],notes:[{outcome:["criticalSuccess"],predicate:["target:trait:giant"],title:"PF2E.WeaponPropertyRune.giantKilling.Name",text:"PF2E.WeaponPropertyRune.giantKilling.Note.criticalSuccess"}]},level:8,name:"PF2E.WeaponPropertyRune.giantKilling.Name",price:450,rarity:"rare",slug:"giantKilling",traits:["magical"]},greaterAnchoring:{damage:{notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.greaterAnchoring.Name",text:"PF2E.WeaponPropertyRune.greaterAnchoring.Note.criticalSuccess"},{outcome:["success"],title:"PF2E.WeaponPropertyRune.greaterAnchoring.Name",text:"PF2E.WeaponPropertyRune.greaterAnchoring.Note.success"}]},level:18,name:"PF2E.WeaponPropertyRune.greaterAnchoring.Name",price:22e3,rarity:"uncommon",slug:"greaterAnchoring",traits:["magical"]},greaterAshen:{damage:{dice:[{damageType:"fire",category:"persistent",diceNumber:1,dieSize:"d8"}],notes:[{outcome:["success"],title:"PF2E.WeaponPropertyRune.greaterAshen.Name",text:"PF2E.WeaponPropertyRune.greaterAshen.Note.success"}]},level:16,name:"PF2E.WeaponPropertyRune.greaterAshen.Name",price:9e3,rarity:"common",slug:"greaterAshen",traits:["magical"]},greaterAstral:{level:15,name:"PF2E.WeaponPropertyRune.greaterAstral.Name",price:6e3,rarity:"common",slug:"greaterAstral",traits:["magical","spirit"],damage:{dice:[{damageType:"spirit",diceNumber:1,dieSize:"d6"}],ignoredResistances:[{type:"spirit",max:null}]}},greaterBloodbane:{level:13,name:"PF2E.WeaponPropertyRune.greaterBloodbane.Name",price:2800,rarity:"uncommon",slug:"greaterBloodbane",traits:["dwarf","magical"]},greaterBrilliant:{damage:{dice:[{damageType:"fire",diceNumber:1,dieSize:"d4"},{damageType:"spirit",diceNumber:1,dieSize:"d4",predicate:["target:trait:fiend"]},{damageType:"vitality",diceNumber:1,dieSize:"d4",predicate:["target:negative-healing"]}],notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.greaterBrilliant.Name",text:"PF2E.WeaponPropertyRune.greaterBrilliant.Note.criticalSuccess"},{outcome:["success"],title:"PF2E.WeaponPropertyRune.greaterBrilliant.Name",text:"PF2E.WeaponPropertyRune.greaterBrilliant.Note.success"}],ignoredResistances:[{type:"fire",max:null},{type:"spirit",max:null},{type:"vitality",max:null}]},level:18,name:"PF2E.WeaponPropertyRune.greaterBrilliant.Name",price:24e3,rarity:"common",slug:"greaterBrilliant",traits:["magical"]},greaterCorrosive:{damage:{dice:[{damageType:"acid",diceNumber:1,dieSize:"d6"}],notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.greaterCorrosive.Name",text:"PF2E.WeaponPropertyRune.greaterCorrosive.Note.criticalSuccess"},{outcome:["success"],title:"PF2E.WeaponPropertyRune.greaterCorrosive.Name",text:"PF2E.WeaponPropertyRune.greaterCorrosive.Note.success"}],ignoredResistances:[{type:"acid",max:null}]},level:15,name:"PF2E.WeaponPropertyRune.greaterCorrosive.Name",price:6500,rarity:"common",slug:"greaterCorrosive",traits:["acid","magical"]},greaterCrushing:{damage:{notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.greaterCrushing.Name",text:"PF2E.WeaponPropertyRune.greaterCrushing.Note.criticalSuccess"}]},level:9,name:"PF2E.WeaponPropertyRune.greaterCrushing.Name",price:650,rarity:"uncommon",slug:"greaterCrushing",traits:["magical"]},greaterDecaying:{damage:{dice:[{slug:"decaying",damageType:"void",diceNumber:1,dieSize:"d4"},{slug:"decaying-persistent",category:"persistent",damageType:"void",diceNumber:4,dieSize:"d4",critical:!0}],ignoredResistances:[{type:"void",max:null}]},level:15,name:"PF2E.WeaponPropertyRune.greaterDecaying.Name",price:6500,rarity:"common",slug:"greaterDecaying",traits:["acid","magical","void"]},greaterDisrupting:{damage:{dice:[{category:"persistent",damageType:"vitality",diceNumber:2,dieSize:"d6",predicate:["target:negative-healing"]}],notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.greaterDisrupting.Name",text:"PF2E.WeaponPropertyRune.greaterDisrupting.Note.criticalSuccess",predicate:["target:negative-healing"]}]},level:14,name:"PF2E.WeaponPropertyRune.greaterDisrupting.Name",price:4300,rarity:"uncommon",slug:"greaterDisrupting",traits:["magical"]},greaterExtending:{level:13,name:"PF2E.WeaponPropertyRune.greaterExtending.Name",price:3e3,rarity:"common",slug:"greaterExtending",traits:["magical"]},greaterFanged:{level:8,name:"PF2E.WeaponPropertyRune.greaterFanged.Name",price:425,rarity:"uncommon",slug:"greaterFanged",traits:["magical"]},greaterFearsome:{damage:{notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.greaterFearsome.Name",text:"PF2E.WeaponPropertyRune.greaterFearsome.Note.criticalSuccess"}]},level:12,name:"PF2E.WeaponPropertyRune.greaterFearsome.Name",price:2e3,rarity:"common",slug:"greaterFearsome",traits:["emotion","fear","magical","mental"]},greaterFlaming:{damage:{dice:[{damageType:"fire",diceNumber:1,dieSize:"d6"},{damageType:"fire",category:"persistent",diceNumber:2,dieSize:"d10",critical:!0}],notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.greaterFlaming.Name",text:"PF2E.WeaponPropertyRune.greaterFlaming.Note.criticalSuccess"},{outcome:["success"],title:"PF2E.WeaponPropertyRune.greaterFlaming.Name",text:"PF2E.WeaponPropertyRune.greaterFlaming.Note.success"}],ignoredResistances:[{type:"fire",max:null}]},level:15,name:"PF2E.WeaponPropertyRune.greaterFlaming.Name",price:6500,rarity:"common",slug:"greaterFlaming",traits:["fire","magical"]},greaterFrost:{damage:{dice:[{damageType:"cold",diceNumber:1,dieSize:"d6"}],notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.greaterFrost.Name",text:"PF2E.WeaponPropertyRune.greaterFrost.Note.criticalSuccess"},{outcome:["success"],title:"PF2E.WeaponPropertyRune.greaterFrost.Name",text:"PF2E.WeaponPropertyRune.greaterFrost.Note.success"}],ignoredResistances:[{type:"cold",max:null}]},level:15,name:"PF2E.WeaponPropertyRune.greaterFrost.Name",price:6500,rarity:"common",slug:"greaterFrost",traits:["cold","magical"]},greaterGiantKilling:{damage:{dice:[{slug:"greaterGiantKilling",damageType:"mental",diceNumber:2,dieSize:"d6",predicate:["target:trait:giant"]}],ignoredResistances:[{type:"mental",max:null}],notes:[{outcome:["criticalSuccess"],predicate:["target:trait:giant"],title:"PF2E.WeaponPropertyRune.greaterGiantKilling.Name",text:"PF2E.WeaponPropertyRune.greaterGiantKilling.Note.criticalSuccess"}]},level:15,name:"PF2E.WeaponPropertyRune.greaterGiantKilling.Name",price:6e3,rarity:"rare",slug:"greaterGiantKilling",traits:["magical"]},greaterHauling:{level:11,name:"PF2E.WeaponPropertyRune.greaterHauling.Name",price:1300,rarity:"uncommon",slug:"greaterHauling",traits:["magical"]},greaterImpactful:{damage:{dice:[{damageType:"force",diceNumber:1,dieSize:"d6"}],notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.greaterImpactful.Name",text:"PF2E.WeaponPropertyRune.greaterImpactful.Note.criticalSuccess"}]},level:17,name:"PF2E.WeaponPropertyRune.greaterImpactful.Name",price:15e3,rarity:"common",slug:"greaterImpactful",traits:["force","magical"]},greaterRooting:{level:11,name:"PF2E.WeaponPropertyRune.greaterRooting.Name",price:1400,rarity:"common",slug:"greaterRooting",traits:["plant","magical","wood"],damage:{notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.greaterRooting.Name",text:"PF2E.WeaponPropertyRune.greaterRooting.Note.criticalSuccess"},{outcome:["success"],title:"PF2E.WeaponPropertyRune.greaterRooting.Name",text:"PF2E.WeaponPropertyRune.greaterRooting.Note.success"}]}},greaterShock:{damage:{dice:[{damageType:"electricity",diceNumber:1,dieSize:"d6"}],notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.greaterShock.Name",text:"PF2E.WeaponPropertyRune.greaterShock.Note.criticalSuccess"},{outcome:["success"],title:"PF2E.WeaponPropertyRune.greaterShock.Name",text:"PF2E.WeaponPropertyRune.greaterShock.Note.success"}],ignoredResistances:[{type:"electricity",max:null}]},level:15,name:"PF2E.WeaponPropertyRune.greaterShock.Name",price:6500,rarity:"common",slug:"greaterShock",traits:["electricity","magical"]},greaterThundering:{damage:{dice:[{damageType:"sonic",diceNumber:1,dieSize:"d6"}],notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.greaterThundering.Name",text:"PF2E.WeaponPropertyRune.greaterThundering.Note.criticalSuccess"},{outcome:["success"],title:"PF2E.WeaponPropertyRune.greaterThundering.Name",text:"PF2E.WeaponPropertyRune.greaterThundering.Note.success"}],ignoredResistances:[{type:"sonic",max:null}]},level:15,name:"PF2E.WeaponPropertyRune.greaterThundering.Name",price:6500,rarity:"common",slug:"greaterThundering",traits:["magical","sonic"]},grievous:{damage:{dice:[{damageType:"bleed",diceNumber:1,dieSize:"d6",critical:!0,predicate:["critical-specialization","item:group:dart"]}],notes:[{outcome:["criticalSuccess"],predicate:["item:group:axe"],title:"PF2E.WeaponPropertyRune.grievous.Name",text:"PF2E.WeaponPropertyRune.grievous.Note.Axe"},{outcome:["criticalSuccess"],predicate:["item:group:brawling"],title:"PF2E.WeaponPropertyRune.grievous.Name",text:"PF2E.WeaponPropertyRune.grievous.Note.Brawling"},{outcome:["criticalSuccess"],predicate:["item:group:club"],title:"PF2E.WeaponPropertyRune.grievous.Name",text:"PF2E.WeaponPropertyRune.grievous.Note.Club"},{outcome:["criticalSuccess"],predicate:["item:group:flail"],title:"PF2E.WeaponPropertyRune.grievous.Name",text:"PF2E.WeaponPropertyRune.grievous.Note.Flail"},{outcome:["criticalSuccess"],predicate:["item:group:hammer"],title:"PF2E.WeaponPropertyRune.grievous.Name",text:"PF2E.WeaponPropertyRune.grievous.Note.Hammer"},{outcome:["criticalSuccess"],predicate:["item:group:knife"],title:"PF2E.WeaponPropertyRune.grievous.Name",text:"PF2E.WeaponPropertyRune.grievous.Note.Knife"},{outcome:["criticalSuccess"],predicate:["item:group:polearm"],title:"PF2E.WeaponPropertyRune.grievous.Name",text:"PF2E.WeaponPropertyRune.grievous.Note.Polearm"},{outcome:["criticalSuccess"],predicate:["item:group:shield"],title:"PF2E.WeaponPropertyRune.grievous.Name",text:"PF2E.WeaponPropertyRune.grievous.Note.Shield"},{outcome:["criticalSuccess"],predicate:["item:group:sling"],title:"PF2E.WeaponPropertyRune.grievous.Name",text:"PF2E.WeaponPropertyRune.grievous.Note.Sling"},{outcome:["criticalSuccess"],predicate:["item:group:spear"],title:"PF2E.WeaponPropertyRune.grievous.Name",text:"PF2E.WeaponPropertyRune.grievous.Note.Spear"},{outcome:["criticalSuccess"],predicate:["item:group:sword"],title:"PF2E.WeaponPropertyRune.grievous.Name",text:"PF2E.WeaponPropertyRune.grievous.Note.Sword"}],adjustments:[{slug:"critical-specialization",test:t=>new H("item:group:pick").test(t),getNewValue:t=>t*2}]},level:9,name:"PF2E.WeaponPropertyRune.grievous.Name",price:700,rarity:"common",slug:"grievous",traits:["magical"]},hauling:{level:6,name:"PF2E.WeaponPropertyRune.hauling.Name",price:225,rarity:"uncommon",slug:"hauling",traits:["magical"]},holy:{level:11,name:"PF2E.WeaponPropertyRune.holy.Name",price:1400,rarity:"common",slug:"holy",traits:["holy","magical"],damage:{dice:[{damageType:"spirit",diceNumber:1,dieSize:"d4",predicate:[{not:"target:trait:unholy"}]},{damageType:"spirit",diceNumber:2,dieSize:"d4",predicate:["target:trait:unholy"]}]},strikeAdjustments:[{adjustTraits:(t,e)=>{e.includes("holy")||e.push("holy")}}]},hopeful:{attack:{notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.hopeful.Name",text:"PF2E.WeaponPropertyRune.hopeful.Note.criticalSuccess"}]},level:11,name:"PF2E.WeaponPropertyRune.hopeful.Name",price:1200,rarity:"uncommon",slug:"hopeful",traits:["magical"]},hooked:{level:5,name:"PF2E.WeaponPropertyRune.hooked.Name",price:140,rarity:"rare",slug:"hooked",traits:["magical"],strikeAdjustments:[{adjustWeapon:t=>{t.system.traits.value.includes("trip")||t.system.traits.value.push("trip")}}]},impactful:{damage:{dice:[{damageType:"force",diceNumber:1,dieSize:"d6"}],notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.impactful.Name",text:"PF2E.WeaponPropertyRune.impactful.Note.criticalSuccess"}]},level:10,name:"PF2E.WeaponPropertyRune.impactful.Name",price:1e3,rarity:"common",slug:"impactful",traits:["force","magical"]},impossible:{level:20,name:"PF2E.WeaponPropertyRune.impossible.Name",price:7e4,rarity:"common",slug:"impossible",traits:["magical"],strikeAdjustments:[{adjustWeapon:t=>{if(t.isOfType("weapon")&&t.system.range&&t._source.system.range){let e=t._source.system.range,i=t.system.range;t.system.range=e*2+Math.abs(i-e)}}}]},keen:{attack:{dosAdjustments:[{adjustments:{success:{label:"PF2E.WeaponPropertyRune.keen.Name",amount:"criticalSuccess"}},predicate:new H(["check:total:natural:19",{or:["item:damage:type:slashing","item:damage:type:piercing"]}])}]},level:13,name:"PF2E.WeaponPropertyRune.keen.Name",price:3e3,rarity:"uncommon",slug:"keen",traits:["magical"]},kinWarding:{level:3,name:"PF2E.WeaponPropertyRune.kinWarding.Name",price:52,rarity:"uncommon",slug:"kinWarding",traits:["dwarf","magical"]},majorFanged:{level:15,name:"PF2E.WeaponPropertyRune.majorFanged.Name",price:6e3,rarity:"uncommon",slug:"majorFanged",traits:["magical"]},majorRooting:{level:15,name:"PF2E.WeaponPropertyRune.majorRooting.Name",price:6500,rarity:"common",slug:"majorRooting",traits:["plant","magical","wood"],damage:{notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.majorRooting.Name",text:"PF2E.WeaponPropertyRune.majorRooting.Note.criticalSuccess"}]}},merciful:{strikeAdjustments:[{adjustWeapon:t=>{t.system.traits.value.includes("nonlethal")||t.system.traits.value.push("nonlethal")}}],level:4,name:"PF2E.WeaponPropertyRune.merciful.Name",price:70,rarity:"common",slug:"merciful",traits:["magical","mental"]},pacifying:{level:5,name:"PF2E.WeaponPropertyRune.pacifying.Name",price:150,rarity:"uncommon",slug:"pacifying",traits:["magical"]},returning:{attack:{notes:[{title:"PF2E.WeaponPropertyRune.returning.Name",text:"PF2E.WeaponPropertyRune.returning.Note"}]},level:3,name:"PF2E.WeaponPropertyRune.returning.Name",price:55,rarity:"common",slug:"returning",traits:["magical"]},rooting:{level:7,name:"PF2E.WeaponPropertyRune.rooting.Name",price:360,rarity:"common",slug:"rooting",traits:["plant","magical","wood"],damage:{notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.rooting.Name",text:"PF2E.WeaponPropertyRune.rooting.Note.criticalSuccess"}]}},serrating:{damage:{dice:[{damageType:"slashing",diceNumber:1,dieSize:"d4"}]},level:10,name:"PF2E.WeaponPropertyRune.serrating.Name",price:1e3,rarity:"uncommon",slug:"serrating",traits:["magical"]},shifting:{level:6,name:"PF2E.WeaponPropertyRune.shifting.Name",price:225,rarity:"common",slug:"shifting",traits:["magical"]},shock:{damage:{dice:[{damageType:"electricity",diceNumber:1,dieSize:"d6"}],notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.shock.Name",text:"PF2E.WeaponPropertyRune.shock.Note.criticalSuccess"}]},level:8,name:"PF2E.WeaponPropertyRune.shock.Name",price:500,rarity:"common",slug:"shock",traits:["electricity","magical"]},speed:{level:16,name:"PF2E.Actor.Speed.Label",price:1e4,rarity:"rare",slug:"speed",traits:["magical"]},spellStoring:{level:13,name:"PF2E.WeaponPropertyRune.spellStoring.Name",price:2700,rarity:"uncommon",slug:"spellStoring",traits:["magical"]},swarming:{level:9,name:"PF2E.WeaponPropertyRune.swarming.Name",price:700,rarity:"common",slug:"swarming",traits:["magical"]},thundering:{damage:{dice:[{damageType:"sonic",diceNumber:1,dieSize:"d6"}],notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.thundering.Name",text:"PF2E.WeaponPropertyRune.thundering.Note.criticalSuccess"}]},level:8,name:"PF2E.WeaponPropertyRune.thundering.Name",price:500,rarity:"common",slug:"thundering",traits:["magical","sonic"]},trueRooting:{level:19,name:"PF2E.WeaponPropertyRune.trueRooting.Name",price:4e4,rarity:"common",slug:"trueRooting",traits:["plant","magical","wood"],damage:{notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.trueRooting.Name",text:"PF2E.WeaponPropertyRune.trueRooting.Note.criticalSuccess"}]}},underwater:{level:3,name:"PF2E.WeaponPropertyRune.underwater.Name",price:50,rarity:"common",slug:"underwater",traits:["magical","water"]},unholy:{level:11,name:"PF2E.WeaponPropertyRune.unholy.Name",price:1400,rarity:"common",slug:"unholy",traits:["unholy","magical"],damage:{dice:[{damageType:"spirit",diceNumber:1,dieSize:"d4",predicate:[{not:"target:trait:holy"}]},{damageType:"spirit",diceNumber:2,dieSize:"d4",predicate:["target:trait:holy"]}]},strikeAdjustments:[{adjustTraits:(t,e)=>{e.includes("unholy")||e.push("unholy")}}]},vorpal:{level:17,name:"PF2E.WeaponPropertyRune.vorpal.Name",price:15e3,rarity:"rare",slug:"vorpal",traits:["magical"]},wounding:{damage:{dice:[{damageType:"bleed",diceNumber:1,dieSize:"d6"}]},level:7,name:"PF2E.WeaponPropertyRune.wounding.Name",price:340,rarity:"common",slug:"wounding",traits:["magical"]}};function Ii(t){return t.flatMap(e=>nn[e].strikeAdjustments??[])}a(Ii,"getPropertyRuneStrikeAdjustments");async function Ai(t){let[e,i]=canvas.ready&&!t.viewOnly?[canvas.tokens.controlled.find(v=>v.actor===this)??this.getActiveTokens().shift()??null,t.target?.token??t.target?.actor?.getActiveTokens().shift()??null]:[null,null],n=["attack","attack-roll","attack-damage"].some(v=>t.domains.includes(v)),o=!!(t.melee||t.item?.isOfType("weapon","melee")&&t.item.isMelee),r=o&&t.item?.isOfType("action","weapon","melee")?this.getReach({action:"attack",weapon:t.item}):this.getReach({action:"attack"}),s=!!(n&&o&&typeof r=="number"&&i?.actor&&e?.isFlanking(i,{reach:r})),c=await Pt({affects:"origin",origin:this,target:t.target?.actor??i?.actor??null,item:t.item??null,domains:t.domains,options:[...t.options,...t.item?.getRollOptions("item")??[]]}),l=(()=>{let v=i?this.synthetics.tokenMarks.get(i.document.uuid):null;return v?`target:mark:${v}`:null})(),p=t.traits?.map(v=>`self:action:trait:${v}`)??[],d=t.viewOnly||!i?.actor?this:this.getContextualClone(se.compact([...Array.from(t.options),...i.actor.getSelfRollOptions("target"),l,...p,s?"self:flanking":null]),c),u=t.statistic instanceof game.pf2e.StatisticModifier,g=u?d.system.actions?.flatMap(v=>[v,v.altUsages??[]].flat())??[]:[],m=t.viewOnly?t.statistic:u?g.find(v=>t.item?.id!==v.item.id||t?.item.name!==v.item.name?!1:t.item.isOfType("melee")&&v.item.isOfType("melee")?!0:t.item.isOfType("weapon")&&v.item.isOfType("weapon")&&t.item.isMelee===v.item.isMelee)??t.statistic:t.statistic,y=(()=>{if(d===this)return t.item??null;if(m&&"item"in m&&m.item instanceof Item&&m.item.isOfType("action","melee","spell","weapon"))return m.item;let v=d.items.get(t.item?.id??"");return v?.isOfType("melee","weapon")?v:t.item??null})(),k=y?.getRollOptions("item")??[],R=(()=>{let v=se.compact([t.traits].flat());if(y?.isOfType("weapon","melee")){let C=[d.synthetics.strikeAdjustments,Ii(y.system.runes.property)].flat();for(let K of C)K.adjustTraits?.(y,v)}return se.uniq(v).sort()})(),E=e&&i?e.distanceTo(i):null,[S,F]=typeof E=="number"?[`origin:distance:${E}`,`target:distance:${E}`]:[null,null],T=(()=>{let v=e?i?.actor?.synthetics.tokenMarks.get(e.document.uuid):null;return v?`origin:mark:${v}`:null})(),A=e&&i?se.compact(se.uniq([...d.getSelfRollOptions("origin"),...R.map(v=>`origin:action:trait${v}`),...S?[S]:[],T])):[],b=a(v=>{let C=v?.getSelfRollOptions("target")??[];return i&&(C.push("target"),l&&C.push(l)),C.sort()},"getTargetRollOptions"),N=b(i?.actor),G=await Pt({affects:"target",origin:d,target:i?.actor??null,item:y,domains:t.domains,options:[...t.options,...k,...N]});if(e?.actor&&i?.actor&&!t.viewOnly){let v=re(e,i,{extraOptions:k,distance:E}),C=oe(e,i,{perception:v,affects:"origin"});C&&B(v,"target","visibility","noff",C)&&(C=void 0),P[C]>P.concealed&&G.push(Vt(C));let K=dt(e,i,{perception:v,affects:"target",options:k}),ve;if(K){let le=B(v,"target","cover","ac",K)?.first();le!=null&&(le=Math.clamped(rt(le),0,4)),le===0?K=void 0:le&&(ve=le)}x[K]>x.none&&G.push(Se(K,ve))}if(s&&qt(i.actor,d,A)){let v=game.i18n.localize("PF2E.Item.Condition.Flanked"),C=game.pf2e.ConditionManager.getCondition("off-guard",{name:v});G.push(C.toObject())}let ce=t.viewOnly?null:(t.target?.actor??i?.actor)?.getContextualClone(se.compact([...t.options,...k,...A]),G)??null,Ce=new Set(se.compact([...t.options,...d.getRollOptions(t.domains),...ce?b(ce):N,...R.map(v=>`self:action:trait:${v}`),...k,n?"attack":null]).sort());F&&Ce.add(F);let W=y?Kt(y,E):null;W&&Ce.add(`target:range-increment:${W}`);let _={actor:d,token:e?.document??null,statistic:m,item:y,modifiers:[]},D=ce&&i&&E!==null?{actor:ce,token:i.document,distance:E,rangeIncrement:W}:null;return{options:Ce,self:_,target:D,traits:R}}a(Ai,"getRollContext");var rn=["cover","concealed","hidden","undetected","unnoticed"],je=class extends FormApplication{static get defaultOptions(){return foundry.utils.mergeObject(super.defaultOptions,{template:X("icon-path-menu"),title:h("settings.icon-path.name"),width:500})}getData(){let e=O("icon-path");return{icons:rn.map(n=>({name:n,placeholder:Ge[n],value:e[n]??"",label:n==="cover"?h("icon-path.cover"):game.i18n.localize(CONFIG.PF2E.conditionTypes[n])})),i18n:h}}activateListeners(e){super.activateListeners(e),e.find("button[name=cancel]").on("click",i=>{i.prefentDefault(),this.close()})}async _updateObject(e,i){Ue("icon-path",i)}};a(je,"IconPathMenu");function Wi(){L("icon-path",Object,{},{config:!1}),game.settings.registerMenu(f,"icon-path-menu",{name:I("icon-path","name"),label:I("icon-path","label"),icon:"fa-solid fa-list",restricted:!0,type:je}),L("permission",String,CONST.USER_ROLES.GAMEMASTER,{choices:{1:I("permission","choices.1"),2:I("permission","choices.2"),3:I("permission","choices.3"),4:I("permission","choices.4")}}),L("npc-vision",Boolean,!1),L("target",Boolean,!0,{onChange:()=>ui.combat?.render()}),L("lesser",String,"ten",{choices:{none:I("lesser","choices.none"),cross:I("lesser","choices.cross"),zero:I("lesser","choices.zero"),ten:I("lesser","choices.ten"),twenty:I("lesser","choices.twenty")}}),L("standard",Boolean,!0),L("dead-cover",Boolean,!0),L("prone-cover",Boolean,!0),L("standard-type",String,"center",{choices:{center:I("standard-type","choices.center"),points:I("standard-type","choices.points")}}),L("skip-cover",Boolean,!0),L("validation",String,"all",{choices:{all:I("validation","choices.all"),selected:I("validation","choices.selected"),changed:I("validation","choices.changed")}}),L("flat-check",String,"roll",{choices:{none:I("flat-check","choices.none"),roll:I("flat-check","choices.roll"),cancel:I("flat-check","choices.cancel")}}),L("encounter",Boolean,!1),L("icon-size",Number,26,{scope:"client",range:{min:26,max:52}}),L("seek-template",Boolean,!0,{scope:"client"})}a(Wi,"registerSettings");function I(t,e){return`${f}.settings.${t}.${e}`}a(I,"path");function L(t,e,i,n={}){game.settings.register(f,t,{name:I(t,"name"),hint:I(t,"hint"),scope:"world",config:!0,type:e,default:i,...n})}a(L,"register");var on="game.pf2e.Check.roll",an="CONFIG.Token.documentClass.prototype.rulesBasedVision",sn="CONFIG.MeasuredTemplate.objectClass.prototype.highlightGrid",cn="CONFIG.Actor.documentClass.prototype.getRollContext",ln="DetectionMode.prototype.testVisibility",un="CONFIG.Canvas.detectionModes.basicSight._canDetect",dn="CONFIG.Canvas.detectionModes.hearing._canDetect",pn="CONFIG.Canvas.detectionModes.feelTremor._canDetect";Hooks.once("init",()=>{Wi(),ki(),ii(),libWrapper.register(f,on,bi),libWrapper.register(f,sn,ei,"OVERRIDE"),libWrapper.register(f,an,pi,"OVERRIDE"),libWrapper.register(f,cn,Ai,"OVERRIDE"),libWrapper.register(f,ln,xi,"OVERRIDE"),libWrapper.register(f,un,Fi,"OVERRIDE"),libWrapper.register(f,dn,Ni,"OVERRIDE"),libWrapper.register(f,pn,Ci,"OVERRIDE"),game.data.users.find(e=>e._id===game.data.userId).role>=CONST.USER_ROLES.GAMEMASTER?(Hooks.on("renderSceneConfig",Ht),Hooks.on("renderCombatTrackerConfig",Ri)):Hooks.on("renderCombatTracker",Ti),game.modules.get(f).custom={getWallCover:void 0,getCreatureCover:void 0}});Hooks.once("ready",()=>{game.modules.get(f).api=Si,Hooks.on("renderChatMessage",xt);for(let t of document.querySelectorAll("#chat-log .chat-message")){let e=game.messages.get(t.dataset.messageId);e&&xt(e,$(t))}game.user.isGM&&game.modules.get("pf2e-rules-based-npc-vision")?.active&&ui.notifications.error(`${f}.warning.npc-vision`,{permanent:!0,localize:!0})});Hooks.on("hoverToken",ci);Hooks.on("pasteToken",oi);Hooks.on("updateToken",si);Hooks.on("deleteToken",li);Hooks.on("controlToken",di);Hooks.on("renderTokenHUD",ri);Hooks.on("preCreateToken",gi);Hooks.on("canvasPan",()=>ye());Hooks.on("renderCheckModifiersDialog",Ei);Hooks.on("preCreateMeasuredTemplate",ti);Hooks.on("createMeasuredTemplate",it);Hooks.on("updateMeasuredTemplate",it);Hooks.on("deleteMeasuredTemplate",it);})(); +
`),e.find('input[name="pf2e-perception.encounter"]').on("change",n=>{let o=n.currentTarget.checked;Ue("encounter",o)})}a(Ri,"renderCombatTrackerConfig");function xi(t,e,i={}){return!e.enabled||!this._canDetect(t,i.object,i)?!1:i.tests.some(n=>this._testPoint(t,e,i.object,n))}a(xi,"detectionModeTestVisibility");function Fi(t,e,i){if(e instanceof PlaceableObject&&e.document.hidden)return!1;if(!(e instanceof Token))return!0;let n=t.object,o=n.document;return o instanceof TokenDocument&&o.hasStatusEffect(CONFIG.specialStatusEffects.BLIND)?!1:n instanceof Token?!Ct(n,e,P.hidden,i):!e.document?.hasStatusEffect(CONFIG.specialStatusEffects.INVISIBLE)&&!e.actor?.hasCondition("hidden","undetected","unnoticed")}a(Fi,"basicSightCanDetect");function Ni(t,e,i){if(e.document.hidden||!(e instanceof Token)||!e.actor?.emitsSound)return!1;if(!game.settings.get("pf2e","automation.rulesBasedVision"))return!0;let n=t.object;return n.actor?.hasCondition("deafened")?!1:n instanceof Token?!Ct(n,e,P.undetected,i):!e.actor?.hasCondition("undetected","unnoticed")}a(Ni,"hearingCanDetect");function Ci(t,e,i){if(e.document.hidden||!(e instanceof Token)||e.document.elevation>canvas.primary.background.elevation||e.actor?.isOfType("loot"))return!1;let n=t.object;return n instanceof Token?!Ct(n,e,P.undetected,i):!e.actor?.hasCondition("undetected","unnoticed")}a(Ci,"feelTremorCanDetect");function Ct(t,e,i,n={}){if(!n.visibility){let o=re(t,e);n.visibility=oe(e,t,{perception:o,affects:"target"})}return P[n.visibility]>=i}a(Ct,"reachesThreshold");function Ji(t,e,i){let n=t.length-e.length,o=Array.from(e);if(n===0)return t(...o);if(n===1){let r=a(s=>t(s,...o),"ret");return(i||t.lazy)&&(r.lazy=i||t.lazy,r.lazyArgs=e),r}throw new Error("Wrong number of arguments")}a(Ji,"purry");function en(t,e,i){let n=[];for(let o=0;ot.has(e)?{done:!1,hasNext:!1}:(t.add(e),{done:!1,hasNext:!0,next:e})}a(Oi,"uniqLazy");function tn(t){return en(t,Oi())}a(tn,"_uniq");var se={compact:t=>t.filter(Boolean),uniq:function(){return Ji(tn,arguments,Oi)}};var H=class extends Array{constructor(...e){super(...Array.isArray(e[0])?e[0]:e),this.isValid=H.isValid(this)}static isValid(e){return this.isArray(e)}static isArray(e){return super.isArray(e)&&e.every(i=>he.isStatement(i))}static test(e=[],i){return e instanceof H?e.test(i):new H(...e).test(i)}test(e){if(this.length===0)return!0;if(!this.isValid)return console.warn("PF2e System | The provided predicate set is malformed."),!1;let i=e instanceof Set?e:new Set(e);return this.every(n=>this.#e(n,i))}toObject(){return deepClone([...this])}clone(){return new H(this.toObject())}#e(e,i){return typeof e=="string"&&i.has(e)||he.isBinaryOp(e)&&this.#i(e,i)||he.isCompound(e)&&this.#t(e,i)}#i(e,i){if("eq"in e)return i.has(`${e.eq[0]}:${e.eq[1]}`);{let n=Object.keys(e)[0],[o,r]=Object.values(e)[0],s=Array.from(i),c=a(d=>{let u=Number(d);if(!Number.isNaN(u))return[u];let g=new RegExp(String.raw`^${d}:([^:]+)$`),m=s.map(y=>Number(g.exec(y)?.[1]||NaN)).filter(y=>!Number.isNaN(y));return m.length>0?m:[NaN]},"getValues"),l=c(o),p=c(r);switch(n){case"gt":return l.some(d=>p.every(u=>d>u));case"gte":return l.some(d=>p.every(u=>d>=u));case"lt":return l.some(d=>p.every(u=>dp.every(u=>d<=u));default:return console.warn("PF2e System | Malformed binary operation encountered"),!1}}}#t(e,i){return"and"in e&&e.and.every(n=>this.#e(n,i))||"nand"in e&&!e.nand.every(n=>this.#e(n,i))||"or"in e&&e.or.some(n=>this.#e(n,i))||"xor"in e&&e.xor.filter(n=>this.#e(n,i)).length===1||"nor"in e&&!e.nor.some(n=>this.#e(n,i))||"not"in e&&!this.#e(e.not,i)||"if"in e&&!(this.#e(e.if,i)&&!this.#e(e.then,i))}};a(H,"PredicatePF2e");var ft,he=class{static isStatement(e){return e instanceof Object?this.isCompound(e)||this.isBinaryOp(e):typeof e=="string"?this.isAtomic(e):!1}static isAtomic(e){return typeof e=="string"&&e.length>0||this.isBinaryOp(e)}static isBinaryOp(e){if(!kt(e))return!1;let i=Object.entries(e);if(i.length>1)return!1;let[n,o]=i[0];return Wt(this,ft).has(n)&&Array.isArray(o)&&o.length===2&&typeof o[0]=="string"&&["string","number"].includes(typeof o[1])}static isCompound(e){return kt(e)&&(this.isAnd(e)||this.isOr(e)||this.isNand(e)||this.isXor(e)||this.isNor(e)||this.isNot(e)||this.isIf(e))}static isAnd(e){return Object.keys(e).length===1&&Array.isArray(e.and)&&e.and.every(i=>this.isStatement(i))}static isNand(e){return Object.keys(e).length===1&&Array.isArray(e.nand)&&e.nand.every(i=>this.isStatement(i))}static isOr(e){return Object.keys(e).length===1&&Array.isArray(e.or)&&e.or.every(i=>this.isStatement(i))}static isXor(e){return Object.keys(e).length===1&&Array.isArray(e.xor)&&e.xor.every(i=>this.isStatement(i))}static isNor(e){return Object.keys(e).length===1&&Array.isArray(e.nor)&&e.nor.every(i=>this.isStatement(i))}static isNot(e){return Object.keys(e).length===1&&!!e.not&&this.isStatement(e.not)}static isIf(e){return Object.keys(e).length===2&&this.isStatement(e.if)&&this.isStatement(e.then)}};a(he,"StatementValidator"),ft=new WeakMap,ue(he,ft,new Set(["eq","gt","gte","lt","lte"]));var nn={ancestralEchoing:{level:15,name:"PF2E.WeaponPropertyRune.ancestralEchoing.Name",price:9500,rarity:"rare",slug:"ancestralEchoing",traits:["dwarf","magical","saggorak"]},anchoring:{damage:{notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.anchoring.Name",text:"PF2E.WeaponPropertyRune.anchoring.Note.criticalSuccess"}]},level:10,name:"PF2E.WeaponPropertyRune.anchoring.Name",price:900,rarity:"uncommon",slug:"anchoring",traits:["magical"]},ashen:{damage:{dice:[{damageType:"fire",category:"persistent",diceNumber:1,dieSize:"d4"}],notes:[{outcome:["success"],title:"PF2E.WeaponPropertyRune.ashen.Name",text:"PF2E.WeaponPropertyRune.ashen.Note.success"}]},level:9,name:"PF2E.WeaponPropertyRune.ashen.Name",price:700,rarity:"common",slug:"ashen",traits:["magical"]},astral:{level:8,name:"PF2E.WeaponPropertyRune.astral.Name",price:450,rarity:"common",slug:"astral",traits:["magical","spirit"],damage:{dice:[{damageType:"spirit",diceNumber:1,dieSize:"d6"}]}},authorized:{level:3,name:"PF2E.WeaponPropertyRune.authorized.Name",price:50,rarity:"common",slug:"authorized",traits:["magical"]},bane:{level:4,name:"PF2E.WeaponPropertyRune.bane.Name",price:100,rarity:"uncommon",slug:"bane",traits:["magical"]},bloodbane:{level:8,name:"PF2E.WeaponPropertyRune.bloodbane.Name",price:475,rarity:"uncommon",slug:"bloodbane",traits:["dwarf","magical"]},bloodthirsty:{damage:{notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.bloodbane.Name",text:"PF2E.WeaponPropertyRune.bloodthirsty.Note.criticalSuccess"}]},level:16,name:"PF2E.WeaponPropertyRune.bloodthirsty.Name",price:8500,rarity:"uncommon",slug:"bloodthirsty",traits:["magical"]},brilliant:{damage:{dice:[{damageType:"fire",diceNumber:1,dieSize:"d4"},{damageType:"spirit",diceNumber:1,dieSize:"d4",predicate:["target:trait:fiend"]},{damageType:"vitality",diceNumber:1,dieSize:"d4",predicate:["target:negative-healing"]}],notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.brilliant.Name",text:"PF2E.WeaponPropertyRune.brilliant.Note.criticalSuccess"}]},level:12,name:"PF2E.WeaponPropertyRune.brilliant.Name",price:2e3,rarity:"common",slug:"brilliant",traits:["magical"]},called:{level:7,name:"PF2E.WeaponPropertyRune.called.Name",price:350,rarity:"common",slug:"called",traits:["magical"]},coating:{level:9,name:"PF2E.WeaponPropertyRune.coating.Name",price:700,rarity:"common",slug:"coating",traits:["extradimensional","magical"]},conducting:{level:7,name:"PF2E.WeaponPropertyRune.conducting.Name",price:300,rarity:"common",slug:"conducting",traits:["magical"]},corrosive:{damage:{dice:[{damageType:"acid",diceNumber:1,dieSize:"d6"}],notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.corrosive.Name",text:"PF2E.WeaponPropertyRune.corrosive.Note.criticalSuccess"}]},level:8,name:"PF2E.WeaponPropertyRune.corrosive.Name",price:500,rarity:"common",slug:"corrosive",traits:["acid","magical"]},crushing:{damage:{notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.crushing.Name",text:"PF2E.WeaponPropertyRune.crushing.Note.criticalSuccess"}]},level:3,name:"PF2E.WeaponPropertyRune.crushing.Name",price:50,rarity:"uncommon",slug:"crushing",traits:["magical"]},cunning:{level:5,name:"PF2E.WeaponPropertyRune.cunning.Name",price:140,rarity:"common",slug:"cunning",traits:["magical"]},dancing:{level:13,name:"PF2E.WeaponPropertyRune.dancing.Name",price:2700,rarity:"uncommon",slug:"dancing",traits:["magical"]},decaying:{damage:{dice:[{slug:"decaying",damageType:"void",diceNumber:1,dieSize:"d4"},{slug:"decaying-persistent",category:"persistent",damageType:"void",diceNumber:2,dieSize:"d4",critical:!0}]},level:8,name:"PF2E.WeaponPropertyRune.decaying.Name",price:500,rarity:"common",slug:"decaying",traits:["acid","magical","void"]},deathdrinking:{damage:{dice:[{slug:"deathdrinking-negative",damageType:"void",diceNumber:1,dieSize:"d6",critical:!0,predicate:["target:mode:living",{not:"target:negative-healing"}]},{slug:"deathdrinking-positive",damageType:"vitality",diceNumber:1,dieSize:"d6",critical:!0,predicate:["target:negative-healing"]}]},level:7,name:"PF2E.WeaponPropertyRune.deathdrinking.Name",price:360,rarity:"rare",slug:"deathdrinking",traits:["magical"]},demolishing:{damage:{dice:[{damageType:"force",category:"persistent",diceNumber:1,dieSize:"d6",predicate:["target:trait:construct"]}]},level:6,name:"PF2E.WeaponPropertyRune.demolishing.Name",price:225,rarity:"rare",slug:"demolishing",traits:["magical"]},disrupting:{damage:{dice:[{category:"persistent",damageType:"vitality",diceNumber:1,dieSize:"d6",predicate:["target:negative-healing"]}],notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.disrupting.Name",text:"PF2E.WeaponPropertyRune.disrupting.Note.criticalSuccess",predicate:["target:negative-healing"]}]},level:5,name:"PF2E.WeaponPropertyRune.disrupting.Name",price:150,rarity:"common",slug:"disrupting",traits:["magical"]},earthbinding:{level:5,name:"PF2E.WeaponPropertyRune.earthbinding.Name",price:125,rarity:"common",slug:"earthbinding",traits:["magical"]},energizing:{level:6,name:"PF2E.WeaponPropertyRune.energizing.Name",price:250,rarity:"uncommon",slug:"energizing",traits:["magical"]},extending:{level:7,name:"PF2E.WeaponPropertyRune.extending.Name",price:700,rarity:"common",slug:"extending",traits:["magical"]},fanged:{level:2,name:"PF2E.WeaponPropertyRune.fanged.Name",price:30,rarity:"uncommon",slug:"fanged",traits:["magical"]},fearsome:{damage:{notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.fearsome.Name",text:"PF2E.WeaponPropertyRune.fearsome.Note.criticalSuccess"}]},level:5,name:"PF2E.WeaponPropertyRune.fearsome.Name",price:160,rarity:"common",slug:"fearsome",traits:["emotion","fear","magical","mental"]},flaming:{damage:{dice:[{damageType:"fire",diceNumber:1,dieSize:"d6"},{damageType:"fire",category:"persistent",diceNumber:1,dieSize:"d10",critical:!0}]},level:8,name:"PF2E.WeaponPropertyRune.flaming.Name",price:500,rarity:"common",slug:"flaming",traits:["fire","magical"]},flurrying:{level:7,name:"PF2E.WeaponPropertyRune.flurrying.Name",price:360,rarity:"common",slug:"flurrying",traits:["magical"]},frost:{damage:{dice:[{damageType:"cold",diceNumber:1,dieSize:"d6"}],notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.frost.Name",text:"PF2E.WeaponPropertyRune.frost.Note.criticalSuccess"}]},level:8,name:"PF2E.WeaponPropertyRune.frost.Name",price:500,rarity:"common",slug:"frost",traits:["cold","magical"]},ghostTouch:{level:4,name:"PF2E.WeaponPropertyRune.ghostTouch.Name",price:75,rarity:"common",slug:"ghostTouch",traits:["magical"]},giantKilling:{damage:{dice:[{slug:"giantKilling",damageType:"mental",diceNumber:1,dieSize:"d6",predicate:["target:trait:giant"]}],notes:[{outcome:["criticalSuccess"],predicate:["target:trait:giant"],title:"PF2E.WeaponPropertyRune.giantKilling.Name",text:"PF2E.WeaponPropertyRune.giantKilling.Note.criticalSuccess"}]},level:8,name:"PF2E.WeaponPropertyRune.giantKilling.Name",price:450,rarity:"rare",slug:"giantKilling",traits:["magical"]},greaterAnchoring:{damage:{notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.greaterAnchoring.Name",text:"PF2E.WeaponPropertyRune.greaterAnchoring.Note.criticalSuccess"},{outcome:["success"],title:"PF2E.WeaponPropertyRune.greaterAnchoring.Name",text:"PF2E.WeaponPropertyRune.greaterAnchoring.Note.success"}]},level:18,name:"PF2E.WeaponPropertyRune.greaterAnchoring.Name",price:22e3,rarity:"uncommon",slug:"greaterAnchoring",traits:["magical"]},greaterAshen:{damage:{dice:[{damageType:"fire",category:"persistent",diceNumber:1,dieSize:"d8"}],notes:[{outcome:["success"],title:"PF2E.WeaponPropertyRune.greaterAshen.Name",text:"PF2E.WeaponPropertyRune.greaterAshen.Note.success"}]},level:16,name:"PF2E.WeaponPropertyRune.greaterAshen.Name",price:9e3,rarity:"common",slug:"greaterAshen",traits:["magical"]},greaterAstral:{level:15,name:"PF2E.WeaponPropertyRune.greaterAstral.Name",price:6e3,rarity:"common",slug:"greaterAstral",traits:["magical","spirit"],damage:{dice:[{damageType:"spirit",diceNumber:1,dieSize:"d6"}],ignoredResistances:[{type:"spirit",max:null}]}},greaterBloodbane:{level:13,name:"PF2E.WeaponPropertyRune.greaterBloodbane.Name",price:2800,rarity:"uncommon",slug:"greaterBloodbane",traits:["dwarf","magical"]},greaterBrilliant:{damage:{dice:[{damageType:"fire",diceNumber:1,dieSize:"d4"},{damageType:"spirit",diceNumber:1,dieSize:"d4",predicate:["target:trait:fiend"]},{damageType:"vitality",diceNumber:1,dieSize:"d4",predicate:["target:negative-healing"]}],notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.greaterBrilliant.Name",text:"PF2E.WeaponPropertyRune.greaterBrilliant.Note.criticalSuccess"},{outcome:["success"],title:"PF2E.WeaponPropertyRune.greaterBrilliant.Name",text:"PF2E.WeaponPropertyRune.greaterBrilliant.Note.success"}],ignoredResistances:[{type:"fire",max:null},{type:"spirit",max:null},{type:"vitality",max:null}]},level:18,name:"PF2E.WeaponPropertyRune.greaterBrilliant.Name",price:24e3,rarity:"common",slug:"greaterBrilliant",traits:["magical"]},greaterCorrosive:{damage:{dice:[{damageType:"acid",diceNumber:1,dieSize:"d6"}],notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.greaterCorrosive.Name",text:"PF2E.WeaponPropertyRune.greaterCorrosive.Note.criticalSuccess"},{outcome:["success"],title:"PF2E.WeaponPropertyRune.greaterCorrosive.Name",text:"PF2E.WeaponPropertyRune.greaterCorrosive.Note.success"}],ignoredResistances:[{type:"acid",max:null}]},level:15,name:"PF2E.WeaponPropertyRune.greaterCorrosive.Name",price:6500,rarity:"common",slug:"greaterCorrosive",traits:["acid","magical"]},greaterCrushing:{damage:{notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.greaterCrushing.Name",text:"PF2E.WeaponPropertyRune.greaterCrushing.Note.criticalSuccess"}]},level:9,name:"PF2E.WeaponPropertyRune.greaterCrushing.Name",price:650,rarity:"uncommon",slug:"greaterCrushing",traits:["magical"]},greaterDecaying:{damage:{dice:[{slug:"decaying",damageType:"void",diceNumber:1,dieSize:"d4"},{slug:"decaying-persistent",category:"persistent",damageType:"void",diceNumber:4,dieSize:"d4",critical:!0}],ignoredResistances:[{type:"void",max:null}]},level:15,name:"PF2E.WeaponPropertyRune.greaterDecaying.Name",price:6500,rarity:"common",slug:"greaterDecaying",traits:["acid","magical","void"]},greaterDisrupting:{damage:{dice:[{category:"persistent",damageType:"vitality",diceNumber:2,dieSize:"d6",predicate:["target:negative-healing"]}],notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.greaterDisrupting.Name",text:"PF2E.WeaponPropertyRune.greaterDisrupting.Note.criticalSuccess",predicate:["target:negative-healing"]}]},level:14,name:"PF2E.WeaponPropertyRune.greaterDisrupting.Name",price:4300,rarity:"uncommon",slug:"greaterDisrupting",traits:["magical"]},greaterExtending:{level:13,name:"PF2E.WeaponPropertyRune.greaterExtending.Name",price:3e3,rarity:"common",slug:"greaterExtending",traits:["magical"]},greaterFanged:{level:8,name:"PF2E.WeaponPropertyRune.greaterFanged.Name",price:425,rarity:"uncommon",slug:"greaterFanged",traits:["magical"]},greaterFearsome:{damage:{notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.greaterFearsome.Name",text:"PF2E.WeaponPropertyRune.greaterFearsome.Note.criticalSuccess"}]},level:12,name:"PF2E.WeaponPropertyRune.greaterFearsome.Name",price:2e3,rarity:"common",slug:"greaterFearsome",traits:["emotion","fear","magical","mental"]},greaterFlaming:{damage:{dice:[{damageType:"fire",diceNumber:1,dieSize:"d6"},{damageType:"fire",category:"persistent",diceNumber:2,dieSize:"d10",critical:!0}],notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.greaterFlaming.Name",text:"PF2E.WeaponPropertyRune.greaterFlaming.Note.criticalSuccess"},{outcome:["success"],title:"PF2E.WeaponPropertyRune.greaterFlaming.Name",text:"PF2E.WeaponPropertyRune.greaterFlaming.Note.success"}],ignoredResistances:[{type:"fire",max:null}]},level:15,name:"PF2E.WeaponPropertyRune.greaterFlaming.Name",price:6500,rarity:"common",slug:"greaterFlaming",traits:["fire","magical"]},greaterFrost:{damage:{dice:[{damageType:"cold",diceNumber:1,dieSize:"d6"}],notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.greaterFrost.Name",text:"PF2E.WeaponPropertyRune.greaterFrost.Note.criticalSuccess"},{outcome:["success"],title:"PF2E.WeaponPropertyRune.greaterFrost.Name",text:"PF2E.WeaponPropertyRune.greaterFrost.Note.success"}],ignoredResistances:[{type:"cold",max:null}]},level:15,name:"PF2E.WeaponPropertyRune.greaterFrost.Name",price:6500,rarity:"common",slug:"greaterFrost",traits:["cold","magical"]},greaterGiantKilling:{damage:{dice:[{slug:"greaterGiantKilling",damageType:"mental",diceNumber:2,dieSize:"d6",predicate:["target:trait:giant"]}],ignoredResistances:[{type:"mental",max:null}],notes:[{outcome:["criticalSuccess"],predicate:["target:trait:giant"],title:"PF2E.WeaponPropertyRune.greaterGiantKilling.Name",text:"PF2E.WeaponPropertyRune.greaterGiantKilling.Note.criticalSuccess"}]},level:15,name:"PF2E.WeaponPropertyRune.greaterGiantKilling.Name",price:6e3,rarity:"rare",slug:"greaterGiantKilling",traits:["magical"]},greaterHauling:{level:11,name:"PF2E.WeaponPropertyRune.greaterHauling.Name",price:1300,rarity:"uncommon",slug:"greaterHauling",traits:["magical"]},greaterImpactful:{damage:{dice:[{damageType:"force",diceNumber:1,dieSize:"d6"}],notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.greaterImpactful.Name",text:"PF2E.WeaponPropertyRune.greaterImpactful.Note.criticalSuccess"}]},level:17,name:"PF2E.WeaponPropertyRune.greaterImpactful.Name",price:15e3,rarity:"common",slug:"greaterImpactful",traits:["force","magical"]},greaterRooting:{level:11,name:"PF2E.WeaponPropertyRune.greaterRooting.Name",price:1400,rarity:"common",slug:"greaterRooting",traits:["plant","magical","wood"],damage:{notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.greaterRooting.Name",text:"PF2E.WeaponPropertyRune.greaterRooting.Note.criticalSuccess"},{outcome:["success"],title:"PF2E.WeaponPropertyRune.greaterRooting.Name",text:"PF2E.WeaponPropertyRune.greaterRooting.Note.success"}]}},greaterShock:{damage:{dice:[{damageType:"electricity",diceNumber:1,dieSize:"d6"}],notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.greaterShock.Name",text:"PF2E.WeaponPropertyRune.greaterShock.Note.criticalSuccess"},{outcome:["success"],title:"PF2E.WeaponPropertyRune.greaterShock.Name",text:"PF2E.WeaponPropertyRune.greaterShock.Note.success"}],ignoredResistances:[{type:"electricity",max:null}]},level:15,name:"PF2E.WeaponPropertyRune.greaterShock.Name",price:6500,rarity:"common",slug:"greaterShock",traits:["electricity","magical"]},greaterThundering:{damage:{dice:[{damageType:"sonic",diceNumber:1,dieSize:"d6"}],notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.greaterThundering.Name",text:"PF2E.WeaponPropertyRune.greaterThundering.Note.criticalSuccess"},{outcome:["success"],title:"PF2E.WeaponPropertyRune.greaterThundering.Name",text:"PF2E.WeaponPropertyRune.greaterThundering.Note.success"}],ignoredResistances:[{type:"sonic",max:null}]},level:15,name:"PF2E.WeaponPropertyRune.greaterThundering.Name",price:6500,rarity:"common",slug:"greaterThundering",traits:["magical","sonic"]},grievous:{damage:{dice:[{damageType:"bleed",diceNumber:1,dieSize:"d6",critical:!0,predicate:["critical-specialization","item:group:dart"]}],notes:[{outcome:["criticalSuccess"],predicate:["item:group:axe"],title:"PF2E.WeaponPropertyRune.grievous.Name",text:"PF2E.WeaponPropertyRune.grievous.Note.Axe"},{outcome:["criticalSuccess"],predicate:["item:group:brawling"],title:"PF2E.WeaponPropertyRune.grievous.Name",text:"PF2E.WeaponPropertyRune.grievous.Note.Brawling"},{outcome:["criticalSuccess"],predicate:["item:group:club"],title:"PF2E.WeaponPropertyRune.grievous.Name",text:"PF2E.WeaponPropertyRune.grievous.Note.Club"},{outcome:["criticalSuccess"],predicate:["item:group:flail"],title:"PF2E.WeaponPropertyRune.grievous.Name",text:"PF2E.WeaponPropertyRune.grievous.Note.Flail"},{outcome:["criticalSuccess"],predicate:["item:group:hammer"],title:"PF2E.WeaponPropertyRune.grievous.Name",text:"PF2E.WeaponPropertyRune.grievous.Note.Hammer"},{outcome:["criticalSuccess"],predicate:["item:group:knife"],title:"PF2E.WeaponPropertyRune.grievous.Name",text:"PF2E.WeaponPropertyRune.grievous.Note.Knife"},{outcome:["criticalSuccess"],predicate:["item:group:polearm"],title:"PF2E.WeaponPropertyRune.grievous.Name",text:"PF2E.WeaponPropertyRune.grievous.Note.Polearm"},{outcome:["criticalSuccess"],predicate:["item:group:shield"],title:"PF2E.WeaponPropertyRune.grievous.Name",text:"PF2E.WeaponPropertyRune.grievous.Note.Shield"},{outcome:["criticalSuccess"],predicate:["item:group:sling"],title:"PF2E.WeaponPropertyRune.grievous.Name",text:"PF2E.WeaponPropertyRune.grievous.Note.Sling"},{outcome:["criticalSuccess"],predicate:["item:group:spear"],title:"PF2E.WeaponPropertyRune.grievous.Name",text:"PF2E.WeaponPropertyRune.grievous.Note.Spear"},{outcome:["criticalSuccess"],predicate:["item:group:sword"],title:"PF2E.WeaponPropertyRune.grievous.Name",text:"PF2E.WeaponPropertyRune.grievous.Note.Sword"}],adjustments:[{slug:"critical-specialization",test:t=>new H("item:group:pick").test(t),getNewValue:t=>t*2}]},level:9,name:"PF2E.WeaponPropertyRune.grievous.Name",price:700,rarity:"common",slug:"grievous",traits:["magical"]},hauling:{level:6,name:"PF2E.WeaponPropertyRune.hauling.Name",price:225,rarity:"uncommon",slug:"hauling",traits:["magical"]},holy:{level:11,name:"PF2E.WeaponPropertyRune.holy.Name",price:1400,rarity:"common",slug:"holy",traits:["holy","magical"],damage:{dice:[{damageType:"spirit",diceNumber:1,dieSize:"d4",predicate:[{not:"target:trait:unholy"}]},{damageType:"spirit",diceNumber:2,dieSize:"d4",predicate:["target:trait:unholy"]}]},strikeAdjustments:[{adjustTraits:(t,e)=>{e.includes("holy")||e.push("holy")}}]},hopeful:{attack:{notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.hopeful.Name",text:"PF2E.WeaponPropertyRune.hopeful.Note.criticalSuccess"}]},level:11,name:"PF2E.WeaponPropertyRune.hopeful.Name",price:1200,rarity:"uncommon",slug:"hopeful",traits:["magical"]},hooked:{level:5,name:"PF2E.WeaponPropertyRune.hooked.Name",price:140,rarity:"rare",slug:"hooked",traits:["magical"],strikeAdjustments:[{adjustWeapon:t=>{t.system.traits.value.includes("trip")||t.system.traits.value.push("trip")}}]},impactful:{damage:{dice:[{damageType:"force",diceNumber:1,dieSize:"d6"}],notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.impactful.Name",text:"PF2E.WeaponPropertyRune.impactful.Note.criticalSuccess"}]},level:10,name:"PF2E.WeaponPropertyRune.impactful.Name",price:1e3,rarity:"common",slug:"impactful",traits:["force","magical"]},impossible:{level:20,name:"PF2E.WeaponPropertyRune.impossible.Name",price:7e4,rarity:"common",slug:"impossible",traits:["magical"],strikeAdjustments:[{adjustWeapon:t=>{if(t.isOfType("weapon")&&t.system.range&&t._source.system.range){let e=t._source.system.range,i=t.system.range;t.system.range=e*2+Math.abs(i-e)}}}]},keen:{attack:{dosAdjustments:[{adjustments:{success:{label:"PF2E.WeaponPropertyRune.keen.Name",amount:"criticalSuccess"}},predicate:new H(["check:total:natural:19",{or:["item:damage:type:slashing","item:damage:type:piercing"]}])}]},level:13,name:"PF2E.WeaponPropertyRune.keen.Name",price:3e3,rarity:"uncommon",slug:"keen",traits:["magical"]},kinWarding:{level:3,name:"PF2E.WeaponPropertyRune.kinWarding.Name",price:52,rarity:"uncommon",slug:"kinWarding",traits:["dwarf","magical"]},majorFanged:{level:15,name:"PF2E.WeaponPropertyRune.majorFanged.Name",price:6e3,rarity:"uncommon",slug:"majorFanged",traits:["magical"]},majorRooting:{level:15,name:"PF2E.WeaponPropertyRune.majorRooting.Name",price:6500,rarity:"common",slug:"majorRooting",traits:["plant","magical","wood"],damage:{notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.majorRooting.Name",text:"PF2E.WeaponPropertyRune.majorRooting.Note.criticalSuccess"}]}},merciful:{strikeAdjustments:[{adjustWeapon:t=>{t.system.traits.value.includes("nonlethal")||t.system.traits.value.push("nonlethal")}}],level:4,name:"PF2E.WeaponPropertyRune.merciful.Name",price:70,rarity:"common",slug:"merciful",traits:["magical","mental"]},pacifying:{level:5,name:"PF2E.WeaponPropertyRune.pacifying.Name",price:150,rarity:"uncommon",slug:"pacifying",traits:["magical"]},returning:{attack:{notes:[{title:"PF2E.WeaponPropertyRune.returning.Name",text:"PF2E.WeaponPropertyRune.returning.Note"}]},level:3,name:"PF2E.WeaponPropertyRune.returning.Name",price:55,rarity:"common",slug:"returning",traits:["magical"]},rooting:{level:7,name:"PF2E.WeaponPropertyRune.rooting.Name",price:360,rarity:"common",slug:"rooting",traits:["plant","magical","wood"],damage:{notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.rooting.Name",text:"PF2E.WeaponPropertyRune.rooting.Note.criticalSuccess"}]}},serrating:{damage:{dice:[{damageType:"slashing",diceNumber:1,dieSize:"d4"}]},level:10,name:"PF2E.WeaponPropertyRune.serrating.Name",price:1e3,rarity:"uncommon",slug:"serrating",traits:["magical"]},shifting:{level:6,name:"PF2E.WeaponPropertyRune.shifting.Name",price:225,rarity:"common",slug:"shifting",traits:["magical"]},shock:{damage:{dice:[{damageType:"electricity",diceNumber:1,dieSize:"d6"}],notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.shock.Name",text:"PF2E.WeaponPropertyRune.shock.Note.criticalSuccess"}]},level:8,name:"PF2E.WeaponPropertyRune.shock.Name",price:500,rarity:"common",slug:"shock",traits:["electricity","magical"]},speed:{level:16,name:"PF2E.Actor.Speed.Label",price:1e4,rarity:"rare",slug:"speed",traits:["magical"]},spellStoring:{level:13,name:"PF2E.WeaponPropertyRune.spellStoring.Name",price:2700,rarity:"uncommon",slug:"spellStoring",traits:["magical"]},swarming:{level:9,name:"PF2E.WeaponPropertyRune.swarming.Name",price:700,rarity:"common",slug:"swarming",traits:["magical"]},thundering:{damage:{dice:[{damageType:"sonic",diceNumber:1,dieSize:"d6"}],notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.thundering.Name",text:"PF2E.WeaponPropertyRune.thundering.Note.criticalSuccess"}]},level:8,name:"PF2E.WeaponPropertyRune.thundering.Name",price:500,rarity:"common",slug:"thundering",traits:["magical","sonic"]},trueRooting:{level:19,name:"PF2E.WeaponPropertyRune.trueRooting.Name",price:4e4,rarity:"common",slug:"trueRooting",traits:["plant","magical","wood"],damage:{notes:[{outcome:["criticalSuccess"],title:"PF2E.WeaponPropertyRune.trueRooting.Name",text:"PF2E.WeaponPropertyRune.trueRooting.Note.criticalSuccess"}]}},underwater:{level:3,name:"PF2E.WeaponPropertyRune.underwater.Name",price:50,rarity:"common",slug:"underwater",traits:["magical","water"]},unholy:{level:11,name:"PF2E.WeaponPropertyRune.unholy.Name",price:1400,rarity:"common",slug:"unholy",traits:["unholy","magical"],damage:{dice:[{damageType:"spirit",diceNumber:1,dieSize:"d4",predicate:[{not:"target:trait:holy"}]},{damageType:"spirit",diceNumber:2,dieSize:"d4",predicate:["target:trait:holy"]}]},strikeAdjustments:[{adjustTraits:(t,e)=>{e.includes("unholy")||e.push("unholy")}}]},vorpal:{level:17,name:"PF2E.WeaponPropertyRune.vorpal.Name",price:15e3,rarity:"rare",slug:"vorpal",traits:["magical"]},wounding:{damage:{dice:[{damageType:"bleed",diceNumber:1,dieSize:"d6"}]},level:7,name:"PF2E.WeaponPropertyRune.wounding.Name",price:340,rarity:"common",slug:"wounding",traits:["magical"]}};function Ii(t){return t.flatMap(e=>nn[e].strikeAdjustments??[])}a(Ii,"getPropertyRuneStrikeAdjustments");async function Ai(t){let[e,i]=canvas.ready&&!t.viewOnly?[canvas.tokens.controlled.find(v=>v.actor===this)??this.getActiveTokens().shift()??null,t.target?.token??t.target?.actor?.getActiveTokens().shift()??null]:[null,null],n=["attack","attack-roll","attack-damage"].some(v=>t.domains.includes(v)),o=!!(t.melee||t.item?.isOfType("weapon","melee")&&t.item.isMelee),r=o&&t.item?.isOfType("action","weapon","melee")?this.getReach({action:"attack",weapon:t.item}):this.getReach({action:"attack"}),s=!!(n&&o&&typeof r=="number"&&i?.actor&&e?.isFlanking(i,{reach:r})),c=await Pt({affects:"origin",origin:this,target:t.target?.actor??i?.actor??null,item:t.item??null,domains:t.domains,options:[...t.options,...t.item?.getRollOptions("item")??[]]}),l=(()=>{let v=i?this.synthetics.tokenMarks.get(i.document.uuid):null;return v?`target:mark:${v}`:null})(),p=t.traits?.map(v=>`self:action:trait:${v}`)??[],d=t.viewOnly||!i?.actor?this:this.getContextualClone(se.compact([...Array.from(t.options),...i.actor.getSelfRollOptions("target"),l,...p,s?"self:flanking":null]),c),u=t.statistic instanceof game.pf2e.StatisticModifier,g=u?d.system.actions?.flatMap(v=>[v,v.altUsages??[]].flat())??[]:[],m=t.viewOnly?t.statistic:u?g.find(v=>t.item?.id!==v.item.id||t?.item.name!==v.item.name?!1:t.item.isOfType("melee")&&v.item.isOfType("melee")?!0:t.item.isOfType("weapon")&&v.item.isOfType("weapon")&&t.item.isMelee===v.item.isMelee)??t.statistic:t.statistic,y=(()=>{if(d===this)return t.item??null;if(m&&"item"in m&&m.item instanceof Item&&m.item.isOfType("action","melee","spell","weapon"))return m.item;let v=d.items.get(t.item?.id??"");return v?.isOfType("melee","weapon")?v:t.item??null})(),k=y?.getRollOptions("item")??[],R=(()=>{let v=se.compact([t.traits].flat());if(y?.isOfType("weapon","melee")){let C=[d.synthetics.strikeAdjustments,Ii(y.system.runes.property)].flat();for(let K of C)K.adjustTraits?.(y,v)}return se.uniq(v).sort()})(),E=e&&i?e.distanceTo(i):null,[b,F]=typeof E=="number"?[`origin:distance:${E}`,`target:distance:${E}`]:[null,null],T=(()=>{let v=e?i?.actor?.synthetics.tokenMarks.get(e.document.uuid):null;return v?`origin:mark:${v}`:null})(),A=e&&i?se.compact(se.uniq([...d.getSelfRollOptions("origin"),...R.map(v=>`origin:action:trait${v}`),...b?[b]:[],T])):[],S=a(v=>{let C=v?.getSelfRollOptions("target")??[];return i&&(C.push("target"),l&&C.push(l)),C.sort()},"getTargetRollOptions"),N=S(i?.actor),G=await Pt({affects:"target",origin:d,target:i?.actor??null,item:y,domains:t.domains,options:[...t.options,...k,...N]});if(e?.actor&&i?.actor&&!t.viewOnly){let v=re(e,i,{extraOptions:k,distance:E}),C=oe(e,i,{perception:v,affects:"origin"});C&&B(v,"target","visibility","noff",C)&&(C=void 0),P[C]>P.concealed&&G.push(Vt(C));let K=dt(e,i,{perception:v,affects:"target",options:k}),ve;if(K){let le=B(v,"target","cover","ac",K)?.first();le!=null&&(le=Math.clamped(rt(le),0,4)),le===0?K=void 0:le&&(ve=le)}x[K]>x.none&&G.push(be(K,ve))}if(s&&qt(i.actor,d,A)){let v=game.i18n.localize("PF2E.Item.Condition.Flanked"),C=game.pf2e.ConditionManager.getCondition("off-guard",{name:v});G.push(C.toObject())}let ce=t.viewOnly?null:(t.target?.actor??i?.actor)?.getContextualClone(se.compact([...t.options,...k,...A]),G)??null,Ce=new Set(se.compact([...t.options,...d.getRollOptions(t.domains),...ce?S(ce):N,...R.map(v=>`self:action:trait:${v}`),...k,n?"attack":null]).sort());F&&Ce.add(F);let W=y?Kt(y,E):null;W&&Ce.add(`target:range-increment:${W}`);let _={actor:d,token:e?.document??null,statistic:m,item:y,modifiers:[]},D=ce&&i&&E!==null?{actor:ce,token:i.document,distance:E,rangeIncrement:W}:null;return{options:Ce,self:_,target:D,traits:R}}a(Ai,"getRollContext");var rn=["cover","concealed","hidden","undetected","unnoticed"],je=class extends FormApplication{static get defaultOptions(){return foundry.utils.mergeObject(super.defaultOptions,{template:X("icon-path-menu"),title:h("settings.icon-path.name"),width:500})}getData(){let e=O("icon-path");return{icons:rn.map(n=>({name:n,placeholder:Ge[n],value:e[n]??"",label:n==="cover"?h("icon-path.cover"):game.i18n.localize(CONFIG.PF2E.conditionTypes[n])})),i18n:h}}activateListeners(e){super.activateListeners(e),e.find("button[name=cancel]").on("click",i=>{i.prefentDefault(),this.close()})}async _updateObject(e,i){Ue("icon-path",i)}};a(je,"IconPathMenu");function Wi(){L("icon-path",Object,{},{config:!1}),game.settings.registerMenu(f,"icon-path-menu",{name:I("icon-path","name"),label:I("icon-path","label"),icon:"fa-solid fa-list",restricted:!0,type:je}),L("permission",String,CONST.USER_ROLES.GAMEMASTER,{choices:{1:I("permission","choices.1"),2:I("permission","choices.2"),3:I("permission","choices.3"),4:I("permission","choices.4")}}),L("npc-vision",Boolean,!1),L("target",Boolean,!0,{onChange:()=>ui.combat?.render()}),L("lesser",String,"ten",{choices:{none:I("lesser","choices.none"),cross:I("lesser","choices.cross"),zero:I("lesser","choices.zero"),ten:I("lesser","choices.ten"),twenty:I("lesser","choices.twenty")}}),L("standard",Boolean,!0),L("dead-cover",Boolean,!0),L("prone-cover",Boolean,!0),L("standard-type",String,"center",{choices:{center:I("standard-type","choices.center"),points:I("standard-type","choices.points")}}),L("skip-cover",Boolean,!0),L("validation",String,"all",{choices:{all:I("validation","choices.all"),selected:I("validation","choices.selected"),changed:I("validation","choices.changed")}}),L("flat-check",String,"roll",{choices:{none:I("flat-check","choices.none"),roll:I("flat-check","choices.roll"),cancel:I("flat-check","choices.cancel")}}),L("encounter",Boolean,!1),L("icon-size",Number,26,{scope:"client",range:{min:26,max:52}}),L("seek-template",Boolean,!0,{scope:"client"})}a(Wi,"registerSettings");function I(t,e){return`${f}.settings.${t}.${e}`}a(I,"path");function L(t,e,i,n={}){game.settings.register(f,t,{name:I(t,"name"),hint:I(t,"hint"),scope:"world",config:!0,type:e,default:i,...n})}a(L,"register");var on="game.pf2e.Check.roll",an="CONFIG.Token.documentClass.prototype.rulesBasedVision",sn="CONFIG.MeasuredTemplate.objectClass.prototype.highlightGrid",cn="CONFIG.Actor.documentClass.prototype.getRollContext",ln="DetectionMode.prototype.testVisibility",un="CONFIG.Canvas.detectionModes.basicSight._canDetect",dn="CONFIG.Canvas.detectionModes.hearing._canDetect",pn="CONFIG.Canvas.detectionModes.feelTremor._canDetect";Hooks.once("init",()=>{Wi(),ki(),ii(),libWrapper.register(f,on,Si),libWrapper.register(f,sn,ei,"OVERRIDE"),libWrapper.register(f,an,pi,"OVERRIDE"),libWrapper.register(f,cn,Ai,"OVERRIDE"),libWrapper.register(f,ln,xi,"OVERRIDE"),libWrapper.register(f,un,Fi,"OVERRIDE"),libWrapper.register(f,dn,Ni,"OVERRIDE"),libWrapper.register(f,pn,Ci,"OVERRIDE"),game.data.users.find(e=>e._id===game.data.userId).role>=CONST.USER_ROLES.GAMEMASTER?(Hooks.on("renderSceneConfig",Ht),Hooks.on("renderCombatTrackerConfig",Ri)):Hooks.on("renderCombatTracker",Ti),game.modules.get(f).custom={getWallCover:void 0,getCreatureCover:void 0}});Hooks.once("ready",()=>{game.modules.get(f).api=bi,Hooks.on("renderChatMessage",xt);for(let t of document.querySelectorAll("#chat-log .chat-message")){let e=game.messages.get(t.dataset.messageId);e&&xt(e,$(t))}game.user.isGM&&game.modules.get("pf2e-rules-based-npc-vision")?.active&&ui.notifications.error(`${f}.warning.npc-vision`,{permanent:!0,localize:!0})});Hooks.on("hoverToken",ci);Hooks.on("pasteToken",oi);Hooks.on("updateToken",si);Hooks.on("deleteToken",li);Hooks.on("controlToken",di);Hooks.on("renderTokenHUD",ri);Hooks.on("preCreateToken",gi);Hooks.on("canvasPan",()=>ye());Hooks.on("renderCheckModifiersDialog",Ei);Hooks.on("preCreateMeasuredTemplate",ti);Hooks.on("createMeasuredTemplate",it);Hooks.on("updateMeasuredTemplate",it);Hooks.on("deleteMeasuredTemplate",it);})(); //# sourceMappingURL=main.js.map diff --git a/scripts/main.js.map b/scripts/main.js.map index 110fe6b..2cd036c 100644 --- a/scripts/main.js.map +++ b/scripts/main.js.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["../src/constants.js", "../src/module.js", "../src/effect.js", "../src/actor.js", "../src/pf2e/success.js", "../src/scene.js", "../src/pf2e/helpers.js", "../src/pf2e/highlight.js", "../src/template.js", "../src/utils.js", "../src/apps/base-menu.js", "../src/apps/perception.js", "../src/geometry.js", "../src/lighting.js", "../src/rule-element.js", "../src/token.js", "../src/apps/validation.js", "../src/chat.js", "../src/action.js", "../src/api.js", "../src/check.js", "../src/combat.js", "../src/detection.js", "../src/remeda.js", "../src/pf2e/predicate.js", "../src/pf2e/rune.js", "../src/pf2e/rollcontext.js", "../src/apps/icon-path-menu.js", "../src/settings.js", "../src/main.js"], - "sourcesContent": ["export const COVER_UUID = 'Compendium.pf2e.other-effects.Item.I9lfZUiCwMiGogVi'\r\n\r\nexport const VISIBILITY_VALUES = {\r\n [undefined]: 0,\r\n observed: 0,\r\n concealed: 1,\r\n hidden: 2,\r\n undetected: 3,\r\n unnoticed: 4,\r\n}\r\n\r\nexport const VISIBILITIES = ['observed', 'concealed', 'hidden', 'undetected', 'unnoticed']\r\n\r\nexport const COVERS = ['none', 'lesser', 'standard', 'greater', 'greater-prone']\r\n\r\nexport const COVER_VALUES = {\r\n [undefined]: 0,\r\n none: 0,\r\n lesser: 1,\r\n standard: 2,\r\n greater: 3,\r\n 'greater-prone': 4,\r\n}\r\n\r\nexport const defaultValues = {\r\n cover: 'none',\r\n visibility: 'observed',\r\n}\r\n\r\nexport const attackCheckRoll = ['attack-roll', 'spell-attack-roll']\r\n\r\nexport const validCheckRoll = [...attackCheckRoll, 'skill-check', 'perception-check']\r\n\r\nexport const ICONS_PATHS = {\r\n cover: 'modules/pf2e-perception/images/cover.webp',\r\n concealed: 'systems/pf2e/icons/conditions/concealed.webp',\r\n hidden: 'systems/pf2e/icons/conditions/hidden.webp',\r\n undetected: 'systems/pf2e/icons/conditions/undetected.webp',\r\n unnoticed: 'systems/pf2e/icons/conditions/unnoticed.webp',\r\n}\r\n\r\nexport const VISION_LEVELS = {\r\n BLINDED: 0,\r\n NORMAL: 1,\r\n LOWLIGHT: 2,\r\n DARKVISION: 3,\r\n}\r\n\r\nexport const DARKNESS_COLOR = '#000000'\r\nexport const MIST_COLOR = '#656665'\r\nexport const POISON_GREEN = '#809e71'\r\n\r\nexport const DARKNESS_SLUGS = ['darkness', 'dance-of-darkness', 'ravenous-darkness']\r\nexport const MIST_SLUGS = ['obscuring-mist', 'stinking-cloud', 'noxious-vapors']\r\n", "export const MODULE_ID = 'pf2e-perception'\r\n\r\nexport function templatePath(template) {\r\n return `modules/${MODULE_ID}/templates/${template}.hbs`\r\n}\r\n\r\nexport function localize(...args) {\r\n const data = args.at(-1)\r\n const useFormat = typeof data === 'object'\r\n\r\n const keys = useFormat ? args.slice(0, -1) : args\r\n keys.unshift(MODULE_ID)\r\n\r\n return game.i18n[useFormat ? 'format' : 'localize'](keys.join('.'), data)\r\n}\r\n\r\nexport function getFlag(doc, flag) {\r\n return doc.getFlag(MODULE_ID, flag)\r\n}\r\n\r\nexport function setFlag(doc, flag, value) {\r\n return doc.setFlag(MODULE_ID, flag, value)\r\n}\r\n\r\nexport function unsetFlag(doc, flag) {\r\n return doc.unsetFlag(MODULE_ID, flag, true)\r\n}\r\n\r\nexport function getFlags(doc) {\r\n return getProperty(doc, `flags.${MODULE_ID}`) ?? {}\r\n}\r\n\r\nexport function getSetting(setting) {\r\n return game.settings.get(MODULE_ID, setting)\r\n}\r\n\r\nexport function setSetting(setting, value) {\r\n return game.settings.set(MODULE_ID, setting, value)\r\n}\r\n\r\nexport function hasPermission() {\r\n return game.user.role >= getSetting('permission')\r\n}\r\n\r\nexport function getActionName(action) {\r\n return game.i18n.localize(`PF2E.Actions.${action}.Title`)\r\n}\r\n", "import { COVER_UUID, COVER_VALUES } from './constants.js'\r\nimport { MODULE_ID, localize } from './module.js'\r\n\r\nexport function createFlatFootedSource(visibility) {\r\n const condition = game.pf2e.ConditionManager.getCondition('off-guard')\r\n const source = condition.toObject()\r\n source.name += ` (${game.i18n.localize(`PF2E.condition.${visibility}.name`)})`\r\n return source\r\n}\r\n\r\nexport function createCoverSource(level, bonus) {\r\n bonus ??= COVER_VALUES[level] === 3 ? 4 : COVER_VALUES[level]\r\n\r\n return {\r\n _id: 'I9lfZUiCwMiGogVi',\r\n img: 'systems/pf2e/icons/conditions-2/status_acup.webp',\r\n name: localize('cover', level),\r\n system: {\r\n description: {\r\n gm: '',\r\n value: \"

When you're behind an obstacle that could block weapons, guard you against explosions, and make you harder to detect, you're behind cover. Standard cover gives you a +2 circumstance bonus to AC, to Reflex saves against area effects, and to Stealth checks to Hide, Sneak, or otherwise avoid detection. You can increase this to greater cover using the Take Cover basic action, increasing the circumstance bonus to +4. If cover is especially light, typically when it's provided by a creature, you have lesser cover, which grants a +1 circumstance bonus to AC. A creature with standard cover or greater cover can attempt to use Stealth to Hide, but lesser cover isn't sufficient.

\",\r\n },\r\n rules: [\r\n { domain: 'all', key: 'RollOption', option: `self:cover-bonus:${bonus}` },\r\n { domain: 'all', key: 'RollOption', option: `self:cover-level:${level}` },\r\n {\r\n key: 'FlatModifier',\r\n predicate: [\r\n { or: [{ and: ['self:condition:prone', 'item:ranged'] }, { not: 'self:cover-level:greater-prone' }] },\r\n ],\r\n selector: 'ac',\r\n type: 'circumstance',\r\n value: bonus,\r\n },\r\n {\r\n key: 'FlatModifier',\r\n predicate: ['area-effect', { not: 'self:cover-level:greater-prone' }],\r\n selector: 'reflex',\r\n type: 'circumstance',\r\n value: bonus,\r\n },\r\n {\r\n key: 'FlatModifier',\r\n predicate: [\r\n { or: ['action:hide', 'action:sneak', 'avoid-detection'] },\r\n { not: 'self:cover-level:greater-prone' },\r\n ],\r\n selector: 'stealth',\r\n type: 'circumstance',\r\n value: bonus,\r\n },\r\n {\r\n key: 'FlatModifier',\r\n predicate: ['action:avoid-notice', { not: 'self:cover-level:greater-prone' }],\r\n selector: 'initiative',\r\n type: 'circumstance',\r\n value: bonus,\r\n },\r\n ],\r\n slug: 'effect-cover',\r\n },\r\n type: 'effect',\r\n flags: {\r\n core: { sourceId: COVER_UUID },\r\n [MODULE_ID]: {\r\n level,\r\n bonus,\r\n },\r\n },\r\n }\r\n}\r\n\r\nexport function findChoiceSetRule(item, flag = undefined) {\r\n if (!item) return undefined\r\n return item.system.rules.find(rule => rule.key === 'ChoiceSet' && (!flag || rule.flag === flag))\r\n}\r\n", "import { COVER_UUID, VISION_LEVELS } from './constants.js'\r\nimport { findChoiceSetRule } from './effect.js'\r\n\r\nexport function getActorToken(actor, target = false) {\r\n if (!actor) return undefined\r\n const actorId = actor.id\r\n const isToken = actor.isToken\r\n const tokens = target ? game.user.targets : canvas.tokens.controlled\r\n return (\r\n tokens.find(token => (isToken ? token.actor === actor : token.actor.id === actorId)) ??\r\n actor.getActiveTokens().shift() ??\r\n null\r\n )\r\n}\r\n\r\nexport function isProne(actor) {\r\n return actor.itemTypes.condition.some(item => item.slug === 'prone')\r\n}\r\n\r\nexport function getCoverEffect(actor, selection = false) {\r\n const effect = actor.itemTypes.effect.find(x => x.sourceId === COVER_UUID)\r\n return selection ? findChoiceSetRule(effect)?.selection.level : effect\r\n}\r\n\r\nexport function getFeatWithUUID(actor, uuid) {\r\n return actor.itemTypes.feat.find(f => f.sourceId === uuid)\r\n}\r\n\r\nfunction hasSense(actor, sense) {\r\n if (!actor || !sense || !actor.system.perception?.senses) return false\r\n sense = sense.toLowerCase()\r\n return !!actor.system.perception.senses.find(({ type }) => type === sense)\r\n}\r\n\r\nexport function hasGreaterDarkvision(actor) {\r\n return hasSense(actor, 'greater-darkvision')\r\n}\r\n\r\nexport function seeInvisibility(actor) {\r\n return hasSense(actor, 'see-invisibility')\r\n}\r\n", "const DEGREE_ADJUSTMENT_AMOUNTS = {\r\n LOWER_BY_TWO: -2,\r\n LOWER: -1,\r\n INCREASE: 1,\r\n INCREASE_BY_TWO: 2,\r\n TO_CRITICAL_FAILURE: 'criticalFailure',\r\n TO_FAILURE: 'failure',\r\n TO_SUCCESS: 'success',\r\n TO_CRITICAL_SUCCESS: 'criticalSuccess',\r\n}\r\n\r\nconst DEGREE_OF_SUCCESS_STRINGS = ['criticalFailure', 'failure', 'success', 'criticalSuccess']\r\n\r\nexport class DegreeOfSuccess {\r\n constructor(roll, dc, dosAdjustments = null) {\r\n if (roll instanceof Roll) {\r\n this.dieResult =\r\n (roll.isDeterministic\r\n ? roll.terms.find(t => t instanceof NumericTerm)\r\n : roll.dice.find(d => d instanceof Die && d.faces === 20)\r\n )?.total ?? 1\r\n this.rollTotal = roll.total\r\n } else {\r\n this.dieResult = roll.dieValue\r\n this.rollTotal = roll.dieValue + roll.modifier\r\n }\r\n\r\n this.dc = typeof dc === 'number' ? { value: dc } : dc\r\n\r\n this.unadjusted = this.#calculateDegreeOfSuccess()\r\n this.adjustment = this.#getDegreeAdjustment(this.unadjusted, dosAdjustments)\r\n this.value = this.adjustment ? this.#adjustDegreeOfSuccess(this.adjustment.amount, this.unadjusted) : this.unadjusted\r\n }\r\n\r\n static CRITICAL_FAILURE = 0\r\n static FAILURE = 1\r\n static SUCCESS = 2\r\n static CRITICAL_SUCCESS = 3\r\n\r\n #getDegreeAdjustment(degree, adjustments) {\r\n if (!adjustments) return null\r\n\r\n for (const outcome of ['all', ...DEGREE_OF_SUCCESS_STRINGS]) {\r\n const { label, amount } = adjustments[outcome] ?? {}\r\n if (\r\n amount &&\r\n label &&\r\n !(degree === DegreeOfSuccess.CRITICAL_SUCCESS && amount === DEGREE_ADJUSTMENT_AMOUNTS.INCREASE) &&\r\n !(degree === DegreeOfSuccess.CRITICAL_FAILURE && amount === DEGREE_ADJUSTMENT_AMOUNTS.LOWER) &&\r\n (outcome === 'all' || DEGREE_OF_SUCCESS_STRINGS.indexOf(outcome) === degree)\r\n ) {\r\n return { label, amount }\r\n }\r\n }\r\n\r\n return null\r\n }\r\n\r\n #adjustDegreeOfSuccess(amount, degreeOfSuccess) {\r\n switch (amount) {\r\n case 'criticalFailure':\r\n return 0\r\n case 'failure':\r\n return 1\r\n case 'success':\r\n return 2\r\n case 'criticalSuccess':\r\n return 3\r\n default:\r\n return Math.clamped(degreeOfSuccess + amount, 0, 3)\r\n }\r\n }\r\n\r\n /**\r\n * @param degree The current success value\r\n * @return The new success value\r\n */\r\n #adjustDegreeByDieValue(degree) {\r\n if (this.dieResult === 20) {\r\n return this.#adjustDegreeOfSuccess(DEGREE_ADJUSTMENT_AMOUNTS.INCREASE, degree)\r\n } else if (this.dieResult === 1) {\r\n return this.#adjustDegreeOfSuccess(DEGREE_ADJUSTMENT_AMOUNTS.LOWER, degree)\r\n }\r\n\r\n return degree\r\n }\r\n\r\n #calculateDegreeOfSuccess() {\r\n const dc = this.dc.value\r\n\r\n if (this.rollTotal - dc >= 10) {\r\n return this.#adjustDegreeByDieValue(DegreeOfSuccess.CRITICAL_SUCCESS)\r\n } else if (dc - this.rollTotal >= 10) {\r\n return this.#adjustDegreeByDieValue(DegreeOfSuccess.CRITICAL_FAILURE)\r\n } else if (this.rollTotal >= dc) {\r\n return this.#adjustDegreeByDieValue(DegreeOfSuccess.SUCCESS)\r\n }\r\n\r\n return this.#adjustDegreeByDieValue(DegreeOfSuccess.FAILURE)\r\n }\r\n}\r\n", "import { getFlag, getSetting, localize } from './module.js'\r\n\r\nexport function renderSceneConfig(config, html) {\r\n let settings = ''\r\n\r\n const list = ['standard', 'npc-vision']\r\n for (const setting of list) {\r\n const checked = getSceneSetting(config.object, setting)\r\n\r\n settings += `
\r\n \r\n \r\n

${localize(`settings.${setting}.short`)}

\r\n
`\r\n }\r\n\r\n settings += '
'\r\n\r\n html.find('.tab[data-tab=\"basic\"] hr').first().after(settings)\r\n\r\n const addedHeight = html\r\n .find('.pf2e-perception-injected')\r\n .toArray()\r\n .reduce((height, el) => ((height += el.clientHeight), height), 0)\r\n\r\n config.setPosition({ top: config.position.top - addedHeight / 2 })\r\n}\r\n\r\nexport function getValidTokens(token) {\r\n token = token instanceof Token ? token.document : token\r\n if (!(token instanceof TokenDocument)) return []\r\n\r\n let tokens = token.scene.tokens.filter(t => t !== token && t.actor?.isOfType('creature'))\r\n\r\n if (getSetting('encounter')) {\r\n const combat = game.combats.active\r\n if (!combat) return tokens\r\n\r\n return tokens.filter(t => {\r\n const actor = t.actor\r\n const traits = actor.traits\r\n return actor.type === 'familiar' || traits.has('minion') || traits.has('eidolon') || combat.getCombatantByToken(t.id)\r\n })\r\n }\r\n\r\n return tokens\r\n}\r\n\r\nexport function validateTokens(token, tokens) {\r\n const validToken = getValidTokens(token).map(t => t.id)\r\n return tokens.filter(t => {\r\n const id = t instanceof Token || t instanceof TokenDocument ? t.id : t\r\n return validToken.includes(id)\r\n })\r\n}\r\n\r\nexport function getSceneSetting(scene, setting) {\r\n return getFlag(scene, setting) ?? getSetting(setting)\r\n}\r\n", "export async function extractEphemeralEffects({ affects, origin, target, item, domains, options }) {\r\n if (!(origin && target)) return []\r\n\r\n const [effectsFrom, effectsTo] = affects === 'target' ? [origin, target] : [target, origin]\r\n const fullOptions = [...options, effectsFrom.getRollOptions(domains), effectsTo.getSelfRollOptions(affects)].flat()\r\n const resolvables = item ? (item.isOfType('spell') ? { spell: item } : { weapon: item }) : {}\r\n return (\r\n await Promise.all(\r\n domains\r\n .flatMap(s => effectsFrom.synthetics.ephemeralEffects[s]?.[affects] ?? [])\r\n .map(d => d({ test: fullOptions, resolvables }))\r\n )\r\n ).flatMap(e => e ?? [])\r\n}\r\n\r\nexport function traitSlugToObject(trait, dictionary) {\r\n // Look up trait labels from `npcAttackTraits` instead of `weaponTraits` in case a battle form attack is\r\n // in use, which can include what are normally NPC-only traits\r\n const traitObject = {\r\n name: trait,\r\n label: game.i18n.localize(dictionary[trait] ?? trait),\r\n }\r\n if (objectHasKey(CONFIG.PF2E.traitsDescriptions, trait)) {\r\n traitObject.description = CONFIG.PF2E.traitsDescriptions[trait]\r\n }\r\n\r\n return traitObject\r\n}\r\n\r\nexport function objectHasKey(obj, key) {\r\n return (typeof key === 'string' || typeof key === 'number') && key in obj\r\n}\r\n\r\nexport function getRangeIncrement(attackItem, distance) {\r\n if (!attackItem.isOfType('action', 'melee', 'weapon')) return null\r\n\r\n const { increment } = attackItem.range ?? {}\r\n return increment && typeof distance === 'number' ? Math.max(Math.ceil(distance / increment), 1) : null\r\n}\r\n\r\nexport function isOffGuardFromFlanking(target, origin) {\r\n if (!target?.isOfType('creature')) return false\r\n const { flanking } = target.attributes\r\n return !flanking.flankable\r\n ? false\r\n : typeof flanking.offGuardable === 'number'\r\n ? origin.level > flanking.offGuardable\r\n : flanking.offGuardable\r\n}\r\n\r\nexport function isObject(value) {\r\n return typeof value === 'object' && value !== null\r\n}\r\n\r\nexport function tupleHasValue(array, value) {\r\n return array.includes(value)\r\n}\r\n", "/**\r\n * Measure distance using Pathfinder 2e grid-counting rules\r\n * @param p0 The origin point\r\n * @param p1 The destination point\r\n */\r\nfunction measureDistance(p0, p1) {\r\n if (!canvas.dimensions) return NaN\r\n\r\n if (canvas.grid.type !== CONST.GRID_TYPES.SQUARE) {\r\n return canvas.grid.measureDistance(p0, p1)\r\n }\r\n\r\n return measureDistanceOnGrid(new Ray(p0, p1))\r\n}\r\n\r\n/**\r\n * Given the distance in each dimension, measure the distance in grid units\r\n * @param segment A pair of x/y distances constituting the line segment between two points\r\n * @param [reach] If this is a reach measurement, the origin actor's reach\r\n */\r\nfunction measureDistanceOnGrid(segment, { reach = null } = {}) {\r\n if (!canvas.dimensions) return NaN\r\n\r\n const gridSize = canvas.dimensions.size\r\n const gridDistance = canvas.dimensions.distance\r\n\r\n const nx = Math.ceil(Math.abs(segment.dx / gridSize))\r\n const ny = Math.ceil(Math.abs(segment.dy / gridSize))\r\n const nz = Math.ceil(Math.abs((segment.dz || 0) / gridSize))\r\n\r\n // ingore the lowest difference\r\n const sortedDistance = [nx, ny, nz].sort((a, b) => a - b)\r\n // Get the number of straight and diagonal moves\r\n const squares = {\r\n doubleDiagonal: sortedDistance[0],\r\n diagonal: sortedDistance[1] - sortedDistance[0],\r\n straight: sortedDistance[2] - sortedDistance[1],\r\n }\r\n\r\n // \"Unlike with measuring most distances, 10-foot reach can reach 2 squares diagonally.\" (CRB pg 455)\r\n const reduction = squares.diagonal + squares.doubleDiagonal > 1 && reach === 10 ? 1 : 0\r\n\r\n // Diagonals in PF pretty much count as 1.5 times a straight\r\n // for diagonals across the x, y, and z axis count it as 1.75 as a best guess\r\n const distance = Math.floor(squares.doubleDiagonal * 1.75 + squares.diagonal * 1.5 + squares.straight) - reduction\r\n\r\n return distance * gridDistance\r\n}\r\n\r\n/** Highlight grid according to Pathfinder 2e effect-area shapes */\r\nexport function highlightGrid({ areaType, object, colors, document, collisionType = 'move', preview = false, collisionOrigin }) {\r\n // Only highlight for objects that are non-previews (have IDs)\r\n if (!object.id && !preview) return\r\n\r\n const { grid, dimensions } = canvas\r\n if (!(grid && dimensions)) return\r\n\r\n // Set data defaults\r\n const angle = document.angle ?? 0\r\n const direction = document.direction ?? 45\r\n\r\n // Clear existing highlight\r\n const highlightLayer = grid.getHighlightLayer(object.highlightId)?.clear()\r\n if (!highlightLayer) return\r\n\r\n const [cx, cy] = grid.getCenter(document.x, document.y)\r\n const [col0, row0] = grid.grid.getGridPositionFromPixels(cx, cy)\r\n const minAngle = (360 + ((direction - angle * 0.5) % 360)) % 360\r\n const maxAngle = (360 + ((direction + angle * 0.5) % 360)) % 360\r\n const snappedOrigin = canvas.grid.getSnappedPosition(document.x, document.y, object.layer.gridPrecision)\r\n const withinAngle = (min, max, value) => {\r\n min = (360 + (min % 360)) % 360\r\n max = (360 + (max % 360)) % 360\r\n value = (360 + (value % 360)) % 360\r\n\r\n if (min < max) return value >= min && value <= max\r\n return value >= min || value <= max\r\n }\r\n\r\n // Offset measurement for cones to ensure that cones only start measuring from cell borders\r\n const coneOriginOffset = (() => {\r\n if (areaType !== 'cone') return { x: 0, y: 0 }\r\n\r\n // Degrees anticlockwise from pointing right. In 45-degree increments from 0 to 360\r\n const dir = (direction >= 0 ? 360 - direction : -direction) % 360\r\n // If we're not on a border for X, offset by 0.5 or -0.5 to the border of the cell in the direction we're looking on X axis\r\n const xOffset =\r\n snappedOrigin.x % dimensions.size !== 0\r\n ? Math.sign((1 * Math.round(Math.cos(Math.toRadians(dir)) * 100)) / 100) / 2\r\n : 0\r\n // Same for Y, but cos Y goes down on screens, we invert\r\n const yOffset =\r\n snappedOrigin.y % dimensions.size !== 0\r\n ? -Math.sign((1 * Math.round(Math.sin(Math.toRadians(dir)) * 100)) / 100) / 2\r\n : 0\r\n return { x: xOffset * dimensions.size, y: yOffset * dimensions.size }\r\n })()\r\n\r\n // Point we are measuring distances from\r\n const padding = Math.clamped(document.width ?? 0, 1.5, 2)\r\n const docDistance = document.distance ?? 0\r\n const padded = (docDistance * padding) / dimensions.distance\r\n const rowCount = Math.ceil(padded / (dimensions.size / grid.h))\r\n const columnCount = Math.ceil(padded / (dimensions.size / grid.w))\r\n\r\n // If this is an emanation, measure from the outer squares of the token's space\r\n const offsetEmanationOrigin = destination => {\r\n if (!(areaType === 'emanation' && object instanceof Token)) {\r\n return { x: 0, y: 0 }\r\n }\r\n\r\n // No offset is needed for medium and smaller creatures\r\n if (object.w <= dimensions.size) return { x: 0, y: 0 }\r\n\r\n const offset = (object.w - dimensions.size) / 2\r\n const getCoordinate = (centerCoord, destCoord) =>\r\n destCoord === centerCoord ? 0 : destCoord > centerCoord ? offset : -offset\r\n\r\n return {\r\n x: getCoordinate(object.center.x, destination.x),\r\n y: getCoordinate(object.center.y, destination.y),\r\n }\r\n }\r\n\r\n for (let a = -columnCount; a < columnCount; a++) {\r\n for (let b = -rowCount; b < rowCount; b++) {\r\n // Position of cell's top-left corner, in pixels\r\n const [gx, gy] = canvas.grid.grid.getPixelsFromGridPosition(col0 + a, row0 + b)\r\n // Position of cell's center in pixels\r\n const destination = {\r\n x: gx + dimensions.size * 0.5,\r\n y: gy + dimensions.size * 0.5,\r\n }\r\n if (destination.x < 0 || destination.y < 0) continue\r\n\r\n // Determine point of origin\r\n const emanationOriginOffset = offsetEmanationOrigin(destination)\r\n const origin = {\r\n x: snappedOrigin.x + coneOriginOffset.x + emanationOriginOffset.x,\r\n y: snappedOrigin.y + coneOriginOffset.y + emanationOriginOffset.y,\r\n }\r\n\r\n if (areaType === 'cone') {\r\n const ray = new Ray(origin, destination)\r\n const rayAngle = (360 + ((ray.angle / (Math.PI / 180)) % 360)) % 360\r\n if (ray.distance > 0 && !withinAngle(minAngle, maxAngle, rayAngle)) {\r\n continue\r\n }\r\n }\r\n\r\n // Determine grid-square point to which we're measuring the distance\r\n const distance = measureDistance(destination, origin)\r\n if (distance > docDistance) continue\r\n\r\n const hasCollision =\r\n canvas.ready &&\r\n CONFIG.Canvas.polygonBackends[collisionType].testCollision(collisionOrigin ?? origin, destination, {\r\n type: collisionType,\r\n mode: 'any',\r\n })\r\n\r\n if (hasCollision) {\r\n grid.grid.highlightGridPosition(highlightLayer, {\r\n x: gx,\r\n y: gy,\r\n border: 0x000001,\r\n color: 0x000000,\r\n })\r\n highlightLayer\r\n .beginFill(0x000000, 0.5)\r\n .moveTo(gx, gy)\r\n .lineTo(gx + dimensions.size, gy + dimensions.size)\r\n .endFill()\r\n } else {\r\n grid.grid.highlightGridPosition(highlightLayer, {\r\n x: gx,\r\n y: gy,\r\n border: colors.border,\r\n color: colors.fill,\r\n })\r\n }\r\n }\r\n }\r\n}\r\n", "import { DARKNESS_COLOR, DARKNESS_SLUGS, MIST_COLOR, MIST_SLUGS, POISON_GREEN } from './constants.js'\r\nimport { MODULE_ID, getFlag, localize } from './module.js'\r\nimport { tupleHasValue } from './pf2e/helpers.js'\r\nimport { highlightGrid } from './pf2e/highlight.js'\r\n\r\nconst templateConversion = {\r\n burst: 'circle',\r\n emanation: 'circle',\r\n line: 'ray',\r\n cone: 'cone',\r\n rect: 'rect',\r\n cube: 'rect',\r\n square: 'rect',\r\n}\r\n\r\nexport function createSeekTemplate({ type = 'burst', token, distance }) {\r\n if (!checkScene(token)) return\r\n\r\n distance ??= type === 'cone' ? 30 : 15\r\n\r\n createTemplate({\r\n type,\r\n distance,\r\n traits: ['concentrate', 'secret'],\r\n flags: {\r\n type: 'seek',\r\n tokenId: token.id,\r\n collisionType: 'sight',\r\n collisionOrigin: token.center,\r\n },\r\n })\r\n}\r\n\r\nexport function createDarknessTemplate({ type = 'burst', distance = 20, conceal = false } = {}) {\r\n createTemplate({\r\n type,\r\n distance,\r\n fillColor: DARKNESS_COLOR,\r\n flags: {\r\n type: 'darkness',\r\n conceal,\r\n },\r\n })\r\n}\r\n\r\nexport function createMistTemplate({ type = 'burst', distance = 20 } = {}) {\r\n createTemplate({\r\n type,\r\n distance,\r\n fillColor: MIST_COLOR,\r\n flags: {\r\n type: 'mist',\r\n },\r\n })\r\n}\r\n\r\nfunction getTemplates(type, token) {\r\n if (token && !checkScene(token)) return null\r\n return canvas.scene.templates.filter(t => getFlag(t, 'type') === type) ?? []\r\n}\r\n\r\nexport function getDarknessTemplates(token) {\r\n return getTemplates('darkness', token)\r\n}\r\n\r\nexport function getMistTemplates(token) {\r\n return getTemplates('mist', token)\r\n}\r\n\r\nexport function getSeekTemplateTokens(token) {\r\n if (!checkScene(token)) return null\r\n\r\n const template = canvas.scene.templates.find(t => getFlag(t, 'type') === 'seek')\r\n if (!template) return null\r\n\r\n const tokenDoc = token instanceof Token ? token.document : token\r\n\r\n return getTemplateTokens(template, { collisionType: 'sight', collisionOrigin: tokenDoc.center })\r\n}\r\n\r\nexport async function deleteSeekTemplate(token) {\r\n const templates = token.scene.templates.filter(t => getFlag(t, 'type') === 'seek' && getFlag(t, 'tokenId') === token.id)\r\n for (const template of templates) {\r\n await template.delete()\r\n }\r\n}\r\n\r\nfunction checkScene(token) {\r\n if (canvas.scene === token.scene) return true\r\n ui.notifications.error(localize('template.scene'))\r\n return false\r\n}\r\n\r\nexport function createTemplate({ type, distance, traits, fillColor, width, flags }) {\r\n const templateType = templateConversion[type]\r\n\r\n const templateData = {\r\n distance,\r\n t: templateType,\r\n fillColor: fillColor || game.user.color,\r\n flags: {\r\n [MODULE_ID]: flags,\r\n },\r\n }\r\n\r\n switch (templateType) {\r\n case 'ray':\r\n templateData.width = width || CONFIG.MeasuredTemplate.defaults.width * (canvas.dimensions?.distance ?? 1)\r\n break\r\n case 'cone':\r\n templateData.angle = CONFIG.MeasuredTemplate.defaults.angle\r\n break\r\n case 'rect': {\r\n const distance = templateData.distance ?? 0\r\n templateData.distance = Math.hypot(distance, distance)\r\n templateData.width = distance\r\n templateData.direction = 45\r\n break\r\n }\r\n }\r\n\r\n if (traits) setProperty(templateData, 'flags.pf2e.origin.traits', traits)\r\n\r\n canvas.templates.createPreview(templateData)\r\n}\r\n\r\nexport function getTemplateTokens(template, { collisionOrigin, collisionType = 'move' } = {}) {\r\n const templateObj = template instanceof MeasuredTemplateDocument ? template.object : template\r\n\r\n if (!canvas.scene) return []\r\n const { grid, dimensions } = canvas\r\n if (!(grid && dimensions)) return []\r\n\r\n const gridHighlight = grid.getHighlightLayer(templateObj.highlightId)\r\n if (!gridHighlight || grid.type !== CONST.GRID_TYPES.SQUARE) return []\r\n const origin = collisionOrigin ?? templateObj.center\r\n\r\n // Get all the tokens that are inside the highlight bounds\r\n const tokens = canvas.tokens.quadtree.getObjects(gridHighlight.getLocalBounds(undefined, true))\r\n\r\n const containedTokens = []\r\n for (const token of tokens) {\r\n const tokenDoc = token.document\r\n\r\n // Collect the position of all grid squares that this token occupies as \"x.y\"\r\n const tokenPositions = []\r\n for (let h = 0; h < tokenDoc.height; h++) {\r\n const y = token.y + h * grid.size\r\n tokenPositions.push(`${token.x}.${y}`)\r\n if (tokenDoc.width > 1) {\r\n for (let w = 1; w < tokenDoc.width; w++) {\r\n tokenPositions.push(`${token.x + w * grid.size}.${y}`)\r\n }\r\n }\r\n }\r\n\r\n for (const position of tokenPositions) {\r\n // Check if a position exists within this GridHiglight\r\n if (!gridHighlight.positions.has(position)) {\r\n continue\r\n }\r\n // Position of cell's top-left corner, in pixels\r\n const [gx, gy] = position.split('.').map(s => Number(s))\r\n // Position of cell's center in pixels\r\n const destination = {\r\n x: gx + dimensions.size * 0.5,\r\n y: gy + dimensions.size * 0.5,\r\n }\r\n if (destination.x < 0 || destination.y < 0) continue\r\n\r\n const hasCollision =\r\n canvas.ready &&\r\n collisionType &&\r\n CONFIG.Canvas.polygonBackends[collisionType].testCollision(origin, destination, {\r\n type: collisionType,\r\n mode: 'any',\r\n })\r\n\r\n if (!hasCollision) {\r\n containedTokens.push(token)\r\n break\r\n }\r\n }\r\n }\r\n return containedTokens\r\n}\r\n\r\nexport function highlightTemplateGrid() {\r\n const isCircleOrCone = ['circle', 'cone'].includes(this.document.t)\r\n const hasSquareGrid = canvas.grid.type === CONST.GRID_TYPES.SQUARE\r\n if (!isCircleOrCone || !hasSquareGrid) {\r\n return MeasuredTemplate.prototype.highlightGrid.call(this)\r\n }\r\n\r\n // Refrain from highlighting if not visible\r\n if (!this.isVisible) {\r\n canvas.grid.getHighlightLayer(this.highlightId)?.clear()\r\n return\r\n }\r\n\r\n const collisionType = getFlag(this.document, 'collisionType')\r\n const collisionOrigin = getFlag(this.document, 'collisionOrigin')\r\n\r\n this.snapForShape()\r\n highlightGrid({\r\n areaType: tupleHasValue(['burst', 'cone', 'emanation'], this.areaType) ? this.areaType : 'burst',\r\n object: this,\r\n document: this.document,\r\n colors: { border: this.borderColor, fill: this.fillColor },\r\n preview: true,\r\n collisionType,\r\n collisionOrigin,\r\n })\r\n}\r\n\r\nexport function preCreateMeasuredTemplate(template) {\r\n const { type, slug, castLevel = 0 } = template.getFlag('pf2e', 'origin') ?? {}\r\n if (type !== 'spell') return\r\n\r\n if (DARKNESS_SLUGS.includes(slug)) {\r\n template.updateSource({\r\n fillColor: DARKNESS_COLOR,\r\n [`flags.${MODULE_ID}`]: { type: 'darkness', conceal: castLevel >= 4 },\r\n })\r\n } else if (MIST_SLUGS.includes(slug)) {\r\n template.updateSource({\r\n fillColor: MIST_COLOR,\r\n [`flags.${MODULE_ID}`]: { type: 'mist' },\r\n })\r\n } else if (slug === 'cloudkill') {\r\n template.updateSource({\r\n fillColor: POISON_GREEN,\r\n [`flags.${MODULE_ID}`]: { type: 'mist' },\r\n })\r\n }\r\n}\r\n\r\nexport function onMeasuredTemplate(template) {\r\n if (getFlag(template, 'type') === 'darkness') canvas.perception.update({ initializeVision: true })\r\n}\r\n", "export function modifier(value) {\r\n return value >= 0 ? `+${value}` : value\r\n}\r\n\r\nexport function omit(object, names) {\r\n const set = new Set(names)\r\n return Object.entries(object).reduce((acc, [name, value]) => {\r\n if (!set.has(name)) acc[name] = value\r\n return acc\r\n }, {})\r\n}\r\n\r\nexport function getPrototype(obj, depth = 1) {\r\n const prototype = Object.getPrototypeOf(obj)\r\n if (depth > 1) return getPrototype(prototype, depth - 1)\r\n return prototype\r\n}\r\n\r\nexport function sortByName(a, b) {\r\n return a.name.localeCompare(b.name)\r\n}\r\n\r\nexport function asNumberOnly(value) {\r\n value = Number(value)\r\n return isNaN(value) ? undefined : value\r\n}\r\n", "import { COVERS, VISIBILITIES, defaultValues } from '../constants.js'\r\nimport { MODULE_ID, localize } from '../module.js'\r\nimport { validateTokens } from '../scene.js'\r\nimport { getTokenData, setTokenData } from '../token.js'\r\nimport { sortByName } from '../utils.js'\r\n\r\nexport class BaseMenu extends Application {\r\n #token\r\n #resolve\r\n #selected\r\n #_currentData\r\n #hoverTokenListener\r\n\r\n constructor({ token, resolve, selected = [] }, options = {}) {\r\n super(options)\r\n\r\n this.#token = token\r\n this.#resolve = resolve\r\n this.#selected = selected\r\n\r\n this.#hoverTokenListener = (token, hover) => {\r\n const tokenId = token.id\r\n const tokens = this.element.find('[data-token-id]')\r\n tokens.removeClass('hover')\r\n if (hover) tokens.filter(`[data-token-id=${tokenId}]`).addClass('hover')\r\n }\r\n\r\n Hooks.on('hoverToken', this.#hoverTokenListener)\r\n }\r\n\r\n async close(options = {}) {\r\n Hooks.off('hoverToken', this.#hoverTokenListener)\r\n this.#resolve?.(options.resolve ?? false)\r\n super.close(options)\r\n }\r\n\r\n static get defaultOptions() {\r\n return mergeObject(Application.defaultOptions, {\r\n minimizable: false,\r\n })\r\n }\r\n\r\n static async openMenu(params, options = {}) {\r\n if (params.token instanceof TokenDocument) params.token = params.token.object\r\n if (!params.token) {\r\n ui.notifications.error(localize('menu.no-token'))\r\n return\r\n }\r\n\r\n options.id = `${MODULE_ID}-${params.token.document.uuid}`\r\n\r\n const win = Object.values(ui.windows).find(x => x.id === options.id)\r\n if (win) win.close()\r\n\r\n return new Promise(resolve => {\r\n params.resolve = resolve\r\n // biome-ignore lint/complexity/noThisInStatic: not working\r\n new this(params, options).render(true)\r\n })\r\n }\r\n\r\n static createPropertyData(original, current, property) {\r\n const defaultValue = defaultValues[property]\r\n const originalValue = original[property] ?? defaultValue\r\n const currentValue = current[property] ?? defaultValue\r\n return {\r\n original: originalValue,\r\n current: currentValue,\r\n changed: originalValue !== currentValue,\r\n custom: currentValue !== defaultValue,\r\n originalCustom: originalValue !== defaultValue,\r\n }\r\n }\r\n\r\n get token() {\r\n return this.#token\r\n }\r\n\r\n get document() {\r\n return this.#token.document\r\n }\r\n\r\n get actor() {\r\n return this.#token.actor\r\n }\r\n\r\n get scene() {\r\n return this.#token.scene\r\n }\r\n\r\n get selected() {\r\n return this.#selected.length ? validateTokens(this.token, this.#selected) : []\r\n }\r\n\r\n get currentData() {\r\n return deepClone(this.#currentData)\r\n }\r\n\r\n get #currentData() {\r\n if (!this.#_currentData) this.#_currentData = this.getSavedData()\r\n return this.#_currentData\r\n }\r\n\r\n getSavedData() {\r\n const data = getTokenData(this.document) ?? {}\r\n return deepClone(data)\r\n }\r\n\r\n reset() {\r\n this.#_currentData = this.getSavedData()\r\n this.#selected = []\r\n this.render()\r\n }\r\n\r\n isSelected(token) {\r\n const id = typeof token === 'object' ? token.id : token\r\n return this.#selected.includes(id)\r\n }\r\n\r\n getData(options) {\r\n return {\r\n i18n: localize,\r\n covers: COVERS.map(value => ({ value, label: localize(`cover.${value}`) })),\r\n visibilities: VISIBILITIES.map(value => ({ value, label: localize(`visibility.${value}`) })),\r\n }\r\n }\r\n\r\n activateListeners(html) {\r\n html.find('[data-token-id]').on('mouseenter', event => {\r\n const { tokenId } = event.currentTarget.dataset\r\n const token = this.scene.tokens.get(tokenId)?.object\r\n if (!token || token.controlled) return\r\n token._onHoverIn(event, { hoverOutOthers: true })\r\n })\r\n\r\n html.find('[data-action=close]').on('click', () => {\r\n this.close({ resolve: true })\r\n })\r\n\r\n html.find('select[name=visibility], select[name=cover]').on('change', event => {\r\n const target = event.currentTarget\r\n const property = target.name\r\n const defaultValue = defaultValues[property]\r\n const value = target.value || defaultValue\r\n const tokenId = target.closest('.token')?.dataset.tokenId\r\n const tokenIds = tokenId ? [tokenId] : this.#selected\r\n\r\n for (const tokenId of tokenIds) {\r\n setProperty(this.#currentData, `${tokenId}.${property}`, value)\r\n }\r\n\r\n if (tokenId) {\r\n target.classList.toggle('changed', value !== target.dataset.original)\r\n target.classList.toggle('custom', value !== defaultValue)\r\n } else this.render()\r\n })\r\n\r\n html.find('[data-action=accept]').on('click', event => {\r\n this._saveData(this.#currentData)\r\n this.close({ resolve: true })\r\n })\r\n }\r\n\r\n _saveData(currentData) {\r\n setTokenData(this.document, currentData)\r\n }\r\n\r\n _setSelected(selected) {\r\n this.#selected =\r\n selected ??\r\n this.element\r\n .find('[data-token-id].ui-selected')\r\n .toArray()\r\n .map(el => el.dataset.tokenId)\r\n }\r\n\r\n _spliIntoAlliances(tokens) {\r\n const allies = []\r\n const enemies = []\r\n const neutral = []\r\n\r\n const alliance = this.actor.alliance\r\n const opposition = alliance === 'party' ? 'opposition' : alliance === 'opposition' ? 'party' : null\r\n\r\n for (const token of tokens) {\r\n if (opposition) {\r\n const actorAlliance = token.actor ? token.actor.alliance : token.alliance\r\n if (actorAlliance === alliance) allies.push(token)\r\n else if (actorAlliance === opposition) enemies.push(token)\r\n else if (actorAlliance === null) neutral.push(token)\r\n } else neutral.push(token)\r\n }\r\n\r\n return {\r\n allies: allies.sort(sortByName),\r\n neutral: neutral.sort(sortByName),\r\n enemies: enemies.sort(sortByName),\r\n hasTokens: allies.length || enemies.length || neutral.length,\r\n }\r\n }\r\n}\r\n", "import { localize, templatePath } from '../module.js'\r\nimport { getValidTokens } from '../scene.js'\r\nimport { BaseMenu } from './base-menu.js'\r\n\r\nexport class PerceptionMenu extends BaseMenu {\r\n get title() {\r\n return localize('menu.perception.title', { name: this.token.name })\r\n }\r\n\r\n get template() {\r\n return templatePath('perception')\r\n }\r\n\r\n getData(options) {\r\n const selected = this.selected\r\n const currentData = this.currentData\r\n const originalData = this.getSavedData()\r\n\r\n const tokens = getValidTokens(this.token).map(({ id, name, actor }) => {\r\n const current = currentData[id] ?? {}\r\n const original = originalData[id] ?? {}\r\n\r\n return {\r\n id,\r\n name,\r\n alliance: actor.alliance,\r\n cover: BaseMenu.createPropertyData(original, current, 'cover'),\r\n visibility: BaseMenu.createPropertyData(original, current, 'visibility'),\r\n selected: selected.includes(id),\r\n }\r\n })\r\n\r\n return {\r\n ...super.getData(options),\r\n ...this._spliIntoAlliances(tokens),\r\n }\r\n }\r\n\r\n activateListeners(html) {\r\n super.activateListeners(html)\r\n\r\n html.filter('.tokens').selectable({\r\n autoRefresh: false,\r\n filter: '.token',\r\n cancel: 'header,select',\r\n stop: () => this._setSelected(),\r\n })\r\n\r\n html.find('[data-action=select-all]').on('click', event => {\r\n const section = $(event.currentTarget).closest('section')\r\n const tokens = (section.length ? section : html).find('[data-token-id]')\r\n const allSelected = tokens.filter(':not(.ui-selected)').length === 0\r\n tokens.toggleClass('ui-selected', !allSelected)\r\n this._setSelected()\r\n })\r\n\r\n html.find('[data-action=use-selection]').on('click', event => {\r\n this._setSelected(canvas.tokens.controlled.map(t => t.id))\r\n this.render()\r\n })\r\n\r\n html.find('[data-action=reset]').on('click', event => this.reset())\r\n }\r\n}\r\n", "export const RECT_CORNERS = [\r\n { x: 0, y: 0 },\r\n { x: 1, y: 0 },\r\n { x: 0, y: 1 },\r\n { x: 1, y: 1 },\r\n]\r\n\r\nexport const RECT_SPREAD = [\r\n { x: 0.25, y: 0.25 },\r\n { x: 0.5, y: 0.25 },\r\n { x: 0.75, y: 0.25 },\r\n { x: 0.25, y: 0.5 },\r\n { x: 0.5, y: 0.5 },\r\n { x: 0.75, y: 0.5 },\r\n { x: 0.25, y: 0.75 },\r\n { x: 0.5, y: 0.75 },\r\n { x: 0.75, y: 0.75 },\r\n]\r\n\r\nexport function getRectEdges(rect, margin) {\r\n const opposite = 1 - margin\r\n return {\r\n top: { A: getRectPoint({ x: margin, y: margin }, rect), B: getRectPoint({ x: opposite, y: margin }, rect) },\r\n right: { A: getRectPoint({ x: opposite, y: margin }, rect), B: getRectPoint({ x: opposite, y: opposite }, rect) },\r\n bottom: { A: getRectPoint({ x: opposite, y: opposite }, rect), B: getRectPoint({ x: margin, y: opposite }, rect) },\r\n left: { A: getRectPoint({ x: margin, y: opposite }, rect), B: getRectPoint({ x: margin, y: margin }, rect) },\r\n }\r\n}\r\n\r\nexport function lineIntersectWall(origin, target, debug = false) {\r\n if (debug) drawDebugLine(origin, target)\r\n return CONFIG.Canvas.polygonBackends.move.testCollision(origin, target, { type: 'move', mode: 'any' })\r\n}\r\n\r\nexport function pointToTokenIntersectWall(origin, token, debug = false) {\r\n for (const point of rectSpread(token.bounds)) {\r\n if (lineIntersectWall(origin, point, debug)) return true\r\n }\r\n return false\r\n}\r\n\r\nexport function getRectPoint(point, rect) {\r\n return { x: rect.x + rect.width * point.x, y: rect.y + rect.height * point.y }\r\n}\r\n\r\nexport function clearDebug() {\r\n canvas.controls.debug.clear()\r\n}\r\n\r\nexport function drawDebugLine(origin, target, color = 'blue') {\r\n const hex = color === 'blue' ? 0x0066cc : color === 'red' ? 0xff0000 : 0x16a103\r\n canvas.controls.debug.lineStyle(4, hex).moveTo(origin.x, origin.y).lineTo(target.x, target.y)\r\n}\r\n\r\nexport function* rectSpread(rect) {\r\n for (const point of RECT_SPREAD) {\r\n yield getRectPoint(point, rect)\r\n }\r\n}\r\n\r\nexport function* rectCorners(rect) {\r\n for (const point of RECT_CORNERS) {\r\n yield getRectPoint(point, rect)\r\n }\r\n}\r\n", "import { clearDebug, drawDebugLine } from './geometry.js'\r\n\r\nexport function getLightExposure(token, debug = false) {\r\n token = token instanceof Token ? token : token.object\r\n\r\n if (token.document.hasStatusEffect(CONFIG.specialStatusEffects.INVISIBLE)) return undefined\r\n\r\n const scene = token.scene\r\n if (scene !== canvas.scene || !scene.tokenVision || scene.darkness < scene.globalLightThreshold) return undefined\r\n\r\n if (debug) clearDebug()\r\n\r\n const center = token.document.center\r\n let exposure = null\r\n\r\n for (const light of canvas.effects.lightSources) {\r\n if (!light.active) continue\r\n\r\n const bright = light.data.bright\r\n const dim = light.data.dim\r\n\r\n if (light.object === token) {\r\n if (bright) return 'bright'\r\n if (dim) exposure = 'dim'\r\n continue\r\n }\r\n\r\n if (!light.shape.contains(center.x, center.y)) {\r\n if (debug) drawDebugLine(light, center, 'red')\r\n continue\r\n }\r\n\r\n if (light.ratio === 1) {\r\n if (debug) drawDebugLine(light, center, 'green')\r\n return 'bright'\r\n }\r\n\r\n if (light.ratio === 0) {\r\n if (debug) drawDebugLine(light, center, 'blue')\r\n exposure = 'dim'\r\n continue\r\n }\r\n\r\n const distance = new Ray(light, center).distance\r\n if (distance <= bright) {\r\n if (debug) {\r\n drawDebugLine(light, center, 'green')\r\n exposure = 'bright'\r\n } else return 'bright'\r\n } else {\r\n if (debug) {\r\n drawDebugLine(light, center, 'blue')\r\n if (exposure !== 'bright') exposure = 'dim'\r\n } else exposure = 'dim'\r\n }\r\n }\r\n\r\n return exposure\r\n}\r\n", "import { COVERS, VISIBILITIES } from './constants.js'\r\n\r\nconst DATA = {\r\n cover: {\r\n cancel: { targets: ['lesser', 'standard', 'greater', 'greater-prone'] },\r\n set: {\r\n targets: ['none', 'lesser', 'standard', 'greater', 'greater-prone'],\r\n value: ['none', 'lesser', 'standard', 'greater', 'greater-prone'],\r\n },\r\n reduce: { targets: ['lesser', 'standard', 'greater', 'greater-prone'] },\r\n ignore: { targets: 'string' },\r\n ignored: { targets: ['allies', 'enemies'] },\r\n ac: { targets: ['lesser', 'standard', 'greater', 'greater-prone'], value: ['number'] },\r\n },\r\n visibility: {\r\n cancel: { targets: ['concealed', 'hidden', 'undetected', 'unnoticed'] },\r\n set: {\r\n targets: ['observed', 'concealed', 'hidden', 'undetected', 'unnoticed'],\r\n value: ['observed', 'concealed', 'hidden', 'undetected', 'unnoticed'],\r\n },\r\n reduce: { targets: ['concealed', 'hidden', 'undetected', 'unnoticed'] },\r\n noff: { targets: ['hidden', 'undetected', 'unnoticed'] },\r\n noinvis: {},\r\n dc: { targets: ['concealed', 'hidden'], value: ['number', 'string'] },\r\n },\r\n}\r\n\r\nconst SELECTORS = {\r\n cover: Object.keys(DATA.cover),\r\n visibility: Object.keys(DATA.visibility),\r\n all: [...Object.keys(DATA.cover), ...Object.keys(DATA.visibility)],\r\n}\r\n\r\nexport function setupRuleElement() {\r\n const rollOptionSchema = game.pf2e.RuleElements.builtin.RollOption.defineSchema()\r\n const PredicateField = rollOptionSchema.predicate.constructor\r\n const ResolvableValueField = rollOptionSchema.value.constructor\r\n\r\n class PF2ePerceptionRuleElement extends game.pf2e.RuleElement {\r\n constructor(source, options) {\r\n if (typeof source.targets === 'string') source.targets = [source.targets]\r\n\r\n super({ priority: CONST.ACTIVE_EFFECT_MODES.CUSTOM, ...source }, options)\r\n\r\n const selectorType = SELECTORS[source.type]\r\n if (!selectorType) return\r\n\r\n if (!selectorType?.includes(source.selector)) {\r\n this.failValidation(`The type \"${source.type}\" only accepts the following selectors: ${selectorType.join(', ')}.`)\r\n return\r\n }\r\n\r\n const selector = DATA[source.type]?.[source.selector]\r\n if (!selector) return\r\n\r\n const selectorWarn = msg => {\r\n const { name, uuid } = this.item\r\n console.warn(`PF2e System | PF2ePerception rules element on item ${name} (${uuid}) simple warning: ${msg}`)\r\n }\r\n\r\n const targetsType = Array.isArray(selector.targets) ? [...selector.targets, 'all'] : selector.targets\r\n const joinedTargets = Array.isArray(targetsType) ? targetsType.join(', ') : null\r\n\r\n if (!targetsType && source.targets?.length) {\r\n selectorWarn(`The selector \"${source.selector}\" doesn't accept any targets property.`)\r\n return\r\n }\r\n\r\n if (source.selector === 'ignore' && !source.targets?.length) {\r\n const msg = `The selector \"${source.selector}\" requires a targets property with the ids of the tokens on the scene that should not give cover.`\r\n this.failValidation(msg)\r\n return\r\n }\r\n\r\n if (joinedTargets && source.targets?.some(t => !targetsType.includes(t))) {\r\n const msg = `The targets property of selector \"${source.selector}\" only accepts the following: ${joinedTargets}.`\r\n this.failValidation(msg)\r\n return\r\n } else if (!joinedTargets && targetsType && source.targets?.some(t => typeof t !== targetsType)) {\r\n const msg = `The targets property of selector \"${source.selector}\" needs to be of type \"${targetsType}\".`\r\n this.failValidation(msg)\r\n return\r\n }\r\n\r\n if (!selector.value && source.value) {\r\n selectorWarn(`The selector \"${source.selector}\" doesn't accept any value property.`)\r\n return\r\n }\r\n\r\n if (source.selector === 'set') {\r\n if (!selector.value.includes(source.value)) {\r\n const joinedValues = selector.value.join(', ')\r\n const msg = `The selector \"${source.selector}\" only accepts the following: ${joinedValues}.`\r\n this.failValidation(msg)\r\n }\r\n } else {\r\n const sourcevalueType = typeof source.value\r\n if (selector.value && !selector.value.includes(sourcevalueType)) {\r\n const msg = `The selector \"${source.selector}\" does not accept a value property of type ${sourcevalueType}.`\r\n this.failValidation(msg)\r\n }\r\n }\r\n }\r\n\r\n static defineSchema() {\r\n const { fields } = foundry.data\r\n\r\n return {\r\n ...super.defineSchema(),\r\n\r\n type: new fields.StringField({\r\n required: true,\r\n nullable: false,\r\n blank: false,\r\n choices: ['visibility', 'cover'],\r\n }),\r\n\r\n affects: new fields.StringField({\r\n required: true,\r\n nullable: false,\r\n blank: false,\r\n initial: 'self',\r\n choices: ['self', 'other'],\r\n }),\r\n\r\n selector: new fields.StringField({\r\n required: true,\r\n nullable: false,\r\n blank: false,\r\n }),\r\n\r\n targets: new fields.ArrayField(\r\n new fields.StringField({\r\n required: true,\r\n nullable: false,\r\n blank: false,\r\n initial: undefined,\r\n }),\r\n {\r\n required: true,\r\n nullable: false,\r\n initial: ['all'],\r\n }\r\n ),\r\n\r\n predicate: new PredicateField({\r\n required: false,\r\n nullable: false,\r\n }),\r\n\r\n value: new ResolvableValueField({\r\n required: false,\r\n initial: undefined,\r\n }),\r\n }\r\n }\r\n\r\n test(rollOptions, password) {\r\n if (!password) return false\r\n return super.test(rollOptions)\r\n }\r\n\r\n addToPerception(affects, perception, options) {\r\n if (!this.test(options, true)) return\r\n\r\n const prefix = this.affects === 'self' ? affects : affects === 'origin' ? 'target' : 'origin'\r\n const root = `${prefix}.${this.type}.${this.selector}`\r\n const verificator = DATA[this.type][this.selector]\r\n\r\n if (!verificator.targets) {\r\n setProperty(perception, root, true)\r\n return\r\n }\r\n\r\n const targets = this.targets.includes('all') ? verificator.targets : this.targets\r\n\r\n if (!verificator.value) {\r\n for (const target of targets) {\r\n const path = `${root}.${target}`\r\n setProperty(perception, path, true)\r\n }\r\n return\r\n }\r\n\r\n for (const target of targets) {\r\n const path = `${root}.${target}`\r\n\r\n let value = getProperty(perception, path)\r\n if (value) value.add(this.value)\r\n else value = new Set([this.value])\r\n\r\n setProperty(perception, path, value)\r\n }\r\n }\r\n }\r\n\r\n game.pf2e.RuleElements.custom.PF2ePerception = PF2ePerceptionRuleElement\r\n}\r\n\r\nexport function perceptionRules(origin, target, { distance, extraOptions = [] } = {}) {\r\n const originActor = origin.actor\r\n const targetActor = target.actor\r\n if (!originActor || !targetActor) return {}\r\n\r\n const rules = {\r\n origin: originActor.rules.filter(r => !r.ignored && r.key === 'PF2ePerception') ?? [],\r\n target: targetActor.rules.filter(r => !r.ignored && r.key === 'PF2ePerception') ?? [],\r\n }\r\n if (!rules.origin.length && !rules.target.length) return {}\r\n\r\n const selfOptions = {\r\n origin: originActor.getRollOptions(),\r\n target: targetActor.getRollOptions(),\r\n }\r\n\r\n const otherOptions = {\r\n origin: targetActor.getSelfRollOptions('target'),\r\n target: originActor.getSelfRollOptions('origin'),\r\n }\r\n\r\n origin = origin instanceof Token ? origin : origin.object\r\n target = target instanceof Token ? target : target.object\r\n\r\n distance ??= origin.distanceTo(target)\r\n const distances = [`origin:distance:${distance}`, `target:distance:${distance}`]\r\n\r\n const perception = {}\r\n\r\n for (const prefix of ['origin', 'target']) {\r\n const testOptions = [...extraOptions, ...selfOptions[prefix], ...otherOptions[prefix], ...distances]\r\n for (const rule of rules[prefix]) {\r\n rule.addToPerception(prefix, perception, testOptions)\r\n }\r\n }\r\n\r\n return perception\r\n}\r\n\r\nexport function getIgnoredPerception(token) {\r\n const actor = token.actor\r\n if (!actor) return []\r\n\r\n const rules =\r\n actor.rules.filter(r => !r.ignored && r.key === 'PF2ePerception' && r.type === 'cover' && r.selector === 'ignored') ?? []\r\n\r\n return rules.flatMap(r => r.targets)\r\n}\r\n\r\nexport function getPerception(perception, affects, type, selector, targets) {\r\n let cursor = perception[affects]?.[type]?.[selector]\r\n return targets ? cursor?.[targets] : cursor\r\n}\r\n\r\nexport function updateFromPerceptionRules(perception, affects, type, value) {\r\n if (value === undefined) {\r\n value = type === 'cover' ? 'none' : 'observed'\r\n }\r\n\r\n const list = type === 'cover' ? COVERS : VISIBILITIES\r\n\r\n if (value && getPerception(perception, affects, type, 'cancel', value)) return undefined\r\n\r\n const setValue = getPerception(perception, affects, type, 'set', value)?.first()\r\n if (setValue && list.includes(setValue)) {\r\n value = setValue\r\n } else if (value && getPerception(perception, affects, type, 'reduce', value)) {\r\n const index = list.indexOf(value)\r\n value = list[Math.max(0, index - 1)]\r\n }\r\n\r\n return value === list[0] ? undefined : value\r\n}\r\n", "import { getCoverEffect, hasGreaterDarkvision, isProne, seeInvisibility } from './actor.js'\r\nimport { PerceptionMenu } from './apps/perception.js'\r\nimport { COVERS, COVER_VALUES, ICONS_PATHS, VISIBILITY_VALUES, defaultValues } from './constants.js'\r\nimport { clearDebug, drawDebugLine, getRectEdges, lineIntersectWall, pointToTokenIntersectWall } from './geometry.js'\r\nimport { getLightExposure } from './lighting.js'\r\nimport { MODULE_ID, getFlag, getSetting, hasPermission, unsetFlag } from './module.js'\r\nimport { getIgnoredPerception, getPerception, updateFromPerceptionRules } from './rule-element.js'\r\nimport { getSceneSetting, getValidTokens } from './scene.js'\r\nimport { getDarknessTemplates, getMistTemplates, getTemplateTokens } from './template.js'\r\n\r\nexport function renderTokenHUD(hud, html) {\r\n if (!hasPermission() || !hud.object.actor?.isOfType('creature')) return\r\n html.find('.col.left').append(`
`)\r\n html.find('[data-action=pf2e-perception]').on('click', event => openHUD(hud.object))\r\n}\r\n\r\nexport function openHUD(token) {\r\n return PerceptionMenu.openMenu({ token })\r\n}\r\n\r\nexport function pasteToken(originals, sources) {\r\n for (const source of sources) {\r\n delete source.flags?.[MODULE_ID]\r\n }\r\n}\r\n\r\nexport function getTokenData(token, ...path) {\r\n path.unshift('data')\r\n token = token instanceof Token ? token.document : token\r\n return getFlag(token, path.join('.'))\r\n}\r\n\r\nexport async function clearTokenData(token) {\r\n token = token instanceof Token ? token.document : token\r\n return unsetFlag(token, 'data')\r\n}\r\n\r\nexport async function setTokenData(token, data) {\r\n const valid = getValidTokens(token).map(t => t.id)\r\n const updates = {}\r\n\r\n for (const tokenId in data) {\r\n if (!valid.includes(tokenId)) {\r\n updates[`flags.${MODULE_ID}.data.-=${tokenId}`] = true\r\n continue\r\n }\r\n\r\n const current = data[tokenId]\r\n const original = getTokenData(token, tokenId) ?? {}\r\n\r\n if (current.visibility === defaultValues.visibility) delete current.visibility\r\n if (current.cover === defaultValues.cover) delete current.cover\r\n\r\n if (original.cover === current.cover && original.visibility === current.visibility) continue\r\n\r\n if (!current.visibility && !current.cover) {\r\n updates[`flags.${MODULE_ID}.data.-=${tokenId}`] = true\r\n } else {\r\n for (const property of ['cover', 'visibility']) {\r\n if (original[property] === current[property]) continue\r\n if (!current[property]) updates[`flags.${MODULE_ID}.data.${tokenId}.-=${property}`] = true\r\n else updates[`flags.${MODULE_ID}.data.${tokenId}.${property}`] = current[property]\r\n }\r\n }\r\n }\r\n\r\n token = token instanceof Token ? token.document : token\r\n return token.update(updates)\r\n}\r\n\r\nexport function getWallCover(origin, target, debug = false) {\r\n const scene = origin.scene\r\n if (!getSceneSetting(scene, 'standard')) return\r\n\r\n if (debug) clearDebug()\r\n\r\n const standard = getSetting('standard-type')\r\n const intersects =\r\n standard === 'points'\r\n ? pointToTokenIntersectWall(origin.center, target, debug)\r\n : lineIntersectWall(origin.center, target.center, debug)\r\n\r\n return intersects ? 'standard' : undefined\r\n}\r\n\r\nconst SIZES = {\r\n tiny: 0,\r\n sm: 1,\r\n med: 2,\r\n lg: 3,\r\n huge: 4,\r\n grg: 5,\r\n}\r\n\r\nexport function getCover(origin, target, { perception = {}, options = [], affects = 'origin', debug = false } = {}) {\r\n const prone = options.includes('item:ranged') ? isProne(target.actor) : false\r\n\r\n const returnValue = value => {\r\n return updateFromPerceptionRules(perception, affects, 'cover', value)\r\n }\r\n\r\n let systemCover = getCoverEffect(target.actor, true)\r\n if (prone && COVER_VALUES[systemCover] > COVER_VALUES.lesser) return returnValue('greater-prone')\r\n\r\n if (!prone && systemCover === 'greater-prone') systemCover = undefined\r\n\r\n let cover = getTokenData(target, origin.id, 'cover')\r\n if (prone && COVER_VALUES[cover] > COVER_VALUES.lesser) return returnValue('greater-prone')\r\n\r\n if (!prone && cover === 'greater-prone') cover = undefined\r\n\r\n if (COVER_VALUES[systemCover] < COVER_VALUES.standard) {\r\n const api = game.modules.get(MODULE_ID).custom ?? {}\r\n\r\n if (COVER_VALUES[cover] < COVER_VALUES.standard) {\r\n const custom = api.getWallCover\r\n let wallCover\r\n\r\n if (typeof custom === 'function') {\r\n const customCover = custom(origin, target, debug)\r\n wallCover = COVERS.includes(customCover) ? customCover : getWallCover(origin, target, debug)\r\n } else {\r\n wallCover = getWallCover(origin, target, debug)\r\n }\r\n\r\n if (COVER_VALUES[wallCover] > COVER_VALUES[cover]) cover = wallCover\r\n }\r\n\r\n if (COVER_VALUES[cover] < COVER_VALUES.standard && origin.distanceTo(target) > 5) {\r\n const custom = api.getCreatureCover\r\n let creatureCover\r\n\r\n if (typeof custom === 'function') {\r\n const customCover = custom(origin, target, { perception, debug })\r\n creatureCover = COVERS.includes(customCover)\r\n ? customCover\r\n : getCreatureCover(origin, target, { perception, debug })\r\n } else {\r\n creatureCover = getCreatureCover(origin, target, { perception, debug })\r\n }\r\n\r\n if (COVER_VALUES[creatureCover] > COVER_VALUES[cover]) cover = creatureCover\r\n }\r\n }\r\n\r\n if (prone && COVER_VALUES[cover] > COVER_VALUES.lesser) return returnValue('greater-prone')\r\n return returnValue(COVER_VALUES[cover] > COVER_VALUES[systemCover] ? cover : undefined)\r\n}\r\n\r\nexport function getCreatureCover(originToken, targetToken, { perception = {}, debug = false } = {}) {\r\n const setting = getSetting('lesser')\r\n if (setting === 'none') return undefined\r\n\r\n originToken = originToken instanceof Token ? originToken.document : originToken\r\n targetToken = targetToken instanceof Token ? targetToken.document : targetToken\r\n\r\n const ignoreIds = (() => {\r\n const originIds = Object.keys(perception.origin?.cover?.ignore ?? {})\r\n const targetIds = Object.keys(perception.target?.cover?.ignore ?? {})\r\n return new Set([...originIds, ...targetIds])\r\n })()\r\n\r\n let cover = undefined\r\n const origin = originToken.center\r\n const target = targetToken.center\r\n\r\n const originActor = originToken.actor\r\n const targetActor = targetToken.actor\r\n\r\n if (debug) {\r\n clearDebug()\r\n drawDebugLine(origin, target)\r\n }\r\n\r\n const isExtraLarge = token => {\r\n const size = SIZES[token.actor.size]\r\n return size - originSize >= 2 && size - targetSize >= 2\r\n }\r\n\r\n const originSize = SIZES[originActor.size]\r\n const targetSize = SIZES[targetActor.size]\r\n\r\n const originAlliance = originActor.alliance\r\n const deadCover = getSetting('dead-cover')\r\n const proneCover = getSetting('prone-cover')\r\n\r\n const tokens = originToken.scene.tokens.contents\r\n .filter(token => {\r\n const actor = token.actor\r\n const ignored = getIgnoredPerception(token)\r\n\r\n return (\r\n actor &&\r\n !token.hidden &&\r\n token !== originToken &&\r\n token !== targetToken &&\r\n (proneCover || !isProne(actor)) &&\r\n (deadCover || actor.hitPoints?.value !== 0) &&\r\n !ignoreIds.has(token.id) &&\r\n !(ignored.includes('all') || ignored.includes(actor.alliance === originAlliance ? 'allies' : 'enemies'))\r\n )\r\n })\r\n .sort((a, b) => SIZES[b.actor.size] - SIZES[a.actor.size])\r\n\r\n let extralarges = originSize < SIZES.huge && targetSize < SIZES.huge && tokens.filter(isExtraLarge).length\r\n\r\n const margin = setting === 'ten' ? 0.1 : setting === 'twenty' ? 0.2 : 0\r\n\r\n const intersectsEdge = edge => {\r\n if (debug) drawDebugLine(edge.A, edge.B, 'red')\r\n return lineSegmentIntersects(origin, target, edge.A, edge.B)\r\n }\r\n\r\n const intersectsWith =\r\n setting === 'cross'\r\n ? edges => {\r\n return (\r\n (intersectsEdge(edges.top) && intersectsEdge(edges.bottom)) ||\r\n (intersectsEdge(edges.left) && intersectsEdge(edges.right))\r\n )\r\n }\r\n : edges => Object.values(edges).some(edge => intersectsEdge(edge))\r\n\r\n for (const tokenDocument of tokens) {\r\n const token = tokenDocument.object\r\n const edges = getRectEdges(token.bounds, margin)\r\n if (intersectsWith(edges)) return extralarges ? 'standard' : 'lesser'\r\n else if (isExtraLarge(tokenDocument)) extralarges--\r\n }\r\n\r\n return cover\r\n}\r\n\r\nexport function getVisibility(origin, target, { perception = {}, affects = 'origin', debug = false } = {}) {\r\n origin = origin instanceof Token ? origin : origin.object\r\n target = target instanceof Token ? target : target.object\r\n\r\n const originActor = origin.actor\r\n const targetActor = target.actor\r\n\r\n let systemVisibility = (() => {\r\n if (!originActor || !targetActor) return\r\n\r\n let visibility\r\n\r\n if (targetActor.hasCondition('blinded')) visibility = 'hidden'\r\n else if (targetActor.hasCondition('dazzled')) visibility = 'concealed'\r\n\r\n for (const condition of ['unnoticed', 'undetected', 'hidden', 'concealed']) {\r\n if (VISIBILITY_VALUES[condition] > VISIBILITY_VALUES[visibility] && originActor.hasCondition(condition))\r\n visibility = condition\r\n }\r\n\r\n return visibility\r\n })()\r\n\r\n const returnValue = value => {\r\n if (!isInvisible) return updateFromPerceptionRules(perception, affects, 'visibility', value)\r\n\r\n if (VISIBILITY_VALUES[value] < VISIBILITY_VALUES.hidden) value = 'hidden'\r\n\r\n const seeInvis = seeInvisibility(targetActor) || getPerception(perception, affects, 'visibility', 'noinvis')\r\n if (seeInvis) value = 'concealed'\r\n\r\n return updateFromPerceptionRules(perception, affects, 'visibility', value)\r\n }\r\n\r\n const isInvisible = originActor?.hasCondition('invisible')\r\n const visibility = getTokenData(origin, target.id, 'visibility')\r\n let mergedVisibility = VISIBILITY_VALUES[systemVisibility] > VISIBILITY_VALUES[visibility] ? systemVisibility : visibility\r\n\r\n if (VISIBILITY_VALUES[mergedVisibility] >= VISIBILITY_VALUES.hidden || isInvisible) return returnValue(mergedVisibility)\r\n\r\n const targetLowlight = targetActor?.hasLowLightVision\r\n const targetDarkvision = targetActor?.hasDarkvision\r\n const targetGreaterDarkvision = targetActor && hasGreaterDarkvision(targetActor)\r\n if (targetGreaterDarkvision && mergedVisibility === 'concealed') return returnValue(mergedVisibility)\r\n\r\n let inDarkness\r\n if (!targetGreaterDarkvision) {\r\n const darknessTemplates = getDarknessTemplates(origin)\r\n if (darknessTemplates?.length) {\r\n let darknessVisibility\r\n\r\n for (const template of darknessTemplates) {\r\n const darknessTokens = getTemplateTokens(template)\r\n if (!darknessTokens.length) continue\r\n\r\n const inTemplate = darknessTokens.includes(origin) || darknessTokens.includes(target)\r\n if (inTemplate) inDarkness = true\r\n else continue\r\n\r\n if (!targetDarkvision) return returnValue('hidden')\r\n\r\n const templateConceals = getFlag(template, 'conceal')\r\n if (templateConceals) darknessVisibility = 'concealed'\r\n }\r\n\r\n if (darknessVisibility === 'concealed') mergedVisibility = 'concealed'\r\n if (inDarkness && mergedVisibility === 'concealed') return returnValue(mergedVisibility)\r\n }\r\n }\r\n\r\n if (mergedVisibility !== 'concealed') {\r\n const mistTemplates = getMistTemplates(origin)\r\n if (mistTemplates?.length) {\r\n for (const template of mistTemplates) {\r\n const mistTokens = getTemplateTokens(template)\r\n if (!mistTokens.length) continue\r\n\r\n const inTemplate = mistTokens.includes(origin) || mistTokens.includes(target)\r\n if (inTemplate) return returnValue('concealed')\r\n }\r\n }\r\n }\r\n\r\n if (inDarkness || targetGreaterDarkvision) return returnValue(mergedVisibility)\r\n\r\n const exposure = getLightExposure(origin, debug)\r\n let exposedVisibility = exposure === 'dim' ? 'concealed' : exposure === null ? 'hidden' : undefined\r\n if (exposedVisibility === 'concealed' && targetLowlight) exposedVisibility = undefined\r\n else if (exposedVisibility === 'hidden' && targetDarkvision) exposedVisibility = undefined\r\n\r\n if (VISIBILITY_VALUES[exposedVisibility] > VISIBILITY_VALUES[mergedVisibility]) mergedVisibility = exposedVisibility\r\n return returnValue(mergedVisibility)\r\n}\r\n\r\nexport function updateToken(token, data, context, userId) {\r\n const flags = data.flags?.['pf2e-perception']\r\n\r\n if (flags && (flags.data || flags['-=data'] !== undefined)) {\r\n token.object.renderFlags.set({ refreshVisibility: true })\r\n\r\n if (game.user.isGM) return\r\n\r\n const hk = Hooks.on('refreshToken', refreshed => {\r\n if (!token.object === refreshed) return\r\n Hooks.off('refreshToken', hk)\r\n if (game.combat?.getCombatantByToken(token.id)) ui.combat.render()\r\n })\r\n }\r\n}\r\n\r\nexport function hoverToken(token, hovered) {\r\n if (hovered) showAllConditionals(token)\r\n else clearConditionals(token)\r\n}\r\n\r\nexport function deleteToken(token) {\r\n clearConditionals(token)\r\n if (!game.user.isGM) ui.combat.render()\r\n}\r\n\r\nexport function controlToken(token, controlled) {\r\n if (!controlled) return\r\n clearConditionals()\r\n Hooks.once('sightRefresh', () => token.hover && showAllConditionals(token))\r\n}\r\n\r\nexport function clearConditionals(token) {\r\n const tokenId = token?.id\r\n if (!tokenId) return $('.pf2e-conditionals').remove()\r\n $(`.pf2e-conditionals[data-hover-id=${token.id}]`).remove()\r\n $(`.pf2e-conditionals[data-token-id=${token.id}]`).remove()\r\n}\r\n\r\nexport function showAllConditionals(token) {\r\n const tokens = getValidTokens(token)\r\n for (const target of tokens) {\r\n showConditionals(target, token)\r\n }\r\n}\r\n\r\nexport async function showConditionals(origin, target) {\r\n origin = origin instanceof Token ? origin : origin.object\r\n if (!origin.visible || !origin.actor?.isOfType('creature')) return\r\n\r\n let data = getTokenData(origin, target.id)\r\n if (isEmpty(data)) return\r\n\r\n if (!game.user.isGM && !target.document.hasPlayerOwner && VISIBILITY_VALUES[data.visibility] >= VISIBILITY_VALUES.hidden) {\r\n if (!data.cover) return\r\n data = { cover: data.cover }\r\n }\r\n\r\n const scale = origin.worldTransform.a\r\n const coords = canvas.clientCoordinatesFromCanvas(origin.document._source)\r\n const iconSize = getSetting('icon-size')\r\n\r\n const style = [\r\n `top: ${coords.y}px`,\r\n `left: ${coords.x + (origin.hitArea.width * scale) / 2}px`,\r\n `--icon-size: ${iconSize}px`,\r\n ].join('; ')\r\n\r\n let content = `
`\r\n\r\n const savedPaths = getSetting('icon-path')\r\n Object.entries(data).map(([property, value]) => {\r\n const icon = property === 'cover' ? 'cover' : value\r\n let path = savedPaths[icon] || ICONS_PATHS[icon]\r\n if (path.startsWith('systems') || path.startsWith('modules')) path = `../../../${path}`\r\n content += `
`\r\n })\r\n\r\n content += '
'\r\n\r\n $(document.body).append(content)\r\n}\r\n\r\nexport function rulesBasedVision() {\r\n return !!(this.sight.enabled && this.actor?.isOfType('creature') && this.scene?.rulesBasedVision)\r\n}\r\n\r\nexport function preCreateToken(token) {\r\n const actor = token.actor\r\n if (!actor?.isOfType('creature')) return\r\n\r\n if (actor.isOfType('npc') && getSceneSetting(token.scene, 'npc-vision')) {\r\n token.updateSource({ 'sight.enabled': true })\r\n }\r\n\r\n if (game.user.isGM && token.hidden) {\r\n const targets = game.user.targets\r\n const updates = {}\r\n\r\n for (const target of targets) {\r\n updates[target.id] = { visibility: 'unnoticed' }\r\n }\r\n\r\n if (targets.size) {\r\n token.updateSource({ [`flags.${MODULE_ID}.data`]: updates })\r\n }\r\n }\r\n}\r\n", "import { validateMessage } from '../chat.js'\r\nimport { COVERS, VISIBILITIES, VISIBILITY_VALUES, defaultValues } from '../constants.js'\r\nimport { MODULE_ID, getSetting, localize, templatePath } from '../module.js'\r\nimport { DegreeOfSuccess } from '../pf2e/success.js'\r\nimport { getValidTokens } from '../scene.js'\r\nimport { deleteSeekTemplate } from '../template.js'\r\nimport { getTokenData } from '../token.js'\r\nimport { BaseMenu } from './base-menu.js'\r\n\r\nclass ValidationMenu extends BaseMenu {\r\n static async openMenu(params, options) {\r\n // biome-ignore lint/complexity/noThisInStatic: shit aint working\r\n const validated = await super.openMenu(params, options)\r\n if (validated && params.message) validateMessage(params.message)\r\n return validated\r\n }\r\n\r\n get title() {\r\n return localize('menu.validation.title', { name: this.token.name })\r\n }\r\n\r\n get template() {\r\n return templatePath('validation')\r\n }\r\n\r\n get selected() {\r\n const selected = super.selected\r\n if (selected.length) return selected\r\n return this.globalSelection\r\n }\r\n\r\n get globalSelection() {\r\n const token = this.token\r\n const alliance = token.actor.alliance\r\n return getValidTokens(token)\r\n .filter(t => t.actor.alliance !== alliance)\r\n .map(t => t.id)\r\n }\r\n\r\n getSavedData(converted = true) {\r\n const data = super.getSavedData()\r\n return converted ? this._convertData(data) : data\r\n }\r\n\r\n _convertData(data) {\r\n const property = this.property\r\n const scene = this.scene\r\n const selected = this.selected\r\n const defaultValue = defaultValues[property]\r\n const propertyList = property === 'cover' ? COVERS : VISIBILITIES\r\n\r\n for (const tokenId of selected) {\r\n const token = scene.tokens.get(tokenId)\r\n const fullProperty = `${tokenId}.${property}`\r\n const currentValue = getProperty(data, fullProperty) ?? defaultValue\r\n\r\n let processedValue = this.processValue({ token, value: currentValue })\r\n if (!propertyList.includes(processedValue)) processedValue = currentValue\r\n\r\n if (currentValue === processedValue) continue\r\n setProperty(data, fullProperty, processedValue)\r\n }\r\n\r\n return data\r\n }\r\n\r\n processValue(params) {\r\n throw new Error(`${this.constructor.name} doesn't have a 'processValue' method defined`)\r\n }\r\n\r\n getData(options) {\r\n const { covers, visibilities, i18n } = super.getData(options)\r\n const currentData = this.currentData\r\n const originalData = this.getSavedData(false)\r\n const property = this.property\r\n\r\n const selected = this.selected\r\n let tokens = getValidTokens(this.token)\r\n\r\n tokens = tokens.map(({ id, name, actor }) => {\r\n const current = currentData[id] ?? {}\r\n const original = originalData[id] ?? {}\r\n\r\n return {\r\n id,\r\n name,\r\n alliance: actor.alliance,\r\n selected: selected.includes(id),\r\n ...BaseMenu.createPropertyData(original, current, property),\r\n }\r\n })\r\n\r\n const validation = getSetting('validation')\r\n if (validation === 'selected') tokens = tokens.filter(t => t.selected)\r\n else if (validation === 'changed') tokens = tokens.filter(t => t.changed)\r\n\r\n return {\r\n ...this._spliIntoAlliances(tokens),\r\n i18n,\r\n property: property,\r\n options: property === 'cover' ? covers : visibilities,\r\n showSelected: selected.length !== tokens.length && validation === 'all',\r\n showChanges: validation !== 'changed',\r\n }\r\n }\r\n\r\n activateListeners(html) {\r\n super.activateListeners(html)\r\n\r\n html.find('[data-action=cancel]').on('click', event => {\r\n this.close()\r\n })\r\n }\r\n}\r\n\r\nexport class CoverValidationMenu extends ValidationMenu {\r\n #value\r\n\r\n constructor(params, options = {}) {\r\n super(params, options)\r\n this.#value = params.value\r\n }\r\n\r\n get property() {\r\n return 'cover'\r\n }\r\n\r\n processValue() {\r\n return this.#value\r\n }\r\n}\r\n\r\nclass VisibilityValidationMenu extends ValidationMenu {\r\n #roll\r\n\r\n constructor(params, options = {}) {\r\n super(params, options)\r\n this.#roll = params.roll\r\n }\r\n\r\n get property() {\r\n return 'visibility'\r\n }\r\n\r\n get roll() {\r\n return this.#roll\r\n }\r\n}\r\n\r\nexport class HideValidationMenu extends VisibilityValidationMenu {\r\n processValue({ token, value }) {\r\n const roll = this.roll\r\n const dc = token.actor.perception.dc.value\r\n const visibility = VISIBILITY_VALUES[value]\r\n const success = new DegreeOfSuccess(roll, dc).value\r\n\r\n if (success >= DegreeOfSuccess.SUCCESS && visibility < VISIBILITY_VALUES.hidden) return 'hidden'\r\n if (success <= DegreeOfSuccess.FAILURE && visibility >= VISIBILITY_VALUES.hidden) return 'observed'\r\n return value\r\n }\r\n}\r\n\r\nexport class CreateADiversionMenu extends VisibilityValidationMenu {\r\n processValue({ token, value }) {\r\n const roll = this.roll\r\n const dc = token.actor.perception.dc.value\r\n const visibility = VISIBILITY_VALUES[value]\r\n const success = new DegreeOfSuccess(roll, dc).value\r\n\r\n if (success >= DegreeOfSuccess.SUCCESS && visibility < VISIBILITY_VALUES.hidden) return 'hidden'\r\n return value\r\n }\r\n}\r\n\r\nexport class UnHideValidationMenu extends VisibilityValidationMenu {\r\n get selected() {\r\n return getValidTokens(this.token).map(t => t.id)\r\n }\r\n\r\n processValue({ token, value }) {\r\n const visibility = VISIBILITY_VALUES[value]\r\n if (visibility >= VISIBILITY_VALUES.hidden) return 'observed'\r\n return value\r\n }\r\n}\r\n\r\nexport class PointOutValidationMenu extends VisibilityValidationMenu {\r\n #originator\r\n\r\n constructor(params, options = {}) {\r\n super(params, options)\r\n this.#originator = params.originator\r\n }\r\n\r\n get selected() {\r\n const token = this.token\r\n const alliance = token.actor.alliance\r\n const originatorId = this.#originator.id\r\n const data = getTokenData(token) ?? {}\r\n\r\n return getValidTokens(token)\r\n .filter(t => {\r\n if (t.id === originatorId || t.actor.alliance === alliance) return false\r\n const visibility = getProperty(data, `${t.id}.visibility`)\r\n return VISIBILITY_VALUES[visibility] >= VISIBILITY_VALUES.undetected\r\n })\r\n .map(t => t.id)\r\n }\r\n\r\n processValue({ token, value }) {\r\n return VISIBILITY_VALUES[value] >= VISIBILITY_VALUES.undetected ? 'hidden' : value\r\n }\r\n}\r\n\r\nclass ReverseVisibilityValidationMenu extends VisibilityValidationMenu {\r\n getSavedData(converted = true) {\r\n const thisId = this.token.id\r\n const tokens = getValidTokens(this.token)\r\n const data = {}\r\n\r\n for (const token of tokens) {\r\n const tokenData = getTokenData(token, thisId)\r\n if (tokenData) data[token.id] = deepClone(tokenData)\r\n }\r\n\r\n return converted ? this._convertData(data) : data\r\n }\r\n\r\n getData() {\r\n const parentData = super.getData()\r\n parentData.isReversed = true\r\n parentData.options = VISIBILITIES.map(value => ({ value, label: localize(`visibility.reversed.${value}`) }))\r\n return parentData\r\n }\r\n\r\n _saveData(currentData) {\r\n const scene = this.scene\r\n const thisId = this.token.id\r\n const updates = []\r\n\r\n for (const [tokenId, data] of Object.entries(currentData)) {\r\n const update = { _id: tokenId }\r\n const token = scene.tokens.get(tokenId)\r\n\r\n if (token) {\r\n if (data.visibility === defaultValues.visibility) {\r\n // biome-ignore lint/performance/noDelete: needs to be gone\r\n delete data.visibility\r\n }\r\n\r\n const original = getTokenData(token, thisId) ?? {}\r\n if (original?.visibility === data.visibility) continue\r\n\r\n if (!original.cover && !data.visibility) {\r\n update[`flags.${MODULE_ID}.data.-=${thisId}`] = true\r\n } else if (!data.visibility) {\r\n update[`flags.${MODULE_ID}.data.${thisId}.-=visibility`] = true\r\n } else {\r\n update[`flags.${MODULE_ID}.data.${thisId}.visibility`] = data.visibility\r\n }\r\n } else update[`flags.${MODULE_ID}.data.-=${thisId}`] = true\r\n\r\n updates.push(update)\r\n }\r\n\r\n scene.updateEmbeddedDocuments('Token', updates)\r\n }\r\n}\r\n\r\nexport class SeekValidationMenu extends ReverseVisibilityValidationMenu {\r\n #fromTemplate\r\n\r\n constructor(params, options = {}) {\r\n super(params, options)\r\n this.#fromTemplate = params.fromTemplate\r\n }\r\n\r\n get globalSelection() {\r\n return []\r\n }\r\n\r\n static async openMenu(params, options) {\r\n // biome-ignore lint/complexity/noThisInStatic: nop\r\n const validated = await super.openMenu(params, options)\r\n if (validated) deleteSeekTemplate(params.token)\r\n }\r\n\r\n processValue({ token, value }) {\r\n const roll = this.roll\r\n const dc = token.actor.skills.stealth.dc.value\r\n const visibility = VISIBILITY_VALUES[value]\r\n const success = new DegreeOfSuccess(roll, dc).value\r\n\r\n if (success >= DegreeOfSuccess.CRITICAL_SUCCESS && visibility >= VISIBILITY_VALUES.hidden) return 'observed'\r\n if (success >= DegreeOfSuccess.SUCCESS && visibility === VISIBILITY_VALUES.hidden) return 'observed'\r\n if (success >= DegreeOfSuccess.SUCCESS && visibility >= VISIBILITY_VALUES.undetected) return 'hidden'\r\n return value\r\n }\r\n}\r\n", "import {\r\n CoverValidationMenu,\r\n CreateADiversionMenu,\r\n HideValidationMenu,\r\n PointOutValidationMenu,\r\n SeekValidationMenu,\r\n UnHideValidationMenu,\r\n} from './apps/validation.js'\r\nimport { attackCheckRoll } from './constants.js'\r\nimport { MODULE_ID, getActionName, getFlag, getFlags, localize, setFlag } from './module.js'\r\nimport { deleteSeekTemplate } from './template.js'\r\n\r\nexport function renderChatMessage(message, html) {\r\n const token = message.token\r\n if (!token) return\r\n\r\n const isGM = game.user.isGM\r\n const hasPlayerOwner = token.hasPlayerOwner\r\n const { cover, selected, skipWait, validated, pointOut } = getFlags(message)\r\n const pf2eContext = message.getFlag('pf2e', 'context')\r\n\r\n if (cover) {\r\n if (isGM) {\r\n const button = createValidateButton({ property: 'cover', skipWait, validated })\r\n html.find('.message-content').append(button)\r\n html.find('[data-action=validate-cover]').on('click', () => {\r\n CoverValidationMenu.openMenu({ token, selected, value: cover, message })\r\n })\r\n } else if (!skipWait) {\r\n const hint = createWaitHint('cover', validated)\r\n html.find('.message-content').append(hint)\r\n }\r\n } else if (pf2eContext?.pf2ePerception?.visibility) {\r\n if (!validated) html.find('.message-buttons').remove()\r\n\r\n const flavor = html.find('.flavor-text')\r\n\r\n if (!isGM && hasPlayerOwner) {\r\n html.find('.message-sender').text(token.name)\r\n flavor.empty()\r\n }\r\n\r\n const msg = localize(`message.flat-check.${validated === undefined ? 'blind' : validated ? 'success' : 'failure'}`)\r\n const hint = createHint(msg, validated)\r\n flavor.append(hint)\r\n\r\n if (isGM) {\r\n for (const type of ['success', 'failure']) {\r\n flavor.append(\r\n createChatButton({\r\n action: `${type}-message`,\r\n icon: 'fa-solid fa-message',\r\n label: localize('message.flat-check.button', type),\r\n })\r\n )\r\n html.find(`[data-action=${type}-message]`).on('click', () => {\r\n setFlag(message, 'validated', type === 'success')\r\n })\r\n }\r\n }\r\n } else if (pf2eContext?.type === 'skill-check' && pf2eContext.pf2ePerception) {\r\n if (isGM) {\r\n if (pf2eContext.options.includes('action:hide')) {\r\n const button = createValidateButton({ property: 'visibility', skipWait, validated })\r\n html.find('.flavor-text').append(button)\r\n html.find('[data-action=validate-visibility]').on('click', () => {\r\n HideValidationMenu.openMenu({\r\n token,\r\n message,\r\n roll: message.rolls[0],\r\n selected: pf2eContext.pf2ePerception.selected,\r\n })\r\n })\r\n } else if (pf2eContext.options.includes('action:create-a-diversion')) {\r\n const button = createValidateButton({ property: 'visibility', skipWait, validated })\r\n html.find('.flavor-text').append(button)\r\n html.find('[data-action=validate-visibility]').on('click', () => {\r\n CreateADiversionMenu.openMenu({\r\n token,\r\n message,\r\n roll: message.rolls[0],\r\n selected: pf2eContext.pf2ePerception.selected,\r\n })\r\n })\r\n }\r\n } else if (hasPlayerOwner) {\r\n if (pf2eContext.options.includes('action:hide')) {\r\n addBlindSkillCheckFlavor({ token, message, html, validated, action: 'Hide' })\r\n } else if (pf2eContext.options.includes('action:create-a-diversion')) {\r\n addSkillCheckFlavor(html, validated)\r\n }\r\n }\r\n } else if (pf2eContext?.type === 'perception-check' && pf2eContext.pf2ePerception) {\r\n if (isGM) {\r\n if (pf2eContext.options.includes('action:seek')) {\r\n const buttons = createValidateCombo({\r\n skipWait,\r\n validated,\r\n smallAction: 'delete-template',\r\n smallIcon: 'fa-thin fa-cubes',\r\n smallSlashed: true,\r\n })\r\n\r\n html.find('.flavor-text').append(buttons)\r\n\r\n html.find('[data-action=validate-visibility]').on('click', () => {\r\n SeekValidationMenu.openMenu({\r\n token,\r\n message,\r\n roll: message.rolls[0],\r\n selected: pf2eContext.pf2ePerception.selected,\r\n fromTemplate: pf2eContext.pf2ePerception.fromTemplate,\r\n })\r\n })\r\n\r\n html.find('[data-action=delete-template').on('click', () => {\r\n deleteSeekTemplate(token)\r\n })\r\n }\r\n } else if (hasPlayerOwner) {\r\n if (pf2eContext.options.includes('action:seek')) {\r\n addBlindSkillCheckFlavor({ token, message, html, validated, action: 'Seek' })\r\n }\r\n }\r\n } else if (pointOut) {\r\n const selectedToken = token.scene.tokens.get(pointOut)\r\n if (!selectedToken) return\r\n\r\n if (isGM) {\r\n const buttons = createValidateCombo({\r\n skipWait,\r\n validated,\r\n smallAction: 'ping-token',\r\n smallIcon: 'fa-solid fa-signal-stream',\r\n })\r\n\r\n html.find('.message-content').append(buttons)\r\n\r\n html.find('[data-action=validate-visibility]').on('click', () => {\r\n PointOutValidationMenu.openMenu({\r\n message,\r\n token: selectedToken,\r\n originator: token,\r\n selected: canvas.tokens.controlled.map(t => t.id),\r\n })\r\n })\r\n\r\n html.find('[data-action=ping-token]').on('click', () => {\r\n canvas.ping(selectedToken.center)\r\n })\r\n } else if (hasPlayerOwner) {\r\n const hint = createWaitHint('visibility', validated)\r\n html.find('.message-content').append(hint)\r\n }\r\n }\r\n\r\n if (isGM && attackCheckRoll.includes(pf2eContext?.type)) {\r\n const tooltip = localize('message.unhide.tooltip')\r\n const button = `\r\n \r\n`\r\n\r\n html.find('.dice-result .dice-total').append(button)\r\n html.find('[data-action=unhide]').on('click', event => {\r\n event.stopPropagation()\r\n UnHideValidationMenu.openMenu({ token })\r\n })\r\n }\r\n}\r\n\r\nexport function validateMessage(message) {\r\n if (!getFlag(message, 'validated')) setFlag(message, 'validated', true)\r\n}\r\n\r\nfunction createValidateCombo({ skipWait, validated, smallIcon, smallAction, smallSlashed }) {\r\n let buttons = '
'\r\n\r\n buttons += createValidateButton({ property: 'visibility', skipWait, validated })\r\n buttons += createChatButton({\r\n action: smallAction,\r\n icon: smallIcon,\r\n slashed: smallSlashed,\r\n tooltip: localize(`message.visibility.small-button.${smallAction}`),\r\n })\r\n\r\n buttons += '
'\r\n\r\n return buttons\r\n}\r\n\r\nfunction actionTitle(action, modifier) {\r\n const skillName = game.i18n.localize(\r\n modifier === 'perception' ? 'PF2E.PerceptionLabel' : `PF2E.Skill${modifier.capitalize()}`\r\n )\r\n const check = localize('message.check')\r\n return `

\r\n ${getActionName(action)}\r\n 1\r\n (${skillName} ${check})\r\n

`\r\n}\r\n\r\nfunction addSkillCheckFlavor(html, validated) {\r\n const hint = createWaitHint('visibility', validated)\r\n html.find('.flavor-text').append(hint)\r\n}\r\n\r\nfunction addBlindSkillCheckFlavor({ html, token, message, validated, action }) {\r\n const modifier = message.getFlag('pf2e', 'modifierName')\r\n const title = actionTitle(action, modifier)\r\n\r\n html.find('.message-sender').text(token.name)\r\n html.find('.flavor-text').html(title)\r\n\r\n addSkillCheckFlavor(html, validated)\r\n}\r\n\r\nfunction createWaitHint(property, validated) {\r\n const hint = localize(`message.${property}.player.${validated ? 'validated' : 'wait'}`)\r\n return createHint(hint, validated)\r\n}\r\n\r\nfunction createHint(hint, validated) {\r\n const str =\r\n validated === true\r\n ? ` ${hint}`\r\n : validated === false\r\n ? ` ${hint}`\r\n : hint\r\n return `${str}`\r\n}\r\n\r\nfunction createValidateButton({ skipWait, validated, property }) {\r\n let label = localize(`message.${property}.gm.${skipWait ? 'check' : validated ? 'validated' : 'validate'}`)\r\n if (!skipWait && validated) label += ''\r\n return createChatButton({\r\n action: `validate-${property}`,\r\n icon: 'fa-solid fa-list',\r\n label,\r\n })\r\n}\r\n\r\nexport function createChatButton({ action, icon, label, tooltip, slashed = false }) {\r\n let button = `'\r\n\r\n return button\r\n}\r\n\r\nexport async function createTokenMessage({ content, token, flags, secret }) {\r\n const data = { content, speaker: ChatMessage.getSpeaker({ token: token instanceof Token ? token.document : token }) }\r\n if (flags) setProperty(data, `flags.${MODULE_ID}`, flags)\r\n if (secret) {\r\n data.type = CONST.CHAT_MESSAGE_TYPES.WHISPER\r\n data.whisper = ChatMessage.getWhisperRecipients('gm')\r\n }\r\n return ChatMessage.create(data)\r\n}\r\n", "import { getActorToken, getCoverEffect, isProne } from './actor.js'\r\nimport { createTokenMessage } from './chat.js'\r\nimport { VISIBILITY_VALUES, defaultValues } from './constants.js'\r\nimport { createCoverSource } from './effect.js'\r\nimport { MODULE_ID, getActionName, getSetting, localize, templatePath } from './module.js'\r\nimport { validateTokens } from './scene.js'\r\nimport { createSeekTemplate, deleteSeekTemplate } from './template.js'\r\nimport { clearTokenData, getTokenData, setTokenData } from './token.js'\r\nimport { getPrototype } from './utils.js'\r\n\r\nexport function setupActions() {\r\n const hide = game.pf2e.actions.get('hide')\r\n const BaseAction = getPrototype(hide, 2).constructor\r\n const BaseActionVariant = getPrototype(hide.toActionVariant(), 2).constructor\r\n const SingleCheckAction = getPrototype(hide, 1).constructor\r\n const SingleCheckActionVariant = getPrototype(hide.toActionVariant(), 1).constructor\r\n\r\n setupCover(BaseAction, BaseActionVariant)\r\n setupHide(SingleCheckAction, SingleCheckActionVariant)\r\n setupCreateADiversion(SingleCheckAction, SingleCheckActionVariant)\r\n setupSneak(SingleCheckAction, SingleCheckActionVariant)\r\n setupSeek(SingleCheckAction, SingleCheckActionVariant)\r\n setupPointOut(BaseAction, BaseActionVariant)\r\n}\r\n\r\nfunction setupPointOut(BaseAction, BaseActionVariant) {\r\n class PointOutVariant extends BaseActionVariant {\r\n async use(options = {}) {\r\n const action = localize('action.point-out')\r\n const token = getSelectedToken(options, action)\r\n if (token) pointOut(this, token)\r\n }\r\n }\r\n\r\n class PointOut extends BaseAction {\r\n constructor() {\r\n super({\r\n cost: 1,\r\n name: `${MODULE_ID}.action.point-out`,\r\n description: `${MODULE_ID}.action.point-out.description`,\r\n rollOptions: ['action:point-out'],\r\n slug: 'point-out',\r\n traits: ['auditory', 'manipulate', 'visual'],\r\n })\r\n }\r\n\r\n toActionVariant(data = {}) {\r\n data.name ??= this.name\r\n return new PointOutVariant(this, data)\r\n }\r\n }\r\n\r\n game.pf2e.actions.set('point-out', new PointOut())\r\n}\r\n\r\nasync function pointOut({ name, traits }, token) {\r\n const target = game.user.targets.filter(t => t.actor).first()\r\n const visibility = target ? getTokenData(target, token.id, 'visibility') : undefined\r\n const isVisible = target && VISIBILITY_VALUES[visibility] < VISIBILITY_VALUES.undetected\r\n\r\n let description\r\n if (isVisible) {\r\n const dc = target.actor.skills.stealth.dc.value\r\n description = localize('message.point-out.short-check', {\r\n check: `@Check[type:perception|dc:${dc}|traits:auditory,manipulate,visual|showDC:gm]`,\r\n })\r\n } else description = localize('message.point-out.short')\r\n\r\n const content = await renderTemplate(templatePath('point-out'), {\r\n description,\r\n name,\r\n traits: traits.map(slug => ({\r\n slug,\r\n tooltip: CONFIG.PF2E.traitsDescriptions[slug],\r\n name: CONFIG.PF2E.actionTraits[slug],\r\n })),\r\n })\r\n\r\n const flags = {\r\n pointOut: isVisible ? target.id : undefined,\r\n }\r\n\r\n createTokenMessage({ content, token, flags })\r\n}\r\n\r\nfunction setupSeek(SingleCheckAction, SingleCheckActionVariant) {\r\n class SeekVariant extends SingleCheckActionVariant {\r\n async use(options = {}) {\r\n const action = getActionName('Seek')\r\n const token = getSelectedToken(options, action)\r\n if (!token) return\r\n\r\n if (getSetting('seek-template')) {\r\n const useTemplate = await seek(token)\r\n if (!useTemplate) {\r\n return deleteSeekTemplate(token)\r\n }\r\n }\r\n\r\n options.actors = [token.actor]\r\n return super.use(options)\r\n }\r\n }\r\n\r\n class Seek extends SingleCheckAction {\r\n constructor() {\r\n super({\r\n cost: 1,\r\n description: 'PF2E.Actions.Seek.Description',\r\n name: 'PF2E.Actions.Seek.Title',\r\n notes: [\r\n { outcome: ['criticalSuccess'], text: 'PF2E.Actions.Seek.Notes.criticalSuccess' },\r\n { outcome: ['success'], text: 'PF2E.Actions.Seek.Notes.success' },\r\n ],\r\n rollOptions: ['action:seek'],\r\n slug: 'seek',\r\n statistic: 'perception',\r\n traits: ['concentrate', 'secret'],\r\n })\r\n }\r\n\r\n toActionVariant(data) {\r\n return new SeekVariant(this, data)\r\n }\r\n }\r\n\r\n game.pf2e.actions.set('seek', new Seek())\r\n}\r\n\r\nasync function seek(token) {\r\n const unit = game.i18n.localize('PF2E.Foot')\r\n\r\n let content = '

'\r\n content += `${localize('dialog.seek.hint')}

`\r\n\r\n content += createButton(\r\n 'create-cone',\r\n 'fa-thin fa-cubes',\r\n game.i18n.format('PF2E.TemplateLabel', {\r\n size: 30,\r\n unit,\r\n shape: game.i18n.localize(CONFIG.PF2E.areaTypes.cone),\r\n })\r\n )\r\n\r\n content += createButton(\r\n 'create-burst',\r\n 'fa-thin fa-cubes',\r\n game.i18n.format('PF2E.TemplateLabel', {\r\n size: 15,\r\n unit,\r\n shape: game.i18n.localize(CONFIG.PF2E.areaTypes.burst),\r\n })\r\n )\r\n\r\n content += '

'\r\n\r\n return Dialog.wait(\r\n {\r\n title: `${token.name} - ${game.i18n.localize('PF2E.Actions.Seek.Title')}`,\r\n content,\r\n buttons: {\r\n ok: {\r\n icon: '',\r\n label: localize('dialog.seek.accept'),\r\n callback: () => true,\r\n },\r\n no: {\r\n icon: '',\r\n label: localize('dialog.seek.cancel'),\r\n callback: html => false,\r\n },\r\n },\r\n close: () => false,\r\n render: html => {\r\n const content = html.filter('.dialog-content')\r\n content.find('[data-action=create-cone], [data-action=create-burst]').on('click', event => {\r\n const { action } = event.currentTarget.dataset\r\n deleteSeekTemplate(token)\r\n createSeekTemplate({ type: action === 'create-cone' ? 'cone' : 'burst', token })\r\n })\r\n },\r\n },\r\n { width: 300, left: 10 }\r\n )\r\n}\r\n\r\nfunction setupSneak(SingleCheckAction, SingleCheckActionVariant) {\r\n class SneakVariant extends SingleCheckActionVariant {\r\n async use(options = {}) {\r\n const action = getActionName('Sneak')\r\n const token = getSelectedToken(options, action)\r\n if (!token) return\r\n\r\n options.actors = [token.actor]\r\n return super.use(options)\r\n }\r\n }\r\n\r\n class Sneak extends SingleCheckAction {\r\n constructor() {\r\n super({\r\n cost: 1,\r\n description: 'PF2E.Actions.Sneak.Description',\r\n name: 'PF2E.Actions.Sneak.Title',\r\n notes: [\r\n { outcome: ['success', 'criticalSuccess'], text: 'PF2E.Actions.Sneak.Notes.success' },\r\n { outcome: ['failure'], text: 'PF2E.Actions.Sneak.Notes.failure' },\r\n { outcome: ['criticalFailure'], text: 'PF2E.Actions.Sneak.Notes.criticalFailure' },\r\n ],\r\n rollOptions: ['action:sneak'],\r\n slug: 'sneak',\r\n traits: ['move', 'secret'],\r\n })\r\n }\r\n\r\n toActionVariant(data) {\r\n return new SneakVariant(this, data)\r\n }\r\n }\r\n\r\n // game.pf2e.actions.set('sneak', new Sneak())\r\n}\r\n\r\nfunction setupCreateADiversion(SingleCheckAction, SingleCheckActionVariant) {\r\n class CreateADiversionVariant extends SingleCheckActionVariant {\r\n async use(options = {}) {\r\n const action = getActionName('CreateADiversion')\r\n const token = getSelectedToken(options, action)\r\n if (!token) return\r\n\r\n options.actors = [token.actor]\r\n return super.use(options)\r\n }\r\n }\r\n\r\n class CreateADiversion extends SingleCheckAction {\r\n constructor() {\r\n super({\r\n cost: 1,\r\n description: 'PF2E.Actions.CreateADiversion.Description',\r\n name: 'PF2E.Actions.CreateADiversion.Title',\r\n notes: [\r\n { outcome: ['criticalSuccess', 'success'], text: 'PF2E.Actions.CreateADiversion.Notes.success' },\r\n { outcome: ['criticalFailure', 'failure'], text: 'PF2E.Actions.CreateADiversion.Notes.failure' },\r\n ],\r\n section: 'skill',\r\n slug: 'create-a-diversion',\r\n statistic: 'deception',\r\n traits: ['mental'],\r\n variants: [\r\n {\r\n name: 'PF2E.Actions.CreateADiversion.DistractingWords.Title',\r\n rollOptions: ['action:create-a-diversion', 'action:create-a-diversion:distracting-words'],\r\n slug: 'distracting-words',\r\n traits: ['auditory', 'linguistic', 'mental'],\r\n },\r\n {\r\n name: 'PF2E.Actions.CreateADiversion.Gesture.Title',\r\n rollOptions: ['action:create-a-diversion', 'action:create-a-diversion:gesture'],\r\n slug: 'gesture',\r\n traits: ['manipulate', 'mental'],\r\n },\r\n {\r\n name: 'PF2E.Actions.CreateADiversion.Trick.Title',\r\n rollOptions: ['action:create-a-diversion', 'action:create-a-diversion:trick'],\r\n slug: 'trick',\r\n traits: ['manipulate', 'mental'],\r\n },\r\n ],\r\n })\r\n }\r\n\r\n toActionVariant(data) {\r\n return new CreateADiversionVariant(this, data)\r\n }\r\n }\r\n\r\n game.pf2e.actions.set('create-a-diversion', new CreateADiversion())\r\n}\r\n\r\nfunction setupHide(SingleCheckAction, SingleCheckActionVariant) {\r\n class HideVariant extends SingleCheckActionVariant {\r\n async use(options = {}) {\r\n const action = getActionName('Hide')\r\n const token = getSelectedToken(options, action)\r\n if (!token) return\r\n\r\n options.actors = [token.actor]\r\n return super.use(options)\r\n }\r\n }\r\n\r\n class Hide extends SingleCheckAction {\r\n constructor() {\r\n super({\r\n cost: 1,\r\n description: 'PF2E.Actions.Hide.Description',\r\n name: 'PF2E.Actions.Hide.Title',\r\n rollOptions: ['action:hide'],\r\n slug: 'hide',\r\n statistic: 'stealth',\r\n traits: ['secret'],\r\n notes: [{ outcome: ['success', 'criticalSuccess'], text: 'PF2E.Actions.Hide.Notes.success' }],\r\n })\r\n }\r\n\r\n toActionVariant(data) {\r\n return new HideVariant(this, data)\r\n }\r\n }\r\n\r\n game.pf2e.actions.set('hide', new Hide())\r\n}\r\n\r\nfunction setupCover(BaseAction, BaseActionVariant) {\r\n class TakeCoverVariant extends BaseActionVariant {\r\n async use(options = {}) {\r\n const action = localize('action.take-cover')\r\n const token = getSelectedToken(options, action)\r\n if (token) takeCover(token)\r\n }\r\n }\r\n\r\n class TakeCover extends BaseAction {\r\n constructor() {\r\n super({\r\n cost: 1,\r\n description: 'PF2E.Actions.TakeCover.Description',\r\n img: 'systems/pf2e/icons/conditions-2/status_acup.webp',\r\n name: 'PF2E.Actions.TakeCover.Title',\r\n slug: 'take-cover',\r\n })\r\n }\r\n\r\n toActionVariant(data) {\r\n return new TakeCoverVariant(this, data)\r\n }\r\n }\r\n\r\n game.pf2e.actions.set('take-cover', new TakeCover())\r\n}\r\n\r\nasync function takeCover(token) {\r\n const actor = token.actor\r\n const cover = getCoverEffect(actor)\r\n\r\n const targets = validateTokens(token, game.user.targets.ids)\r\n if (cover && !targets.length) return cover.delete()\r\n\r\n const data = getTokenData(token) ?? {}\r\n const covers = Object.entries(data).reduce((covers, [tokenId, { cover }]) => {\r\n if (cover) covers[tokenId] = cover\r\n return covers\r\n }, {})\r\n\r\n const content = await renderTemplate(templatePath('covers-dialog'), {\r\n i18n: localize,\r\n hasTargets: !!targets.length,\r\n hasCovers: !isEmpty(covers),\r\n hasTargetCover: targets.some(id => id in covers),\r\n isProne: isProne(actor),\r\n })\r\n\r\n const dialog = new Dialog({\r\n title: `${token.name} - ${localize('action.take-cover')}`,\r\n content,\r\n buttons: {},\r\n render: html => {\r\n html.find('button').on('click', async event => {\r\n const { level } = event.currentTarget.dataset\r\n const skip = getSetting('skip-cover')\r\n\r\n const process = async (cover, isSelected) => {\r\n const selected = isSelected ? targets : undefined\r\n\r\n const flavor = cover === defaultValues.cover ? (selected ? 'remove' : 'remove-all') : 'take'\r\n await createTokenMessage({\r\n content: localize(`message.cover.${flavor}`, { cover: localize(`cover.${cover}`) }),\r\n flags: { selected, cover, skipWait: skip },\r\n token,\r\n })\r\n\r\n if (skip) {\r\n if (cover === defaultValues.cover && !selected) return clearTokenData(token)\r\n const data = deepClone(getTokenData(token)) ?? {}\r\n for (const tokenId of targets) {\r\n setProperty(data, `${tokenId}.cover`, cover)\r\n }\r\n return setTokenData(token, data)\r\n }\r\n }\r\n\r\n if (level === 'remove-all') process(defaultValues.cover)\r\n else if (level === 'remove') process(defaultValues.cover, true)\r\n else if (targets.length) process(level, true)\r\n else {\r\n const source = createCoverSource(level)\r\n actor.createEmbeddedDocuments('Item', [source])\r\n }\r\n\r\n dialog.close()\r\n })\r\n },\r\n }).render(true)\r\n}\r\n\r\nfunction getSelectedToken(options, action) {\r\n let tokens = options.tokens?.filter(t => t.actor) ?? []\r\n if (!Array.isArray(tokens)) tokens = [tokens]\r\n\r\n let actors = options.actors ?? []\r\n if (!Array.isArray(actors)) actors = [actors]\r\n\r\n if (!tokens.length && actors.length === 1) tokens = [getActorToken(actors[0])].filter(Boolean)\r\n if (!tokens.length) tokens = canvas.tokens.controlled.filter(t => t.actor)\r\n if (!tokens.length) tokens = [getActorToken(game.user.character)].filter(Boolean)\r\n\r\n if (tokens.length > 1) {\r\n ui.notifications.warn(localize('action.only-one', { action }))\r\n return\r\n }\r\n\r\n if (!tokens.length) {\r\n ui.notifications.warn(localize('action.must-one', { action }))\r\n return\r\n }\r\n\r\n const token = tokens[0]\r\n if (!token?.actor?.isOfType('creature')) {\r\n ui.notifications.warn(localize('action.must-creature', { action }))\r\n return\r\n }\r\n\r\n return token\r\n}\r\n\r\nfunction createButton(action, icon, label) {\r\n return `\r\n`\r\n}\r\n", "import { getCoverEffect, hasGreaterDarkvision, isProne, seeInvisibility } from './actor.js'\r\nimport { clearDebug, getRectEdges, lineIntersectWall, pointToTokenIntersectWall } from './geometry.js'\r\nimport { getLightExposure } from './lighting.js'\r\nimport { getPerception, perceptionRules, updateFromPerceptionRules } from './rule-element.js'\r\nimport { getSceneSetting, getValidTokens, validateTokens } from './scene.js'\r\nimport {\r\n createDarknessTemplate,\r\n createMistTemplate,\r\n createSeekTemplate,\r\n deleteSeekTemplate,\r\n getDarknessTemplates,\r\n getMistTemplates,\r\n getSeekTemplateTokens,\r\n getTemplateTokens,\r\n} from './template.js'\r\nimport {\r\n clearConditionals,\r\n getCover,\r\n getCreatureCover,\r\n getTokenData,\r\n getVisibility,\r\n getWallCover,\r\n openHUD,\r\n showAllConditionals,\r\n showConditionals,\r\n} from './token.js'\r\n\r\nexport const API = {\r\n geometry: {\r\n clearDebug,\r\n getRectEdges,\r\n lineIntersectWall,\r\n pointToTokenIntersectWall,\r\n },\r\n token: {\r\n getCreatureCover,\r\n getWallCover,\r\n getVisibility,\r\n clearConditionals,\r\n showConditionals,\r\n showAllConditionals,\r\n getTokenData,\r\n getCover,\r\n openHUD,\r\n },\r\n lighting: {\r\n getLightExposure,\r\n },\r\n actor: {\r\n isProne,\r\n getCoverEffect,\r\n seeInvisibility,\r\n hasGreaterDarkvision,\r\n },\r\n scene: {\r\n getValidTokens,\r\n validateTokens,\r\n getSceneSetting,\r\n },\r\n template: {\r\n createSeekTemplate,\r\n createDarknessTemplate,\r\n createMistTemplate,\r\n getDarknessTemplates,\r\n getMistTemplates,\r\n getSeekTemplateTokens,\r\n deleteSeekTemplate,\r\n getTemplateTokens,\r\n },\r\n ruleElement: {\r\n perceptionRules,\r\n getPerception,\r\n updateFromPerceptionRules,\r\n },\r\n}\r\n", "import { getActorToken, getCoverEffect, isProne } from './actor.js'\r\nimport { COVERS, COVER_UUID, VISIBILITY_VALUES, attackCheckRoll, validCheckRoll } from './constants.js'\r\nimport { createCoverSource, findChoiceSetRule } from './effect.js'\r\nimport { MODULE_ID, getFlag, getSetting, localize } from './module.js'\r\nimport { getPerception, perceptionRules } from './rule-element.js'\r\nimport { validateTokens } from './scene.js'\r\nimport { getSeekTemplateTokens } from './template.js'\r\nimport { getVisibility } from './token.js'\r\nimport { asNumberOnly } from './utils.js'\r\n\r\nexport async function checkRoll(wrapped, ...args) {\r\n const context = args[1]\r\n if (!context) return wrapped(...args)\r\n\r\n if (Array.isArray(context.options)) context.options = new Set(context.options)\r\n\r\n const { actor, createMessage = 'true', type, token, target, isReroll } = context\r\n const originToken = token ?? getActorToken(actor)\r\n const targetToken = target?.token\r\n const isAttackRoll = attackCheckRoll.includes(type)\r\n const flatCheck = getSetting('flat-check')\r\n\r\n if (\r\n isReroll ||\r\n !createMessage ||\r\n !originToken ||\r\n actor.isOfType('hazard') ||\r\n !validCheckRoll.includes(type) ||\r\n (isAttackRoll && (!targetToken || flatCheck === 'none'))\r\n )\r\n return wrapped(...args)\r\n\r\n if (isAttackRoll && targetToken.actor) {\r\n const event = args[2]\r\n const perception = perceptionRules(originToken, targetToken, {\r\n extraOptions: context.options.filter(o => o.startsWith('item:')),\r\n })\r\n\r\n const visibility = getVisibility(targetToken, originToken, { perception, affects: 'target' })\r\n if (!visibility) return wrapped(...args)\r\n\r\n const dc = (() => {\r\n const dc = getPerception(perception, 'target', 'visibility', 'dc', visibility)?.first()\r\n const numberedDC = asNumberOnly(dc)\r\n if (!numberedDC) return numberedDC\r\n\r\n const sign = dc[0]\r\n if (!['-', '+'].includes(sign)) return numberedDC\r\n\r\n return (visibility === 'concealed' ? 5 : 11) + numberedDC\r\n })()\r\n if (dc === 0) return wrapped(...args)\r\n\r\n const isUndetected = VISIBILITY_VALUES[visibility] >= VISIBILITY_VALUES.undetected\r\n const isBlind = event?.ctrlKey || event?.metaKey\r\n\r\n const roll = await new originToken.actor.saves.reflex.constructor(originToken.actor, {\r\n slug: 'visibility-check',\r\n label: `${game.i18n.localize('PF2E.FlatCheck')}: ${game.i18n.localize(`PF2E.condition.${visibility}.name`)}`,\r\n check: { type: 'flat-check' },\r\n }).roll({\r\n dc: { value: dc ?? (visibility === 'concealed' ? 5 : 11) },\r\n target: targetToken.actor,\r\n rollMode: isUndetected || isBlind ? (game.user.isGM ? 'gmroll' : 'blindroll') : 'roll',\r\n })\r\n\r\n const isSuccess = roll.degreeOfSuccess > 1\r\n\r\n if (isUndetected) {\r\n context.options.add('secret')\r\n context.pf2ePerception = {\r\n isSuccess: isSuccess,\r\n visibility,\r\n }\r\n }\r\n\r\n if (flatCheck !== 'roll' && !isUndetected && !isSuccess) return\r\n } else if (context.options.has('action:hide')) {\r\n setProperty(context, 'pf2ePerception.selected', game.user.targets.ids)\r\n // } else if (context.options.has('action:sneak')) {\r\n // context.selected = game.user.targets.ids\r\n } else if (context.options.has('action:create-a-diversion')) {\r\n setProperty(context, 'pf2ePerception.selected', game.user.targets.ids)\r\n } else if (context.options.has('action:seek')) {\r\n const highlighted = getSeekTemplateTokens(originToken)\r\n const tokens = highlighted ?? Array.from(game.user.targets)\r\n const selected = validateTokens(originToken, tokens)\r\n .filter(t => !t.document.hidden)\r\n .map(t => t.id)\r\n\r\n setProperty(context, 'pf2ePerception.selected', selected)\r\n setProperty(context, 'pf2ePerception.fromTemplate', !!highlighted)\r\n }\r\n\r\n return wrapped(...args)\r\n}\r\n\r\nexport function renderCheckModifiersDialog(dialog, html) {\r\n const { createMessage = 'true', type, token, target, isReroll, options, dc } = dialog.context\r\n const originToken = token\r\n const targetToken = target?.token\r\n const targetActor = target?.actor\r\n\r\n if (isReroll || !createMessage || !originToken || !targetToken || !targetActor || !attackCheckRoll.includes(type)) return\r\n\r\n const coverEffect = getCoverEffect(targetActor)\r\n const currentCover = coverEffect\r\n ? findChoiceSetRule(coverEffect)?.selection.level ?? getFlag(coverEffect, 'level')\r\n : undefined\r\n let coverOverride = dialog[MODULE_ID]?.coverOverride ?? currentCover\r\n\r\n let template = '
'\r\n template += `
${localize('dice-checks.cover.label')}
`\r\n template += `
'\r\n\r\n // visibility override here\r\n\r\n template += '
'\r\n\r\n html.find('.roll-mode-panel').before(template)\r\n\r\n html.find('select[name=overrideCover]').on('change', event => {\r\n const value = event.currentTarget.value || undefined\r\n setProperty(dialog, `${MODULE_ID}.coverOverride`, value)\r\n coverOverride = value\r\n })\r\n\r\n html.find('button.roll')[0].addEventListener(\r\n 'click',\r\n event => {\r\n event.preventDefault()\r\n event.stopPropagation()\r\n event.stopImmediatePropagation()\r\n\r\n let modified = false\r\n const items = deepClone(targetActor._source.items)\r\n\r\n if (coverOverride !== currentCover) {\r\n modified = true\r\n\r\n const coverIndex = items.findIndex(i => getProperty(i, 'flags.core.sourceId') === COVER_UUID)\r\n if (coverIndex !== -1) items.splice(coverIndex, 1)\r\n\r\n if (coverOverride) {\r\n const source = createCoverSource(coverOverride)\r\n items.push(source)\r\n }\r\n }\r\n\r\n if (modified) {\r\n target.actor = targetActor.clone({ items }, { keepId: true })\r\n\r\n if (dc?.slug) {\r\n const statistic = target.actor.getStatistic(dc.slug)?.dc\r\n if (statistic) {\r\n dc.value = statistic.value\r\n dc.statistic = statistic\r\n }\r\n }\r\n }\r\n\r\n dialog.resolve(true)\r\n dialog.isResolved = true\r\n dialog.close()\r\n },\r\n true\r\n )\r\n\r\n dialog.setPosition()\r\n}\r\n", "import { getSetting, localize, setSetting } from './module.js'\r\n\r\nexport function renderCombatTracker(tracker, html) {\r\n if (getSetting('target')) setupToggleTarget(html)\r\n // hideUndetected(html)\r\n}\r\n\r\nfunction hideUndetected(html) {\r\n if (!canvas.ready) return\r\n\r\n const combatants = game.combats.viewed?.combatants\r\n if (!combatants?.size) return\r\n\r\n html.find('#combat-tracker .combatant').each((i, li) => {\r\n const { combatantId } = li.dataset\r\n const token = combatants.get(combatantId ?? '')?.token\r\n if (!token) return\r\n\r\n // if (isUndetected(token, 'basicSight', true)) li.remove()\r\n })\r\n}\r\n\r\nfunction setupToggleTarget(html) {\r\n html.find('[data-control=toggleTarget]').each((_, el) => {\r\n el.addEventListener(\r\n 'click',\r\n event => {\r\n event.preventDefault()\r\n event.stopPropagation()\r\n event.stopImmediatePropagation()\r\n\r\n const { combatantId } = event.currentTarget.closest('.combatant').dataset\r\n const combatant = game.combats.viewed.combatants.get(combatantId ?? '')\r\n const token = combatant?.token\r\n if (!token) return\r\n\r\n const isTargeted = Array.from(game.user.targets).some(t => t.document === token)\r\n token.object.setTarget(!isTargeted, { releaseOthers: !event.shiftKey })\r\n },\r\n true\r\n )\r\n })\r\n}\r\n\r\nexport function renderCombatTrackerConfig(config, html) {\r\n const checked = getSetting('encounter')\r\n\r\n html.find('.form-group').last().after(`
\r\n \r\n \r\n

${localize('settings.encounter.short')}

\r\n
`)\r\n\r\n html.find('input[name=\"pf2e-perception.encounter\"]').on('change', event => {\r\n const checked = event.currentTarget.checked\r\n setSetting('encounter', checked)\r\n })\r\n}\r\n", "import { VISIBILITY_VALUES } from './constants.js'\r\nimport { perceptionRules } from './rule-element.js'\r\nimport { getVisibility } from './token.js'\r\n\r\nexport function detectionModeTestVisibility(visionSource, mode, config = {}) {\r\n if (!mode.enabled) return false\r\n if (!this._canDetect(visionSource, config.object, config)) return false\r\n return config.tests.some(test => this._testPoint(visionSource, mode, config.object, test))\r\n}\r\n\r\nexport function basicSightCanDetect(visionSource, target, config) {\r\n if (target instanceof PlaceableObject && target.document.hidden) return false\r\n if (!(target instanceof Token)) return true\r\n\r\n const origin = visionSource.object\r\n const originDocument = origin.document\r\n if (originDocument instanceof TokenDocument && originDocument.hasStatusEffect(CONFIG.specialStatusEffects.BLIND)) return false\r\n\r\n if (!(origin instanceof Token)) {\r\n return (\r\n !target.document?.hasStatusEffect(CONFIG.specialStatusEffects.INVISIBLE) &&\r\n !target.actor?.hasCondition('hidden', 'undetected', 'unnoticed')\r\n )\r\n }\r\n\r\n return !reachesThreshold(origin, target, VISIBILITY_VALUES.hidden, config)\r\n}\r\n\r\nexport function hearingCanDetect(visionSource, target, config) {\r\n if (target.document.hidden || !(target instanceof Token) || !target.actor?.emitsSound) return false\r\n if (!game.settings.get('pf2e', 'automation.rulesBasedVision')) return true\r\n\r\n const origin = visionSource.object\r\n if (origin.actor?.hasCondition('deafened')) return false\r\n\r\n if (!(origin instanceof Token)) {\r\n return !target.actor?.hasCondition('undetected', 'unnoticed')\r\n }\r\n\r\n return !reachesThreshold(origin, target, VISIBILITY_VALUES.undetected, config)\r\n}\r\n\r\nexport function feelTremorCanDetect(visionSource, target, config) {\r\n if (\r\n target.document.hidden ||\r\n !(target instanceof Token) ||\r\n target.document.elevation > canvas.primary.background.elevation ||\r\n target.actor?.isOfType('loot')\r\n )\r\n return false\r\n\r\n const origin = visionSource.object\r\n if (!(origin instanceof Token)) {\r\n return !target.actor?.hasCondition('undetected', 'unnoticed')\r\n }\r\n\r\n return !reachesThreshold(origin, target, VISIBILITY_VALUES.undetected, config)\r\n}\r\n\r\nfunction reachesThreshold(origin, target, threshold, config = {}) {\r\n if (!config.visibility) {\r\n const perception = perceptionRules(origin, target)\r\n config.visibility = getVisibility(target, origin, { perception, affects: 'target' })\r\n }\r\n\r\n return VISIBILITY_VALUES[config.visibility] >= threshold\r\n}\r\n", "function purry(fn, args, lazy) {\r\n const diff = fn.length - args.length\r\n const arrayArgs = Array.from(args)\r\n if (diff === 0) {\r\n return fn(...arrayArgs)\r\n }\r\n if (diff === 1) {\r\n const ret = data => fn(data, ...arrayArgs)\r\n if (lazy || fn.lazy) {\r\n ret.lazy = lazy || fn.lazy\r\n ret.lazyArgs = args\r\n }\r\n return ret\r\n }\r\n throw new Error('Wrong number of arguments')\r\n}\r\n\r\nfunction _reduceLazy(array, lazy, indexed) {\r\n const newArray = []\r\n // We intentionally use a for loop here instead of reduce for performance reasons. See https://leanylabs.com/blog/js-forEach-map-reduce-vs-for-for_of/ for more info\r\n for (let index = 0; index < array.length; index++) {\r\n const item = array[index]\r\n const result = indexed ? lazy(item, index, array) : lazy(item)\r\n if (result.hasMany === true) {\r\n newArray.push(...result.next)\r\n } else if (result.hasNext) {\r\n newArray.push(result.next)\r\n }\r\n }\r\n return newArray\r\n}\r\n\r\nfunction uniqLazy() {\r\n const set = new Set()\r\n return value => {\r\n if (set.has(value)) {\r\n return {\r\n done: false,\r\n hasNext: false,\r\n }\r\n }\r\n set.add(value)\r\n return {\r\n done: false,\r\n hasNext: true,\r\n next: value,\r\n }\r\n }\r\n}\r\n\r\nfunction _uniq(array) {\r\n return _reduceLazy(array, uniqLazy())\r\n}\r\n\r\nexport const R = {\r\n compact: arr => arr.filter(Boolean),\r\n uniq: function () {\r\n return purry(_uniq, arguments, uniqLazy)\r\n },\r\n}\r\n", "import { isObject } from './helpers.js'\r\n\r\nexport class PredicatePF2e extends Array {\r\n constructor(...statements) {\r\n super(...(Array.isArray(statements[0]) ? statements[0] : statements))\r\n this.isValid = PredicatePF2e.isValid(this)\r\n }\r\n\r\n /** Structurally validate the predicates */\r\n static isValid(statements) {\r\n return this.isArray(statements)\r\n }\r\n\r\n /** Is this an array of predicatation statements? */\r\n static isArray(statements) {\r\n return super.isArray(statements) && statements.every(s => StatementValidator.isStatement(s))\r\n }\r\n\r\n /** Test if the given predicate passes for the given list of options. */\r\n static test(predicate = [], options) {\r\n return predicate instanceof PredicatePF2e ? predicate.test(options) : new PredicatePF2e(...predicate).test(options)\r\n }\r\n\r\n /** Test this predicate against a domain of discourse */\r\n test(options) {\r\n if (this.length === 0) {\r\n return true\r\n } else if (!this.isValid) {\r\n console.warn('PF2e System | The provided predicate set is malformed.')\r\n return false\r\n }\r\n\r\n const domain = options instanceof Set ? options : new Set(options)\r\n return this.every(s => this.#isTrue(s, domain))\r\n }\r\n\r\n toObject() {\r\n return deepClone([...this])\r\n }\r\n\r\n clone() {\r\n return new PredicatePF2e(this.toObject())\r\n }\r\n\r\n /** Is the provided statement true? */\r\n #isTrue(statement, domain) {\r\n return (\r\n (typeof statement === 'string' && domain.has(statement)) ||\r\n (StatementValidator.isBinaryOp(statement) && this.#testBinaryOp(statement, domain)) ||\r\n (StatementValidator.isCompound(statement) && this.#testCompound(statement, domain))\r\n )\r\n }\r\n\r\n #testBinaryOp(statement, domain) {\r\n if ('eq' in statement) {\r\n return domain.has(`${statement.eq[0]}:${statement.eq[1]}`)\r\n } else {\r\n const operator = Object.keys(statement)[0]\r\n\r\n // Allow for tests of partial statements against numeric values\r\n // E.g., `{ \"gt\": [\"actor:level\", 5] }` would match against \"actor:level:6\" and \"actor:level:7\"\r\n const [left, right] = Object.values(statement)[0]\r\n const domainArray = Array.from(domain)\r\n const getValues = operand => {\r\n const maybeNumber = Number(operand)\r\n if (!Number.isNaN(maybeNumber)) return [maybeNumber]\r\n const pattern = new RegExp(String.raw`^${operand}:([^:]+)$`)\r\n const values = domainArray.map(s => Number(pattern.exec(s)?.[1] || NaN)).filter(v => !Number.isNaN(v))\r\n return values.length > 0 ? values : [NaN]\r\n }\r\n const leftValues = getValues(left)\r\n const rightValues = getValues(right)\r\n\r\n switch (operator) {\r\n case 'gt':\r\n return leftValues.some(l => rightValues.every(r => l > r))\r\n case 'gte':\r\n return leftValues.some(l => rightValues.every(r => l >= r))\r\n case 'lt':\r\n return leftValues.some(l => rightValues.every(r => l < r))\r\n case 'lte':\r\n return leftValues.some(l => rightValues.every(r => l <= r))\r\n default:\r\n console.warn('PF2e System | Malformed binary operation encountered')\r\n return false\r\n }\r\n }\r\n }\r\n\r\n /** Is the provided compound statement true? */\r\n #testCompound(statement, domain) {\r\n return (\r\n ('and' in statement && statement.and.every(subProp => this.#isTrue(subProp, domain))) ||\r\n ('nand' in statement && !statement.nand.every(subProp => this.#isTrue(subProp, domain))) ||\r\n ('or' in statement && statement.or.some(subProp => this.#isTrue(subProp, domain))) ||\r\n ('xor' in statement && statement.xor.filter(subProp => this.#isTrue(subProp, domain)).length === 1) ||\r\n ('nor' in statement && !statement.nor.some(subProp => this.#isTrue(subProp, domain))) ||\r\n ('not' in statement && !this.#isTrue(statement.not, domain)) ||\r\n ('if' in statement && !(this.#isTrue(statement.if, domain) && !this.#isTrue(statement.then, domain)))\r\n )\r\n }\r\n}\r\n\r\nclass StatementValidator {\r\n static isStatement(statement) {\r\n return statement instanceof Object\r\n ? this.isCompound(statement) || this.isBinaryOp(statement)\r\n : typeof statement === 'string'\r\n ? this.isAtomic(statement)\r\n : false\r\n }\r\n\r\n static isAtomic(statement) {\r\n return (typeof statement === 'string' && statement.length > 0) || this.isBinaryOp(statement)\r\n }\r\n\r\n static #binaryOperators = new Set(['eq', 'gt', 'gte', 'lt', 'lte'])\r\n\r\n static isBinaryOp(statement) {\r\n if (!isObject(statement)) return false\r\n const entries = Object.entries(statement)\r\n if (entries.length > 1) return false\r\n const [operator, operands] = entries[0]\r\n return (\r\n this.#binaryOperators.has(operator) &&\r\n Array.isArray(operands) &&\r\n operands.length === 2 &&\r\n typeof operands[0] === 'string' &&\r\n ['string', 'number'].includes(typeof operands[1])\r\n )\r\n }\r\n\r\n static isCompound(statement) {\r\n return (\r\n isObject(statement) &&\r\n (this.isAnd(statement) ||\r\n this.isOr(statement) ||\r\n this.isNand(statement) ||\r\n this.isXor(statement) ||\r\n this.isNor(statement) ||\r\n this.isNot(statement) ||\r\n this.isIf(statement))\r\n )\r\n }\r\n\r\n static isAnd(statement) {\r\n return (\r\n Object.keys(statement).length === 1 &&\r\n Array.isArray(statement.and) &&\r\n statement.and.every(subProp => this.isStatement(subProp))\r\n )\r\n }\r\n\r\n static isNand(statement) {\r\n return (\r\n Object.keys(statement).length === 1 &&\r\n Array.isArray(statement.nand) &&\r\n statement.nand.every(subProp => this.isStatement(subProp))\r\n )\r\n }\r\n\r\n static isOr(statement) {\r\n return (\r\n Object.keys(statement).length === 1 &&\r\n Array.isArray(statement.or) &&\r\n statement.or.every(subProp => this.isStatement(subProp))\r\n )\r\n }\r\n\r\n static isXor(statement) {\r\n return (\r\n Object.keys(statement).length === 1 &&\r\n Array.isArray(statement.xor) &&\r\n statement.xor.every(subProp => this.isStatement(subProp))\r\n )\r\n }\r\n\r\n static isNor(statement) {\r\n return (\r\n Object.keys(statement).length === 1 &&\r\n Array.isArray(statement.nor) &&\r\n statement.nor.every(subProp => this.isStatement(subProp))\r\n )\r\n }\r\n\r\n static isNot(statement) {\r\n return Object.keys(statement).length === 1 && !!statement.not && this.isStatement(statement.not)\r\n }\r\n\r\n static isIf(statement) {\r\n return Object.keys(statement).length === 2 && this.isStatement(statement.if) && this.isStatement(statement.then)\r\n }\r\n}\r\n", "import { PredicatePF2e } from './predicate'\r\n\r\nconst WEAPON_PROPERTY_RUNES = {\r\n ancestralEchoing: {\r\n level: 15,\r\n name: 'PF2E.WeaponPropertyRune.ancestralEchoing.Name',\r\n price: 9500,\r\n rarity: 'rare',\r\n slug: 'ancestralEchoing',\r\n traits: ['dwarf', 'magical', 'saggorak'],\r\n },\r\n anchoring: {\r\n damage: {\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.anchoring.Name',\r\n text: 'PF2E.WeaponPropertyRune.anchoring.Note.criticalSuccess',\r\n },\r\n ],\r\n },\r\n level: 10,\r\n name: 'PF2E.WeaponPropertyRune.anchoring.Name',\r\n price: 900,\r\n rarity: 'uncommon',\r\n slug: 'anchoring',\r\n traits: ['magical'],\r\n },\r\n ashen: {\r\n damage: {\r\n dice: [\r\n {\r\n damageType: 'fire',\r\n category: 'persistent',\r\n diceNumber: 1,\r\n dieSize: 'd4',\r\n },\r\n ],\r\n notes: [\r\n {\r\n outcome: ['success'],\r\n title: 'PF2E.WeaponPropertyRune.ashen.Name',\r\n text: 'PF2E.WeaponPropertyRune.ashen.Note.success',\r\n },\r\n ],\r\n },\r\n level: 9,\r\n name: 'PF2E.WeaponPropertyRune.ashen.Name',\r\n price: 700,\r\n rarity: 'common',\r\n slug: 'ashen',\r\n traits: ['magical'],\r\n },\r\n astral: {\r\n level: 8,\r\n name: 'PF2E.WeaponPropertyRune.astral.Name',\r\n price: 450,\r\n rarity: 'common',\r\n slug: 'astral',\r\n traits: ['magical', 'spirit'],\r\n damage: {\r\n dice: [{ damageType: 'spirit', diceNumber: 1, dieSize: 'd6' }],\r\n },\r\n },\r\n authorized: {\r\n level: 3,\r\n name: 'PF2E.WeaponPropertyRune.authorized.Name',\r\n price: 50,\r\n rarity: 'common',\r\n slug: 'authorized',\r\n traits: ['magical'],\r\n },\r\n bane: {\r\n level: 4,\r\n name: 'PF2E.WeaponPropertyRune.bane.Name',\r\n price: 100,\r\n rarity: 'uncommon',\r\n slug: 'bane',\r\n traits: ['magical'],\r\n },\r\n bloodbane: {\r\n level: 8,\r\n name: 'PF2E.WeaponPropertyRune.bloodbane.Name',\r\n price: 475,\r\n rarity: 'uncommon',\r\n slug: 'bloodbane',\r\n traits: ['dwarf', 'magical'],\r\n },\r\n bloodthirsty: {\r\n damage: {\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.bloodbane.Name',\r\n text: 'PF2E.WeaponPropertyRune.bloodthirsty.Note.criticalSuccess',\r\n },\r\n ],\r\n },\r\n level: 16,\r\n name: 'PF2E.WeaponPropertyRune.bloodthirsty.Name',\r\n price: 8500,\r\n rarity: 'uncommon',\r\n slug: 'bloodthirsty',\r\n traits: ['magical'],\r\n },\r\n brilliant: {\r\n damage: {\r\n dice: [\r\n { damageType: 'fire', diceNumber: 1, dieSize: 'd4' },\r\n {\r\n damageType: 'spirit',\r\n diceNumber: 1,\r\n dieSize: 'd4',\r\n predicate: ['target:trait:fiend'],\r\n },\r\n {\r\n damageType: 'vitality',\r\n diceNumber: 1,\r\n dieSize: 'd4',\r\n predicate: ['target:negative-healing'],\r\n },\r\n ],\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.brilliant.Name',\r\n text: 'PF2E.WeaponPropertyRune.brilliant.Note.criticalSuccess',\r\n },\r\n ],\r\n },\r\n level: 12,\r\n name: 'PF2E.WeaponPropertyRune.brilliant.Name',\r\n price: 2000,\r\n rarity: 'common',\r\n slug: 'brilliant',\r\n traits: ['magical'],\r\n },\r\n called: {\r\n level: 7,\r\n name: 'PF2E.WeaponPropertyRune.called.Name',\r\n price: 350,\r\n rarity: 'common',\r\n slug: 'called',\r\n traits: ['magical'],\r\n },\r\n coating: {\r\n level: 9,\r\n name: 'PF2E.WeaponPropertyRune.coating.Name',\r\n price: 700,\r\n rarity: 'common',\r\n slug: 'coating',\r\n traits: ['extradimensional', 'magical'],\r\n },\r\n conducting: {\r\n level: 7,\r\n name: 'PF2E.WeaponPropertyRune.conducting.Name',\r\n price: 300,\r\n rarity: 'common',\r\n slug: 'conducting',\r\n traits: ['magical'],\r\n },\r\n corrosive: {\r\n damage: {\r\n dice: [{ damageType: 'acid', diceNumber: 1, dieSize: 'd6' }],\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.corrosive.Name',\r\n text: 'PF2E.WeaponPropertyRune.corrosive.Note.criticalSuccess',\r\n },\r\n ],\r\n },\r\n level: 8,\r\n name: 'PF2E.WeaponPropertyRune.corrosive.Name',\r\n price: 500,\r\n rarity: 'common',\r\n slug: 'corrosive',\r\n traits: ['acid', 'magical'],\r\n },\r\n crushing: {\r\n damage: {\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.crushing.Name',\r\n text: 'PF2E.WeaponPropertyRune.crushing.Note.criticalSuccess',\r\n },\r\n ],\r\n },\r\n level: 3,\r\n name: 'PF2E.WeaponPropertyRune.crushing.Name',\r\n price: 50,\r\n rarity: 'uncommon',\r\n slug: 'crushing',\r\n traits: ['magical'],\r\n },\r\n cunning: {\r\n level: 5,\r\n name: 'PF2E.WeaponPropertyRune.cunning.Name',\r\n price: 140,\r\n rarity: 'common',\r\n slug: 'cunning',\r\n traits: ['magical'],\r\n },\r\n dancing: {\r\n level: 13,\r\n name: 'PF2E.WeaponPropertyRune.dancing.Name',\r\n price: 2700,\r\n rarity: 'uncommon',\r\n slug: 'dancing',\r\n traits: ['magical'],\r\n },\r\n decaying: {\r\n damage: {\r\n dice: [\r\n {\r\n slug: 'decaying',\r\n damageType: 'void',\r\n diceNumber: 1,\r\n dieSize: 'd4',\r\n },\r\n {\r\n slug: 'decaying-persistent',\r\n category: 'persistent',\r\n damageType: 'void',\r\n diceNumber: 2,\r\n dieSize: 'd4',\r\n critical: true,\r\n },\r\n ],\r\n },\r\n level: 8,\r\n name: 'PF2E.WeaponPropertyRune.decaying.Name',\r\n price: 500,\r\n rarity: 'common',\r\n slug: 'decaying',\r\n traits: ['acid', 'magical', 'void'],\r\n },\r\n deathdrinking: {\r\n damage: {\r\n dice: [\r\n {\r\n slug: 'deathdrinking-negative',\r\n damageType: 'void',\r\n diceNumber: 1,\r\n dieSize: 'd6',\r\n critical: true,\r\n predicate: ['target:mode:living', { not: 'target:negative-healing' }],\r\n },\r\n {\r\n slug: 'deathdrinking-positive',\r\n damageType: 'vitality',\r\n diceNumber: 1,\r\n dieSize: 'd6',\r\n critical: true,\r\n predicate: ['target:negative-healing'],\r\n },\r\n ],\r\n },\r\n level: 7,\r\n name: 'PF2E.WeaponPropertyRune.deathdrinking.Name',\r\n price: 360,\r\n rarity: 'rare',\r\n slug: 'deathdrinking',\r\n traits: ['magical'],\r\n },\r\n demolishing: {\r\n damage: {\r\n dice: [\r\n {\r\n damageType: 'force',\r\n category: 'persistent',\r\n diceNumber: 1,\r\n dieSize: 'd6',\r\n predicate: ['target:trait:construct'],\r\n },\r\n ],\r\n },\r\n level: 6,\r\n name: 'PF2E.WeaponPropertyRune.demolishing.Name',\r\n price: 225,\r\n rarity: 'rare',\r\n slug: 'demolishing',\r\n traits: ['magical'],\r\n },\r\n disrupting: {\r\n damage: {\r\n dice: [\r\n {\r\n category: 'persistent',\r\n damageType: 'vitality',\r\n diceNumber: 1,\r\n dieSize: 'd6',\r\n predicate: ['target:negative-healing'],\r\n },\r\n ],\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.disrupting.Name',\r\n text: 'PF2E.WeaponPropertyRune.disrupting.Note.criticalSuccess',\r\n predicate: ['target:negative-healing'],\r\n },\r\n ],\r\n },\r\n level: 5,\r\n name: 'PF2E.WeaponPropertyRune.disrupting.Name',\r\n price: 150,\r\n rarity: 'common',\r\n slug: 'disrupting',\r\n traits: ['magical'],\r\n },\r\n earthbinding: {\r\n level: 5,\r\n name: 'PF2E.WeaponPropertyRune.earthbinding.Name',\r\n price: 125,\r\n rarity: 'common',\r\n slug: 'earthbinding',\r\n traits: ['magical'],\r\n },\r\n energizing: {\r\n level: 6,\r\n name: 'PF2E.WeaponPropertyRune.energizing.Name',\r\n price: 250,\r\n rarity: 'uncommon',\r\n slug: 'energizing',\r\n traits: ['magical'],\r\n },\r\n extending: {\r\n level: 7,\r\n name: 'PF2E.WeaponPropertyRune.extending.Name',\r\n price: 700,\r\n rarity: 'common',\r\n slug: 'extending',\r\n traits: ['magical'],\r\n },\r\n fanged: {\r\n level: 2,\r\n name: 'PF2E.WeaponPropertyRune.fanged.Name',\r\n price: 30,\r\n rarity: 'uncommon',\r\n slug: 'fanged',\r\n traits: ['magical'],\r\n },\r\n fearsome: {\r\n damage: {\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.fearsome.Name',\r\n text: 'PF2E.WeaponPropertyRune.fearsome.Note.criticalSuccess',\r\n },\r\n ],\r\n },\r\n level: 5,\r\n name: 'PF2E.WeaponPropertyRune.fearsome.Name',\r\n price: 160,\r\n rarity: 'common',\r\n slug: 'fearsome',\r\n traits: ['emotion', 'fear', 'magical', 'mental'],\r\n },\r\n flaming: {\r\n damage: {\r\n dice: [\r\n { damageType: 'fire', diceNumber: 1, dieSize: 'd6' },\r\n {\r\n damageType: 'fire',\r\n category: 'persistent',\r\n diceNumber: 1,\r\n dieSize: 'd10',\r\n critical: true,\r\n },\r\n ],\r\n },\r\n level: 8,\r\n name: 'PF2E.WeaponPropertyRune.flaming.Name',\r\n price: 500,\r\n rarity: 'common',\r\n slug: 'flaming',\r\n traits: ['fire', 'magical'],\r\n },\r\n flurrying: {\r\n level: 7,\r\n name: 'PF2E.WeaponPropertyRune.flurrying.Name',\r\n price: 360,\r\n rarity: 'common',\r\n slug: 'flurrying',\r\n traits: ['magical'],\r\n },\r\n frost: {\r\n damage: {\r\n dice: [{ damageType: 'cold', diceNumber: 1, dieSize: 'd6' }],\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.frost.Name',\r\n text: 'PF2E.WeaponPropertyRune.frost.Note.criticalSuccess',\r\n },\r\n ],\r\n },\r\n level: 8,\r\n name: 'PF2E.WeaponPropertyRune.frost.Name',\r\n price: 500,\r\n rarity: 'common',\r\n slug: 'frost',\r\n traits: ['cold', 'magical'],\r\n },\r\n ghostTouch: {\r\n level: 4,\r\n name: 'PF2E.WeaponPropertyRune.ghostTouch.Name',\r\n price: 75,\r\n rarity: 'common',\r\n slug: 'ghostTouch',\r\n traits: ['magical'],\r\n },\r\n giantKilling: {\r\n damage: {\r\n dice: [\r\n {\r\n slug: 'giantKilling',\r\n damageType: 'mental',\r\n diceNumber: 1,\r\n dieSize: 'd6',\r\n predicate: ['target:trait:giant'],\r\n },\r\n ],\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n predicate: ['target:trait:giant'],\r\n title: 'PF2E.WeaponPropertyRune.giantKilling.Name',\r\n text: 'PF2E.WeaponPropertyRune.giantKilling.Note.criticalSuccess',\r\n },\r\n ],\r\n },\r\n level: 8,\r\n name: 'PF2E.WeaponPropertyRune.giantKilling.Name',\r\n price: 450,\r\n rarity: 'rare',\r\n slug: 'giantKilling',\r\n traits: ['magical'],\r\n },\r\n greaterAnchoring: {\r\n damage: {\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.greaterAnchoring.Name',\r\n text: 'PF2E.WeaponPropertyRune.greaterAnchoring.Note.criticalSuccess',\r\n },\r\n {\r\n outcome: ['success'],\r\n title: 'PF2E.WeaponPropertyRune.greaterAnchoring.Name',\r\n text: 'PF2E.WeaponPropertyRune.greaterAnchoring.Note.success',\r\n },\r\n ],\r\n },\r\n level: 18,\r\n name: 'PF2E.WeaponPropertyRune.greaterAnchoring.Name',\r\n price: 22_000,\r\n rarity: 'uncommon',\r\n slug: 'greaterAnchoring',\r\n traits: ['magical'],\r\n },\r\n greaterAshen: {\r\n damage: {\r\n dice: [\r\n {\r\n damageType: 'fire',\r\n category: 'persistent',\r\n diceNumber: 1,\r\n dieSize: 'd8',\r\n },\r\n ],\r\n notes: [\r\n {\r\n outcome: ['success'],\r\n title: 'PF2E.WeaponPropertyRune.greaterAshen.Name',\r\n text: 'PF2E.WeaponPropertyRune.greaterAshen.Note.success',\r\n },\r\n ],\r\n },\r\n level: 16,\r\n name: 'PF2E.WeaponPropertyRune.greaterAshen.Name',\r\n price: 9000,\r\n rarity: 'common',\r\n slug: 'greaterAshen',\r\n traits: ['magical'],\r\n },\r\n greaterAstral: {\r\n level: 15,\r\n name: 'PF2E.WeaponPropertyRune.greaterAstral.Name',\r\n price: 6000,\r\n rarity: 'common',\r\n slug: 'greaterAstral',\r\n traits: ['magical', 'spirit'],\r\n damage: {\r\n dice: [{ damageType: 'spirit', diceNumber: 1, dieSize: 'd6' }],\r\n ignoredResistances: [{ type: 'spirit', max: null }],\r\n },\r\n },\r\n greaterBloodbane: {\r\n level: 13,\r\n name: 'PF2E.WeaponPropertyRune.greaterBloodbane.Name',\r\n price: 2800,\r\n rarity: 'uncommon',\r\n slug: 'greaterBloodbane',\r\n traits: ['dwarf', 'magical'],\r\n },\r\n greaterBrilliant: {\r\n damage: {\r\n dice: [\r\n { damageType: 'fire', diceNumber: 1, dieSize: 'd4' },\r\n {\r\n damageType: 'spirit',\r\n diceNumber: 1,\r\n dieSize: 'd4',\r\n predicate: ['target:trait:fiend'],\r\n },\r\n {\r\n damageType: 'vitality',\r\n diceNumber: 1,\r\n dieSize: 'd4',\r\n predicate: ['target:negative-healing'],\r\n },\r\n ],\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.greaterBrilliant.Name',\r\n text: 'PF2E.WeaponPropertyRune.greaterBrilliant.Note.criticalSuccess',\r\n },\r\n {\r\n outcome: ['success'],\r\n title: 'PF2E.WeaponPropertyRune.greaterBrilliant.Name',\r\n text: 'PF2E.WeaponPropertyRune.greaterBrilliant.Note.success',\r\n },\r\n ],\r\n ignoredResistances: [\r\n { type: 'fire', max: null },\r\n { type: 'spirit', max: null },\r\n { type: 'vitality', max: null },\r\n ],\r\n },\r\n level: 18,\r\n name: 'PF2E.WeaponPropertyRune.greaterBrilliant.Name',\r\n price: 24_000,\r\n rarity: 'common',\r\n slug: 'greaterBrilliant',\r\n traits: ['magical'],\r\n },\r\n greaterCorrosive: {\r\n damage: {\r\n dice: [{ damageType: 'acid', diceNumber: 1, dieSize: 'd6' }],\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.greaterCorrosive.Name',\r\n text: 'PF2E.WeaponPropertyRune.greaterCorrosive.Note.criticalSuccess',\r\n },\r\n {\r\n outcome: ['success'],\r\n title: 'PF2E.WeaponPropertyRune.greaterCorrosive.Name',\r\n text: 'PF2E.WeaponPropertyRune.greaterCorrosive.Note.success',\r\n },\r\n ],\r\n ignoredResistances: [{ type: 'acid', max: null }],\r\n },\r\n level: 15,\r\n name: 'PF2E.WeaponPropertyRune.greaterCorrosive.Name',\r\n price: 6500,\r\n rarity: 'common',\r\n slug: 'greaterCorrosive',\r\n traits: ['acid', 'magical'],\r\n },\r\n greaterCrushing: {\r\n damage: {\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.greaterCrushing.Name',\r\n text: 'PF2E.WeaponPropertyRune.greaterCrushing.Note.criticalSuccess',\r\n },\r\n ],\r\n },\r\n level: 9,\r\n name: 'PF2E.WeaponPropertyRune.greaterCrushing.Name',\r\n price: 650,\r\n rarity: 'uncommon',\r\n slug: 'greaterCrushing',\r\n traits: ['magical'],\r\n },\r\n greaterDecaying: {\r\n damage: {\r\n dice: [\r\n {\r\n slug: 'decaying',\r\n damageType: 'void',\r\n diceNumber: 1,\r\n dieSize: 'd4',\r\n },\r\n {\r\n slug: 'decaying-persistent',\r\n category: 'persistent',\r\n damageType: 'void',\r\n diceNumber: 4,\r\n dieSize: 'd4',\r\n critical: true,\r\n },\r\n ],\r\n ignoredResistances: [{ type: 'void', max: null }],\r\n },\r\n level: 15,\r\n name: 'PF2E.WeaponPropertyRune.greaterDecaying.Name',\r\n price: 6500,\r\n rarity: 'common',\r\n slug: 'greaterDecaying',\r\n traits: ['acid', 'magical', 'void'],\r\n },\r\n greaterDisrupting: {\r\n damage: {\r\n dice: [\r\n {\r\n category: 'persistent',\r\n damageType: 'vitality',\r\n diceNumber: 2,\r\n dieSize: 'd6',\r\n predicate: ['target:negative-healing'],\r\n },\r\n ],\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.greaterDisrupting.Name',\r\n text: 'PF2E.WeaponPropertyRune.greaterDisrupting.Note.criticalSuccess',\r\n predicate: ['target:negative-healing'],\r\n },\r\n ],\r\n },\r\n level: 14,\r\n name: 'PF2E.WeaponPropertyRune.greaterDisrupting.Name',\r\n price: 4300,\r\n rarity: 'uncommon',\r\n slug: 'greaterDisrupting',\r\n traits: ['magical'],\r\n },\r\n greaterExtending: {\r\n level: 13,\r\n name: 'PF2E.WeaponPropertyRune.greaterExtending.Name',\r\n price: 3000,\r\n rarity: 'common',\r\n slug: 'greaterExtending',\r\n traits: ['magical'],\r\n },\r\n greaterFanged: {\r\n level: 8,\r\n name: 'PF2E.WeaponPropertyRune.greaterFanged.Name',\r\n price: 425,\r\n rarity: 'uncommon',\r\n slug: 'greaterFanged',\r\n traits: ['magical'],\r\n },\r\n greaterFearsome: {\r\n damage: {\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.greaterFearsome.Name',\r\n text: 'PF2E.WeaponPropertyRune.greaterFearsome.Note.criticalSuccess',\r\n },\r\n ],\r\n },\r\n level: 12,\r\n name: 'PF2E.WeaponPropertyRune.greaterFearsome.Name',\r\n price: 2000,\r\n rarity: 'common',\r\n slug: 'greaterFearsome',\r\n traits: ['emotion', 'fear', 'magical', 'mental'],\r\n },\r\n greaterFlaming: {\r\n damage: {\r\n dice: [\r\n { damageType: 'fire', diceNumber: 1, dieSize: 'd6' },\r\n {\r\n damageType: 'fire',\r\n category: 'persistent',\r\n diceNumber: 2,\r\n dieSize: 'd10',\r\n critical: true,\r\n },\r\n ],\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.greaterFlaming.Name',\r\n text: 'PF2E.WeaponPropertyRune.greaterFlaming.Note.criticalSuccess',\r\n },\r\n {\r\n outcome: ['success'],\r\n title: 'PF2E.WeaponPropertyRune.greaterFlaming.Name',\r\n text: 'PF2E.WeaponPropertyRune.greaterFlaming.Note.success',\r\n },\r\n ],\r\n ignoredResistances: [{ type: 'fire', max: null }],\r\n },\r\n level: 15,\r\n name: 'PF2E.WeaponPropertyRune.greaterFlaming.Name',\r\n price: 6500,\r\n rarity: 'common',\r\n slug: 'greaterFlaming',\r\n traits: ['fire', 'magical'],\r\n },\r\n greaterFrost: {\r\n damage: {\r\n dice: [{ damageType: 'cold', diceNumber: 1, dieSize: 'd6' }],\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.greaterFrost.Name',\r\n text: 'PF2E.WeaponPropertyRune.greaterFrost.Note.criticalSuccess',\r\n },\r\n {\r\n outcome: ['success'],\r\n title: 'PF2E.WeaponPropertyRune.greaterFrost.Name',\r\n text: 'PF2E.WeaponPropertyRune.greaterFrost.Note.success',\r\n },\r\n ],\r\n ignoredResistances: [{ type: 'cold', max: null }],\r\n },\r\n level: 15,\r\n name: 'PF2E.WeaponPropertyRune.greaterFrost.Name',\r\n price: 6500,\r\n rarity: 'common',\r\n slug: 'greaterFrost',\r\n traits: ['cold', 'magical'],\r\n },\r\n greaterGiantKilling: {\r\n damage: {\r\n dice: [\r\n {\r\n slug: 'greaterGiantKilling',\r\n damageType: 'mental',\r\n diceNumber: 2,\r\n dieSize: 'd6',\r\n predicate: ['target:trait:giant'],\r\n },\r\n ],\r\n ignoredResistances: [{ type: 'mental', max: null }],\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n predicate: ['target:trait:giant'],\r\n title: 'PF2E.WeaponPropertyRune.greaterGiantKilling.Name',\r\n text: 'PF2E.WeaponPropertyRune.greaterGiantKilling.Note.criticalSuccess',\r\n },\r\n ],\r\n },\r\n level: 15,\r\n name: 'PF2E.WeaponPropertyRune.greaterGiantKilling.Name',\r\n price: 6000,\r\n rarity: 'rare',\r\n slug: 'greaterGiantKilling',\r\n traits: ['magical'],\r\n },\r\n greaterHauling: {\r\n level: 11,\r\n name: 'PF2E.WeaponPropertyRune.greaterHauling.Name',\r\n price: 1300,\r\n rarity: 'uncommon',\r\n slug: 'greaterHauling',\r\n traits: ['magical'],\r\n },\r\n greaterImpactful: {\r\n damage: {\r\n dice: [{ damageType: 'force', diceNumber: 1, dieSize: 'd6' }],\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.greaterImpactful.Name',\r\n text: 'PF2E.WeaponPropertyRune.greaterImpactful.Note.criticalSuccess',\r\n },\r\n ],\r\n },\r\n level: 17,\r\n name: 'PF2E.WeaponPropertyRune.greaterImpactful.Name',\r\n price: 15_000,\r\n rarity: 'common',\r\n slug: 'greaterImpactful',\r\n traits: ['force', 'magical'],\r\n },\r\n greaterRooting: {\r\n level: 11,\r\n name: 'PF2E.WeaponPropertyRune.greaterRooting.Name',\r\n price: 1400,\r\n rarity: 'common',\r\n slug: 'greaterRooting',\r\n traits: ['plant', 'magical', 'wood'],\r\n damage: {\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.greaterRooting.Name',\r\n text: 'PF2E.WeaponPropertyRune.greaterRooting.Note.criticalSuccess',\r\n },\r\n {\r\n outcome: ['success'],\r\n title: 'PF2E.WeaponPropertyRune.greaterRooting.Name',\r\n text: 'PF2E.WeaponPropertyRune.greaterRooting.Note.success',\r\n },\r\n ],\r\n },\r\n },\r\n greaterShock: {\r\n damage: {\r\n dice: [{ damageType: 'electricity', diceNumber: 1, dieSize: 'd6' }],\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.greaterShock.Name',\r\n text: 'PF2E.WeaponPropertyRune.greaterShock.Note.criticalSuccess',\r\n },\r\n {\r\n outcome: ['success'],\r\n title: 'PF2E.WeaponPropertyRune.greaterShock.Name',\r\n text: 'PF2E.WeaponPropertyRune.greaterShock.Note.success',\r\n },\r\n ],\r\n ignoredResistances: [{ type: 'electricity', max: null }],\r\n },\r\n level: 15,\r\n name: 'PF2E.WeaponPropertyRune.greaterShock.Name',\r\n price: 6500,\r\n rarity: 'common',\r\n slug: 'greaterShock',\r\n traits: ['electricity', 'magical'],\r\n },\r\n greaterThundering: {\r\n damage: {\r\n dice: [{ damageType: 'sonic', diceNumber: 1, dieSize: 'd6' }],\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.greaterThundering.Name',\r\n text: 'PF2E.WeaponPropertyRune.greaterThundering.Note.criticalSuccess',\r\n },\r\n {\r\n outcome: ['success'],\r\n title: 'PF2E.WeaponPropertyRune.greaterThundering.Name',\r\n text: 'PF2E.WeaponPropertyRune.greaterThundering.Note.success',\r\n },\r\n ],\r\n ignoredResistances: [{ type: 'sonic', max: null }],\r\n },\r\n level: 15,\r\n name: 'PF2E.WeaponPropertyRune.greaterThundering.Name',\r\n price: 6500,\r\n rarity: 'common',\r\n slug: 'greaterThundering',\r\n traits: ['magical', 'sonic'],\r\n },\r\n grievous: {\r\n damage: {\r\n dice: [\r\n {\r\n damageType: 'bleed',\r\n diceNumber: 1,\r\n dieSize: 'd6',\r\n critical: true,\r\n predicate: ['critical-specialization', 'item:group:dart'],\r\n },\r\n ],\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n predicate: ['item:group:axe'],\r\n title: 'PF2E.WeaponPropertyRune.grievous.Name',\r\n text: 'PF2E.WeaponPropertyRune.grievous.Note.Axe',\r\n },\r\n {\r\n outcome: ['criticalSuccess'],\r\n predicate: ['item:group:brawling'],\r\n title: 'PF2E.WeaponPropertyRune.grievous.Name',\r\n text: 'PF2E.WeaponPropertyRune.grievous.Note.Brawling',\r\n },\r\n {\r\n outcome: ['criticalSuccess'],\r\n predicate: ['item:group:club'],\r\n title: 'PF2E.WeaponPropertyRune.grievous.Name',\r\n text: 'PF2E.WeaponPropertyRune.grievous.Note.Club',\r\n },\r\n {\r\n outcome: ['criticalSuccess'],\r\n predicate: ['item:group:flail'],\r\n title: 'PF2E.WeaponPropertyRune.grievous.Name',\r\n text: 'PF2E.WeaponPropertyRune.grievous.Note.Flail',\r\n },\r\n {\r\n outcome: ['criticalSuccess'],\r\n predicate: ['item:group:hammer'],\r\n title: 'PF2E.WeaponPropertyRune.grievous.Name',\r\n text: 'PF2E.WeaponPropertyRune.grievous.Note.Hammer',\r\n },\r\n {\r\n outcome: ['criticalSuccess'],\r\n predicate: ['item:group:knife'],\r\n title: 'PF2E.WeaponPropertyRune.grievous.Name',\r\n text: 'PF2E.WeaponPropertyRune.grievous.Note.Knife',\r\n },\r\n {\r\n outcome: ['criticalSuccess'],\r\n predicate: ['item:group:polearm'],\r\n title: 'PF2E.WeaponPropertyRune.grievous.Name',\r\n text: 'PF2E.WeaponPropertyRune.grievous.Note.Polearm',\r\n },\r\n {\r\n outcome: ['criticalSuccess'],\r\n predicate: ['item:group:shield'],\r\n title: 'PF2E.WeaponPropertyRune.grievous.Name',\r\n text: 'PF2E.WeaponPropertyRune.grievous.Note.Shield',\r\n },\r\n {\r\n outcome: ['criticalSuccess'],\r\n predicate: ['item:group:sling'],\r\n title: 'PF2E.WeaponPropertyRune.grievous.Name',\r\n text: 'PF2E.WeaponPropertyRune.grievous.Note.Sling',\r\n },\r\n {\r\n outcome: ['criticalSuccess'],\r\n predicate: ['item:group:spear'],\r\n title: 'PF2E.WeaponPropertyRune.grievous.Name',\r\n text: 'PF2E.WeaponPropertyRune.grievous.Note.Spear',\r\n },\r\n {\r\n outcome: ['criticalSuccess'],\r\n predicate: ['item:group:sword'],\r\n title: 'PF2E.WeaponPropertyRune.grievous.Name',\r\n text: 'PF2E.WeaponPropertyRune.grievous.Note.Sword',\r\n },\r\n ],\r\n adjustments: [\r\n {\r\n slug: 'critical-specialization',\r\n test: options => new PredicatePF2e('item:group:pick').test(options),\r\n getNewValue: current => current * 2,\r\n },\r\n ],\r\n },\r\n level: 9,\r\n name: 'PF2E.WeaponPropertyRune.grievous.Name',\r\n price: 700,\r\n rarity: 'common',\r\n slug: 'grievous',\r\n traits: ['magical'],\r\n },\r\n hauling: {\r\n level: 6,\r\n name: 'PF2E.WeaponPropertyRune.hauling.Name',\r\n price: 225,\r\n rarity: 'uncommon',\r\n slug: 'hauling',\r\n traits: ['magical'],\r\n },\r\n holy: {\r\n level: 11,\r\n name: 'PF2E.WeaponPropertyRune.holy.Name',\r\n price: 1400,\r\n rarity: 'common',\r\n slug: 'holy',\r\n traits: ['holy', 'magical'],\r\n damage: {\r\n dice: [\r\n {\r\n damageType: 'spirit',\r\n diceNumber: 1,\r\n dieSize: 'd4',\r\n predicate: [{ not: 'target:trait:unholy' }],\r\n },\r\n {\r\n damageType: 'spirit',\r\n diceNumber: 2,\r\n dieSize: 'd4',\r\n predicate: ['target:trait:unholy'],\r\n },\r\n ],\r\n },\r\n strikeAdjustments: [\r\n {\r\n adjustTraits: (_weapon, traits) => {\r\n if (!traits.includes('holy')) traits.push('holy')\r\n },\r\n },\r\n ],\r\n },\r\n hopeful: {\r\n attack: {\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.hopeful.Name',\r\n text: 'PF2E.WeaponPropertyRune.hopeful.Note.criticalSuccess',\r\n },\r\n ],\r\n },\r\n level: 11,\r\n name: 'PF2E.WeaponPropertyRune.hopeful.Name',\r\n price: 1200,\r\n rarity: 'uncommon',\r\n slug: 'hopeful',\r\n traits: ['magical'],\r\n },\r\n hooked: {\r\n level: 5,\r\n name: 'PF2E.WeaponPropertyRune.hooked.Name',\r\n price: 140,\r\n rarity: 'rare',\r\n slug: 'hooked',\r\n traits: ['magical'],\r\n strikeAdjustments: [\r\n {\r\n adjustWeapon: weapon => {\r\n if (!weapon.system.traits.value.includes('trip')) {\r\n weapon.system.traits.value.push('trip')\r\n }\r\n },\r\n },\r\n ],\r\n },\r\n impactful: {\r\n damage: {\r\n dice: [{ damageType: 'force', diceNumber: 1, dieSize: 'd6' }],\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.impactful.Name',\r\n text: 'PF2E.WeaponPropertyRune.impactful.Note.criticalSuccess',\r\n },\r\n ],\r\n },\r\n level: 10,\r\n name: 'PF2E.WeaponPropertyRune.impactful.Name',\r\n price: 1000,\r\n rarity: 'common',\r\n slug: 'impactful',\r\n traits: ['force', 'magical'],\r\n },\r\n impossible: {\r\n level: 20,\r\n name: 'PF2E.WeaponPropertyRune.impossible.Name',\r\n price: 70_000,\r\n rarity: 'common',\r\n slug: 'impossible',\r\n traits: ['magical'],\r\n strikeAdjustments: [\r\n {\r\n // Double the base range increment\r\n adjustWeapon: weapon => {\r\n if (weapon.isOfType('weapon') && weapon.system.range && weapon._source.system.range) {\r\n const sourceRange = weapon._source.system.range\r\n const preparedRange = weapon.system.range\r\n weapon.system.range = sourceRange * 2 + Math.abs(preparedRange - sourceRange)\r\n }\r\n },\r\n },\r\n ],\r\n },\r\n keen: {\r\n attack: {\r\n dosAdjustments: [\r\n {\r\n adjustments: { success: { label: 'PF2E.WeaponPropertyRune.keen.Name', amount: 'criticalSuccess' } },\r\n predicate: new PredicatePF2e([\r\n 'check:total:natural:19',\r\n { or: ['item:damage:type:slashing', 'item:damage:type:piercing'] },\r\n ]),\r\n },\r\n ],\r\n },\r\n level: 13,\r\n name: 'PF2E.WeaponPropertyRune.keen.Name',\r\n price: 3000,\r\n rarity: 'uncommon',\r\n slug: 'keen',\r\n traits: ['magical'],\r\n },\r\n kinWarding: {\r\n level: 3,\r\n name: 'PF2E.WeaponPropertyRune.kinWarding.Name',\r\n price: 52,\r\n rarity: 'uncommon',\r\n slug: 'kinWarding',\r\n traits: ['dwarf', 'magical'],\r\n },\r\n majorFanged: {\r\n level: 15,\r\n name: 'PF2E.WeaponPropertyRune.majorFanged.Name',\r\n price: 6000,\r\n rarity: 'uncommon',\r\n slug: 'majorFanged',\r\n traits: ['magical'],\r\n },\r\n majorRooting: {\r\n level: 15,\r\n name: 'PF2E.WeaponPropertyRune.majorRooting.Name',\r\n price: 6500,\r\n rarity: 'common',\r\n slug: 'majorRooting',\r\n traits: ['plant', 'magical', 'wood'],\r\n damage: {\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.majorRooting.Name',\r\n text: 'PF2E.WeaponPropertyRune.majorRooting.Note.criticalSuccess',\r\n },\r\n ],\r\n },\r\n },\r\n merciful: {\r\n strikeAdjustments: [\r\n {\r\n adjustWeapon: weapon => {\r\n if (!weapon.system.traits.value.includes('nonlethal')) {\r\n weapon.system.traits.value.push('nonlethal')\r\n }\r\n },\r\n },\r\n ],\r\n level: 4,\r\n name: 'PF2E.WeaponPropertyRune.merciful.Name',\r\n price: 70,\r\n rarity: 'common',\r\n slug: 'merciful',\r\n traits: ['magical', 'mental'],\r\n },\r\n pacifying: {\r\n level: 5,\r\n name: 'PF2E.WeaponPropertyRune.pacifying.Name',\r\n price: 150,\r\n rarity: 'uncommon',\r\n slug: 'pacifying',\r\n traits: ['magical'],\r\n },\r\n returning: {\r\n attack: {\r\n notes: [{ title: 'PF2E.WeaponPropertyRune.returning.Name', text: 'PF2E.WeaponPropertyRune.returning.Note' }],\r\n },\r\n level: 3,\r\n name: 'PF2E.WeaponPropertyRune.returning.Name',\r\n price: 55,\r\n rarity: 'common',\r\n slug: 'returning',\r\n traits: ['magical'],\r\n },\r\n rooting: {\r\n level: 7,\r\n name: 'PF2E.WeaponPropertyRune.rooting.Name',\r\n price: 360,\r\n rarity: 'common',\r\n slug: 'rooting',\r\n traits: ['plant', 'magical', 'wood'],\r\n damage: {\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.rooting.Name',\r\n text: 'PF2E.WeaponPropertyRune.rooting.Note.criticalSuccess',\r\n },\r\n ],\r\n },\r\n },\r\n serrating: {\r\n damage: {\r\n dice: [{ damageType: 'slashing', diceNumber: 1, dieSize: 'd4' }],\r\n },\r\n level: 10,\r\n name: 'PF2E.WeaponPropertyRune.serrating.Name',\r\n price: 1000,\r\n rarity: 'uncommon',\r\n slug: 'serrating',\r\n traits: ['magical'],\r\n },\r\n shifting: {\r\n level: 6,\r\n name: 'PF2E.WeaponPropertyRune.shifting.Name',\r\n price: 225,\r\n rarity: 'common',\r\n slug: 'shifting',\r\n traits: ['magical'],\r\n },\r\n shock: {\r\n damage: {\r\n dice: [{ damageType: 'electricity', diceNumber: 1, dieSize: 'd6' }],\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.shock.Name',\r\n text: 'PF2E.WeaponPropertyRune.shock.Note.criticalSuccess',\r\n },\r\n ],\r\n },\r\n level: 8,\r\n name: 'PF2E.WeaponPropertyRune.shock.Name',\r\n price: 500,\r\n rarity: 'common',\r\n slug: 'shock',\r\n traits: ['electricity', 'magical'],\r\n },\r\n speed: {\r\n level: 16,\r\n name: 'PF2E.Actor.Speed.Label',\r\n price: 10_000,\r\n rarity: 'rare',\r\n slug: 'speed',\r\n traits: ['magical'],\r\n },\r\n spellStoring: {\r\n level: 13,\r\n name: 'PF2E.WeaponPropertyRune.spellStoring.Name',\r\n price: 2700,\r\n rarity: 'uncommon',\r\n slug: 'spellStoring',\r\n traits: ['magical'],\r\n },\r\n swarming: {\r\n level: 9,\r\n name: 'PF2E.WeaponPropertyRune.swarming.Name',\r\n price: 700,\r\n rarity: 'common',\r\n slug: 'swarming',\r\n traits: ['magical'],\r\n },\r\n thundering: {\r\n damage: {\r\n dice: [{ damageType: 'sonic', diceNumber: 1, dieSize: 'd6' }],\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.thundering.Name',\r\n text: 'PF2E.WeaponPropertyRune.thundering.Note.criticalSuccess',\r\n },\r\n ],\r\n },\r\n level: 8,\r\n name: 'PF2E.WeaponPropertyRune.thundering.Name',\r\n price: 500,\r\n rarity: 'common',\r\n slug: 'thundering',\r\n traits: ['magical', 'sonic'],\r\n },\r\n trueRooting: {\r\n level: 19,\r\n name: 'PF2E.WeaponPropertyRune.trueRooting.Name',\r\n price: 40_000,\r\n rarity: 'common',\r\n slug: 'trueRooting',\r\n traits: ['plant', 'magical', 'wood'],\r\n damage: {\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.trueRooting.Name',\r\n text: 'PF2E.WeaponPropertyRune.trueRooting.Note.criticalSuccess',\r\n },\r\n ],\r\n },\r\n },\r\n underwater: {\r\n level: 3,\r\n name: 'PF2E.WeaponPropertyRune.underwater.Name',\r\n price: 50,\r\n rarity: 'common',\r\n slug: 'underwater',\r\n traits: ['magical', 'water'],\r\n },\r\n unholy: {\r\n level: 11,\r\n name: 'PF2E.WeaponPropertyRune.unholy.Name',\r\n price: 1400,\r\n rarity: 'common',\r\n slug: 'unholy',\r\n traits: ['unholy', 'magical'],\r\n damage: {\r\n dice: [\r\n {\r\n damageType: 'spirit',\r\n diceNumber: 1,\r\n dieSize: 'd4',\r\n predicate: [{ not: 'target:trait:holy' }],\r\n },\r\n {\r\n damageType: 'spirit',\r\n diceNumber: 2,\r\n dieSize: 'd4',\r\n predicate: ['target:trait:holy'],\r\n },\r\n ],\r\n },\r\n strikeAdjustments: [\r\n {\r\n adjustTraits: (_weapon, traits) => {\r\n if (!traits.includes('unholy')) traits.push('unholy')\r\n },\r\n },\r\n ],\r\n },\r\n vorpal: {\r\n level: 17,\r\n name: 'PF2E.WeaponPropertyRune.vorpal.Name',\r\n price: 15_000,\r\n rarity: 'rare',\r\n slug: 'vorpal',\r\n traits: ['magical'],\r\n },\r\n wounding: {\r\n damage: {\r\n dice: [{ damageType: 'bleed', diceNumber: 1, dieSize: 'd6' }],\r\n },\r\n level: 7,\r\n name: 'PF2E.WeaponPropertyRune.wounding.Name',\r\n price: 340,\r\n rarity: 'common',\r\n slug: 'wounding',\r\n traits: ['magical'],\r\n },\r\n}\r\n\r\nexport function getPropertyRuneStrikeAdjustments(runes) {\r\n return runes.flatMap(r => WEAPON_PROPERTY_RUNES[r].strikeAdjustments ?? [])\r\n}\r\n", "import { COVER_VALUES, VISIBILITY_VALUES } from '../constants'\r\nimport { createCoverSource, createFlatFootedSource } from '../effect'\r\nimport { R } from '../remeda'\r\nimport { getPerception, perceptionRules } from '../rule-element'\r\nimport { getCover, getVisibility } from '../token'\r\nimport { asNumberOnly } from '../utils'\r\nimport { extractEphemeralEffects, getRangeIncrement, isOffGuardFromFlanking } from './helpers'\r\nimport { getPropertyRuneStrikeAdjustments } from './rune'\r\n\r\nexport async function getRollContext(params) {\r\n const [selfToken, targetToken] =\r\n canvas.ready && !params.viewOnly\r\n ? [\r\n canvas.tokens.controlled.find(t => t.actor === this) ?? this.getActiveTokens().shift() ?? null,\r\n params.target?.token ?? params.target?.actor?.getActiveTokens().shift() ?? null,\r\n ]\r\n : [null, null]\r\n\r\n const isAttackAction = ['attack', 'attack-roll', 'attack-damage'].some(d => params.domains.includes(d))\r\n const isMelee = !!(params.melee || (params.item?.isOfType('weapon', 'melee') && params.item.isMelee))\r\n const reach =\r\n isMelee && params.item?.isOfType('action', 'weapon', 'melee')\r\n ? this.getReach({ action: 'attack', weapon: params.item })\r\n : this.getReach({ action: 'attack' })\r\n const isFlankingAttack = !!(\r\n isAttackAction &&\r\n isMelee &&\r\n typeof reach === 'number' &&\r\n targetToken?.actor &&\r\n selfToken?.isFlanking(targetToken, { reach })\r\n )\r\n\r\n // Get ephemeral effects from the target that affect this actor while attacking\r\n const originEphemeralEffects = await extractEphemeralEffects({\r\n affects: 'origin',\r\n origin: this,\r\n target: params.target?.actor ?? targetToken?.actor ?? null,\r\n item: params.item ?? null,\r\n domains: params.domains,\r\n options: [...params.options, ...(params.item?.getRollOptions('item') ?? [])],\r\n })\r\n\r\n const targetMarkOption = (() => {\r\n const tokenMark = targetToken ? this.synthetics.tokenMarks.get(targetToken.document.uuid) : null\r\n return tokenMark ? `target:mark:${tokenMark}` : null\r\n })()\r\n const initialActionOptions = params.traits?.map(t => `self:action:trait:${t}`) ?? []\r\n\r\n const selfActor =\r\n params.viewOnly || !targetToken?.actor\r\n ? this\r\n : this.getContextualClone(\r\n R.compact([\r\n ...Array.from(params.options),\r\n ...targetToken.actor.getSelfRollOptions('target'),\r\n targetMarkOption,\r\n ...initialActionOptions,\r\n isFlankingAttack ? 'self:flanking' : null,\r\n ]),\r\n originEphemeralEffects\r\n )\r\n\r\n const isStrike = params.statistic instanceof game.pf2e.StatisticModifier\r\n const strikeActions = isStrike ? selfActor.system.actions?.flatMap(a => [a, a.altUsages ?? []].flat()) ?? [] : []\r\n\r\n const statistic = params.viewOnly\r\n ? params.statistic\r\n : isStrike\r\n ? strikeActions.find(action => {\r\n // Find the matching weapon or melee item\r\n if (params.item?.id !== action.item.id || params?.item.name !== action.item.name) return false\r\n if (params.item.isOfType('melee') && action.item.isOfType('melee')) return true\r\n\r\n // Discriminate between melee/thrown usages by checking that both are either melee or ranged\r\n return (\r\n params.item.isOfType('weapon') && action.item.isOfType('weapon') && params.item.isMelee === action.item.isMelee\r\n )\r\n }) ?? params.statistic\r\n : params.statistic\r\n\r\n const selfItem = (() => {\r\n // 1. Simplest case: no context clone, so used the item passed to this method\r\n if (selfActor === this) return params.item ?? null\r\n\r\n // 2. Get the item from the statistic if it's stored therein\r\n if (\r\n statistic &&\r\n 'item' in statistic &&\r\n statistic.item instanceof Item &&\r\n statistic.item.isOfType('action', 'melee', 'spell', 'weapon')\r\n ) {\r\n return statistic.item\r\n }\r\n\r\n // 3. Get the item directly from the context clone\r\n const itemClone = selfActor.items.get(params.item?.id ?? '')\r\n if (itemClone?.isOfType('melee', 'weapon')) return itemClone\r\n\r\n // 4 Give up :(\r\n return params.item ?? null\r\n })()\r\n\r\n const itemOptions = selfItem?.getRollOptions('item') ?? []\r\n\r\n const actionTraits = (() => {\r\n const traits = R.compact([params.traits].flat())\r\n if (selfItem?.isOfType('weapon', 'melee')) {\r\n const strikeAdjustments = [\r\n selfActor.synthetics.strikeAdjustments,\r\n getPropertyRuneStrikeAdjustments(selfItem.system.runes.property),\r\n ].flat()\r\n for (const adjustment of strikeAdjustments) {\r\n adjustment.adjustTraits?.(selfItem, traits)\r\n }\r\n }\r\n\r\n return R.uniq(traits).sort()\r\n })()\r\n\r\n // Calculate distance and range increment, set as a roll option\r\n const distance = selfToken && targetToken ? selfToken.distanceTo(targetToken) : null\r\n const [originDistance, targetDistance] =\r\n typeof distance === 'number' ? [`origin:distance:${distance}`, `target:distance:${distance}`] : [null, null]\r\n\r\n const originMarkOption = (() => {\r\n const tokenMark = selfToken ? targetToken?.actor?.synthetics.tokenMarks.get(selfToken.document.uuid) : null\r\n return tokenMark ? `origin:mark:${tokenMark}` : null\r\n })()\r\n const originRollOptions =\r\n selfToken && targetToken\r\n ? R.compact(\r\n R.uniq([\r\n ...selfActor.getSelfRollOptions('origin'),\r\n ...actionTraits.map(t => `origin:action:trait${t}`),\r\n ...(originDistance ? [originDistance] : []),\r\n originMarkOption,\r\n ])\r\n )\r\n : []\r\n\r\n // Target roll options\r\n const getTargetRollOptions = actor => {\r\n const targetOptions = actor?.getSelfRollOptions('target') ?? []\r\n if (targetToken) {\r\n targetOptions.push('target') // An indicator that there is a target of any kind\r\n if (targetMarkOption) targetOptions.push(targetMarkOption)\r\n }\r\n return targetOptions.sort()\r\n }\r\n const targetRollOptions = getTargetRollOptions(targetToken?.actor)\r\n\r\n // Get ephemeral effects from this actor that affect the target while being attacked\r\n const targetEphemeralEffects = await extractEphemeralEffects({\r\n affects: 'target',\r\n origin: selfActor,\r\n target: targetToken?.actor ?? null,\r\n item: selfItem,\r\n domains: params.domains,\r\n options: [...params.options, ...itemOptions, ...targetRollOptions],\r\n })\r\n\r\n /**\r\n * WE ADDED STUFF HERE\r\n */\r\n if (selfToken?.actor && targetToken?.actor && !params.viewOnly) {\r\n const perception = perceptionRules(selfToken, targetToken, {\r\n extraOptions: itemOptions,\r\n distance,\r\n })\r\n\r\n let visibility = getVisibility(selfToken, targetToken, { perception, affects: 'origin' })\r\n\r\n if (visibility && getPerception(perception, 'target', 'visibility', 'noff', visibility)) {\r\n visibility = undefined\r\n }\r\n\r\n if (VISIBILITY_VALUES[visibility] > VISIBILITY_VALUES.concealed)\r\n targetEphemeralEffects.push(createFlatFootedSource(visibility))\r\n\r\n let cover = getCover(selfToken, targetToken, { perception, affects: 'target', options: itemOptions })\r\n let coverBonus = undefined\r\n\r\n if (cover) {\r\n let ac = getPerception(perception, 'target', 'cover', 'ac', cover)?.first()\r\n if (ac != null) ac = Math.clamped(asNumberOnly(ac), 0, 4)\r\n if (ac === 0) cover = undefined\r\n else if (ac) coverBonus = ac\r\n }\r\n\r\n if (COVER_VALUES[cover] > COVER_VALUES.none) targetEphemeralEffects.push(createCoverSource(cover, coverBonus))\r\n }\r\n /**\r\n * END OF THE ADDED STUFF\r\n */\r\n\r\n // Add an epehemeral effect from flanking\r\n if (isFlankingAttack && isOffGuardFromFlanking(targetToken.actor, selfActor, originRollOptions)) {\r\n const name = game.i18n.localize('PF2E.Item.Condition.Flanked')\r\n const condition = game.pf2e.ConditionManager.getCondition('off-guard', { name })\r\n targetEphemeralEffects.push(condition.toObject())\r\n }\r\n\r\n // Clone the actor to recalculate its AC with contextual roll options\r\n const targetActor = params.viewOnly\r\n ? null\r\n : (params.target?.actor ?? targetToken?.actor)?.getContextualClone(\r\n R.compact([...params.options, ...itemOptions, ...originRollOptions]),\r\n targetEphemeralEffects\r\n ) ?? null\r\n\r\n const rollOptions = new Set(\r\n R.compact([\r\n ...params.options,\r\n ...selfActor.getRollOptions(params.domains),\r\n ...(targetActor ? getTargetRollOptions(targetActor) : targetRollOptions),\r\n ...actionTraits.map(t => `self:action:trait:${t}`),\r\n ...itemOptions,\r\n // Backward compatibility for predication looking for an \"attack\" trait by its lonesome\r\n isAttackAction ? 'attack' : null,\r\n ]).sort()\r\n )\r\n\r\n if (targetDistance) rollOptions.add(targetDistance)\r\n const rangeIncrement = selfItem ? getRangeIncrement(selfItem, distance) : null\r\n if (rangeIncrement) rollOptions.add(`target:range-increment:${rangeIncrement}`)\r\n\r\n const self = {\r\n actor: selfActor,\r\n token: selfToken?.document ?? null,\r\n statistic,\r\n item: selfItem,\r\n modifiers: [],\r\n }\r\n\r\n const target =\r\n targetActor && targetToken && distance !== null\r\n ? { actor: targetActor, token: targetToken.document, distance, rangeIncrement }\r\n : null\r\n\r\n return {\r\n options: rollOptions,\r\n self,\r\n target,\r\n traits: actionTraits,\r\n }\r\n}\r\n", "import { ICONS_PATHS } from '../constants.js'\r\nimport { getSetting, localize, setSetting, templatePath } from '../module.js'\r\n\r\nconst ICONS = ['cover', 'concealed', 'hidden', 'undetected', 'unnoticed']\r\n\r\nexport class IconPathMenu extends FormApplication {\r\n static get defaultOptions() {\r\n return foundry.utils.mergeObject(super.defaultOptions, {\r\n template: templatePath('icon-path-menu'),\r\n title: localize('settings.icon-path.name'),\r\n width: 500,\r\n })\r\n }\r\n\r\n getData() {\r\n const saved = getSetting('icon-path')\r\n\r\n const icons = ICONS.map(name => ({\r\n name,\r\n placeholder: ICONS_PATHS[name],\r\n value: saved[name] ?? '',\r\n label: name === 'cover' ? localize('icon-path.cover') : game.i18n.localize(CONFIG.PF2E.conditionTypes[name]),\r\n }))\r\n\r\n return {\r\n icons,\r\n i18n: localize,\r\n }\r\n }\r\n\r\n activateListeners(html) {\r\n super.activateListeners(html)\r\n\r\n html.find('button[name=cancel]').on('click', event => {\r\n event.prefentDefault()\r\n this.close()\r\n })\r\n }\r\n\r\n async _updateObject(event, formData) {\r\n setSetting('icon-path', formData)\r\n }\r\n}\r\n", "import { IconPathMenu } from './apps/icon-path-menu.js'\r\nimport { MODULE_ID } from './module.js'\r\n\r\nexport function registerSettings() {\r\n register('icon-path', Object, {}, { config: false })\r\n game.settings.registerMenu(MODULE_ID, 'icon-path-menu', {\r\n name: path('icon-path', 'name'),\r\n label: path('icon-path', 'label'),\r\n icon: 'fa-solid fa-list',\r\n restricted: true,\r\n type: IconPathMenu,\r\n })\r\n\r\n register('permission', String, CONST.USER_ROLES.GAMEMASTER, {\r\n choices: {\r\n 1: path('permission', 'choices.1'),\r\n 2: path('permission', 'choices.2'),\r\n 3: path('permission', 'choices.3'),\r\n 4: path('permission', 'choices.4'),\r\n },\r\n })\r\n\r\n register('npc-vision', Boolean, false)\r\n\r\n register('target', Boolean, true, {\r\n onChange: () => ui.combat?.render(),\r\n })\r\n\r\n register('lesser', String, 'ten', {\r\n choices: {\r\n none: path('lesser', 'choices.none'),\r\n cross: path('lesser', 'choices.cross'),\r\n zero: path('lesser', 'choices.zero'),\r\n ten: path('lesser', 'choices.ten'),\r\n twenty: path('lesser', 'choices.twenty'),\r\n },\r\n })\r\n\r\n register('standard', Boolean, true)\r\n\r\n register('dead-cover', Boolean, true)\r\n\r\n register('prone-cover', Boolean, true)\r\n\r\n register('standard-type', String, 'center', {\r\n choices: {\r\n center: path('standard-type', 'choices.center'),\r\n points: path('standard-type', 'choices.points'),\r\n },\r\n })\r\n\r\n register('skip-cover', Boolean, true)\r\n\r\n register('validation', String, 'all', {\r\n choices: {\r\n all: path('validation', 'choices.all'),\r\n selected: path('validation', 'choices.selected'),\r\n changed: path('validation', 'choices.changed'),\r\n },\r\n })\r\n\r\n register('flat-check', String, 'roll', {\r\n choices: {\r\n none: path('flat-check', 'choices.none'),\r\n roll: path('flat-check', 'choices.roll'),\r\n cancel: path('flat-check', 'choices.cancel'),\r\n },\r\n })\r\n\r\n register('encounter', Boolean, false)\r\n\r\n register('icon-size', Number, 26, {\r\n scope: 'client',\r\n range: {\r\n min: 26,\r\n max: 52,\r\n },\r\n })\r\n\r\n register('seek-template', Boolean, true, {\r\n scope: 'client',\r\n })\r\n}\r\n\r\nfunction path(setting, key) {\r\n return `${MODULE_ID}.settings.${setting}.${key}`\r\n}\r\n\r\nfunction register(name, type, defValue, extra = {}) {\r\n game.settings.register(MODULE_ID, name, {\r\n name: path(name, 'name'),\r\n hint: path(name, 'hint'),\r\n scope: 'world',\r\n config: true,\r\n type,\r\n default: defValue,\r\n ...extra,\r\n })\r\n}\r\n", "import { setupActions } from './action.js'\r\nimport { API } from './api.js'\r\nimport { renderChatMessage } from './chat.js'\r\nimport { checkRoll, renderCheckModifiersDialog } from './check.js'\r\nimport { renderCombatTracker, renderCombatTrackerConfig } from './combat.js'\r\nimport { basicSightCanDetect, detectionModeTestVisibility, feelTremorCanDetect, hearingCanDetect } from './detection.js'\r\nimport { MODULE_ID } from './module.js'\r\nimport { getRollContext } from './pf2e/rollcontext.js'\r\nimport { setupRuleElement } from './rule-element.js'\r\nimport { renderSceneConfig } from './scene.js'\r\nimport { registerSettings } from './settings.js'\r\nimport { highlightTemplateGrid, onMeasuredTemplate, preCreateMeasuredTemplate } from './template.js'\r\nimport {\r\n clearConditionals,\r\n controlToken,\r\n deleteToken,\r\n hoverToken,\r\n pasteToken,\r\n preCreateToken,\r\n renderTokenHUD,\r\n rulesBasedVision,\r\n updateToken,\r\n} from './token.js'\r\n\r\nconst CHECK_ROLL = 'game.pf2e.Check.roll'\r\n\r\nconst RULES_BASED_VISION = 'CONFIG.Token.documentClass.prototype.rulesBasedVision'\r\n\r\nconst HIGHLIGHT_TEMPLATE_GRID = 'CONFIG.MeasuredTemplate.objectClass.prototype.highlightGrid'\r\n\r\nconst GET_ROLL_CONTEXT = 'CONFIG.Actor.documentClass.prototype.getRollContext'\r\n\r\nconst DETECTION_MODE_TEST_VISIBILITY = 'DetectionMode.prototype.testVisibility'\r\nconst BASIC_SIGHT_CAN_DETECT = 'CONFIG.Canvas.detectionModes.basicSight._canDetect'\r\nconst HEARING_CAN_DETECT = 'CONFIG.Canvas.detectionModes.hearing._canDetect'\r\nconst FEEL_TREMOR_CAN_DETECT = 'CONFIG.Canvas.detectionModes.feelTremor._canDetect'\r\n\r\nHooks.once('init', () => {\r\n registerSettings()\r\n setupActions()\r\n setupRuleElement()\r\n\r\n libWrapper.register(MODULE_ID, CHECK_ROLL, checkRoll)\r\n\r\n libWrapper.register(MODULE_ID, HIGHLIGHT_TEMPLATE_GRID, highlightTemplateGrid, 'OVERRIDE')\r\n\r\n libWrapper.register(MODULE_ID, RULES_BASED_VISION, rulesBasedVision, 'OVERRIDE')\r\n\r\n libWrapper.register(MODULE_ID, GET_ROLL_CONTEXT, getRollContext, 'OVERRIDE')\r\n\r\n libWrapper.register(MODULE_ID, DETECTION_MODE_TEST_VISIBILITY, detectionModeTestVisibility, 'OVERRIDE')\r\n libWrapper.register(MODULE_ID, BASIC_SIGHT_CAN_DETECT, basicSightCanDetect, 'OVERRIDE')\r\n libWrapper.register(MODULE_ID, HEARING_CAN_DETECT, hearingCanDetect, 'OVERRIDE')\r\n libWrapper.register(MODULE_ID, FEEL_TREMOR_CAN_DETECT, feelTremorCanDetect, 'OVERRIDE')\r\n\r\n const isGM = game.data.users.find(x => x._id === game.data.userId).role >= CONST.USER_ROLES.GAMEMASTER\r\n if (isGM) {\r\n Hooks.on('renderSceneConfig', renderSceneConfig)\r\n Hooks.on('renderCombatTrackerConfig', renderCombatTrackerConfig)\r\n } else {\r\n Hooks.on('renderCombatTracker', renderCombatTracker)\r\n }\r\n\r\n game.modules.get(MODULE_ID).custom = {\r\n getWallCover: undefined,\r\n getCreatureCover: undefined,\r\n }\r\n})\r\n\r\nHooks.once('ready', () => {\r\n game.modules.get(MODULE_ID).api = API\r\n\r\n Hooks.on('renderChatMessage', renderChatMessage)\r\n\r\n for (const el of document.querySelectorAll('#chat-log .chat-message')) {\r\n const message = game.messages.get(el.dataset.messageId)\r\n if (!message) continue\r\n renderChatMessage(message, $(el))\r\n }\r\n\r\n if (game.user.isGM && game.modules.get('pf2e-rules-based-npc-vision')?.active) {\r\n ui.notifications.error(`${MODULE_ID}.warning.npc-vision`, { permanent: true, localize: true })\r\n }\r\n})\r\n\r\nHooks.on('hoverToken', hoverToken)\r\nHooks.on('pasteToken', pasteToken)\r\nHooks.on('updateToken', updateToken)\r\nHooks.on('deleteToken', deleteToken)\r\nHooks.on('controlToken', controlToken)\r\nHooks.on('renderTokenHUD', renderTokenHUD)\r\nHooks.on('preCreateToken', preCreateToken)\r\n\r\nHooks.on('canvasPan', () => clearConditionals())\r\n\r\nHooks.on('renderCheckModifiersDialog', renderCheckModifiersDialog)\r\n\r\nHooks.on('preCreateMeasuredTemplate', preCreateMeasuredTemplate)\r\nHooks.on('createMeasuredTemplate', onMeasuredTemplate)\r\nHooks.on('updateMeasuredTemplate', onMeasuredTemplate)\r\nHooks.on('deleteMeasuredTemplate', onMeasuredTemplate)\r\n"], - "mappings": "miBAAO,IAAMA,GAAa,sDAEbC,EAAoB,CAC7B,CAAC,MAAS,EAAG,EACb,SAAU,EACV,UAAW,EACX,OAAQ,EACR,WAAY,EACZ,UAAW,CACf,EAEaC,GAAe,CAAC,WAAY,YAAa,SAAU,aAAc,WAAW,EAE5EC,EAAS,CAAC,OAAQ,SAAU,WAAY,UAAW,eAAe,EAElEC,EAAe,CACxB,CAAC,MAAS,EAAG,EAC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cAAeC,EAAW,EACnC,MAAM,GAAG,cAAeC,EAAW,EACnC,MAAM,GAAG,eAAgBC,EAAY,EACrC,MAAM,GAAG,iBAAkBC,EAAc,EACzC,MAAM,GAAG,iBAAkBC,EAAc,EAEzC,MAAM,GAAG,YAAa,IAAMC,GAAkB,CAAC,EAE/C,MAAM,GAAG,6BAA8BC,EAA0B,EAEjE,MAAM,GAAG,4BAA6BC,EAAyB,EAC/D,MAAM,GAAG,yBAA0BC,EAAkB,EACrD,MAAM,GAAG,yBAA0BA,EAAkB,EACrD,MAAM,GAAG,yBAA0BA,EAAkB", + "sourcesContent": ["export const COVER_UUID = 'Compendium.pf2e.other-effects.Item.I9lfZUiCwMiGogVi'\r\n\r\nexport const VISIBILITY_VALUES = {\r\n [undefined]: 0,\r\n observed: 0,\r\n concealed: 1,\r\n hidden: 2,\r\n undetected: 3,\r\n unnoticed: 4,\r\n}\r\n\r\nexport const VISIBILITIES = ['observed', 'concealed', 'hidden', 'undetected', 'unnoticed']\r\n\r\nexport const COVERS = ['none', 'lesser', 'standard', 'greater', 'greater-prone']\r\n\r\nexport const COVER_VALUES = {\r\n [undefined]: 0,\r\n none: 0,\r\n lesser: 1,\r\n standard: 2,\r\n greater: 3,\r\n 'greater-prone': 4,\r\n}\r\n\r\nexport const defaultValues = {\r\n cover: 'none',\r\n visibility: 'observed',\r\n}\r\n\r\nexport const attackCheckRoll = ['attack-roll', 'spell-attack-roll']\r\n\r\nexport const validCheckRoll = [...attackCheckRoll, 'skill-check', 'perception-check']\r\n\r\nexport const ICONS_PATHS = {\r\n cover: 'modules/pf2e-perception/images/cover.webp',\r\n concealed: 'systems/pf2e/icons/conditions/concealed.webp',\r\n hidden: 'systems/pf2e/icons/conditions/hidden.webp',\r\n undetected: 'systems/pf2e/icons/conditions/undetected.webp',\r\n unnoticed: 'systems/pf2e/icons/conditions/unnoticed.webp',\r\n}\r\n\r\nexport const VISION_LEVELS = {\r\n BLINDED: 0,\r\n NORMAL: 1,\r\n LOWLIGHT: 2,\r\n DARKVISION: 3,\r\n}\r\n\r\nexport const DARKNESS_COLOR = '#000000'\r\nexport const MIST_COLOR = '#656665'\r\nexport const POISON_GREEN = '#809e71'\r\n\r\nexport const DARKNESS_SLUGS = ['darkness', 'dance-of-darkness', 'ravenous-darkness']\r\nexport const MIST_SLUGS = ['obscuring-mist', 'stinking-cloud', 'noxious-vapors']\r\n", "export const MODULE_ID = 'pf2e-perception'\r\n\r\nexport function templatePath(template) {\r\n return `modules/${MODULE_ID}/templates/${template}.hbs`\r\n}\r\n\r\nexport function localize(...args) {\r\n const data = args.at(-1)\r\n const useFormat = typeof data === 'object'\r\n\r\n const keys = useFormat ? args.slice(0, -1) : args\r\n keys.unshift(MODULE_ID)\r\n\r\n return game.i18n[useFormat ? 'format' : 'localize'](keys.join('.'), data)\r\n}\r\n\r\nexport function getFlag(doc, flag) {\r\n return doc.getFlag(MODULE_ID, flag)\r\n}\r\n\r\nexport function setFlag(doc, flag, value) {\r\n return doc.setFlag(MODULE_ID, flag, value)\r\n}\r\n\r\nexport function unsetFlag(doc, flag) {\r\n return doc.unsetFlag(MODULE_ID, flag, true)\r\n}\r\n\r\nexport function getFlags(doc) {\r\n return getProperty(doc, `flags.${MODULE_ID}`) ?? {}\r\n}\r\n\r\nexport function getSetting(setting) {\r\n return game.settings.get(MODULE_ID, setting)\r\n}\r\n\r\nexport function setSetting(setting, value) {\r\n return game.settings.set(MODULE_ID, setting, value)\r\n}\r\n\r\nexport function hasPermission() {\r\n return game.user.role >= getSetting('permission')\r\n}\r\n\r\nexport function getActionName(action) {\r\n return game.i18n.localize(`PF2E.Actions.${action}.Title`)\r\n}\r\n", "import { COVER_UUID, COVER_VALUES } from './constants.js'\r\nimport { MODULE_ID, localize } from './module.js'\r\n\r\nexport function createFlatFootedSource(visibility) {\r\n const condition = game.pf2e.ConditionManager.getCondition('off-guard')\r\n const source = condition.toObject()\r\n source.name += ` (${game.i18n.localize(`PF2E.condition.${visibility}.name`)})`\r\n return source\r\n}\r\n\r\nexport function createCoverSource(level, bonus) {\r\n bonus ??= COVER_VALUES[level] === 3 ? 4 : COVER_VALUES[level]\r\n\r\n return {\r\n _id: 'I9lfZUiCwMiGogVi',\r\n img: 'systems/pf2e/icons/conditions-2/status_acup.webp',\r\n name: localize('cover', level),\r\n system: {\r\n description: {\r\n gm: '',\r\n value: \"

When you're behind an obstacle that could block weapons, guard you against explosions, and make you harder to detect, you're behind cover. Standard cover gives you a +2 circumstance bonus to AC, to Reflex saves against area effects, and to Stealth checks to Hide, Sneak, or otherwise avoid detection. You can increase this to greater cover using the Take Cover basic action, increasing the circumstance bonus to +4. If cover is especially light, typically when it's provided by a creature, you have lesser cover, which grants a +1 circumstance bonus to AC. A creature with standard cover or greater cover can attempt to use Stealth to Hide, but lesser cover isn't sufficient.

\",\r\n },\r\n rules: [\r\n { domain: 'all', key: 'RollOption', option: `self:cover-bonus:${bonus}` },\r\n { domain: 'all', key: 'RollOption', option: `self:cover-level:${level}` },\r\n {\r\n key: 'FlatModifier',\r\n predicate: [\r\n { or: [{ and: ['self:condition:prone', 'item:ranged'] }, { not: 'self:cover-level:greater-prone' }] },\r\n ],\r\n selector: 'ac',\r\n type: 'circumstance',\r\n value: bonus,\r\n },\r\n {\r\n key: 'FlatModifier',\r\n predicate: ['area-effect', { not: 'self:cover-level:greater-prone' }],\r\n selector: 'reflex',\r\n type: 'circumstance',\r\n value: bonus,\r\n },\r\n {\r\n key: 'FlatModifier',\r\n predicate: [\r\n { or: ['action:hide', 'action:sneak', 'avoid-detection'] },\r\n { not: 'self:cover-level:greater-prone' },\r\n ],\r\n selector: 'stealth',\r\n type: 'circumstance',\r\n value: bonus,\r\n },\r\n {\r\n key: 'FlatModifier',\r\n predicate: ['action:avoid-notice', { not: 'self:cover-level:greater-prone' }],\r\n selector: 'initiative',\r\n type: 'circumstance',\r\n value: bonus,\r\n },\r\n ],\r\n slug: 'effect-cover',\r\n },\r\n type: 'effect',\r\n flags: {\r\n core: { sourceId: COVER_UUID },\r\n [MODULE_ID]: {\r\n level,\r\n bonus,\r\n },\r\n },\r\n }\r\n}\r\n\r\nexport function findChoiceSetRule(item, flag = undefined) {\r\n if (!item) return undefined\r\n return item.system.rules.find(rule => rule.key === 'ChoiceSet' && (!flag || rule.flag === flag))\r\n}\r\n", "import { COVER_UUID } from './constants.js'\r\nimport { findChoiceSetRule } from './effect.js'\r\n\r\nexport function getActorToken(actor, target = false) {\r\n if (!actor) return undefined\r\n const actorId = actor.id\r\n const isToken = actor.isToken\r\n const tokens = target ? game.user.targets : canvas.tokens?.controlled ?? []\r\n return (\r\n tokens.find(token => (isToken ? token.actor === actor : token.actor.id === actorId)) ??\r\n actor.getActiveTokens().shift() ??\r\n null\r\n )\r\n}\r\n\r\nexport function isProne(actor) {\r\n return actor.itemTypes.condition.some(item => item.slug === 'prone')\r\n}\r\n\r\nexport function getCoverEffect(actor, selection = false) {\r\n const effect = actor.itemTypes.effect.find(x => x.sourceId === COVER_UUID)\r\n return selection ? findChoiceSetRule(effect)?.selection.level : effect\r\n}\r\n\r\nexport function getFeatWithUUID(actor, uuid) {\r\n return actor.itemTypes.feat.find(f => f.sourceId === uuid)\r\n}\r\n\r\nfunction hasSense(actor, sense) {\r\n if (!actor || !sense || !actor.system.perception?.senses) return false\r\n sense = sense.toLowerCase()\r\n return !!actor.system.perception.senses.find(({ type }) => type === sense)\r\n}\r\n\r\nexport function hasGreaterDarkvision(actor) {\r\n return hasSense(actor, 'greater-darkvision')\r\n}\r\n\r\nexport function seeInvisibility(actor) {\r\n return hasSense(actor, 'see-invisibility')\r\n}\r\n", "const DEGREE_ADJUSTMENT_AMOUNTS = {\r\n LOWER_BY_TWO: -2,\r\n LOWER: -1,\r\n INCREASE: 1,\r\n INCREASE_BY_TWO: 2,\r\n TO_CRITICAL_FAILURE: 'criticalFailure',\r\n TO_FAILURE: 'failure',\r\n TO_SUCCESS: 'success',\r\n TO_CRITICAL_SUCCESS: 'criticalSuccess',\r\n}\r\n\r\nconst DEGREE_OF_SUCCESS_STRINGS = ['criticalFailure', 'failure', 'success', 'criticalSuccess']\r\n\r\nexport class DegreeOfSuccess {\r\n constructor(roll, dc, dosAdjustments = null) {\r\n if (roll instanceof Roll) {\r\n this.dieResult =\r\n (roll.isDeterministic\r\n ? roll.terms.find(t => t instanceof NumericTerm)\r\n : roll.dice.find(d => d instanceof Die && d.faces === 20)\r\n )?.total ?? 1\r\n this.rollTotal = roll.total\r\n } else {\r\n this.dieResult = roll.dieValue\r\n this.rollTotal = roll.dieValue + roll.modifier\r\n }\r\n\r\n this.dc = typeof dc === 'number' ? { value: dc } : dc\r\n\r\n this.unadjusted = this.#calculateDegreeOfSuccess()\r\n this.adjustment = this.#getDegreeAdjustment(this.unadjusted, dosAdjustments)\r\n this.value = this.adjustment ? this.#adjustDegreeOfSuccess(this.adjustment.amount, this.unadjusted) : this.unadjusted\r\n }\r\n\r\n static CRITICAL_FAILURE = 0\r\n static FAILURE = 1\r\n static SUCCESS = 2\r\n static CRITICAL_SUCCESS = 3\r\n\r\n #getDegreeAdjustment(degree, adjustments) {\r\n if (!adjustments) return null\r\n\r\n for (const outcome of ['all', ...DEGREE_OF_SUCCESS_STRINGS]) {\r\n const { label, amount } = adjustments[outcome] ?? {}\r\n if (\r\n amount &&\r\n label &&\r\n !(degree === DegreeOfSuccess.CRITICAL_SUCCESS && amount === DEGREE_ADJUSTMENT_AMOUNTS.INCREASE) &&\r\n !(degree === DegreeOfSuccess.CRITICAL_FAILURE && amount === DEGREE_ADJUSTMENT_AMOUNTS.LOWER) &&\r\n (outcome === 'all' || DEGREE_OF_SUCCESS_STRINGS.indexOf(outcome) === degree)\r\n ) {\r\n return { label, amount }\r\n }\r\n }\r\n\r\n return null\r\n }\r\n\r\n #adjustDegreeOfSuccess(amount, degreeOfSuccess) {\r\n switch (amount) {\r\n case 'criticalFailure':\r\n return 0\r\n case 'failure':\r\n return 1\r\n case 'success':\r\n return 2\r\n case 'criticalSuccess':\r\n return 3\r\n default:\r\n return Math.clamped(degreeOfSuccess + amount, 0, 3)\r\n }\r\n }\r\n\r\n /**\r\n * @param degree The current success value\r\n * @return The new success value\r\n */\r\n #adjustDegreeByDieValue(degree) {\r\n if (this.dieResult === 20) {\r\n return this.#adjustDegreeOfSuccess(DEGREE_ADJUSTMENT_AMOUNTS.INCREASE, degree)\r\n } else if (this.dieResult === 1) {\r\n return this.#adjustDegreeOfSuccess(DEGREE_ADJUSTMENT_AMOUNTS.LOWER, degree)\r\n }\r\n\r\n return degree\r\n }\r\n\r\n #calculateDegreeOfSuccess() {\r\n const dc = this.dc.value\r\n\r\n if (this.rollTotal - dc >= 10) {\r\n return this.#adjustDegreeByDieValue(DegreeOfSuccess.CRITICAL_SUCCESS)\r\n } else if (dc - this.rollTotal >= 10) {\r\n return this.#adjustDegreeByDieValue(DegreeOfSuccess.CRITICAL_FAILURE)\r\n } else if (this.rollTotal >= dc) {\r\n return this.#adjustDegreeByDieValue(DegreeOfSuccess.SUCCESS)\r\n }\r\n\r\n return this.#adjustDegreeByDieValue(DegreeOfSuccess.FAILURE)\r\n }\r\n}\r\n", "import { getFlag, getSetting, localize } from './module.js'\r\n\r\nexport function renderSceneConfig(config, html) {\r\n let settings = ''\r\n\r\n const list = ['standard', 'npc-vision']\r\n for (const setting of list) {\r\n const checked = getSceneSetting(config.object, setting)\r\n\r\n settings += `
\r\n \r\n \r\n

${localize(`settings.${setting}.short`)}

\r\n
`\r\n }\r\n\r\n settings += '
'\r\n\r\n html.find('.tab[data-tab=\"basic\"] hr').first().after(settings)\r\n\r\n const addedHeight = html\r\n .find('.pf2e-perception-injected')\r\n .toArray()\r\n .reduce((height, el) => ((height += el.clientHeight), height), 0)\r\n\r\n config.setPosition({ top: config.position.top - addedHeight / 2 })\r\n}\r\n\r\nexport function getValidTokens(token) {\r\n token = token instanceof Token ? token.document : token\r\n if (!(token instanceof TokenDocument)) return []\r\n\r\n let tokens = token.scene.tokens.filter(t => t !== token && t.actor?.isOfType('creature'))\r\n\r\n if (getSetting('encounter')) {\r\n const combat = game.combats.active\r\n if (!combat) return tokens\r\n\r\n return tokens.filter(t => {\r\n const actor = t.actor\r\n const traits = actor.traits\r\n return actor.type === 'familiar' || traits.has('minion') || traits.has('eidolon') || combat.getCombatantByToken(t.id)\r\n })\r\n }\r\n\r\n return tokens\r\n}\r\n\r\nexport function validateTokens(token, tokens) {\r\n const validToken = getValidTokens(token).map(t => t.id)\r\n return tokens.filter(t => {\r\n const id = t instanceof Token || t instanceof TokenDocument ? t.id : t\r\n return validToken.includes(id)\r\n })\r\n}\r\n\r\nexport function getSceneSetting(scene, setting) {\r\n return getFlag(scene, setting) ?? getSetting(setting)\r\n}\r\n", "export async function extractEphemeralEffects({ affects, origin, target, item, domains, options }) {\r\n if (!(origin && target)) return []\r\n\r\n const [effectsFrom, effectsTo] = affects === 'target' ? [origin, target] : [target, origin]\r\n const fullOptions = [...options, effectsFrom.getRollOptions(domains), effectsTo.getSelfRollOptions(affects)].flat()\r\n const resolvables = item ? (item.isOfType('spell') ? { spell: item } : { weapon: item }) : {}\r\n return (\r\n await Promise.all(\r\n domains\r\n .flatMap(s => effectsFrom.synthetics.ephemeralEffects[s]?.[affects] ?? [])\r\n .map(d => d({ test: fullOptions, resolvables }))\r\n )\r\n ).flatMap(e => e ?? [])\r\n}\r\n\r\nexport function traitSlugToObject(trait, dictionary) {\r\n // Look up trait labels from `npcAttackTraits` instead of `weaponTraits` in case a battle form attack is\r\n // in use, which can include what are normally NPC-only traits\r\n const traitObject = {\r\n name: trait,\r\n label: game.i18n.localize(dictionary[trait] ?? trait),\r\n }\r\n if (objectHasKey(CONFIG.PF2E.traitsDescriptions, trait)) {\r\n traitObject.description = CONFIG.PF2E.traitsDescriptions[trait]\r\n }\r\n\r\n return traitObject\r\n}\r\n\r\nexport function objectHasKey(obj, key) {\r\n return (typeof key === 'string' || typeof key === 'number') && key in obj\r\n}\r\n\r\nexport function getRangeIncrement(attackItem, distance) {\r\n if (!attackItem.isOfType('action', 'melee', 'weapon')) return null\r\n\r\n const { increment } = attackItem.range ?? {}\r\n return increment && typeof distance === 'number' ? Math.max(Math.ceil(distance / increment), 1) : null\r\n}\r\n\r\nexport function isOffGuardFromFlanking(target, origin) {\r\n if (!target?.isOfType('creature')) return false\r\n const { flanking } = target.attributes\r\n return !flanking.flankable\r\n ? false\r\n : typeof flanking.offGuardable === 'number'\r\n ? origin.level > flanking.offGuardable\r\n : flanking.offGuardable\r\n}\r\n\r\nexport function isObject(value) {\r\n return typeof value === 'object' && value !== null\r\n}\r\n\r\nexport function tupleHasValue(array, value) {\r\n return array.includes(value)\r\n}\r\n", "/**\r\n * Measure distance using Pathfinder 2e grid-counting rules\r\n * @param p0 The origin point\r\n * @param p1 The destination point\r\n */\r\nfunction measureDistance(p0, p1) {\r\n if (!canvas.dimensions) return NaN\r\n\r\n if (canvas.grid.type !== CONST.GRID_TYPES.SQUARE) {\r\n return canvas.grid.measureDistance(p0, p1)\r\n }\r\n\r\n return measureDistanceOnGrid(new Ray(p0, p1))\r\n}\r\n\r\n/**\r\n * Given the distance in each dimension, measure the distance in grid units\r\n * @param segment A pair of x/y distances constituting the line segment between two points\r\n * @param [reach] If this is a reach measurement, the origin actor's reach\r\n */\r\nfunction measureDistanceOnGrid(segment, { reach = null } = {}) {\r\n if (!canvas.dimensions) return NaN\r\n\r\n const gridSize = canvas.dimensions.size\r\n const gridDistance = canvas.dimensions.distance\r\n\r\n const nx = Math.ceil(Math.abs(segment.dx / gridSize))\r\n const ny = Math.ceil(Math.abs(segment.dy / gridSize))\r\n const nz = Math.ceil(Math.abs((segment.dz || 0) / gridSize))\r\n\r\n // ingore the lowest difference\r\n const sortedDistance = [nx, ny, nz].sort((a, b) => a - b)\r\n // Get the number of straight and diagonal moves\r\n const squares = {\r\n doubleDiagonal: sortedDistance[0],\r\n diagonal: sortedDistance[1] - sortedDistance[0],\r\n straight: sortedDistance[2] - sortedDistance[1],\r\n }\r\n\r\n // \"Unlike with measuring most distances, 10-foot reach can reach 2 squares diagonally.\" (CRB pg 455)\r\n const reduction = squares.diagonal + squares.doubleDiagonal > 1 && reach === 10 ? 1 : 0\r\n\r\n // Diagonals in PF pretty much count as 1.5 times a straight\r\n // for diagonals across the x, y, and z axis count it as 1.75 as a best guess\r\n const distance = Math.floor(squares.doubleDiagonal * 1.75 + squares.diagonal * 1.5 + squares.straight) - reduction\r\n\r\n return distance * gridDistance\r\n}\r\n\r\n/** Highlight grid according to Pathfinder 2e effect-area shapes */\r\nexport function highlightGrid({ areaType, object, colors, document, collisionType = 'move', preview = false, collisionOrigin }) {\r\n // Only highlight for objects that are non-previews (have IDs)\r\n if (!object.id && !preview) return\r\n\r\n const { grid, dimensions } = canvas\r\n if (!(grid && dimensions)) return\r\n\r\n // Set data defaults\r\n const angle = document.angle ?? 0\r\n const direction = document.direction ?? 45\r\n\r\n // Clear existing highlight\r\n const highlightLayer = grid.getHighlightLayer(object.highlightId)?.clear()\r\n if (!highlightLayer) return\r\n\r\n const [cx, cy] = grid.getCenter(document.x, document.y)\r\n const [col0, row0] = grid.grid.getGridPositionFromPixels(cx, cy)\r\n const minAngle = (360 + ((direction - angle * 0.5) % 360)) % 360\r\n const maxAngle = (360 + ((direction + angle * 0.5) % 360)) % 360\r\n const snappedOrigin = canvas.grid.getSnappedPosition(document.x, document.y, object.layer.gridPrecision)\r\n const withinAngle = (min, max, value) => {\r\n min = (360 + (min % 360)) % 360\r\n max = (360 + (max % 360)) % 360\r\n value = (360 + (value % 360)) % 360\r\n\r\n if (min < max) return value >= min && value <= max\r\n return value >= min || value <= max\r\n }\r\n\r\n // Offset measurement for cones to ensure that cones only start measuring from cell borders\r\n const coneOriginOffset = (() => {\r\n if (areaType !== 'cone') return { x: 0, y: 0 }\r\n\r\n // Degrees anticlockwise from pointing right. In 45-degree increments from 0 to 360\r\n const dir = (direction >= 0 ? 360 - direction : -direction) % 360\r\n // If we're not on a border for X, offset by 0.5 or -0.5 to the border of the cell in the direction we're looking on X axis\r\n const xOffset =\r\n snappedOrigin.x % dimensions.size !== 0\r\n ? Math.sign((1 * Math.round(Math.cos(Math.toRadians(dir)) * 100)) / 100) / 2\r\n : 0\r\n // Same for Y, but cos Y goes down on screens, we invert\r\n const yOffset =\r\n snappedOrigin.y % dimensions.size !== 0\r\n ? -Math.sign((1 * Math.round(Math.sin(Math.toRadians(dir)) * 100)) / 100) / 2\r\n : 0\r\n return { x: xOffset * dimensions.size, y: yOffset * dimensions.size }\r\n })()\r\n\r\n // Point we are measuring distances from\r\n const padding = Math.clamped(document.width ?? 0, 1.5, 2)\r\n const docDistance = document.distance ?? 0\r\n const padded = (docDistance * padding) / dimensions.distance\r\n const rowCount = Math.ceil(padded / (dimensions.size / grid.h))\r\n const columnCount = Math.ceil(padded / (dimensions.size / grid.w))\r\n\r\n // If this is an emanation, measure from the outer squares of the token's space\r\n const offsetEmanationOrigin = destination => {\r\n if (!(areaType === 'emanation' && object instanceof Token)) {\r\n return { x: 0, y: 0 }\r\n }\r\n\r\n // No offset is needed for medium and smaller creatures\r\n if (object.w <= dimensions.size) return { x: 0, y: 0 }\r\n\r\n const offset = (object.w - dimensions.size) / 2\r\n const getCoordinate = (centerCoord, destCoord) =>\r\n destCoord === centerCoord ? 0 : destCoord > centerCoord ? offset : -offset\r\n\r\n return {\r\n x: getCoordinate(object.center.x, destination.x),\r\n y: getCoordinate(object.center.y, destination.y),\r\n }\r\n }\r\n\r\n for (let a = -columnCount; a < columnCount; a++) {\r\n for (let b = -rowCount; b < rowCount; b++) {\r\n // Position of cell's top-left corner, in pixels\r\n const [gx, gy] = canvas.grid.grid.getPixelsFromGridPosition(col0 + a, row0 + b)\r\n // Position of cell's center in pixels\r\n const destination = {\r\n x: gx + dimensions.size * 0.5,\r\n y: gy + dimensions.size * 0.5,\r\n }\r\n if (destination.x < 0 || destination.y < 0) continue\r\n\r\n // Determine point of origin\r\n const emanationOriginOffset = offsetEmanationOrigin(destination)\r\n const origin = {\r\n x: snappedOrigin.x + coneOriginOffset.x + emanationOriginOffset.x,\r\n y: snappedOrigin.y + coneOriginOffset.y + emanationOriginOffset.y,\r\n }\r\n\r\n if (areaType === 'cone') {\r\n const ray = new Ray(origin, destination)\r\n const rayAngle = (360 + ((ray.angle / (Math.PI / 180)) % 360)) % 360\r\n if (ray.distance > 0 && !withinAngle(minAngle, maxAngle, rayAngle)) {\r\n continue\r\n }\r\n }\r\n\r\n // Determine grid-square point to which we're measuring the distance\r\n const distance = measureDistance(destination, origin)\r\n if (distance > docDistance) continue\r\n\r\n const hasCollision =\r\n canvas.ready &&\r\n CONFIG.Canvas.polygonBackends[collisionType].testCollision(collisionOrigin ?? origin, destination, {\r\n type: collisionType,\r\n mode: 'any',\r\n })\r\n\r\n if (hasCollision) {\r\n grid.grid.highlightGridPosition(highlightLayer, {\r\n x: gx,\r\n y: gy,\r\n border: 0x000001,\r\n color: 0x000000,\r\n })\r\n highlightLayer\r\n .beginFill(0x000000, 0.5)\r\n .moveTo(gx, gy)\r\n .lineTo(gx + dimensions.size, gy + dimensions.size)\r\n .endFill()\r\n } else {\r\n grid.grid.highlightGridPosition(highlightLayer, {\r\n x: gx,\r\n y: gy,\r\n border: colors.border,\r\n color: colors.fill,\r\n })\r\n }\r\n }\r\n }\r\n}\r\n", "import { DARKNESS_COLOR, DARKNESS_SLUGS, MIST_COLOR, MIST_SLUGS, POISON_GREEN } from './constants.js'\r\nimport { MODULE_ID, getFlag, localize } from './module.js'\r\nimport { tupleHasValue } from './pf2e/helpers.js'\r\nimport { highlightGrid } from './pf2e/highlight.js'\r\n\r\nconst templateConversion = {\r\n burst: 'circle',\r\n emanation: 'circle',\r\n line: 'ray',\r\n cone: 'cone',\r\n rect: 'rect',\r\n cube: 'rect',\r\n square: 'rect',\r\n}\r\n\r\nexport function createSeekTemplate({ type = 'burst', token, distance }) {\r\n if (!checkScene(token)) return\r\n\r\n distance ??= type === 'cone' ? 30 : 15\r\n\r\n createTemplate({\r\n type,\r\n distance,\r\n traits: ['concentrate', 'secret'],\r\n flags: {\r\n type: 'seek',\r\n tokenId: token.id,\r\n collisionType: 'sight',\r\n collisionOrigin: token.center,\r\n },\r\n })\r\n}\r\n\r\nexport function createDarknessTemplate({ type = 'burst', distance = 20, conceal = false } = {}) {\r\n createTemplate({\r\n type,\r\n distance,\r\n fillColor: DARKNESS_COLOR,\r\n flags: {\r\n type: 'darkness',\r\n conceal,\r\n },\r\n })\r\n}\r\n\r\nexport function createMistTemplate({ type = 'burst', distance = 20 } = {}) {\r\n createTemplate({\r\n type,\r\n distance,\r\n fillColor: MIST_COLOR,\r\n flags: {\r\n type: 'mist',\r\n },\r\n })\r\n}\r\n\r\nfunction getTemplates(type, token) {\r\n if (token && !checkScene(token)) return null\r\n return canvas.scene.templates.filter(t => getFlag(t, 'type') === type) ?? []\r\n}\r\n\r\nexport function getDarknessTemplates(token) {\r\n return getTemplates('darkness', token)\r\n}\r\n\r\nexport function getMistTemplates(token) {\r\n return getTemplates('mist', token)\r\n}\r\n\r\nexport function getSeekTemplateTokens(token) {\r\n if (!checkScene(token)) return null\r\n\r\n const template = canvas.scene.templates.find(t => getFlag(t, 'type') === 'seek')\r\n if (!template) return null\r\n\r\n const tokenDoc = token instanceof Token ? token.document : token\r\n\r\n return getTemplateTokens(template, { collisionType: 'sight', collisionOrigin: tokenDoc.center })\r\n}\r\n\r\nexport async function deleteSeekTemplate(token) {\r\n const templates = token.scene.templates.filter(t => getFlag(t, 'type') === 'seek' && getFlag(t, 'tokenId') === token.id)\r\n for (const template of templates) {\r\n await template.delete()\r\n }\r\n}\r\n\r\nfunction checkScene(token) {\r\n if (canvas.scene === token.scene) return true\r\n ui.notifications.error(localize('template.scene'))\r\n return false\r\n}\r\n\r\nexport function createTemplate({ type, distance, traits, fillColor, width, flags }) {\r\n const templateType = templateConversion[type]\r\n\r\n const templateData = {\r\n distance,\r\n t: templateType,\r\n fillColor: fillColor || game.user.color,\r\n flags: {\r\n [MODULE_ID]: flags,\r\n },\r\n }\r\n\r\n switch (templateType) {\r\n case 'ray':\r\n templateData.width = width || CONFIG.MeasuredTemplate.defaults.width * (canvas.dimensions?.distance ?? 1)\r\n break\r\n case 'cone':\r\n templateData.angle = CONFIG.MeasuredTemplate.defaults.angle\r\n break\r\n case 'rect': {\r\n const distance = templateData.distance ?? 0\r\n templateData.distance = Math.hypot(distance, distance)\r\n templateData.width = distance\r\n templateData.direction = 45\r\n break\r\n }\r\n }\r\n\r\n if (traits) setProperty(templateData, 'flags.pf2e.origin.traits', traits)\r\n\r\n canvas.templates.createPreview(templateData)\r\n}\r\n\r\nexport function getTemplateTokens(template, { collisionOrigin, collisionType = 'move' } = {}) {\r\n const templateObj = template instanceof MeasuredTemplateDocument ? template.object : template\r\n\r\n if (!canvas.scene) return []\r\n const { grid, dimensions } = canvas\r\n if (!(grid && dimensions)) return []\r\n\r\n const gridHighlight = grid.getHighlightLayer(templateObj.highlightId)\r\n if (!gridHighlight || grid.type !== CONST.GRID_TYPES.SQUARE) return []\r\n const origin = collisionOrigin ?? templateObj.center\r\n\r\n // Get all the tokens that are inside the highlight bounds\r\n const tokens = canvas.tokens.quadtree.getObjects(gridHighlight.getLocalBounds(undefined, true))\r\n\r\n const containedTokens = []\r\n for (const token of tokens) {\r\n const tokenDoc = token.document\r\n\r\n // Collect the position of all grid squares that this token occupies as \"x.y\"\r\n const tokenPositions = []\r\n for (let h = 0; h < tokenDoc.height; h++) {\r\n const y = token.y + h * grid.size\r\n tokenPositions.push(`${token.x}.${y}`)\r\n if (tokenDoc.width > 1) {\r\n for (let w = 1; w < tokenDoc.width; w++) {\r\n tokenPositions.push(`${token.x + w * grid.size}.${y}`)\r\n }\r\n }\r\n }\r\n\r\n for (const position of tokenPositions) {\r\n // Check if a position exists within this GridHiglight\r\n if (!gridHighlight.positions.has(position)) {\r\n continue\r\n }\r\n // Position of cell's top-left corner, in pixels\r\n const [gx, gy] = position.split('.').map(s => Number(s))\r\n // Position of cell's center in pixels\r\n const destination = {\r\n x: gx + dimensions.size * 0.5,\r\n y: gy + dimensions.size * 0.5,\r\n }\r\n if (destination.x < 0 || destination.y < 0) continue\r\n\r\n const hasCollision =\r\n canvas.ready &&\r\n collisionType &&\r\n CONFIG.Canvas.polygonBackends[collisionType].testCollision(origin, destination, {\r\n type: collisionType,\r\n mode: 'any',\r\n })\r\n\r\n if (!hasCollision) {\r\n containedTokens.push(token)\r\n break\r\n }\r\n }\r\n }\r\n return containedTokens\r\n}\r\n\r\nexport function highlightTemplateGrid() {\r\n const isCircleOrCone = ['circle', 'cone'].includes(this.document.t)\r\n const hasSquareGrid = canvas.grid.type === CONST.GRID_TYPES.SQUARE\r\n if (!isCircleOrCone || !hasSquareGrid) {\r\n return MeasuredTemplate.prototype.highlightGrid.call(this)\r\n }\r\n\r\n // Refrain from highlighting if not visible\r\n if (!this.isVisible) {\r\n canvas.grid.getHighlightLayer(this.highlightId)?.clear()\r\n return\r\n }\r\n\r\n const collisionType = getFlag(this.document, 'collisionType')\r\n const collisionOrigin = getFlag(this.document, 'collisionOrigin')\r\n\r\n this.snapForShape()\r\n highlightGrid({\r\n areaType: tupleHasValue(['burst', 'cone', 'emanation'], this.areaType) ? this.areaType : 'burst',\r\n object: this,\r\n document: this.document,\r\n colors: { border: this.borderColor, fill: this.fillColor },\r\n preview: true,\r\n collisionType,\r\n collisionOrigin,\r\n })\r\n}\r\n\r\nexport function preCreateMeasuredTemplate(template) {\r\n const { type, slug, castLevel = 0 } = template.getFlag('pf2e', 'origin') ?? {}\r\n if (type !== 'spell') return\r\n\r\n if (DARKNESS_SLUGS.includes(slug)) {\r\n template.updateSource({\r\n fillColor: DARKNESS_COLOR,\r\n [`flags.${MODULE_ID}`]: { type: 'darkness', conceal: castLevel >= 4 },\r\n })\r\n } else if (MIST_SLUGS.includes(slug)) {\r\n template.updateSource({\r\n fillColor: MIST_COLOR,\r\n [`flags.${MODULE_ID}`]: { type: 'mist' },\r\n })\r\n } else if (slug === 'cloudkill') {\r\n template.updateSource({\r\n fillColor: POISON_GREEN,\r\n [`flags.${MODULE_ID}`]: { type: 'mist' },\r\n })\r\n }\r\n}\r\n\r\nexport function onMeasuredTemplate(template) {\r\n if (getFlag(template, 'type') === 'darkness') canvas.perception.update({ initializeVision: true })\r\n}\r\n", "export function modifier(value) {\r\n return value >= 0 ? `+${value}` : value\r\n}\r\n\r\nexport function omit(object, names) {\r\n const set = new Set(names)\r\n return Object.entries(object).reduce((acc, [name, value]) => {\r\n if (!set.has(name)) acc[name] = value\r\n return acc\r\n }, {})\r\n}\r\n\r\nexport function getPrototype(obj, depth = 1) {\r\n const prototype = Object.getPrototypeOf(obj)\r\n if (depth > 1) return getPrototype(prototype, depth - 1)\r\n return prototype\r\n}\r\n\r\nexport function sortByName(a, b) {\r\n return a.name.localeCompare(b.name)\r\n}\r\n\r\nexport function asNumberOnly(value) {\r\n value = Number(value)\r\n return isNaN(value) ? undefined : value\r\n}\r\n", "import { COVERS, VISIBILITIES, defaultValues } from '../constants.js'\r\nimport { MODULE_ID, localize } from '../module.js'\r\nimport { validateTokens } from '../scene.js'\r\nimport { getTokenData, setTokenData } from '../token.js'\r\nimport { sortByName } from '../utils.js'\r\n\r\nexport class BaseMenu extends Application {\r\n #token\r\n #resolve\r\n #selected\r\n #_currentData\r\n #hoverTokenListener\r\n\r\n constructor({ token, resolve, selected = [] }, options = {}) {\r\n super(options)\r\n\r\n this.#token = token\r\n this.#resolve = resolve\r\n this.#selected = selected\r\n\r\n this.#hoverTokenListener = (token, hover) => {\r\n const tokenId = token.id\r\n const tokens = this.element.find('[data-token-id]')\r\n tokens.removeClass('hover')\r\n if (hover) tokens.filter(`[data-token-id=${tokenId}]`).addClass('hover')\r\n }\r\n\r\n Hooks.on('hoverToken', this.#hoverTokenListener)\r\n }\r\n\r\n async close(options = {}) {\r\n Hooks.off('hoverToken', this.#hoverTokenListener)\r\n this.#resolve?.(options.resolve ?? false)\r\n super.close(options)\r\n }\r\n\r\n static get defaultOptions() {\r\n return mergeObject(Application.defaultOptions, {\r\n minimizable: false,\r\n })\r\n }\r\n\r\n static async openMenu(params, options = {}) {\r\n if (params.token instanceof TokenDocument) params.token = params.token.object\r\n if (!params.token) {\r\n ui.notifications.error(localize('menu.no-token'))\r\n return\r\n }\r\n\r\n options.id = `${MODULE_ID}-${params.token.document.uuid}`\r\n\r\n const win = Object.values(ui.windows).find(x => x.id === options.id)\r\n if (win) win.close()\r\n\r\n return new Promise(resolve => {\r\n params.resolve = resolve\r\n // biome-ignore lint/complexity/noThisInStatic: not working\r\n new this(params, options).render(true)\r\n })\r\n }\r\n\r\n static createPropertyData(original, current, property) {\r\n const defaultValue = defaultValues[property]\r\n const originalValue = original[property] ?? defaultValue\r\n const currentValue = current[property] ?? defaultValue\r\n return {\r\n original: originalValue,\r\n current: currentValue,\r\n changed: originalValue !== currentValue,\r\n custom: currentValue !== defaultValue,\r\n originalCustom: originalValue !== defaultValue,\r\n }\r\n }\r\n\r\n get token() {\r\n return this.#token\r\n }\r\n\r\n get document() {\r\n return this.#token.document\r\n }\r\n\r\n get actor() {\r\n return this.#token.actor\r\n }\r\n\r\n get scene() {\r\n return this.#token.scene\r\n }\r\n\r\n get selected() {\r\n return this.#selected.length ? validateTokens(this.token, this.#selected) : []\r\n }\r\n\r\n get currentData() {\r\n return deepClone(this.#currentData)\r\n }\r\n\r\n get #currentData() {\r\n if (!this.#_currentData) this.#_currentData = this.getSavedData()\r\n return this.#_currentData\r\n }\r\n\r\n getSavedData() {\r\n const data = getTokenData(this.document) ?? {}\r\n return deepClone(data)\r\n }\r\n\r\n reset() {\r\n this.#_currentData = this.getSavedData()\r\n this.#selected = []\r\n this.render()\r\n }\r\n\r\n isSelected(token) {\r\n const id = typeof token === 'object' ? token.id : token\r\n return this.#selected.includes(id)\r\n }\r\n\r\n getData(options) {\r\n return {\r\n i18n: localize,\r\n covers: COVERS.map(value => ({ value, label: localize(`cover.${value}`) })),\r\n visibilities: VISIBILITIES.map(value => ({ value, label: localize(`visibility.${value}`) })),\r\n }\r\n }\r\n\r\n activateListeners(html) {\r\n html.find('[data-token-id]').on('mouseenter', event => {\r\n const { tokenId } = event.currentTarget.dataset\r\n const token = this.scene.tokens.get(tokenId)?.object\r\n if (!token || token.controlled) return\r\n token._onHoverIn(event, { hoverOutOthers: true })\r\n })\r\n\r\n html.find('[data-action=close]').on('click', () => {\r\n this.close({ resolve: true })\r\n })\r\n\r\n html.find('select[name=visibility], select[name=cover]').on('change', event => {\r\n const target = event.currentTarget\r\n const property = target.name\r\n const defaultValue = defaultValues[property]\r\n const value = target.value || defaultValue\r\n const tokenId = target.closest('.token')?.dataset.tokenId\r\n const tokenIds = tokenId ? [tokenId] : this.#selected\r\n\r\n for (const tokenId of tokenIds) {\r\n setProperty(this.#currentData, `${tokenId}.${property}`, value)\r\n }\r\n\r\n if (tokenId) {\r\n target.classList.toggle('changed', value !== target.dataset.original)\r\n target.classList.toggle('custom', value !== defaultValue)\r\n } else this.render()\r\n })\r\n\r\n html.find('[data-action=accept]').on('click', event => {\r\n this._saveData(this.#currentData)\r\n this.close({ resolve: true })\r\n })\r\n }\r\n\r\n _saveData(currentData) {\r\n setTokenData(this.document, currentData)\r\n }\r\n\r\n _setSelected(selected) {\r\n this.#selected =\r\n selected ??\r\n this.element\r\n .find('[data-token-id].ui-selected')\r\n .toArray()\r\n .map(el => el.dataset.tokenId)\r\n }\r\n\r\n _spliIntoAlliances(tokens) {\r\n const allies = []\r\n const enemies = []\r\n const neutral = []\r\n\r\n const alliance = this.actor.alliance\r\n const opposition = alliance === 'party' ? 'opposition' : alliance === 'opposition' ? 'party' : null\r\n\r\n for (const token of tokens) {\r\n if (opposition) {\r\n const actorAlliance = token.actor ? token.actor.alliance : token.alliance\r\n if (actorAlliance === alliance) allies.push(token)\r\n else if (actorAlliance === opposition) enemies.push(token)\r\n else if (actorAlliance === null) neutral.push(token)\r\n } else neutral.push(token)\r\n }\r\n\r\n return {\r\n allies: allies.sort(sortByName),\r\n neutral: neutral.sort(sortByName),\r\n enemies: enemies.sort(sortByName),\r\n hasTokens: allies.length || enemies.length || neutral.length,\r\n }\r\n }\r\n}\r\n", "import { localize, templatePath } from '../module.js'\r\nimport { getValidTokens } from '../scene.js'\r\nimport { BaseMenu } from './base-menu.js'\r\n\r\nexport class PerceptionMenu extends BaseMenu {\r\n get title() {\r\n return localize('menu.perception.title', { name: this.token.name })\r\n }\r\n\r\n get template() {\r\n return templatePath('perception')\r\n }\r\n\r\n getData(options) {\r\n const selected = this.selected\r\n const currentData = this.currentData\r\n const originalData = this.getSavedData()\r\n\r\n const tokens = getValidTokens(this.token).map(({ id, name, actor }) => {\r\n const current = currentData[id] ?? {}\r\n const original = originalData[id] ?? {}\r\n\r\n return {\r\n id,\r\n name,\r\n alliance: actor.alliance,\r\n cover: BaseMenu.createPropertyData(original, current, 'cover'),\r\n visibility: BaseMenu.createPropertyData(original, current, 'visibility'),\r\n selected: selected.includes(id),\r\n }\r\n })\r\n\r\n return {\r\n ...super.getData(options),\r\n ...this._spliIntoAlliances(tokens),\r\n }\r\n }\r\n\r\n activateListeners(html) {\r\n super.activateListeners(html)\r\n\r\n html.filter('.tokens').selectable({\r\n autoRefresh: false,\r\n filter: '.token',\r\n cancel: 'header,select',\r\n stop: () => this._setSelected(),\r\n })\r\n\r\n html.find('[data-action=select-all]').on('click', event => {\r\n const section = $(event.currentTarget).closest('section')\r\n const tokens = (section.length ? section : html).find('[data-token-id]')\r\n const allSelected = tokens.filter(':not(.ui-selected)').length === 0\r\n tokens.toggleClass('ui-selected', !allSelected)\r\n this._setSelected()\r\n })\r\n\r\n html.find('[data-action=use-selection]').on('click', event => {\r\n this._setSelected(canvas.tokens.controlled.map(t => t.id))\r\n this.render()\r\n })\r\n\r\n html.find('[data-action=reset]').on('click', event => this.reset())\r\n }\r\n}\r\n", "export const RECT_CORNERS = [\r\n { x: 0, y: 0 },\r\n { x: 1, y: 0 },\r\n { x: 0, y: 1 },\r\n { x: 1, y: 1 },\r\n]\r\n\r\nexport const RECT_SPREAD = [\r\n { x: 0.25, y: 0.25 },\r\n { x: 0.5, y: 0.25 },\r\n { x: 0.75, y: 0.25 },\r\n { x: 0.25, y: 0.5 },\r\n { x: 0.5, y: 0.5 },\r\n { x: 0.75, y: 0.5 },\r\n { x: 0.25, y: 0.75 },\r\n { x: 0.5, y: 0.75 },\r\n { x: 0.75, y: 0.75 },\r\n]\r\n\r\nexport function getRectEdges(rect, margin) {\r\n const opposite = 1 - margin\r\n return {\r\n top: { A: getRectPoint({ x: margin, y: margin }, rect), B: getRectPoint({ x: opposite, y: margin }, rect) },\r\n right: { A: getRectPoint({ x: opposite, y: margin }, rect), B: getRectPoint({ x: opposite, y: opposite }, rect) },\r\n bottom: { A: getRectPoint({ x: opposite, y: opposite }, rect), B: getRectPoint({ x: margin, y: opposite }, rect) },\r\n left: { A: getRectPoint({ x: margin, y: opposite }, rect), B: getRectPoint({ x: margin, y: margin }, rect) },\r\n }\r\n}\r\n\r\nexport function lineIntersectWall(origin, target, debug = false) {\r\n if (debug) drawDebugLine(origin, target)\r\n return CONFIG.Canvas.polygonBackends.move.testCollision(origin, target, { type: 'move', mode: 'any' })\r\n}\r\n\r\nexport function pointToTokenIntersectWall(origin, token, debug = false) {\r\n for (const point of rectSpread(token.bounds)) {\r\n if (lineIntersectWall(origin, point, debug)) return true\r\n }\r\n return false\r\n}\r\n\r\nexport function getRectPoint(point, rect) {\r\n return { x: rect.x + rect.width * point.x, y: rect.y + rect.height * point.y }\r\n}\r\n\r\nexport function clearDebug() {\r\n canvas.controls.debug.clear()\r\n}\r\n\r\nexport function drawDebugLine(origin, target, color = 'blue') {\r\n const hex = color === 'blue' ? 0x0066cc : color === 'red' ? 0xff0000 : 0x16a103\r\n canvas.controls.debug.lineStyle(4, hex).moveTo(origin.x, origin.y).lineTo(target.x, target.y)\r\n}\r\n\r\nexport function* rectSpread(rect) {\r\n for (const point of RECT_SPREAD) {\r\n yield getRectPoint(point, rect)\r\n }\r\n}\r\n\r\nexport function* rectCorners(rect) {\r\n for (const point of RECT_CORNERS) {\r\n yield getRectPoint(point, rect)\r\n }\r\n}\r\n", "import { clearDebug, drawDebugLine } from './geometry.js'\r\n\r\nexport function getLightExposure(token, debug = false) {\r\n token = token instanceof Token ? token : token.object\r\n\r\n if (token.document.hasStatusEffect(CONFIG.specialStatusEffects.INVISIBLE)) return undefined\r\n\r\n const scene = token.scene\r\n if (scene !== canvas.scene || !scene.tokenVision || scene.darkness < scene.globalLightThreshold) return undefined\r\n\r\n if (debug) clearDebug()\r\n\r\n const center = token.document.center\r\n let exposure = null\r\n\r\n for (const light of canvas.effects.lightSources) {\r\n if (!light.active) continue\r\n\r\n const bright = light.data.bright\r\n const dim = light.data.dim\r\n\r\n if (light.object === token) {\r\n if (bright) return 'bright'\r\n if (dim) exposure = 'dim'\r\n continue\r\n }\r\n\r\n if (!light.shape.contains(center.x, center.y)) {\r\n if (debug) drawDebugLine(light, center, 'red')\r\n continue\r\n }\r\n\r\n if (light.ratio === 1) {\r\n if (debug) drawDebugLine(light, center, 'green')\r\n return 'bright'\r\n }\r\n\r\n if (light.ratio === 0) {\r\n if (debug) drawDebugLine(light, center, 'blue')\r\n exposure = 'dim'\r\n continue\r\n }\r\n\r\n const distance = new Ray(light, center).distance\r\n if (distance <= bright) {\r\n if (debug) {\r\n drawDebugLine(light, center, 'green')\r\n exposure = 'bright'\r\n } else return 'bright'\r\n } else {\r\n if (debug) {\r\n drawDebugLine(light, center, 'blue')\r\n if (exposure !== 'bright') exposure = 'dim'\r\n } else exposure = 'dim'\r\n }\r\n }\r\n\r\n return exposure\r\n}\r\n", "import { COVERS, VISIBILITIES } from './constants.js'\r\n\r\nconst DATA = {\r\n cover: {\r\n cancel: { targets: ['lesser', 'standard', 'greater', 'greater-prone'] },\r\n set: {\r\n targets: ['none', 'lesser', 'standard', 'greater', 'greater-prone'],\r\n value: ['none', 'lesser', 'standard', 'greater', 'greater-prone'],\r\n },\r\n reduce: { targets: ['lesser', 'standard', 'greater', 'greater-prone'] },\r\n ignore: { targets: 'string' },\r\n ignored: { targets: ['allies', 'enemies'] },\r\n ac: { targets: ['lesser', 'standard', 'greater', 'greater-prone'], value: ['number'] },\r\n },\r\n visibility: {\r\n cancel: { targets: ['concealed', 'hidden', 'undetected', 'unnoticed'] },\r\n set: {\r\n targets: ['observed', 'concealed', 'hidden', 'undetected', 'unnoticed'],\r\n value: ['observed', 'concealed', 'hidden', 'undetected', 'unnoticed'],\r\n },\r\n reduce: { targets: ['concealed', 'hidden', 'undetected', 'unnoticed'] },\r\n noff: { targets: ['hidden', 'undetected', 'unnoticed'] },\r\n noinvis: {},\r\n dc: { targets: ['concealed', 'hidden'], value: ['number', 'string'] },\r\n },\r\n}\r\n\r\nconst SELECTORS = {\r\n cover: Object.keys(DATA.cover),\r\n visibility: Object.keys(DATA.visibility),\r\n all: [...Object.keys(DATA.cover), ...Object.keys(DATA.visibility)],\r\n}\r\n\r\nexport function setupRuleElement() {\r\n const rollOptionSchema = game.pf2e.RuleElements.builtin.RollOption.defineSchema()\r\n const PredicateField = rollOptionSchema.predicate.constructor\r\n const ResolvableValueField = rollOptionSchema.value.constructor\r\n\r\n class PF2ePerceptionRuleElement extends game.pf2e.RuleElement {\r\n constructor(source, options) {\r\n if (typeof source.targets === 'string') source.targets = [source.targets]\r\n\r\n super({ priority: CONST.ACTIVE_EFFECT_MODES.CUSTOM, ...source }, options)\r\n\r\n const selectorType = SELECTORS[source.type]\r\n if (!selectorType) return\r\n\r\n if (!selectorType?.includes(source.selector)) {\r\n this.failValidation(`The type \"${source.type}\" only accepts the following selectors: ${selectorType.join(', ')}.`)\r\n return\r\n }\r\n\r\n const selector = DATA[source.type]?.[source.selector]\r\n if (!selector) return\r\n\r\n const selectorWarn = msg => {\r\n const { name, uuid } = this.item\r\n console.warn(`PF2e System | PF2ePerception rules element on item ${name} (${uuid}) simple warning: ${msg}`)\r\n }\r\n\r\n const targetsType = Array.isArray(selector.targets) ? [...selector.targets, 'all'] : selector.targets\r\n const joinedTargets = Array.isArray(targetsType) ? targetsType.join(', ') : null\r\n\r\n if (!targetsType && source.targets?.length) {\r\n selectorWarn(`The selector \"${source.selector}\" doesn't accept any targets property.`)\r\n return\r\n }\r\n\r\n if (source.selector === 'ignore' && !source.targets?.length) {\r\n const msg = `The selector \"${source.selector}\" requires a targets property with the ids of the tokens on the scene that should not give cover.`\r\n this.failValidation(msg)\r\n return\r\n }\r\n\r\n if (joinedTargets && source.targets?.some(t => !targetsType.includes(t))) {\r\n const msg = `The targets property of selector \"${source.selector}\" only accepts the following: ${joinedTargets}.`\r\n this.failValidation(msg)\r\n return\r\n } else if (!joinedTargets && targetsType && source.targets?.some(t => typeof t !== targetsType)) {\r\n const msg = `The targets property of selector \"${source.selector}\" needs to be of type \"${targetsType}\".`\r\n this.failValidation(msg)\r\n return\r\n }\r\n\r\n if (!selector.value && source.value) {\r\n selectorWarn(`The selector \"${source.selector}\" doesn't accept any value property.`)\r\n return\r\n }\r\n\r\n if (source.selector === 'set') {\r\n if (!selector.value.includes(source.value)) {\r\n const joinedValues = selector.value.join(', ')\r\n const msg = `The selector \"${source.selector}\" only accepts the following: ${joinedValues}.`\r\n this.failValidation(msg)\r\n }\r\n } else {\r\n const sourcevalueType = typeof source.value\r\n if (selector.value && !selector.value.includes(sourcevalueType)) {\r\n const msg = `The selector \"${source.selector}\" does not accept a value property of type ${sourcevalueType}.`\r\n this.failValidation(msg)\r\n }\r\n }\r\n }\r\n\r\n static defineSchema() {\r\n const { fields } = foundry.data\r\n\r\n return {\r\n ...super.defineSchema(),\r\n\r\n type: new fields.StringField({\r\n required: true,\r\n nullable: false,\r\n blank: false,\r\n choices: ['visibility', 'cover'],\r\n }),\r\n\r\n affects: new fields.StringField({\r\n required: true,\r\n nullable: false,\r\n blank: false,\r\n initial: 'self',\r\n choices: ['self', 'other'],\r\n }),\r\n\r\n selector: new fields.StringField({\r\n required: true,\r\n nullable: false,\r\n blank: false,\r\n }),\r\n\r\n targets: new fields.ArrayField(\r\n new fields.StringField({\r\n required: true,\r\n nullable: false,\r\n blank: false,\r\n initial: undefined,\r\n }),\r\n {\r\n required: true,\r\n nullable: false,\r\n initial: ['all'],\r\n }\r\n ),\r\n\r\n predicate: new PredicateField({\r\n required: false,\r\n nullable: false,\r\n }),\r\n\r\n value: new ResolvableValueField({\r\n required: false,\r\n initial: undefined,\r\n }),\r\n }\r\n }\r\n\r\n test(rollOptions, password) {\r\n if (!password) return false\r\n return super.test(rollOptions)\r\n }\r\n\r\n addToPerception(affects, perception, options) {\r\n if (!this.test(options, true)) return\r\n\r\n const prefix = this.affects === 'self' ? affects : affects === 'origin' ? 'target' : 'origin'\r\n const root = `${prefix}.${this.type}.${this.selector}`\r\n const verificator = DATA[this.type][this.selector]\r\n\r\n if (!verificator.targets) {\r\n setProperty(perception, root, true)\r\n return\r\n }\r\n\r\n const targets = this.targets.includes('all') ? verificator.targets : this.targets\r\n\r\n if (!verificator.value) {\r\n for (const target of targets) {\r\n const path = `${root}.${target}`\r\n setProperty(perception, path, true)\r\n }\r\n return\r\n }\r\n\r\n for (const target of targets) {\r\n const path = `${root}.${target}`\r\n\r\n let value = getProperty(perception, path)\r\n if (value) value.add(this.value)\r\n else value = new Set([this.value])\r\n\r\n setProperty(perception, path, value)\r\n }\r\n }\r\n }\r\n\r\n game.pf2e.RuleElements.custom.PF2ePerception = PF2ePerceptionRuleElement\r\n}\r\n\r\nexport function perceptionRules(origin, target, { distance, extraOptions = [] } = {}) {\r\n const originActor = origin.actor\r\n const targetActor = target.actor\r\n if (!originActor || !targetActor) return {}\r\n\r\n const rules = {\r\n origin: originActor.rules.filter(r => !r.ignored && r.key === 'PF2ePerception') ?? [],\r\n target: targetActor.rules.filter(r => !r.ignored && r.key === 'PF2ePerception') ?? [],\r\n }\r\n if (!rules.origin.length && !rules.target.length) return {}\r\n\r\n const selfOptions = {\r\n origin: originActor.getRollOptions(),\r\n target: targetActor.getRollOptions(),\r\n }\r\n\r\n const otherOptions = {\r\n origin: targetActor.getSelfRollOptions('target'),\r\n target: originActor.getSelfRollOptions('origin'),\r\n }\r\n\r\n origin = origin instanceof Token ? origin : origin.object\r\n target = target instanceof Token ? target : target.object\r\n\r\n distance ??= origin.distanceTo(target)\r\n const distances = [`origin:distance:${distance}`, `target:distance:${distance}`]\r\n\r\n const perception = {}\r\n\r\n for (const prefix of ['origin', 'target']) {\r\n const testOptions = [...extraOptions, ...selfOptions[prefix], ...otherOptions[prefix], ...distances]\r\n for (const rule of rules[prefix]) {\r\n rule.addToPerception(prefix, perception, testOptions)\r\n }\r\n }\r\n\r\n return perception\r\n}\r\n\r\nexport function getIgnoredPerception(token) {\r\n const actor = token.actor\r\n if (!actor) return []\r\n\r\n const rules =\r\n actor.rules.filter(r => !r.ignored && r.key === 'PF2ePerception' && r.type === 'cover' && r.selector === 'ignored') ?? []\r\n\r\n return rules.flatMap(r => r.targets)\r\n}\r\n\r\nexport function getPerception(perception, affects, type, selector, targets) {\r\n let cursor = perception[affects]?.[type]?.[selector]\r\n return targets ? cursor?.[targets] : cursor\r\n}\r\n\r\nexport function updateFromPerceptionRules(perception, affects, type, value) {\r\n if (value === undefined) {\r\n value = type === 'cover' ? 'none' : 'observed'\r\n }\r\n\r\n const list = type === 'cover' ? COVERS : VISIBILITIES\r\n\r\n if (value && getPerception(perception, affects, type, 'cancel', value)) return undefined\r\n\r\n const setValue = getPerception(perception, affects, type, 'set', value)?.first()\r\n if (setValue && list.includes(setValue)) {\r\n value = setValue\r\n } else if (value && getPerception(perception, affects, type, 'reduce', value)) {\r\n const index = list.indexOf(value)\r\n value = list[Math.max(0, index - 1)]\r\n }\r\n\r\n return value === list[0] ? undefined : value\r\n}\r\n", "import { getCoverEffect, hasGreaterDarkvision, isProne, seeInvisibility } from './actor.js'\r\nimport { PerceptionMenu } from './apps/perception.js'\r\nimport { COVERS, COVER_VALUES, ICONS_PATHS, VISIBILITY_VALUES, defaultValues } from './constants.js'\r\nimport { clearDebug, drawDebugLine, getRectEdges, lineIntersectWall, pointToTokenIntersectWall } from './geometry.js'\r\nimport { getLightExposure } from './lighting.js'\r\nimport { MODULE_ID, getFlag, getSetting, hasPermission, unsetFlag } from './module.js'\r\nimport { getIgnoredPerception, getPerception, updateFromPerceptionRules } from './rule-element.js'\r\nimport { getSceneSetting, getValidTokens } from './scene.js'\r\nimport { getDarknessTemplates, getMistTemplates, getTemplateTokens } from './template.js'\r\n\r\nexport function renderTokenHUD(hud, html) {\r\n if (!hasPermission() || !hud.object.actor?.isOfType('creature')) return\r\n html.find('.col.left').append(`
`)\r\n html.find('[data-action=pf2e-perception]').on('click', event => openHUD(hud.object))\r\n}\r\n\r\nexport function openHUD(token) {\r\n return PerceptionMenu.openMenu({ token })\r\n}\r\n\r\nexport function pasteToken(originals, sources) {\r\n for (const source of sources) {\r\n delete source.flags?.[MODULE_ID]\r\n }\r\n}\r\n\r\nexport function getTokenData(token, ...path) {\r\n path.unshift('data')\r\n token = token instanceof Token ? token.document : token\r\n return getFlag(token, path.join('.'))\r\n}\r\n\r\nexport async function clearTokenData(token) {\r\n token = token instanceof Token ? token.document : token\r\n return unsetFlag(token, 'data')\r\n}\r\n\r\nexport async function setTokenData(token, data) {\r\n const valid = getValidTokens(token).map(t => t.id)\r\n const updates = {}\r\n\r\n for (const tokenId in data) {\r\n if (!valid.includes(tokenId)) {\r\n updates[`flags.${MODULE_ID}.data.-=${tokenId}`] = true\r\n continue\r\n }\r\n\r\n const current = data[tokenId]\r\n const original = getTokenData(token, tokenId) ?? {}\r\n\r\n if (current.visibility === defaultValues.visibility) delete current.visibility\r\n if (current.cover === defaultValues.cover) delete current.cover\r\n\r\n if (original.cover === current.cover && original.visibility === current.visibility) continue\r\n\r\n if (!current.visibility && !current.cover) {\r\n updates[`flags.${MODULE_ID}.data.-=${tokenId}`] = true\r\n } else {\r\n for (const property of ['cover', 'visibility']) {\r\n if (original[property] === current[property]) continue\r\n if (!current[property]) updates[`flags.${MODULE_ID}.data.${tokenId}.-=${property}`] = true\r\n else updates[`flags.${MODULE_ID}.data.${tokenId}.${property}`] = current[property]\r\n }\r\n }\r\n }\r\n\r\n token = token instanceof Token ? token.document : token\r\n return token.update(updates)\r\n}\r\n\r\nexport function getWallCover(origin, target, debug = false) {\r\n const scene = origin.scene\r\n if (!getSceneSetting(scene, 'standard')) return\r\n\r\n if (debug) clearDebug()\r\n\r\n const standard = getSetting('standard-type')\r\n const intersects =\r\n standard === 'points'\r\n ? pointToTokenIntersectWall(origin.center, target, debug)\r\n : lineIntersectWall(origin.center, target.center, debug)\r\n\r\n return intersects ? 'standard' : undefined\r\n}\r\n\r\nconst SIZES = {\r\n tiny: 0,\r\n sm: 1,\r\n med: 2,\r\n lg: 3,\r\n huge: 4,\r\n grg: 5,\r\n}\r\n\r\nexport function getCover(origin, target, { perception = {}, options = [], affects = 'origin', debug = false } = {}) {\r\n const prone = options.includes('item:ranged') ? isProne(target.actor) : false\r\n\r\n const returnValue = value => {\r\n return updateFromPerceptionRules(perception, affects, 'cover', value)\r\n }\r\n\r\n let systemCover = getCoverEffect(target.actor, true)\r\n if (prone && COVER_VALUES[systemCover] > COVER_VALUES.lesser) return returnValue('greater-prone')\r\n\r\n if (!prone && systemCover === 'greater-prone') systemCover = undefined\r\n\r\n let cover = getTokenData(target, origin.id, 'cover')\r\n if (prone && COVER_VALUES[cover] > COVER_VALUES.lesser) return returnValue('greater-prone')\r\n\r\n if (!prone && cover === 'greater-prone') cover = undefined\r\n\r\n if (COVER_VALUES[systemCover] < COVER_VALUES.standard) {\r\n const api = game.modules.get(MODULE_ID).custom ?? {}\r\n\r\n if (COVER_VALUES[cover] < COVER_VALUES.standard) {\r\n const custom = api.getWallCover\r\n let wallCover\r\n\r\n if (typeof custom === 'function') {\r\n const customCover = custom(origin, target, debug)\r\n wallCover = COVERS.includes(customCover) ? customCover : getWallCover(origin, target, debug)\r\n } else {\r\n wallCover = getWallCover(origin, target, debug)\r\n }\r\n\r\n if (COVER_VALUES[wallCover] > COVER_VALUES[cover]) cover = wallCover\r\n }\r\n\r\n if (COVER_VALUES[cover] < COVER_VALUES.standard && origin.distanceTo(target) > 5) {\r\n const custom = api.getCreatureCover\r\n let creatureCover\r\n\r\n if (typeof custom === 'function') {\r\n const customCover = custom(origin, target, { perception, debug })\r\n creatureCover = COVERS.includes(customCover)\r\n ? customCover\r\n : getCreatureCover(origin, target, { perception, debug })\r\n } else {\r\n creatureCover = getCreatureCover(origin, target, { perception, debug })\r\n }\r\n\r\n if (COVER_VALUES[creatureCover] > COVER_VALUES[cover]) cover = creatureCover\r\n }\r\n }\r\n\r\n if (prone && COVER_VALUES[cover] > COVER_VALUES.lesser) return returnValue('greater-prone')\r\n return returnValue(COVER_VALUES[cover] > COVER_VALUES[systemCover] ? cover : undefined)\r\n}\r\n\r\nexport function getCreatureCover(originToken, targetToken, { perception = {}, debug = false } = {}) {\r\n const setting = getSetting('lesser')\r\n if (setting === 'none') return undefined\r\n\r\n originToken = originToken instanceof Token ? originToken.document : originToken\r\n targetToken = targetToken instanceof Token ? targetToken.document : targetToken\r\n\r\n const ignoreIds = (() => {\r\n const originIds = Object.keys(perception.origin?.cover?.ignore ?? {})\r\n const targetIds = Object.keys(perception.target?.cover?.ignore ?? {})\r\n return new Set([...originIds, ...targetIds])\r\n })()\r\n\r\n let cover = undefined\r\n const origin = originToken.center\r\n const target = targetToken.center\r\n\r\n const originActor = originToken.actor\r\n const targetActor = targetToken.actor\r\n\r\n if (debug) {\r\n clearDebug()\r\n drawDebugLine(origin, target)\r\n }\r\n\r\n const isExtraLarge = token => {\r\n const size = SIZES[token.actor.size]\r\n return size - originSize >= 2 && size - targetSize >= 2\r\n }\r\n\r\n const originSize = SIZES[originActor.size]\r\n const targetSize = SIZES[targetActor.size]\r\n\r\n const originAlliance = originActor.alliance\r\n const deadCover = getSetting('dead-cover')\r\n const proneCover = getSetting('prone-cover')\r\n\r\n const tokens = originToken.scene.tokens.contents\r\n .filter(token => {\r\n const actor = token.actor\r\n const ignored = getIgnoredPerception(token)\r\n\r\n return (\r\n actor &&\r\n !token.hidden &&\r\n token !== originToken &&\r\n token !== targetToken &&\r\n (proneCover || !isProne(actor)) &&\r\n (deadCover || actor.hitPoints?.value !== 0) &&\r\n !ignoreIds.has(token.id) &&\r\n !(ignored.includes('all') || ignored.includes(actor.alliance === originAlliance ? 'allies' : 'enemies'))\r\n )\r\n })\r\n .sort((a, b) => SIZES[b.actor.size] - SIZES[a.actor.size])\r\n\r\n let extralarges = originSize < SIZES.huge && targetSize < SIZES.huge && tokens.filter(isExtraLarge).length\r\n\r\n const margin = setting === 'ten' ? 0.1 : setting === 'twenty' ? 0.2 : 0\r\n\r\n const intersectsEdge = edge => {\r\n if (debug) drawDebugLine(edge.A, edge.B, 'red')\r\n return lineSegmentIntersects(origin, target, edge.A, edge.B)\r\n }\r\n\r\n const intersectsWith =\r\n setting === 'cross'\r\n ? edges => {\r\n return (\r\n (intersectsEdge(edges.top) && intersectsEdge(edges.bottom)) ||\r\n (intersectsEdge(edges.left) && intersectsEdge(edges.right))\r\n )\r\n }\r\n : edges => Object.values(edges).some(edge => intersectsEdge(edge))\r\n\r\n for (const tokenDocument of tokens) {\r\n const token = tokenDocument.object\r\n const edges = getRectEdges(token.bounds, margin)\r\n if (intersectsWith(edges)) return extralarges ? 'standard' : 'lesser'\r\n else if (isExtraLarge(tokenDocument)) extralarges--\r\n }\r\n\r\n return cover\r\n}\r\n\r\nexport function getVisibility(origin, target, { perception = {}, affects = 'origin', debug = false } = {}) {\r\n origin = origin instanceof Token ? origin : origin.object\r\n target = target instanceof Token ? target : target.object\r\n\r\n const originActor = origin.actor\r\n const targetActor = target.actor\r\n\r\n let systemVisibility = (() => {\r\n if (!originActor || !targetActor) return\r\n\r\n let visibility\r\n\r\n if (targetActor.hasCondition('blinded')) visibility = 'hidden'\r\n else if (targetActor.hasCondition('dazzled')) visibility = 'concealed'\r\n\r\n for (const condition of ['unnoticed', 'undetected', 'hidden', 'concealed']) {\r\n if (VISIBILITY_VALUES[condition] > VISIBILITY_VALUES[visibility] && originActor.hasCondition(condition))\r\n visibility = condition\r\n }\r\n\r\n return visibility\r\n })()\r\n\r\n const returnValue = value => {\r\n if (!isInvisible) return updateFromPerceptionRules(perception, affects, 'visibility', value)\r\n\r\n if (VISIBILITY_VALUES[value] < VISIBILITY_VALUES.hidden) value = 'hidden'\r\n\r\n const seeInvis = seeInvisibility(targetActor) || getPerception(perception, affects, 'visibility', 'noinvis')\r\n if (seeInvis) value = 'concealed'\r\n\r\n return updateFromPerceptionRules(perception, affects, 'visibility', value)\r\n }\r\n\r\n const isInvisible = originActor?.hasCondition('invisible')\r\n const visibility = getTokenData(origin, target.id, 'visibility')\r\n let mergedVisibility = VISIBILITY_VALUES[systemVisibility] > VISIBILITY_VALUES[visibility] ? systemVisibility : visibility\r\n\r\n if (VISIBILITY_VALUES[mergedVisibility] >= VISIBILITY_VALUES.hidden || isInvisible) return returnValue(mergedVisibility)\r\n\r\n const targetLowlight = targetActor?.hasLowLightVision\r\n const targetDarkvision = targetActor?.hasDarkvision\r\n const targetGreaterDarkvision = targetActor && hasGreaterDarkvision(targetActor)\r\n if (targetGreaterDarkvision && mergedVisibility === 'concealed') return returnValue(mergedVisibility)\r\n\r\n let inDarkness\r\n if (!targetGreaterDarkvision) {\r\n const darknessTemplates = getDarknessTemplates(origin)\r\n if (darknessTemplates?.length) {\r\n let darknessVisibility\r\n\r\n for (const template of darknessTemplates) {\r\n const darknessTokens = getTemplateTokens(template)\r\n if (!darknessTokens.length) continue\r\n\r\n const inTemplate = darknessTokens.includes(origin) || darknessTokens.includes(target)\r\n if (inTemplate) inDarkness = true\r\n else continue\r\n\r\n if (!targetDarkvision) return returnValue('hidden')\r\n\r\n const templateConceals = getFlag(template, 'conceal')\r\n if (templateConceals) darknessVisibility = 'concealed'\r\n }\r\n\r\n if (darknessVisibility === 'concealed') mergedVisibility = 'concealed'\r\n if (inDarkness && mergedVisibility === 'concealed') return returnValue(mergedVisibility)\r\n }\r\n }\r\n\r\n if (mergedVisibility !== 'concealed') {\r\n const mistTemplates = getMistTemplates(origin)\r\n if (mistTemplates?.length) {\r\n for (const template of mistTemplates) {\r\n const mistTokens = getTemplateTokens(template)\r\n if (!mistTokens.length) continue\r\n\r\n const inTemplate = mistTokens.includes(origin) || mistTokens.includes(target)\r\n if (inTemplate) return returnValue('concealed')\r\n }\r\n }\r\n }\r\n\r\n if (inDarkness || targetGreaterDarkvision) return returnValue(mergedVisibility)\r\n\r\n const exposure = getLightExposure(origin, debug)\r\n let exposedVisibility = exposure === 'dim' ? 'concealed' : exposure === null ? 'hidden' : undefined\r\n if (exposedVisibility === 'concealed' && targetLowlight) exposedVisibility = undefined\r\n else if (exposedVisibility === 'hidden' && targetDarkvision) exposedVisibility = undefined\r\n\r\n if (VISIBILITY_VALUES[exposedVisibility] > VISIBILITY_VALUES[mergedVisibility]) mergedVisibility = exposedVisibility\r\n return returnValue(mergedVisibility)\r\n}\r\n\r\nexport function updateToken(token, data, context, userId) {\r\n const flags = data.flags?.['pf2e-perception']\r\n\r\n if (flags && (flags.data || flags['-=data'] !== undefined)) {\r\n token.object.renderFlags.set({ refreshVisibility: true })\r\n\r\n if (game.user.isGM) return\r\n\r\n const hk = Hooks.on('refreshToken', refreshed => {\r\n if (!token.object === refreshed) return\r\n Hooks.off('refreshToken', hk)\r\n if (game.combat?.getCombatantByToken(token.id)) ui.combat.render()\r\n })\r\n }\r\n}\r\n\r\nexport function hoverToken(token, hovered) {\r\n if (hovered) showAllConditionals(token)\r\n else clearConditionals(token)\r\n}\r\n\r\nexport function deleteToken(token) {\r\n clearConditionals(token)\r\n if (!game.user.isGM) ui.combat.render()\r\n}\r\n\r\nexport function controlToken(token, controlled) {\r\n if (!controlled) return\r\n clearConditionals()\r\n Hooks.once('sightRefresh', () => token.hover && showAllConditionals(token))\r\n}\r\n\r\nexport function clearConditionals(token) {\r\n const tokenId = token?.id\r\n if (!tokenId) return $('.pf2e-conditionals').remove()\r\n $(`.pf2e-conditionals[data-hover-id=${token.id}]`).remove()\r\n $(`.pf2e-conditionals[data-token-id=${token.id}]`).remove()\r\n}\r\n\r\nexport function showAllConditionals(token) {\r\n const tokens = getValidTokens(token)\r\n for (const target of tokens) {\r\n showConditionals(target, token)\r\n }\r\n}\r\n\r\nexport async function showConditionals(origin, target) {\r\n origin = origin instanceof Token ? origin : origin.object\r\n if (!origin.visible || !origin.actor?.isOfType('creature')) return\r\n\r\n let data = getTokenData(origin, target.id)\r\n if (isEmpty(data)) return\r\n\r\n if (!game.user.isGM && !target.document.hasPlayerOwner && VISIBILITY_VALUES[data.visibility] >= VISIBILITY_VALUES.hidden) {\r\n if (!data.cover) return\r\n data = { cover: data.cover }\r\n }\r\n\r\n const scale = origin.worldTransform.a\r\n const coords = canvas.clientCoordinatesFromCanvas(origin.document._source)\r\n const iconSize = getSetting('icon-size')\r\n\r\n const style = [\r\n `top: ${coords.y}px`,\r\n `left: ${coords.x + (origin.hitArea.width * scale) / 2}px`,\r\n `--icon-size: ${iconSize}px`,\r\n ].join('; ')\r\n\r\n let content = `
`\r\n\r\n const savedPaths = getSetting('icon-path')\r\n Object.entries(data).map(([property, value]) => {\r\n const icon = property === 'cover' ? 'cover' : value\r\n let path = savedPaths[icon] || ICONS_PATHS[icon]\r\n if (path.startsWith('systems') || path.startsWith('modules')) path = `../../../${path}`\r\n content += `
`\r\n })\r\n\r\n content += '
'\r\n\r\n $(document.body).append(content)\r\n}\r\n\r\nexport function rulesBasedVision() {\r\n return !!(this.sight.enabled && this.actor?.isOfType('creature') && this.scene?.rulesBasedVision)\r\n}\r\n\r\nexport function preCreateToken(token) {\r\n const actor = token.actor\r\n if (!actor?.isOfType('creature')) return\r\n\r\n if (actor.isOfType('npc') && getSceneSetting(token.scene, 'npc-vision')) {\r\n token.updateSource({ 'sight.enabled': true })\r\n }\r\n\r\n if (game.user.isGM && token.hidden) {\r\n const targets = game.user.targets\r\n const updates = {}\r\n\r\n for (const target of targets) {\r\n updates[target.id] = { visibility: 'unnoticed' }\r\n }\r\n\r\n if (targets.size) {\r\n token.updateSource({ [`flags.${MODULE_ID}.data`]: updates })\r\n }\r\n }\r\n}\r\n", "import { validateMessage } from '../chat.js'\r\nimport { COVERS, VISIBILITIES, VISIBILITY_VALUES, defaultValues } from '../constants.js'\r\nimport { MODULE_ID, getSetting, localize, templatePath } from '../module.js'\r\nimport { DegreeOfSuccess } from '../pf2e/success.js'\r\nimport { getValidTokens } from '../scene.js'\r\nimport { deleteSeekTemplate } from '../template.js'\r\nimport { getTokenData } from '../token.js'\r\nimport { BaseMenu } from './base-menu.js'\r\n\r\nclass ValidationMenu extends BaseMenu {\r\n static async openMenu(params, options) {\r\n // biome-ignore lint/complexity/noThisInStatic: shit aint working\r\n const validated = await super.openMenu(params, options)\r\n if (validated && params.message) validateMessage(params.message)\r\n return validated\r\n }\r\n\r\n get title() {\r\n return localize('menu.validation.title', { name: this.token.name })\r\n }\r\n\r\n get template() {\r\n return templatePath('validation')\r\n }\r\n\r\n get selected() {\r\n const selected = super.selected\r\n if (selected.length) return selected\r\n return this.globalSelection\r\n }\r\n\r\n get globalSelection() {\r\n const token = this.token\r\n const alliance = token.actor.alliance\r\n return getValidTokens(token)\r\n .filter(t => t.actor.alliance !== alliance)\r\n .map(t => t.id)\r\n }\r\n\r\n getSavedData(converted = true) {\r\n const data = super.getSavedData()\r\n return converted ? this._convertData(data) : data\r\n }\r\n\r\n _convertData(data) {\r\n const property = this.property\r\n const scene = this.scene\r\n const selected = this.selected\r\n const defaultValue = defaultValues[property]\r\n const propertyList = property === 'cover' ? COVERS : VISIBILITIES\r\n\r\n for (const tokenId of selected) {\r\n const token = scene.tokens.get(tokenId)\r\n const fullProperty = `${tokenId}.${property}`\r\n const currentValue = getProperty(data, fullProperty) ?? defaultValue\r\n\r\n let processedValue = this.processValue({ token, value: currentValue })\r\n if (!propertyList.includes(processedValue)) processedValue = currentValue\r\n\r\n if (currentValue === processedValue) continue\r\n setProperty(data, fullProperty, processedValue)\r\n }\r\n\r\n return data\r\n }\r\n\r\n processValue(params) {\r\n throw new Error(`${this.constructor.name} doesn't have a 'processValue' method defined`)\r\n }\r\n\r\n getData(options) {\r\n const { covers, visibilities, i18n } = super.getData(options)\r\n const currentData = this.currentData\r\n const originalData = this.getSavedData(false)\r\n const property = this.property\r\n\r\n const selected = this.selected\r\n let tokens = getValidTokens(this.token)\r\n\r\n tokens = tokens.map(({ id, name, actor }) => {\r\n const current = currentData[id] ?? {}\r\n const original = originalData[id] ?? {}\r\n\r\n return {\r\n id,\r\n name,\r\n alliance: actor.alliance,\r\n selected: selected.includes(id),\r\n ...BaseMenu.createPropertyData(original, current, property),\r\n }\r\n })\r\n\r\n const validation = getSetting('validation')\r\n if (validation === 'selected') tokens = tokens.filter(t => t.selected)\r\n else if (validation === 'changed') tokens = tokens.filter(t => t.changed)\r\n\r\n return {\r\n ...this._spliIntoAlliances(tokens),\r\n i18n,\r\n property: property,\r\n options: property === 'cover' ? covers : visibilities,\r\n showSelected: selected.length !== tokens.length && validation === 'all',\r\n showChanges: validation !== 'changed',\r\n }\r\n }\r\n\r\n activateListeners(html) {\r\n super.activateListeners(html)\r\n\r\n html.find('[data-action=cancel]').on('click', event => {\r\n this.close()\r\n })\r\n }\r\n}\r\n\r\nexport class CoverValidationMenu extends ValidationMenu {\r\n #value\r\n\r\n constructor(params, options = {}) {\r\n super(params, options)\r\n this.#value = params.value\r\n }\r\n\r\n get property() {\r\n return 'cover'\r\n }\r\n\r\n processValue() {\r\n return this.#value\r\n }\r\n}\r\n\r\nclass VisibilityValidationMenu extends ValidationMenu {\r\n #roll\r\n\r\n constructor(params, options = {}) {\r\n super(params, options)\r\n this.#roll = params.roll\r\n }\r\n\r\n get property() {\r\n return 'visibility'\r\n }\r\n\r\n get roll() {\r\n return this.#roll\r\n }\r\n}\r\n\r\nexport class HideValidationMenu extends VisibilityValidationMenu {\r\n processValue({ token, value }) {\r\n const roll = this.roll\r\n const dc = token.actor.perception.dc.value\r\n const visibility = VISIBILITY_VALUES[value]\r\n const success = new DegreeOfSuccess(roll, dc).value\r\n\r\n if (success >= DegreeOfSuccess.SUCCESS && visibility < VISIBILITY_VALUES.hidden) return 'hidden'\r\n if (success <= DegreeOfSuccess.FAILURE && visibility >= VISIBILITY_VALUES.hidden) return 'observed'\r\n return value\r\n }\r\n}\r\n\r\nexport class CreateADiversionMenu extends VisibilityValidationMenu {\r\n processValue({ token, value }) {\r\n const roll = this.roll\r\n const dc = token.actor.perception.dc.value\r\n const visibility = VISIBILITY_VALUES[value]\r\n const success = new DegreeOfSuccess(roll, dc).value\r\n\r\n if (success >= DegreeOfSuccess.SUCCESS && visibility < VISIBILITY_VALUES.hidden) return 'hidden'\r\n return value\r\n }\r\n}\r\n\r\nexport class UnHideValidationMenu extends VisibilityValidationMenu {\r\n get selected() {\r\n return getValidTokens(this.token).map(t => t.id)\r\n }\r\n\r\n processValue({ token, value }) {\r\n const visibility = VISIBILITY_VALUES[value]\r\n if (visibility >= VISIBILITY_VALUES.hidden) return 'observed'\r\n return value\r\n }\r\n}\r\n\r\nexport class PointOutValidationMenu extends VisibilityValidationMenu {\r\n #originator\r\n\r\n constructor(params, options = {}) {\r\n super(params, options)\r\n this.#originator = params.originator\r\n }\r\n\r\n get selected() {\r\n const token = this.token\r\n const alliance = token.actor.alliance\r\n const originatorId = this.#originator.id\r\n const data = getTokenData(token) ?? {}\r\n\r\n return getValidTokens(token)\r\n .filter(t => {\r\n if (t.id === originatorId || t.actor.alliance === alliance) return false\r\n const visibility = getProperty(data, `${t.id}.visibility`)\r\n return VISIBILITY_VALUES[visibility] >= VISIBILITY_VALUES.undetected\r\n })\r\n .map(t => t.id)\r\n }\r\n\r\n processValue({ token, value }) {\r\n return VISIBILITY_VALUES[value] >= VISIBILITY_VALUES.undetected ? 'hidden' : value\r\n }\r\n}\r\n\r\nclass ReverseVisibilityValidationMenu extends VisibilityValidationMenu {\r\n getSavedData(converted = true) {\r\n const thisId = this.token.id\r\n const tokens = getValidTokens(this.token)\r\n const data = {}\r\n\r\n for (const token of tokens) {\r\n const tokenData = getTokenData(token, thisId)\r\n if (tokenData) data[token.id] = deepClone(tokenData)\r\n }\r\n\r\n return converted ? this._convertData(data) : data\r\n }\r\n\r\n getData() {\r\n const parentData = super.getData()\r\n parentData.isReversed = true\r\n parentData.options = VISIBILITIES.map(value => ({ value, label: localize(`visibility.reversed.${value}`) }))\r\n return parentData\r\n }\r\n\r\n _saveData(currentData) {\r\n const scene = this.scene\r\n const thisId = this.token.id\r\n const updates = []\r\n\r\n for (const [tokenId, data] of Object.entries(currentData)) {\r\n const update = { _id: tokenId }\r\n const token = scene.tokens.get(tokenId)\r\n\r\n if (token) {\r\n if (data.visibility === defaultValues.visibility) {\r\n // biome-ignore lint/performance/noDelete: needs to be gone\r\n delete data.visibility\r\n }\r\n\r\n const original = getTokenData(token, thisId) ?? {}\r\n if (original?.visibility === data.visibility) continue\r\n\r\n if (!original.cover && !data.visibility) {\r\n update[`flags.${MODULE_ID}.data.-=${thisId}`] = true\r\n } else if (!data.visibility) {\r\n update[`flags.${MODULE_ID}.data.${thisId}.-=visibility`] = true\r\n } else {\r\n update[`flags.${MODULE_ID}.data.${thisId}.visibility`] = data.visibility\r\n }\r\n } else update[`flags.${MODULE_ID}.data.-=${thisId}`] = true\r\n\r\n updates.push(update)\r\n }\r\n\r\n scene.updateEmbeddedDocuments('Token', updates)\r\n }\r\n}\r\n\r\nexport class SeekValidationMenu extends ReverseVisibilityValidationMenu {\r\n #fromTemplate\r\n\r\n constructor(params, options = {}) {\r\n super(params, options)\r\n this.#fromTemplate = params.fromTemplate\r\n }\r\n\r\n get globalSelection() {\r\n return []\r\n }\r\n\r\n static async openMenu(params, options) {\r\n // biome-ignore lint/complexity/noThisInStatic: nop\r\n const validated = await super.openMenu(params, options)\r\n if (validated) deleteSeekTemplate(params.token)\r\n }\r\n\r\n processValue({ token, value }) {\r\n const roll = this.roll\r\n const dc = token.actor.skills.stealth.dc.value\r\n const visibility = VISIBILITY_VALUES[value]\r\n const success = new DegreeOfSuccess(roll, dc).value\r\n\r\n if (success >= DegreeOfSuccess.CRITICAL_SUCCESS && visibility >= VISIBILITY_VALUES.hidden) return 'observed'\r\n if (success >= DegreeOfSuccess.SUCCESS && visibility === VISIBILITY_VALUES.hidden) return 'observed'\r\n if (success >= DegreeOfSuccess.SUCCESS && visibility >= VISIBILITY_VALUES.undetected) return 'hidden'\r\n return value\r\n }\r\n}\r\n", "import {\r\n CoverValidationMenu,\r\n CreateADiversionMenu,\r\n HideValidationMenu,\r\n PointOutValidationMenu,\r\n SeekValidationMenu,\r\n UnHideValidationMenu,\r\n} from './apps/validation.js'\r\nimport { attackCheckRoll } from './constants.js'\r\nimport { MODULE_ID, getActionName, getFlag, getFlags, localize, setFlag } from './module.js'\r\nimport { deleteSeekTemplate } from './template.js'\r\n\r\nexport function renderChatMessage(message, html) {\r\n const token = message.token\r\n if (!token) return\r\n\r\n const isGM = game.user.isGM\r\n const hasPlayerOwner = token.hasPlayerOwner\r\n const { cover, selected, skipWait, validated, pointOut } = getFlags(message)\r\n const pf2eContext = message.getFlag('pf2e', 'context')\r\n\r\n if (cover) {\r\n if (isGM) {\r\n const button = createValidateButton({ property: 'cover', skipWait, validated })\r\n html.find('.message-content').append(button)\r\n html.find('[data-action=validate-cover]').on('click', () => {\r\n CoverValidationMenu.openMenu({ token, selected, value: cover, message })\r\n })\r\n } else if (!skipWait) {\r\n const hint = createWaitHint('cover', validated)\r\n html.find('.message-content').append(hint)\r\n }\r\n } else if (pf2eContext?.pf2ePerception?.visibility) {\r\n if (!validated) html.find('.message-buttons').remove()\r\n\r\n const flavor = html.find('.flavor-text')\r\n\r\n if (!isGM && hasPlayerOwner) {\r\n html.find('.message-sender').text(token.name)\r\n flavor.empty()\r\n }\r\n\r\n const msg = localize(`message.flat-check.${validated === undefined ? 'blind' : validated ? 'success' : 'failure'}`)\r\n const hint = createHint(msg, validated)\r\n flavor.append(hint)\r\n\r\n if (isGM) {\r\n for (const type of ['success', 'failure']) {\r\n flavor.append(\r\n createChatButton({\r\n action: `${type}-message`,\r\n icon: 'fa-solid fa-message',\r\n label: localize('message.flat-check.button', type),\r\n })\r\n )\r\n html.find(`[data-action=${type}-message]`).on('click', () => {\r\n setFlag(message, 'validated', type === 'success')\r\n })\r\n }\r\n }\r\n } else if (pf2eContext?.type === 'skill-check' && pf2eContext.pf2ePerception) {\r\n if (isGM) {\r\n if (pf2eContext.options.includes('action:hide')) {\r\n const button = createValidateButton({ property: 'visibility', skipWait, validated })\r\n html.find('.flavor-text').append(button)\r\n html.find('[data-action=validate-visibility]').on('click', () => {\r\n HideValidationMenu.openMenu({\r\n token,\r\n message,\r\n roll: message.rolls[0],\r\n selected: pf2eContext.pf2ePerception.selected,\r\n })\r\n })\r\n } else if (pf2eContext.options.includes('action:create-a-diversion')) {\r\n const button = createValidateButton({ property: 'visibility', skipWait, validated })\r\n html.find('.flavor-text').append(button)\r\n html.find('[data-action=validate-visibility]').on('click', () => {\r\n CreateADiversionMenu.openMenu({\r\n token,\r\n message,\r\n roll: message.rolls[0],\r\n selected: pf2eContext.pf2ePerception.selected,\r\n })\r\n })\r\n }\r\n } else if (hasPlayerOwner) {\r\n if (pf2eContext.options.includes('action:hide')) {\r\n addBlindSkillCheckFlavor({ token, message, html, validated, action: 'Hide' })\r\n } else if (pf2eContext.options.includes('action:create-a-diversion')) {\r\n addSkillCheckFlavor(html, validated)\r\n }\r\n }\r\n } else if (pf2eContext?.type === 'perception-check' && pf2eContext.pf2ePerception) {\r\n if (isGM) {\r\n if (pf2eContext.options.includes('action:seek')) {\r\n const buttons = createValidateCombo({\r\n skipWait,\r\n validated,\r\n smallAction: 'delete-template',\r\n smallIcon: 'fa-thin fa-cubes',\r\n smallSlashed: true,\r\n })\r\n\r\n html.find('.flavor-text').append(buttons)\r\n\r\n html.find('[data-action=validate-visibility]').on('click', () => {\r\n SeekValidationMenu.openMenu({\r\n token,\r\n message,\r\n roll: message.rolls[0],\r\n selected: pf2eContext.pf2ePerception.selected,\r\n fromTemplate: pf2eContext.pf2ePerception.fromTemplate,\r\n })\r\n })\r\n\r\n html.find('[data-action=delete-template').on('click', () => {\r\n deleteSeekTemplate(token)\r\n })\r\n }\r\n } else if (hasPlayerOwner) {\r\n if (pf2eContext.options.includes('action:seek')) {\r\n addBlindSkillCheckFlavor({ token, message, html, validated, action: 'Seek' })\r\n }\r\n }\r\n } else if (pointOut) {\r\n const selectedToken = token.scene.tokens.get(pointOut)\r\n if (!selectedToken) return\r\n\r\n if (isGM) {\r\n const buttons = createValidateCombo({\r\n skipWait,\r\n validated,\r\n smallAction: 'ping-token',\r\n smallIcon: 'fa-solid fa-signal-stream',\r\n })\r\n\r\n html.find('.message-content').append(buttons)\r\n\r\n html.find('[data-action=validate-visibility]').on('click', () => {\r\n PointOutValidationMenu.openMenu({\r\n message,\r\n token: selectedToken,\r\n originator: token,\r\n selected: canvas.tokens.controlled.map(t => t.id),\r\n })\r\n })\r\n\r\n html.find('[data-action=ping-token]').on('click', () => {\r\n canvas.ping(selectedToken.center)\r\n })\r\n } else if (hasPlayerOwner) {\r\n const hint = createWaitHint('visibility', validated)\r\n html.find('.message-content').append(hint)\r\n }\r\n }\r\n\r\n if (isGM && attackCheckRoll.includes(pf2eContext?.type)) {\r\n const tooltip = localize('message.unhide.tooltip')\r\n const button = `\r\n \r\n`\r\n\r\n html.find('.dice-result .dice-total').append(button)\r\n html.find('[data-action=unhide]').on('click', event => {\r\n event.stopPropagation()\r\n UnHideValidationMenu.openMenu({ token })\r\n })\r\n }\r\n}\r\n\r\nexport function validateMessage(message) {\r\n if (!getFlag(message, 'validated')) setFlag(message, 'validated', true)\r\n}\r\n\r\nfunction createValidateCombo({ skipWait, validated, smallIcon, smallAction, smallSlashed }) {\r\n let buttons = '
'\r\n\r\n buttons += createValidateButton({ property: 'visibility', skipWait, validated })\r\n buttons += createChatButton({\r\n action: smallAction,\r\n icon: smallIcon,\r\n slashed: smallSlashed,\r\n tooltip: localize(`message.visibility.small-button.${smallAction}`),\r\n })\r\n\r\n buttons += '
'\r\n\r\n return buttons\r\n}\r\n\r\nfunction actionTitle(action, modifier) {\r\n const skillName = game.i18n.localize(\r\n modifier === 'perception' ? 'PF2E.PerceptionLabel' : `PF2E.Skill${modifier.capitalize()}`\r\n )\r\n const check = localize('message.check')\r\n return `

\r\n ${getActionName(action)}\r\n 1\r\n (${skillName} ${check})\r\n

`\r\n}\r\n\r\nfunction addSkillCheckFlavor(html, validated) {\r\n const hint = createWaitHint('visibility', validated)\r\n html.find('.flavor-text').append(hint)\r\n}\r\n\r\nfunction addBlindSkillCheckFlavor({ html, token, message, validated, action }) {\r\n const modifier = message.getFlag('pf2e', 'modifierName')\r\n const title = actionTitle(action, modifier)\r\n\r\n html.find('.message-sender').text(token.name)\r\n html.find('.flavor-text').html(title)\r\n\r\n addSkillCheckFlavor(html, validated)\r\n}\r\n\r\nfunction createWaitHint(property, validated) {\r\n const hint = localize(`message.${property}.player.${validated ? 'validated' : 'wait'}`)\r\n return createHint(hint, validated)\r\n}\r\n\r\nfunction createHint(hint, validated) {\r\n const str =\r\n validated === true\r\n ? ` ${hint}`\r\n : validated === false\r\n ? ` ${hint}`\r\n : hint\r\n return `${str}`\r\n}\r\n\r\nfunction createValidateButton({ skipWait, validated, property }) {\r\n let label = localize(`message.${property}.gm.${skipWait ? 'check' : validated ? 'validated' : 'validate'}`)\r\n if (!skipWait && validated) label += ''\r\n return createChatButton({\r\n action: `validate-${property}`,\r\n icon: 'fa-solid fa-list',\r\n label,\r\n })\r\n}\r\n\r\nexport function createChatButton({ action, icon, label, tooltip, slashed = false }) {\r\n let button = `'\r\n\r\n return button\r\n}\r\n\r\nexport async function createTokenMessage({ content, token, flags, secret }) {\r\n const data = { content, speaker: ChatMessage.getSpeaker({ token: token instanceof Token ? token.document : token }) }\r\n if (flags) setProperty(data, `flags.${MODULE_ID}`, flags)\r\n if (secret) {\r\n data.type = CONST.CHAT_MESSAGE_TYPES.WHISPER\r\n data.whisper = ChatMessage.getWhisperRecipients('gm')\r\n }\r\n return ChatMessage.create(data)\r\n}\r\n", "import { getActorToken, getCoverEffect, isProne } from './actor.js'\r\nimport { createTokenMessage } from './chat.js'\r\nimport { VISIBILITY_VALUES, defaultValues } from './constants.js'\r\nimport { createCoverSource } from './effect.js'\r\nimport { MODULE_ID, getActionName, getSetting, localize, templatePath } from './module.js'\r\nimport { validateTokens } from './scene.js'\r\nimport { createSeekTemplate, deleteSeekTemplate } from './template.js'\r\nimport { clearTokenData, getTokenData, setTokenData } from './token.js'\r\nimport { getPrototype } from './utils.js'\r\n\r\nexport function setupActions() {\r\n const hide = game.pf2e.actions.get('hide')\r\n const BaseAction = getPrototype(hide, 2).constructor\r\n const BaseActionVariant = getPrototype(hide.toActionVariant(), 2).constructor\r\n const SingleCheckAction = getPrototype(hide, 1).constructor\r\n const SingleCheckActionVariant = getPrototype(hide.toActionVariant(), 1).constructor\r\n\r\n setupCover(BaseAction, BaseActionVariant)\r\n setupHide(SingleCheckAction, SingleCheckActionVariant)\r\n setupCreateADiversion(SingleCheckAction, SingleCheckActionVariant)\r\n setupSneak(SingleCheckAction, SingleCheckActionVariant)\r\n setupSeek(SingleCheckAction, SingleCheckActionVariant)\r\n setupPointOut(BaseAction, BaseActionVariant)\r\n}\r\n\r\nfunction setupPointOut(BaseAction, BaseActionVariant) {\r\n class PointOutVariant extends BaseActionVariant {\r\n async use(options = {}) {\r\n const action = localize('action.point-out')\r\n const token = getSelectedToken(options, action)\r\n if (token) pointOut(this, token)\r\n }\r\n }\r\n\r\n class PointOut extends BaseAction {\r\n constructor() {\r\n super({\r\n cost: 1,\r\n name: `${MODULE_ID}.action.point-out`,\r\n description: `${MODULE_ID}.action.point-out.description`,\r\n rollOptions: ['action:point-out'],\r\n slug: 'point-out',\r\n traits: ['auditory', 'manipulate', 'visual'],\r\n })\r\n }\r\n\r\n toActionVariant(data = {}) {\r\n data.name ??= this.name\r\n return new PointOutVariant(this, data)\r\n }\r\n }\r\n\r\n game.pf2e.actions.set('point-out', new PointOut())\r\n}\r\n\r\nasync function pointOut({ name, traits }, token) {\r\n const target = game.user.targets.filter(t => t.actor).first()\r\n const visibility = target ? getTokenData(target, token.id, 'visibility') : undefined\r\n const isVisible = target && VISIBILITY_VALUES[visibility] < VISIBILITY_VALUES.undetected\r\n\r\n let description\r\n if (isVisible) {\r\n const dc = target.actor.skills.stealth.dc.value\r\n description = localize('message.point-out.short-check', {\r\n check: `@Check[type:perception|dc:${dc}|traits:auditory,manipulate,visual|showDC:gm]`,\r\n })\r\n } else description = localize('message.point-out.short')\r\n\r\n const content = await renderTemplate(templatePath('point-out'), {\r\n description,\r\n name,\r\n traits: traits.map(slug => ({\r\n slug,\r\n tooltip: CONFIG.PF2E.traitsDescriptions[slug],\r\n name: CONFIG.PF2E.actionTraits[slug],\r\n })),\r\n })\r\n\r\n const flags = {\r\n pointOut: isVisible ? target.id : undefined,\r\n }\r\n\r\n createTokenMessage({ content, token, flags })\r\n}\r\n\r\nfunction setupSeek(SingleCheckAction, SingleCheckActionVariant) {\r\n class SeekVariant extends SingleCheckActionVariant {\r\n async use(options = {}) {\r\n const action = getActionName('Seek')\r\n const token = getSelectedToken(options, action)\r\n if (!token) return\r\n\r\n if (getSetting('seek-template')) {\r\n const useTemplate = await seek(token)\r\n if (!useTemplate) {\r\n return deleteSeekTemplate(token)\r\n }\r\n }\r\n\r\n options.actors = [token.actor]\r\n return super.use(options)\r\n }\r\n }\r\n\r\n class Seek extends SingleCheckAction {\r\n constructor() {\r\n super({\r\n cost: 1,\r\n description: 'PF2E.Actions.Seek.Description',\r\n name: 'PF2E.Actions.Seek.Title',\r\n notes: [\r\n { outcome: ['criticalSuccess'], text: 'PF2E.Actions.Seek.Notes.criticalSuccess' },\r\n { outcome: ['success'], text: 'PF2E.Actions.Seek.Notes.success' },\r\n ],\r\n rollOptions: ['action:seek'],\r\n slug: 'seek',\r\n statistic: 'perception',\r\n traits: ['concentrate', 'secret'],\r\n })\r\n }\r\n\r\n toActionVariant(data) {\r\n return new SeekVariant(this, data)\r\n }\r\n }\r\n\r\n game.pf2e.actions.set('seek', new Seek())\r\n}\r\n\r\nasync function seek(token) {\r\n const unit = game.i18n.localize('PF2E.Foot')\r\n\r\n let content = '

'\r\n content += `${localize('dialog.seek.hint')}

`\r\n\r\n content += createButton(\r\n 'create-cone',\r\n 'fa-thin fa-cubes',\r\n game.i18n.format('PF2E.TemplateLabel', {\r\n size: 30,\r\n unit,\r\n shape: game.i18n.localize(CONFIG.PF2E.areaTypes.cone),\r\n })\r\n )\r\n\r\n content += createButton(\r\n 'create-burst',\r\n 'fa-thin fa-cubes',\r\n game.i18n.format('PF2E.TemplateLabel', {\r\n size: 15,\r\n unit,\r\n shape: game.i18n.localize(CONFIG.PF2E.areaTypes.burst),\r\n })\r\n )\r\n\r\n content += '

'\r\n\r\n return Dialog.wait(\r\n {\r\n title: `${token.name} - ${game.i18n.localize('PF2E.Actions.Seek.Title')}`,\r\n content,\r\n buttons: {\r\n ok: {\r\n icon: '',\r\n label: localize('dialog.seek.accept'),\r\n callback: () => true,\r\n },\r\n no: {\r\n icon: '',\r\n label: localize('dialog.seek.cancel'),\r\n callback: html => false,\r\n },\r\n },\r\n close: () => false,\r\n render: html => {\r\n const content = html.filter('.dialog-content')\r\n content.find('[data-action=create-cone], [data-action=create-burst]').on('click', event => {\r\n const { action } = event.currentTarget.dataset\r\n deleteSeekTemplate(token)\r\n createSeekTemplate({ type: action === 'create-cone' ? 'cone' : 'burst', token })\r\n })\r\n },\r\n },\r\n { width: 300, left: 10 }\r\n )\r\n}\r\n\r\nfunction setupSneak(SingleCheckAction, SingleCheckActionVariant) {\r\n class SneakVariant extends SingleCheckActionVariant {\r\n async use(options = {}) {\r\n const action = getActionName('Sneak')\r\n const token = getSelectedToken(options, action)\r\n if (!token) return\r\n\r\n options.actors = [token.actor]\r\n return super.use(options)\r\n }\r\n }\r\n\r\n class Sneak extends SingleCheckAction {\r\n constructor() {\r\n super({\r\n cost: 1,\r\n description: 'PF2E.Actions.Sneak.Description',\r\n name: 'PF2E.Actions.Sneak.Title',\r\n notes: [\r\n { outcome: ['success', 'criticalSuccess'], text: 'PF2E.Actions.Sneak.Notes.success' },\r\n { outcome: ['failure'], text: 'PF2E.Actions.Sneak.Notes.failure' },\r\n { outcome: ['criticalFailure'], text: 'PF2E.Actions.Sneak.Notes.criticalFailure' },\r\n ],\r\n rollOptions: ['action:sneak'],\r\n slug: 'sneak',\r\n traits: ['move', 'secret'],\r\n })\r\n }\r\n\r\n toActionVariant(data) {\r\n return new SneakVariant(this, data)\r\n }\r\n }\r\n\r\n // game.pf2e.actions.set('sneak', new Sneak())\r\n}\r\n\r\nfunction setupCreateADiversion(SingleCheckAction, SingleCheckActionVariant) {\r\n class CreateADiversionVariant extends SingleCheckActionVariant {\r\n async use(options = {}) {\r\n const action = getActionName('CreateADiversion')\r\n const token = getSelectedToken(options, action)\r\n if (!token) return\r\n\r\n options.actors = [token.actor]\r\n return super.use(options)\r\n }\r\n }\r\n\r\n class CreateADiversion extends SingleCheckAction {\r\n constructor() {\r\n super({\r\n cost: 1,\r\n description: 'PF2E.Actions.CreateADiversion.Description',\r\n name: 'PF2E.Actions.CreateADiversion.Title',\r\n notes: [\r\n { outcome: ['criticalSuccess', 'success'], text: 'PF2E.Actions.CreateADiversion.Notes.success' },\r\n { outcome: ['criticalFailure', 'failure'], text: 'PF2E.Actions.CreateADiversion.Notes.failure' },\r\n ],\r\n section: 'skill',\r\n slug: 'create-a-diversion',\r\n statistic: 'deception',\r\n traits: ['mental'],\r\n variants: [\r\n {\r\n name: 'PF2E.Actions.CreateADiversion.DistractingWords.Title',\r\n rollOptions: ['action:create-a-diversion', 'action:create-a-diversion:distracting-words'],\r\n slug: 'distracting-words',\r\n traits: ['auditory', 'linguistic', 'mental'],\r\n },\r\n {\r\n name: 'PF2E.Actions.CreateADiversion.Gesture.Title',\r\n rollOptions: ['action:create-a-diversion', 'action:create-a-diversion:gesture'],\r\n slug: 'gesture',\r\n traits: ['manipulate', 'mental'],\r\n },\r\n {\r\n name: 'PF2E.Actions.CreateADiversion.Trick.Title',\r\n rollOptions: ['action:create-a-diversion', 'action:create-a-diversion:trick'],\r\n slug: 'trick',\r\n traits: ['manipulate', 'mental'],\r\n },\r\n ],\r\n })\r\n }\r\n\r\n toActionVariant(data) {\r\n return new CreateADiversionVariant(this, data)\r\n }\r\n }\r\n\r\n game.pf2e.actions.set('create-a-diversion', new CreateADiversion())\r\n}\r\n\r\nfunction setupHide(SingleCheckAction, SingleCheckActionVariant) {\r\n class HideVariant extends SingleCheckActionVariant {\r\n async use(options = {}) {\r\n const action = getActionName('Hide')\r\n const token = getSelectedToken(options, action)\r\n if (!token) return\r\n\r\n options.actors = [token.actor]\r\n return super.use(options)\r\n }\r\n }\r\n\r\n class Hide extends SingleCheckAction {\r\n constructor() {\r\n super({\r\n cost: 1,\r\n description: 'PF2E.Actions.Hide.Description',\r\n name: 'PF2E.Actions.Hide.Title',\r\n rollOptions: ['action:hide'],\r\n slug: 'hide',\r\n statistic: 'stealth',\r\n traits: ['secret'],\r\n notes: [{ outcome: ['success', 'criticalSuccess'], text: 'PF2E.Actions.Hide.Notes.success' }],\r\n })\r\n }\r\n\r\n toActionVariant(data) {\r\n return new HideVariant(this, data)\r\n }\r\n }\r\n\r\n game.pf2e.actions.set('hide', new Hide())\r\n}\r\n\r\nfunction setupCover(BaseAction, BaseActionVariant) {\r\n class TakeCoverVariant extends BaseActionVariant {\r\n async use(options = {}) {\r\n const action = localize('action.take-cover')\r\n const token = getSelectedToken(options, action)\r\n if (token) takeCover(token)\r\n }\r\n }\r\n\r\n class TakeCover extends BaseAction {\r\n constructor() {\r\n super({\r\n cost: 1,\r\n description: 'PF2E.Actions.TakeCover.Description',\r\n img: 'systems/pf2e/icons/conditions-2/status_acup.webp',\r\n name: 'PF2E.Actions.TakeCover.Title',\r\n slug: 'take-cover',\r\n })\r\n }\r\n\r\n toActionVariant(data) {\r\n return new TakeCoverVariant(this, data)\r\n }\r\n }\r\n\r\n game.pf2e.actions.set('take-cover', new TakeCover())\r\n}\r\n\r\nasync function takeCover(token) {\r\n const actor = token.actor\r\n const cover = getCoverEffect(actor)\r\n\r\n const targets = validateTokens(token, game.user.targets.ids)\r\n if (cover && !targets.length) return cover.delete()\r\n\r\n const data = getTokenData(token) ?? {}\r\n const covers = Object.entries(data).reduce((covers, [tokenId, { cover }]) => {\r\n if (cover) covers[tokenId] = cover\r\n return covers\r\n }, {})\r\n\r\n const content = await renderTemplate(templatePath('covers-dialog'), {\r\n i18n: localize,\r\n hasTargets: !!targets.length,\r\n hasCovers: !isEmpty(covers),\r\n hasTargetCover: targets.some(id => id in covers),\r\n isProne: isProne(actor),\r\n })\r\n\r\n const dialog = new Dialog({\r\n title: `${token.name} - ${localize('action.take-cover')}`,\r\n content,\r\n buttons: {},\r\n render: html => {\r\n html.find('button').on('click', async event => {\r\n const { level } = event.currentTarget.dataset\r\n const skip = getSetting('skip-cover')\r\n\r\n const process = async (cover, isSelected) => {\r\n const selected = isSelected ? targets : undefined\r\n\r\n const flavor = cover === defaultValues.cover ? (selected ? 'remove' : 'remove-all') : 'take'\r\n await createTokenMessage({\r\n content: localize(`message.cover.${flavor}`, { cover: localize(`cover.${cover}`) }),\r\n flags: { selected, cover, skipWait: skip },\r\n token,\r\n })\r\n\r\n if (skip) {\r\n if (cover === defaultValues.cover && !selected) return clearTokenData(token)\r\n const data = deepClone(getTokenData(token)) ?? {}\r\n for (const tokenId of targets) {\r\n setProperty(data, `${tokenId}.cover`, cover)\r\n }\r\n return setTokenData(token, data)\r\n }\r\n }\r\n\r\n if (level === 'remove-all') process(defaultValues.cover)\r\n else if (level === 'remove') process(defaultValues.cover, true)\r\n else if (targets.length) process(level, true)\r\n else {\r\n const source = createCoverSource(level)\r\n actor.createEmbeddedDocuments('Item', [source])\r\n }\r\n\r\n dialog.close()\r\n })\r\n },\r\n }).render(true)\r\n}\r\n\r\nfunction getSelectedToken(options, action) {\r\n let tokens = options.tokens?.filter(t => t.actor) ?? []\r\n if (!Array.isArray(tokens)) tokens = [tokens]\r\n\r\n let actors = options.actors ?? []\r\n if (!Array.isArray(actors)) actors = [actors]\r\n\r\n if (!tokens.length && actors.length === 1) tokens = [getActorToken(actors[0])].filter(Boolean)\r\n if (!tokens.length) tokens = canvas.tokens.controlled.filter(t => t.actor)\r\n if (!tokens.length) tokens = [getActorToken(game.user.character)].filter(Boolean)\r\n\r\n if (tokens.length > 1) {\r\n ui.notifications.warn(localize('action.only-one', { action }))\r\n return\r\n }\r\n\r\n if (!tokens.length) {\r\n ui.notifications.warn(localize('action.must-one', { action }))\r\n return\r\n }\r\n\r\n const token = tokens[0]\r\n if (!token?.actor?.isOfType('creature')) {\r\n ui.notifications.warn(localize('action.must-creature', { action }))\r\n return\r\n }\r\n\r\n return token\r\n}\r\n\r\nfunction createButton(action, icon, label) {\r\n return `\r\n`\r\n}\r\n", "import { getCoverEffect, hasGreaterDarkvision, isProne, seeInvisibility } from './actor.js'\r\nimport { clearDebug, getRectEdges, lineIntersectWall, pointToTokenIntersectWall } from './geometry.js'\r\nimport { getLightExposure } from './lighting.js'\r\nimport { getPerception, perceptionRules, updateFromPerceptionRules } from './rule-element.js'\r\nimport { getSceneSetting, getValidTokens, validateTokens } from './scene.js'\r\nimport {\r\n createDarknessTemplate,\r\n createMistTemplate,\r\n createSeekTemplate,\r\n deleteSeekTemplate,\r\n getDarknessTemplates,\r\n getMistTemplates,\r\n getSeekTemplateTokens,\r\n getTemplateTokens,\r\n} from './template.js'\r\nimport {\r\n clearConditionals,\r\n getCover,\r\n getCreatureCover,\r\n getTokenData,\r\n getVisibility,\r\n getWallCover,\r\n openHUD,\r\n showAllConditionals,\r\n showConditionals,\r\n} from './token.js'\r\n\r\nexport const API = {\r\n geometry: {\r\n clearDebug,\r\n getRectEdges,\r\n lineIntersectWall,\r\n pointToTokenIntersectWall,\r\n },\r\n token: {\r\n getCreatureCover,\r\n getWallCover,\r\n getVisibility,\r\n clearConditionals,\r\n showConditionals,\r\n showAllConditionals,\r\n getTokenData,\r\n getCover,\r\n openHUD,\r\n },\r\n lighting: {\r\n getLightExposure,\r\n },\r\n actor: {\r\n isProne,\r\n getCoverEffect,\r\n seeInvisibility,\r\n hasGreaterDarkvision,\r\n },\r\n scene: {\r\n getValidTokens,\r\n validateTokens,\r\n getSceneSetting,\r\n },\r\n template: {\r\n createSeekTemplate,\r\n createDarknessTemplate,\r\n createMistTemplate,\r\n getDarknessTemplates,\r\n getMistTemplates,\r\n getSeekTemplateTokens,\r\n deleteSeekTemplate,\r\n getTemplateTokens,\r\n },\r\n ruleElement: {\r\n perceptionRules,\r\n getPerception,\r\n updateFromPerceptionRules,\r\n },\r\n}\r\n", "import { getActorToken, getCoverEffect, isProne } from './actor.js'\r\nimport { COVERS, COVER_UUID, VISIBILITY_VALUES, attackCheckRoll, validCheckRoll } from './constants.js'\r\nimport { createCoverSource, findChoiceSetRule } from './effect.js'\r\nimport { MODULE_ID, getFlag, getSetting, localize } from './module.js'\r\nimport { getPerception, perceptionRules } from './rule-element.js'\r\nimport { validateTokens } from './scene.js'\r\nimport { getSeekTemplateTokens } from './template.js'\r\nimport { getVisibility } from './token.js'\r\nimport { asNumberOnly } from './utils.js'\r\n\r\nexport async function checkRoll(wrapped, ...args) {\r\n const context = args[1]\r\n if (!context) return wrapped(...args)\r\n\r\n if (Array.isArray(context.options)) context.options = new Set(context.options)\r\n\r\n const { actor, createMessage = 'true', type, token, target, isReroll } = context\r\n const originToken = token ?? getActorToken(actor)\r\n const targetToken = target?.token\r\n const isAttackRoll = attackCheckRoll.includes(type)\r\n const flatCheck = getSetting('flat-check')\r\n\r\n if (\r\n isReroll ||\r\n !createMessage ||\r\n !originToken ||\r\n actor.isOfType('hazard') ||\r\n !validCheckRoll.includes(type) ||\r\n (isAttackRoll && (!targetToken || flatCheck === 'none'))\r\n )\r\n return wrapped(...args)\r\n\r\n if (isAttackRoll && targetToken.actor) {\r\n const event = args[2]\r\n const perception = perceptionRules(originToken, targetToken, {\r\n extraOptions: context.options.filter(o => o.startsWith('item:')),\r\n })\r\n\r\n const visibility = getVisibility(targetToken, originToken, { perception, affects: 'target' })\r\n if (!visibility) return wrapped(...args)\r\n\r\n const dc = (() => {\r\n const dc = getPerception(perception, 'target', 'visibility', 'dc', visibility)?.first()\r\n const numberedDC = asNumberOnly(dc)\r\n if (!numberedDC) return numberedDC\r\n\r\n const sign = dc[0]\r\n if (!['-', '+'].includes(sign)) return numberedDC\r\n\r\n return (visibility === 'concealed' ? 5 : 11) + numberedDC\r\n })()\r\n if (dc === 0) return wrapped(...args)\r\n\r\n const isUndetected = VISIBILITY_VALUES[visibility] >= VISIBILITY_VALUES.undetected\r\n const isBlind = event?.ctrlKey || event?.metaKey\r\n\r\n const roll = await new originToken.actor.saves.reflex.constructor(originToken.actor, {\r\n slug: 'visibility-check',\r\n label: `${game.i18n.localize('PF2E.FlatCheck')}: ${game.i18n.localize(`PF2E.condition.${visibility}.name`)}`,\r\n check: { type: 'flat-check' },\r\n }).roll({\r\n dc: { value: dc ?? (visibility === 'concealed' ? 5 : 11) },\r\n target: targetToken.actor,\r\n rollMode: isUndetected || isBlind ? (game.user.isGM ? 'gmroll' : 'blindroll') : 'roll',\r\n })\r\n\r\n const isSuccess = roll.degreeOfSuccess > 1\r\n\r\n if (isUndetected) {\r\n context.options.add('secret')\r\n context.pf2ePerception = {\r\n isSuccess: isSuccess,\r\n visibility,\r\n }\r\n }\r\n\r\n if (flatCheck !== 'roll' && !isUndetected && !isSuccess) return\r\n } else if (context.options.has('action:hide')) {\r\n setProperty(context, 'pf2ePerception.selected', game.user.targets.ids)\r\n // } else if (context.options.has('action:sneak')) {\r\n // context.selected = game.user.targets.ids\r\n } else if (context.options.has('action:create-a-diversion')) {\r\n setProperty(context, 'pf2ePerception.selected', game.user.targets.ids)\r\n } else if (context.options.has('action:seek')) {\r\n const highlighted = getSeekTemplateTokens(originToken)\r\n const tokens = highlighted ?? Array.from(game.user.targets)\r\n const selected = validateTokens(originToken, tokens)\r\n .filter(t => !t.document.hidden)\r\n .map(t => t.id)\r\n\r\n setProperty(context, 'pf2ePerception.selected', selected)\r\n setProperty(context, 'pf2ePerception.fromTemplate', !!highlighted)\r\n }\r\n\r\n return wrapped(...args)\r\n}\r\n\r\nexport function renderCheckModifiersDialog(dialog, html) {\r\n const { createMessage = 'true', type, token, target, isReroll, options, dc } = dialog.context\r\n const originToken = token\r\n const targetToken = target?.token\r\n const targetActor = target?.actor\r\n\r\n if (isReroll || !createMessage || !originToken || !targetToken || !targetActor || !attackCheckRoll.includes(type)) return\r\n\r\n const coverEffect = getCoverEffect(targetActor)\r\n const currentCover = coverEffect\r\n ? findChoiceSetRule(coverEffect)?.selection.level ?? getFlag(coverEffect, 'level')\r\n : undefined\r\n let coverOverride = dialog[MODULE_ID]?.coverOverride ?? currentCover\r\n\r\n let template = '
'\r\n template += `
${localize('dice-checks.cover.label')}
`\r\n template += `
'\r\n\r\n // visibility override here\r\n\r\n template += '
'\r\n\r\n html.find('.roll-mode-panel').before(template)\r\n\r\n html.find('select[name=overrideCover]').on('change', event => {\r\n const value = event.currentTarget.value || undefined\r\n setProperty(dialog, `${MODULE_ID}.coverOverride`, value)\r\n coverOverride = value\r\n })\r\n\r\n html.find('button.roll')[0].addEventListener(\r\n 'click',\r\n event => {\r\n event.preventDefault()\r\n event.stopPropagation()\r\n event.stopImmediatePropagation()\r\n\r\n let modified = false\r\n const items = deepClone(targetActor._source.items)\r\n\r\n if (coverOverride !== currentCover) {\r\n modified = true\r\n\r\n const coverIndex = items.findIndex(i => getProperty(i, 'flags.core.sourceId') === COVER_UUID)\r\n if (coverIndex !== -1) items.splice(coverIndex, 1)\r\n\r\n if (coverOverride) {\r\n const source = createCoverSource(coverOverride)\r\n items.push(source)\r\n }\r\n }\r\n\r\n if (modified) {\r\n target.actor = targetActor.clone({ items }, { keepId: true })\r\n\r\n if (dc?.slug) {\r\n const statistic = target.actor.getStatistic(dc.slug)?.dc\r\n if (statistic) {\r\n dc.value = statistic.value\r\n dc.statistic = statistic\r\n }\r\n }\r\n }\r\n\r\n dialog.resolve(true)\r\n dialog.isResolved = true\r\n dialog.close()\r\n },\r\n true\r\n )\r\n\r\n dialog.setPosition()\r\n}\r\n", "import { getSetting, localize, setSetting } from './module.js'\r\n\r\nexport function renderCombatTracker(tracker, html) {\r\n if (getSetting('target')) setupToggleTarget(html)\r\n // hideUndetected(html)\r\n}\r\n\r\nfunction hideUndetected(html) {\r\n if (!canvas.ready) return\r\n\r\n const combatants = game.combats.viewed?.combatants\r\n if (!combatants?.size) return\r\n\r\n html.find('#combat-tracker .combatant').each((i, li) => {\r\n const { combatantId } = li.dataset\r\n const token = combatants.get(combatantId ?? '')?.token\r\n if (!token) return\r\n\r\n // if (isUndetected(token, 'basicSight', true)) li.remove()\r\n })\r\n}\r\n\r\nfunction setupToggleTarget(html) {\r\n html.find('[data-control=toggleTarget]').each((_, el) => {\r\n el.addEventListener(\r\n 'click',\r\n event => {\r\n event.preventDefault()\r\n event.stopPropagation()\r\n event.stopImmediatePropagation()\r\n\r\n const { combatantId } = event.currentTarget.closest('.combatant').dataset\r\n const combatant = game.combats.viewed.combatants.get(combatantId ?? '')\r\n const token = combatant?.token\r\n if (!token) return\r\n\r\n const isTargeted = Array.from(game.user.targets).some(t => t.document === token)\r\n token.object.setTarget(!isTargeted, { releaseOthers: !event.shiftKey })\r\n },\r\n true\r\n )\r\n })\r\n}\r\n\r\nexport function renderCombatTrackerConfig(config, html) {\r\n const checked = getSetting('encounter')\r\n\r\n html.find('.form-group').last().after(`
\r\n \r\n \r\n

${localize('settings.encounter.short')}

\r\n
`)\r\n\r\n html.find('input[name=\"pf2e-perception.encounter\"]').on('change', event => {\r\n const checked = event.currentTarget.checked\r\n setSetting('encounter', checked)\r\n })\r\n}\r\n", "import { VISIBILITY_VALUES } from './constants.js'\r\nimport { perceptionRules } from './rule-element.js'\r\nimport { getVisibility } from './token.js'\r\n\r\nexport function detectionModeTestVisibility(visionSource, mode, config = {}) {\r\n if (!mode.enabled) return false\r\n if (!this._canDetect(visionSource, config.object, config)) return false\r\n return config.tests.some(test => this._testPoint(visionSource, mode, config.object, test))\r\n}\r\n\r\nexport function basicSightCanDetect(visionSource, target, config) {\r\n if (target instanceof PlaceableObject && target.document.hidden) return false\r\n if (!(target instanceof Token)) return true\r\n\r\n const origin = visionSource.object\r\n const originDocument = origin.document\r\n if (originDocument instanceof TokenDocument && originDocument.hasStatusEffect(CONFIG.specialStatusEffects.BLIND)) return false\r\n\r\n if (!(origin instanceof Token)) {\r\n return (\r\n !target.document?.hasStatusEffect(CONFIG.specialStatusEffects.INVISIBLE) &&\r\n !target.actor?.hasCondition('hidden', 'undetected', 'unnoticed')\r\n )\r\n }\r\n\r\n return !reachesThreshold(origin, target, VISIBILITY_VALUES.hidden, config)\r\n}\r\n\r\nexport function hearingCanDetect(visionSource, target, config) {\r\n if (target.document.hidden || !(target instanceof Token) || !target.actor?.emitsSound) return false\r\n if (!game.settings.get('pf2e', 'automation.rulesBasedVision')) return true\r\n\r\n const origin = visionSource.object\r\n if (origin.actor?.hasCondition('deafened')) return false\r\n\r\n if (!(origin instanceof Token)) {\r\n return !target.actor?.hasCondition('undetected', 'unnoticed')\r\n }\r\n\r\n return !reachesThreshold(origin, target, VISIBILITY_VALUES.undetected, config)\r\n}\r\n\r\nexport function feelTremorCanDetect(visionSource, target, config) {\r\n if (\r\n target.document.hidden ||\r\n !(target instanceof Token) ||\r\n target.document.elevation > canvas.primary.background.elevation ||\r\n target.actor?.isOfType('loot')\r\n )\r\n return false\r\n\r\n const origin = visionSource.object\r\n if (!(origin instanceof Token)) {\r\n return !target.actor?.hasCondition('undetected', 'unnoticed')\r\n }\r\n\r\n return !reachesThreshold(origin, target, VISIBILITY_VALUES.undetected, config)\r\n}\r\n\r\nfunction reachesThreshold(origin, target, threshold, config = {}) {\r\n if (!config.visibility) {\r\n const perception = perceptionRules(origin, target)\r\n config.visibility = getVisibility(target, origin, { perception, affects: 'target' })\r\n }\r\n\r\n return VISIBILITY_VALUES[config.visibility] >= threshold\r\n}\r\n", "function purry(fn, args, lazy) {\r\n const diff = fn.length - args.length\r\n const arrayArgs = Array.from(args)\r\n if (diff === 0) {\r\n return fn(...arrayArgs)\r\n }\r\n if (diff === 1) {\r\n const ret = data => fn(data, ...arrayArgs)\r\n if (lazy || fn.lazy) {\r\n ret.lazy = lazy || fn.lazy\r\n ret.lazyArgs = args\r\n }\r\n return ret\r\n }\r\n throw new Error('Wrong number of arguments')\r\n}\r\n\r\nfunction _reduceLazy(array, lazy, indexed) {\r\n const newArray = []\r\n // We intentionally use a for loop here instead of reduce for performance reasons. See https://leanylabs.com/blog/js-forEach-map-reduce-vs-for-for_of/ for more info\r\n for (let index = 0; index < array.length; index++) {\r\n const item = array[index]\r\n const result = indexed ? lazy(item, index, array) : lazy(item)\r\n if (result.hasMany === true) {\r\n newArray.push(...result.next)\r\n } else if (result.hasNext) {\r\n newArray.push(result.next)\r\n }\r\n }\r\n return newArray\r\n}\r\n\r\nfunction uniqLazy() {\r\n const set = new Set()\r\n return value => {\r\n if (set.has(value)) {\r\n return {\r\n done: false,\r\n hasNext: false,\r\n }\r\n }\r\n set.add(value)\r\n return {\r\n done: false,\r\n hasNext: true,\r\n next: value,\r\n }\r\n }\r\n}\r\n\r\nfunction _uniq(array) {\r\n return _reduceLazy(array, uniqLazy())\r\n}\r\n\r\nexport const R = {\r\n compact: arr => arr.filter(Boolean),\r\n uniq: function () {\r\n return purry(_uniq, arguments, uniqLazy)\r\n },\r\n}\r\n", "import { isObject } from './helpers.js'\r\n\r\nexport class PredicatePF2e extends Array {\r\n constructor(...statements) {\r\n super(...(Array.isArray(statements[0]) ? statements[0] : statements))\r\n this.isValid = PredicatePF2e.isValid(this)\r\n }\r\n\r\n /** Structurally validate the predicates */\r\n static isValid(statements) {\r\n return this.isArray(statements)\r\n }\r\n\r\n /** Is this an array of predicatation statements? */\r\n static isArray(statements) {\r\n return super.isArray(statements) && statements.every(s => StatementValidator.isStatement(s))\r\n }\r\n\r\n /** Test if the given predicate passes for the given list of options. */\r\n static test(predicate = [], options) {\r\n return predicate instanceof PredicatePF2e ? predicate.test(options) : new PredicatePF2e(...predicate).test(options)\r\n }\r\n\r\n /** Test this predicate against a domain of discourse */\r\n test(options) {\r\n if (this.length === 0) {\r\n return true\r\n } else if (!this.isValid) {\r\n console.warn('PF2e System | The provided predicate set is malformed.')\r\n return false\r\n }\r\n\r\n const domain = options instanceof Set ? options : new Set(options)\r\n return this.every(s => this.#isTrue(s, domain))\r\n }\r\n\r\n toObject() {\r\n return deepClone([...this])\r\n }\r\n\r\n clone() {\r\n return new PredicatePF2e(this.toObject())\r\n }\r\n\r\n /** Is the provided statement true? */\r\n #isTrue(statement, domain) {\r\n return (\r\n (typeof statement === 'string' && domain.has(statement)) ||\r\n (StatementValidator.isBinaryOp(statement) && this.#testBinaryOp(statement, domain)) ||\r\n (StatementValidator.isCompound(statement) && this.#testCompound(statement, domain))\r\n )\r\n }\r\n\r\n #testBinaryOp(statement, domain) {\r\n if ('eq' in statement) {\r\n return domain.has(`${statement.eq[0]}:${statement.eq[1]}`)\r\n } else {\r\n const operator = Object.keys(statement)[0]\r\n\r\n // Allow for tests of partial statements against numeric values\r\n // E.g., `{ \"gt\": [\"actor:level\", 5] }` would match against \"actor:level:6\" and \"actor:level:7\"\r\n const [left, right] = Object.values(statement)[0]\r\n const domainArray = Array.from(domain)\r\n const getValues = operand => {\r\n const maybeNumber = Number(operand)\r\n if (!Number.isNaN(maybeNumber)) return [maybeNumber]\r\n const pattern = new RegExp(String.raw`^${operand}:([^:]+)$`)\r\n const values = domainArray.map(s => Number(pattern.exec(s)?.[1] || NaN)).filter(v => !Number.isNaN(v))\r\n return values.length > 0 ? values : [NaN]\r\n }\r\n const leftValues = getValues(left)\r\n const rightValues = getValues(right)\r\n\r\n switch (operator) {\r\n case 'gt':\r\n return leftValues.some(l => rightValues.every(r => l > r))\r\n case 'gte':\r\n return leftValues.some(l => rightValues.every(r => l >= r))\r\n case 'lt':\r\n return leftValues.some(l => rightValues.every(r => l < r))\r\n case 'lte':\r\n return leftValues.some(l => rightValues.every(r => l <= r))\r\n default:\r\n console.warn('PF2e System | Malformed binary operation encountered')\r\n return false\r\n }\r\n }\r\n }\r\n\r\n /** Is the provided compound statement true? */\r\n #testCompound(statement, domain) {\r\n return (\r\n ('and' in statement && statement.and.every(subProp => this.#isTrue(subProp, domain))) ||\r\n ('nand' in statement && !statement.nand.every(subProp => this.#isTrue(subProp, domain))) ||\r\n ('or' in statement && statement.or.some(subProp => this.#isTrue(subProp, domain))) ||\r\n ('xor' in statement && statement.xor.filter(subProp => this.#isTrue(subProp, domain)).length === 1) ||\r\n ('nor' in statement && !statement.nor.some(subProp => this.#isTrue(subProp, domain))) ||\r\n ('not' in statement && !this.#isTrue(statement.not, domain)) ||\r\n ('if' in statement && !(this.#isTrue(statement.if, domain) && !this.#isTrue(statement.then, domain)))\r\n )\r\n }\r\n}\r\n\r\nclass StatementValidator {\r\n static isStatement(statement) {\r\n return statement instanceof Object\r\n ? this.isCompound(statement) || this.isBinaryOp(statement)\r\n : typeof statement === 'string'\r\n ? this.isAtomic(statement)\r\n : false\r\n }\r\n\r\n static isAtomic(statement) {\r\n return (typeof statement === 'string' && statement.length > 0) || this.isBinaryOp(statement)\r\n }\r\n\r\n static #binaryOperators = new Set(['eq', 'gt', 'gte', 'lt', 'lte'])\r\n\r\n static isBinaryOp(statement) {\r\n if (!isObject(statement)) return false\r\n const entries = Object.entries(statement)\r\n if (entries.length > 1) return false\r\n const [operator, operands] = entries[0]\r\n return (\r\n this.#binaryOperators.has(operator) &&\r\n Array.isArray(operands) &&\r\n operands.length === 2 &&\r\n typeof operands[0] === 'string' &&\r\n ['string', 'number'].includes(typeof operands[1])\r\n )\r\n }\r\n\r\n static isCompound(statement) {\r\n return (\r\n isObject(statement) &&\r\n (this.isAnd(statement) ||\r\n this.isOr(statement) ||\r\n this.isNand(statement) ||\r\n this.isXor(statement) ||\r\n this.isNor(statement) ||\r\n this.isNot(statement) ||\r\n this.isIf(statement))\r\n )\r\n }\r\n\r\n static isAnd(statement) {\r\n return (\r\n Object.keys(statement).length === 1 &&\r\n Array.isArray(statement.and) &&\r\n statement.and.every(subProp => this.isStatement(subProp))\r\n )\r\n }\r\n\r\n static isNand(statement) {\r\n return (\r\n Object.keys(statement).length === 1 &&\r\n Array.isArray(statement.nand) &&\r\n statement.nand.every(subProp => this.isStatement(subProp))\r\n )\r\n }\r\n\r\n static isOr(statement) {\r\n return (\r\n Object.keys(statement).length === 1 &&\r\n Array.isArray(statement.or) &&\r\n statement.or.every(subProp => this.isStatement(subProp))\r\n )\r\n }\r\n\r\n static isXor(statement) {\r\n return (\r\n Object.keys(statement).length === 1 &&\r\n Array.isArray(statement.xor) &&\r\n statement.xor.every(subProp => this.isStatement(subProp))\r\n )\r\n }\r\n\r\n static isNor(statement) {\r\n return (\r\n Object.keys(statement).length === 1 &&\r\n Array.isArray(statement.nor) &&\r\n statement.nor.every(subProp => this.isStatement(subProp))\r\n )\r\n }\r\n\r\n static isNot(statement) {\r\n return Object.keys(statement).length === 1 && !!statement.not && this.isStatement(statement.not)\r\n }\r\n\r\n static isIf(statement) {\r\n return Object.keys(statement).length === 2 && this.isStatement(statement.if) && this.isStatement(statement.then)\r\n }\r\n}\r\n", "import { PredicatePF2e } from './predicate'\r\n\r\nconst WEAPON_PROPERTY_RUNES = {\r\n ancestralEchoing: {\r\n level: 15,\r\n name: 'PF2E.WeaponPropertyRune.ancestralEchoing.Name',\r\n price: 9500,\r\n rarity: 'rare',\r\n slug: 'ancestralEchoing',\r\n traits: ['dwarf', 'magical', 'saggorak'],\r\n },\r\n anchoring: {\r\n damage: {\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.anchoring.Name',\r\n text: 'PF2E.WeaponPropertyRune.anchoring.Note.criticalSuccess',\r\n },\r\n ],\r\n },\r\n level: 10,\r\n name: 'PF2E.WeaponPropertyRune.anchoring.Name',\r\n price: 900,\r\n rarity: 'uncommon',\r\n slug: 'anchoring',\r\n traits: ['magical'],\r\n },\r\n ashen: {\r\n damage: {\r\n dice: [\r\n {\r\n damageType: 'fire',\r\n category: 'persistent',\r\n diceNumber: 1,\r\n dieSize: 'd4',\r\n },\r\n ],\r\n notes: [\r\n {\r\n outcome: ['success'],\r\n title: 'PF2E.WeaponPropertyRune.ashen.Name',\r\n text: 'PF2E.WeaponPropertyRune.ashen.Note.success',\r\n },\r\n ],\r\n },\r\n level: 9,\r\n name: 'PF2E.WeaponPropertyRune.ashen.Name',\r\n price: 700,\r\n rarity: 'common',\r\n slug: 'ashen',\r\n traits: ['magical'],\r\n },\r\n astral: {\r\n level: 8,\r\n name: 'PF2E.WeaponPropertyRune.astral.Name',\r\n price: 450,\r\n rarity: 'common',\r\n slug: 'astral',\r\n traits: ['magical', 'spirit'],\r\n damage: {\r\n dice: [{ damageType: 'spirit', diceNumber: 1, dieSize: 'd6' }],\r\n },\r\n },\r\n authorized: {\r\n level: 3,\r\n name: 'PF2E.WeaponPropertyRune.authorized.Name',\r\n price: 50,\r\n rarity: 'common',\r\n slug: 'authorized',\r\n traits: ['magical'],\r\n },\r\n bane: {\r\n level: 4,\r\n name: 'PF2E.WeaponPropertyRune.bane.Name',\r\n price: 100,\r\n rarity: 'uncommon',\r\n slug: 'bane',\r\n traits: ['magical'],\r\n },\r\n bloodbane: {\r\n level: 8,\r\n name: 'PF2E.WeaponPropertyRune.bloodbane.Name',\r\n price: 475,\r\n rarity: 'uncommon',\r\n slug: 'bloodbane',\r\n traits: ['dwarf', 'magical'],\r\n },\r\n bloodthirsty: {\r\n damage: {\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.bloodbane.Name',\r\n text: 'PF2E.WeaponPropertyRune.bloodthirsty.Note.criticalSuccess',\r\n },\r\n ],\r\n },\r\n level: 16,\r\n name: 'PF2E.WeaponPropertyRune.bloodthirsty.Name',\r\n price: 8500,\r\n rarity: 'uncommon',\r\n slug: 'bloodthirsty',\r\n traits: ['magical'],\r\n },\r\n brilliant: {\r\n damage: {\r\n dice: [\r\n { damageType: 'fire', diceNumber: 1, dieSize: 'd4' },\r\n {\r\n damageType: 'spirit',\r\n diceNumber: 1,\r\n dieSize: 'd4',\r\n predicate: ['target:trait:fiend'],\r\n },\r\n {\r\n damageType: 'vitality',\r\n diceNumber: 1,\r\n dieSize: 'd4',\r\n predicate: ['target:negative-healing'],\r\n },\r\n ],\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.brilliant.Name',\r\n text: 'PF2E.WeaponPropertyRune.brilliant.Note.criticalSuccess',\r\n },\r\n ],\r\n },\r\n level: 12,\r\n name: 'PF2E.WeaponPropertyRune.brilliant.Name',\r\n price: 2000,\r\n rarity: 'common',\r\n slug: 'brilliant',\r\n traits: ['magical'],\r\n },\r\n called: {\r\n level: 7,\r\n name: 'PF2E.WeaponPropertyRune.called.Name',\r\n price: 350,\r\n rarity: 'common',\r\n slug: 'called',\r\n traits: ['magical'],\r\n },\r\n coating: {\r\n level: 9,\r\n name: 'PF2E.WeaponPropertyRune.coating.Name',\r\n price: 700,\r\n rarity: 'common',\r\n slug: 'coating',\r\n traits: ['extradimensional', 'magical'],\r\n },\r\n conducting: {\r\n level: 7,\r\n name: 'PF2E.WeaponPropertyRune.conducting.Name',\r\n price: 300,\r\n rarity: 'common',\r\n slug: 'conducting',\r\n traits: ['magical'],\r\n },\r\n corrosive: {\r\n damage: {\r\n dice: [{ damageType: 'acid', diceNumber: 1, dieSize: 'd6' }],\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.corrosive.Name',\r\n text: 'PF2E.WeaponPropertyRune.corrosive.Note.criticalSuccess',\r\n },\r\n ],\r\n },\r\n level: 8,\r\n name: 'PF2E.WeaponPropertyRune.corrosive.Name',\r\n price: 500,\r\n rarity: 'common',\r\n slug: 'corrosive',\r\n traits: ['acid', 'magical'],\r\n },\r\n crushing: {\r\n damage: {\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.crushing.Name',\r\n text: 'PF2E.WeaponPropertyRune.crushing.Note.criticalSuccess',\r\n },\r\n ],\r\n },\r\n level: 3,\r\n name: 'PF2E.WeaponPropertyRune.crushing.Name',\r\n price: 50,\r\n rarity: 'uncommon',\r\n slug: 'crushing',\r\n traits: ['magical'],\r\n },\r\n cunning: {\r\n level: 5,\r\n name: 'PF2E.WeaponPropertyRune.cunning.Name',\r\n price: 140,\r\n rarity: 'common',\r\n slug: 'cunning',\r\n traits: ['magical'],\r\n },\r\n dancing: {\r\n level: 13,\r\n name: 'PF2E.WeaponPropertyRune.dancing.Name',\r\n price: 2700,\r\n rarity: 'uncommon',\r\n slug: 'dancing',\r\n traits: ['magical'],\r\n },\r\n decaying: {\r\n damage: {\r\n dice: [\r\n {\r\n slug: 'decaying',\r\n damageType: 'void',\r\n diceNumber: 1,\r\n dieSize: 'd4',\r\n },\r\n {\r\n slug: 'decaying-persistent',\r\n category: 'persistent',\r\n damageType: 'void',\r\n diceNumber: 2,\r\n dieSize: 'd4',\r\n critical: true,\r\n },\r\n ],\r\n },\r\n level: 8,\r\n name: 'PF2E.WeaponPropertyRune.decaying.Name',\r\n price: 500,\r\n rarity: 'common',\r\n slug: 'decaying',\r\n traits: ['acid', 'magical', 'void'],\r\n },\r\n deathdrinking: {\r\n damage: {\r\n dice: [\r\n {\r\n slug: 'deathdrinking-negative',\r\n damageType: 'void',\r\n diceNumber: 1,\r\n dieSize: 'd6',\r\n critical: true,\r\n predicate: ['target:mode:living', { not: 'target:negative-healing' }],\r\n },\r\n {\r\n slug: 'deathdrinking-positive',\r\n damageType: 'vitality',\r\n diceNumber: 1,\r\n dieSize: 'd6',\r\n critical: true,\r\n predicate: ['target:negative-healing'],\r\n },\r\n ],\r\n },\r\n level: 7,\r\n name: 'PF2E.WeaponPropertyRune.deathdrinking.Name',\r\n price: 360,\r\n rarity: 'rare',\r\n slug: 'deathdrinking',\r\n traits: ['magical'],\r\n },\r\n demolishing: {\r\n damage: {\r\n dice: [\r\n {\r\n damageType: 'force',\r\n category: 'persistent',\r\n diceNumber: 1,\r\n dieSize: 'd6',\r\n predicate: ['target:trait:construct'],\r\n },\r\n ],\r\n },\r\n level: 6,\r\n name: 'PF2E.WeaponPropertyRune.demolishing.Name',\r\n price: 225,\r\n rarity: 'rare',\r\n slug: 'demolishing',\r\n traits: ['magical'],\r\n },\r\n disrupting: {\r\n damage: {\r\n dice: [\r\n {\r\n category: 'persistent',\r\n damageType: 'vitality',\r\n diceNumber: 1,\r\n dieSize: 'd6',\r\n predicate: ['target:negative-healing'],\r\n },\r\n ],\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.disrupting.Name',\r\n text: 'PF2E.WeaponPropertyRune.disrupting.Note.criticalSuccess',\r\n predicate: ['target:negative-healing'],\r\n },\r\n ],\r\n },\r\n level: 5,\r\n name: 'PF2E.WeaponPropertyRune.disrupting.Name',\r\n price: 150,\r\n rarity: 'common',\r\n slug: 'disrupting',\r\n traits: ['magical'],\r\n },\r\n earthbinding: {\r\n level: 5,\r\n name: 'PF2E.WeaponPropertyRune.earthbinding.Name',\r\n price: 125,\r\n rarity: 'common',\r\n slug: 'earthbinding',\r\n traits: ['magical'],\r\n },\r\n energizing: {\r\n level: 6,\r\n name: 'PF2E.WeaponPropertyRune.energizing.Name',\r\n price: 250,\r\n rarity: 'uncommon',\r\n slug: 'energizing',\r\n traits: ['magical'],\r\n },\r\n extending: {\r\n level: 7,\r\n name: 'PF2E.WeaponPropertyRune.extending.Name',\r\n price: 700,\r\n rarity: 'common',\r\n slug: 'extending',\r\n traits: ['magical'],\r\n },\r\n fanged: {\r\n level: 2,\r\n name: 'PF2E.WeaponPropertyRune.fanged.Name',\r\n price: 30,\r\n rarity: 'uncommon',\r\n slug: 'fanged',\r\n traits: ['magical'],\r\n },\r\n fearsome: {\r\n damage: {\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.fearsome.Name',\r\n text: 'PF2E.WeaponPropertyRune.fearsome.Note.criticalSuccess',\r\n },\r\n ],\r\n },\r\n level: 5,\r\n name: 'PF2E.WeaponPropertyRune.fearsome.Name',\r\n price: 160,\r\n rarity: 'common',\r\n slug: 'fearsome',\r\n traits: ['emotion', 'fear', 'magical', 'mental'],\r\n },\r\n flaming: {\r\n damage: {\r\n dice: [\r\n { damageType: 'fire', diceNumber: 1, dieSize: 'd6' },\r\n {\r\n damageType: 'fire',\r\n category: 'persistent',\r\n diceNumber: 1,\r\n dieSize: 'd10',\r\n critical: true,\r\n },\r\n ],\r\n },\r\n level: 8,\r\n name: 'PF2E.WeaponPropertyRune.flaming.Name',\r\n price: 500,\r\n rarity: 'common',\r\n slug: 'flaming',\r\n traits: ['fire', 'magical'],\r\n },\r\n flurrying: {\r\n level: 7,\r\n name: 'PF2E.WeaponPropertyRune.flurrying.Name',\r\n price: 360,\r\n rarity: 'common',\r\n slug: 'flurrying',\r\n traits: ['magical'],\r\n },\r\n frost: {\r\n damage: {\r\n dice: [{ damageType: 'cold', diceNumber: 1, dieSize: 'd6' }],\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.frost.Name',\r\n text: 'PF2E.WeaponPropertyRune.frost.Note.criticalSuccess',\r\n },\r\n ],\r\n },\r\n level: 8,\r\n name: 'PF2E.WeaponPropertyRune.frost.Name',\r\n price: 500,\r\n rarity: 'common',\r\n slug: 'frost',\r\n traits: ['cold', 'magical'],\r\n },\r\n ghostTouch: {\r\n level: 4,\r\n name: 'PF2E.WeaponPropertyRune.ghostTouch.Name',\r\n price: 75,\r\n rarity: 'common',\r\n slug: 'ghostTouch',\r\n traits: ['magical'],\r\n },\r\n giantKilling: {\r\n damage: {\r\n dice: [\r\n {\r\n slug: 'giantKilling',\r\n damageType: 'mental',\r\n diceNumber: 1,\r\n dieSize: 'd6',\r\n predicate: ['target:trait:giant'],\r\n },\r\n ],\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n predicate: ['target:trait:giant'],\r\n title: 'PF2E.WeaponPropertyRune.giantKilling.Name',\r\n text: 'PF2E.WeaponPropertyRune.giantKilling.Note.criticalSuccess',\r\n },\r\n ],\r\n },\r\n level: 8,\r\n name: 'PF2E.WeaponPropertyRune.giantKilling.Name',\r\n price: 450,\r\n rarity: 'rare',\r\n slug: 'giantKilling',\r\n traits: ['magical'],\r\n },\r\n greaterAnchoring: {\r\n damage: {\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.greaterAnchoring.Name',\r\n text: 'PF2E.WeaponPropertyRune.greaterAnchoring.Note.criticalSuccess',\r\n },\r\n {\r\n outcome: ['success'],\r\n title: 'PF2E.WeaponPropertyRune.greaterAnchoring.Name',\r\n text: 'PF2E.WeaponPropertyRune.greaterAnchoring.Note.success',\r\n },\r\n ],\r\n },\r\n level: 18,\r\n name: 'PF2E.WeaponPropertyRune.greaterAnchoring.Name',\r\n price: 22_000,\r\n rarity: 'uncommon',\r\n slug: 'greaterAnchoring',\r\n traits: ['magical'],\r\n },\r\n greaterAshen: {\r\n damage: {\r\n dice: [\r\n {\r\n damageType: 'fire',\r\n category: 'persistent',\r\n diceNumber: 1,\r\n dieSize: 'd8',\r\n },\r\n ],\r\n notes: [\r\n {\r\n outcome: ['success'],\r\n title: 'PF2E.WeaponPropertyRune.greaterAshen.Name',\r\n text: 'PF2E.WeaponPropertyRune.greaterAshen.Note.success',\r\n },\r\n ],\r\n },\r\n level: 16,\r\n name: 'PF2E.WeaponPropertyRune.greaterAshen.Name',\r\n price: 9000,\r\n rarity: 'common',\r\n slug: 'greaterAshen',\r\n traits: ['magical'],\r\n },\r\n greaterAstral: {\r\n level: 15,\r\n name: 'PF2E.WeaponPropertyRune.greaterAstral.Name',\r\n price: 6000,\r\n rarity: 'common',\r\n slug: 'greaterAstral',\r\n traits: ['magical', 'spirit'],\r\n damage: {\r\n dice: [{ damageType: 'spirit', diceNumber: 1, dieSize: 'd6' }],\r\n ignoredResistances: [{ type: 'spirit', max: null }],\r\n },\r\n },\r\n greaterBloodbane: {\r\n level: 13,\r\n name: 'PF2E.WeaponPropertyRune.greaterBloodbane.Name',\r\n price: 2800,\r\n rarity: 'uncommon',\r\n slug: 'greaterBloodbane',\r\n traits: ['dwarf', 'magical'],\r\n },\r\n greaterBrilliant: {\r\n damage: {\r\n dice: [\r\n { damageType: 'fire', diceNumber: 1, dieSize: 'd4' },\r\n {\r\n damageType: 'spirit',\r\n diceNumber: 1,\r\n dieSize: 'd4',\r\n predicate: ['target:trait:fiend'],\r\n },\r\n {\r\n damageType: 'vitality',\r\n diceNumber: 1,\r\n dieSize: 'd4',\r\n predicate: ['target:negative-healing'],\r\n },\r\n ],\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.greaterBrilliant.Name',\r\n text: 'PF2E.WeaponPropertyRune.greaterBrilliant.Note.criticalSuccess',\r\n },\r\n {\r\n outcome: ['success'],\r\n title: 'PF2E.WeaponPropertyRune.greaterBrilliant.Name',\r\n text: 'PF2E.WeaponPropertyRune.greaterBrilliant.Note.success',\r\n },\r\n ],\r\n ignoredResistances: [\r\n { type: 'fire', max: null },\r\n { type: 'spirit', max: null },\r\n { type: 'vitality', max: null },\r\n ],\r\n },\r\n level: 18,\r\n name: 'PF2E.WeaponPropertyRune.greaterBrilliant.Name',\r\n price: 24_000,\r\n rarity: 'common',\r\n slug: 'greaterBrilliant',\r\n traits: ['magical'],\r\n },\r\n greaterCorrosive: {\r\n damage: {\r\n dice: [{ damageType: 'acid', diceNumber: 1, dieSize: 'd6' }],\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.greaterCorrosive.Name',\r\n text: 'PF2E.WeaponPropertyRune.greaterCorrosive.Note.criticalSuccess',\r\n },\r\n {\r\n outcome: ['success'],\r\n title: 'PF2E.WeaponPropertyRune.greaterCorrosive.Name',\r\n text: 'PF2E.WeaponPropertyRune.greaterCorrosive.Note.success',\r\n },\r\n ],\r\n ignoredResistances: [{ type: 'acid', max: null }],\r\n },\r\n level: 15,\r\n name: 'PF2E.WeaponPropertyRune.greaterCorrosive.Name',\r\n price: 6500,\r\n rarity: 'common',\r\n slug: 'greaterCorrosive',\r\n traits: ['acid', 'magical'],\r\n },\r\n greaterCrushing: {\r\n damage: {\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.greaterCrushing.Name',\r\n text: 'PF2E.WeaponPropertyRune.greaterCrushing.Note.criticalSuccess',\r\n },\r\n ],\r\n },\r\n level: 9,\r\n name: 'PF2E.WeaponPropertyRune.greaterCrushing.Name',\r\n price: 650,\r\n rarity: 'uncommon',\r\n slug: 'greaterCrushing',\r\n traits: ['magical'],\r\n },\r\n greaterDecaying: {\r\n damage: {\r\n dice: [\r\n {\r\n slug: 'decaying',\r\n damageType: 'void',\r\n diceNumber: 1,\r\n dieSize: 'd4',\r\n },\r\n {\r\n slug: 'decaying-persistent',\r\n category: 'persistent',\r\n damageType: 'void',\r\n diceNumber: 4,\r\n dieSize: 'd4',\r\n critical: true,\r\n },\r\n ],\r\n ignoredResistances: [{ type: 'void', max: null }],\r\n },\r\n level: 15,\r\n name: 'PF2E.WeaponPropertyRune.greaterDecaying.Name',\r\n price: 6500,\r\n rarity: 'common',\r\n slug: 'greaterDecaying',\r\n traits: ['acid', 'magical', 'void'],\r\n },\r\n greaterDisrupting: {\r\n damage: {\r\n dice: [\r\n {\r\n category: 'persistent',\r\n damageType: 'vitality',\r\n diceNumber: 2,\r\n dieSize: 'd6',\r\n predicate: ['target:negative-healing'],\r\n },\r\n ],\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.greaterDisrupting.Name',\r\n text: 'PF2E.WeaponPropertyRune.greaterDisrupting.Note.criticalSuccess',\r\n predicate: ['target:negative-healing'],\r\n },\r\n ],\r\n },\r\n level: 14,\r\n name: 'PF2E.WeaponPropertyRune.greaterDisrupting.Name',\r\n price: 4300,\r\n rarity: 'uncommon',\r\n slug: 'greaterDisrupting',\r\n traits: ['magical'],\r\n },\r\n greaterExtending: {\r\n level: 13,\r\n name: 'PF2E.WeaponPropertyRune.greaterExtending.Name',\r\n price: 3000,\r\n rarity: 'common',\r\n slug: 'greaterExtending',\r\n traits: ['magical'],\r\n },\r\n greaterFanged: {\r\n level: 8,\r\n name: 'PF2E.WeaponPropertyRune.greaterFanged.Name',\r\n price: 425,\r\n rarity: 'uncommon',\r\n slug: 'greaterFanged',\r\n traits: ['magical'],\r\n },\r\n greaterFearsome: {\r\n damage: {\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.greaterFearsome.Name',\r\n text: 'PF2E.WeaponPropertyRune.greaterFearsome.Note.criticalSuccess',\r\n },\r\n ],\r\n },\r\n level: 12,\r\n name: 'PF2E.WeaponPropertyRune.greaterFearsome.Name',\r\n price: 2000,\r\n rarity: 'common',\r\n slug: 'greaterFearsome',\r\n traits: ['emotion', 'fear', 'magical', 'mental'],\r\n },\r\n greaterFlaming: {\r\n damage: {\r\n dice: [\r\n { damageType: 'fire', diceNumber: 1, dieSize: 'd6' },\r\n {\r\n damageType: 'fire',\r\n category: 'persistent',\r\n diceNumber: 2,\r\n dieSize: 'd10',\r\n critical: true,\r\n },\r\n ],\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.greaterFlaming.Name',\r\n text: 'PF2E.WeaponPropertyRune.greaterFlaming.Note.criticalSuccess',\r\n },\r\n {\r\n outcome: ['success'],\r\n title: 'PF2E.WeaponPropertyRune.greaterFlaming.Name',\r\n text: 'PF2E.WeaponPropertyRune.greaterFlaming.Note.success',\r\n },\r\n ],\r\n ignoredResistances: [{ type: 'fire', max: null }],\r\n },\r\n level: 15,\r\n name: 'PF2E.WeaponPropertyRune.greaterFlaming.Name',\r\n price: 6500,\r\n rarity: 'common',\r\n slug: 'greaterFlaming',\r\n traits: ['fire', 'magical'],\r\n },\r\n greaterFrost: {\r\n damage: {\r\n dice: [{ damageType: 'cold', diceNumber: 1, dieSize: 'd6' }],\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.greaterFrost.Name',\r\n text: 'PF2E.WeaponPropertyRune.greaterFrost.Note.criticalSuccess',\r\n },\r\n {\r\n outcome: ['success'],\r\n title: 'PF2E.WeaponPropertyRune.greaterFrost.Name',\r\n text: 'PF2E.WeaponPropertyRune.greaterFrost.Note.success',\r\n },\r\n ],\r\n ignoredResistances: [{ type: 'cold', max: null }],\r\n },\r\n level: 15,\r\n name: 'PF2E.WeaponPropertyRune.greaterFrost.Name',\r\n price: 6500,\r\n rarity: 'common',\r\n slug: 'greaterFrost',\r\n traits: ['cold', 'magical'],\r\n },\r\n greaterGiantKilling: {\r\n damage: {\r\n dice: [\r\n {\r\n slug: 'greaterGiantKilling',\r\n damageType: 'mental',\r\n diceNumber: 2,\r\n dieSize: 'd6',\r\n predicate: ['target:trait:giant'],\r\n },\r\n ],\r\n ignoredResistances: [{ type: 'mental', max: null }],\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n predicate: ['target:trait:giant'],\r\n title: 'PF2E.WeaponPropertyRune.greaterGiantKilling.Name',\r\n text: 'PF2E.WeaponPropertyRune.greaterGiantKilling.Note.criticalSuccess',\r\n },\r\n ],\r\n },\r\n level: 15,\r\n name: 'PF2E.WeaponPropertyRune.greaterGiantKilling.Name',\r\n price: 6000,\r\n rarity: 'rare',\r\n slug: 'greaterGiantKilling',\r\n traits: ['magical'],\r\n },\r\n greaterHauling: {\r\n level: 11,\r\n name: 'PF2E.WeaponPropertyRune.greaterHauling.Name',\r\n price: 1300,\r\n rarity: 'uncommon',\r\n slug: 'greaterHauling',\r\n traits: ['magical'],\r\n },\r\n greaterImpactful: {\r\n damage: {\r\n dice: [{ damageType: 'force', diceNumber: 1, dieSize: 'd6' }],\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.greaterImpactful.Name',\r\n text: 'PF2E.WeaponPropertyRune.greaterImpactful.Note.criticalSuccess',\r\n },\r\n ],\r\n },\r\n level: 17,\r\n name: 'PF2E.WeaponPropertyRune.greaterImpactful.Name',\r\n price: 15_000,\r\n rarity: 'common',\r\n slug: 'greaterImpactful',\r\n traits: ['force', 'magical'],\r\n },\r\n greaterRooting: {\r\n level: 11,\r\n name: 'PF2E.WeaponPropertyRune.greaterRooting.Name',\r\n price: 1400,\r\n rarity: 'common',\r\n slug: 'greaterRooting',\r\n traits: ['plant', 'magical', 'wood'],\r\n damage: {\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.greaterRooting.Name',\r\n text: 'PF2E.WeaponPropertyRune.greaterRooting.Note.criticalSuccess',\r\n },\r\n {\r\n outcome: ['success'],\r\n title: 'PF2E.WeaponPropertyRune.greaterRooting.Name',\r\n text: 'PF2E.WeaponPropertyRune.greaterRooting.Note.success',\r\n },\r\n ],\r\n },\r\n },\r\n greaterShock: {\r\n damage: {\r\n dice: [{ damageType: 'electricity', diceNumber: 1, dieSize: 'd6' }],\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.greaterShock.Name',\r\n text: 'PF2E.WeaponPropertyRune.greaterShock.Note.criticalSuccess',\r\n },\r\n {\r\n outcome: ['success'],\r\n title: 'PF2E.WeaponPropertyRune.greaterShock.Name',\r\n text: 'PF2E.WeaponPropertyRune.greaterShock.Note.success',\r\n },\r\n ],\r\n ignoredResistances: [{ type: 'electricity', max: null }],\r\n },\r\n level: 15,\r\n name: 'PF2E.WeaponPropertyRune.greaterShock.Name',\r\n price: 6500,\r\n rarity: 'common',\r\n slug: 'greaterShock',\r\n traits: ['electricity', 'magical'],\r\n },\r\n greaterThundering: {\r\n damage: {\r\n dice: [{ damageType: 'sonic', diceNumber: 1, dieSize: 'd6' }],\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.greaterThundering.Name',\r\n text: 'PF2E.WeaponPropertyRune.greaterThundering.Note.criticalSuccess',\r\n },\r\n {\r\n outcome: ['success'],\r\n title: 'PF2E.WeaponPropertyRune.greaterThundering.Name',\r\n text: 'PF2E.WeaponPropertyRune.greaterThundering.Note.success',\r\n },\r\n ],\r\n ignoredResistances: [{ type: 'sonic', max: null }],\r\n },\r\n level: 15,\r\n name: 'PF2E.WeaponPropertyRune.greaterThundering.Name',\r\n price: 6500,\r\n rarity: 'common',\r\n slug: 'greaterThundering',\r\n traits: ['magical', 'sonic'],\r\n },\r\n grievous: {\r\n damage: {\r\n dice: [\r\n {\r\n damageType: 'bleed',\r\n diceNumber: 1,\r\n dieSize: 'd6',\r\n critical: true,\r\n predicate: ['critical-specialization', 'item:group:dart'],\r\n },\r\n ],\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n predicate: ['item:group:axe'],\r\n title: 'PF2E.WeaponPropertyRune.grievous.Name',\r\n text: 'PF2E.WeaponPropertyRune.grievous.Note.Axe',\r\n },\r\n {\r\n outcome: ['criticalSuccess'],\r\n predicate: ['item:group:brawling'],\r\n title: 'PF2E.WeaponPropertyRune.grievous.Name',\r\n text: 'PF2E.WeaponPropertyRune.grievous.Note.Brawling',\r\n },\r\n {\r\n outcome: ['criticalSuccess'],\r\n predicate: ['item:group:club'],\r\n title: 'PF2E.WeaponPropertyRune.grievous.Name',\r\n text: 'PF2E.WeaponPropertyRune.grievous.Note.Club',\r\n },\r\n {\r\n outcome: ['criticalSuccess'],\r\n predicate: ['item:group:flail'],\r\n title: 'PF2E.WeaponPropertyRune.grievous.Name',\r\n text: 'PF2E.WeaponPropertyRune.grievous.Note.Flail',\r\n },\r\n {\r\n outcome: ['criticalSuccess'],\r\n predicate: ['item:group:hammer'],\r\n title: 'PF2E.WeaponPropertyRune.grievous.Name',\r\n text: 'PF2E.WeaponPropertyRune.grievous.Note.Hammer',\r\n },\r\n {\r\n outcome: ['criticalSuccess'],\r\n predicate: ['item:group:knife'],\r\n title: 'PF2E.WeaponPropertyRune.grievous.Name',\r\n text: 'PF2E.WeaponPropertyRune.grievous.Note.Knife',\r\n },\r\n {\r\n outcome: ['criticalSuccess'],\r\n predicate: ['item:group:polearm'],\r\n title: 'PF2E.WeaponPropertyRune.grievous.Name',\r\n text: 'PF2E.WeaponPropertyRune.grievous.Note.Polearm',\r\n },\r\n {\r\n outcome: ['criticalSuccess'],\r\n predicate: ['item:group:shield'],\r\n title: 'PF2E.WeaponPropertyRune.grievous.Name',\r\n text: 'PF2E.WeaponPropertyRune.grievous.Note.Shield',\r\n },\r\n {\r\n outcome: ['criticalSuccess'],\r\n predicate: ['item:group:sling'],\r\n title: 'PF2E.WeaponPropertyRune.grievous.Name',\r\n text: 'PF2E.WeaponPropertyRune.grievous.Note.Sling',\r\n },\r\n {\r\n outcome: ['criticalSuccess'],\r\n predicate: ['item:group:spear'],\r\n title: 'PF2E.WeaponPropertyRune.grievous.Name',\r\n text: 'PF2E.WeaponPropertyRune.grievous.Note.Spear',\r\n },\r\n {\r\n outcome: ['criticalSuccess'],\r\n predicate: ['item:group:sword'],\r\n title: 'PF2E.WeaponPropertyRune.grievous.Name',\r\n text: 'PF2E.WeaponPropertyRune.grievous.Note.Sword',\r\n },\r\n ],\r\n adjustments: [\r\n {\r\n slug: 'critical-specialization',\r\n test: options => new PredicatePF2e('item:group:pick').test(options),\r\n getNewValue: current => current * 2,\r\n },\r\n ],\r\n },\r\n level: 9,\r\n name: 'PF2E.WeaponPropertyRune.grievous.Name',\r\n price: 700,\r\n rarity: 'common',\r\n slug: 'grievous',\r\n traits: ['magical'],\r\n },\r\n hauling: {\r\n level: 6,\r\n name: 'PF2E.WeaponPropertyRune.hauling.Name',\r\n price: 225,\r\n rarity: 'uncommon',\r\n slug: 'hauling',\r\n traits: ['magical'],\r\n },\r\n holy: {\r\n level: 11,\r\n name: 'PF2E.WeaponPropertyRune.holy.Name',\r\n price: 1400,\r\n rarity: 'common',\r\n slug: 'holy',\r\n traits: ['holy', 'magical'],\r\n damage: {\r\n dice: [\r\n {\r\n damageType: 'spirit',\r\n diceNumber: 1,\r\n dieSize: 'd4',\r\n predicate: [{ not: 'target:trait:unholy' }],\r\n },\r\n {\r\n damageType: 'spirit',\r\n diceNumber: 2,\r\n dieSize: 'd4',\r\n predicate: ['target:trait:unholy'],\r\n },\r\n ],\r\n },\r\n strikeAdjustments: [\r\n {\r\n adjustTraits: (_weapon, traits) => {\r\n if (!traits.includes('holy')) traits.push('holy')\r\n },\r\n },\r\n ],\r\n },\r\n hopeful: {\r\n attack: {\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.hopeful.Name',\r\n text: 'PF2E.WeaponPropertyRune.hopeful.Note.criticalSuccess',\r\n },\r\n ],\r\n },\r\n level: 11,\r\n name: 'PF2E.WeaponPropertyRune.hopeful.Name',\r\n price: 1200,\r\n rarity: 'uncommon',\r\n slug: 'hopeful',\r\n traits: ['magical'],\r\n },\r\n hooked: {\r\n level: 5,\r\n name: 'PF2E.WeaponPropertyRune.hooked.Name',\r\n price: 140,\r\n rarity: 'rare',\r\n slug: 'hooked',\r\n traits: ['magical'],\r\n strikeAdjustments: [\r\n {\r\n adjustWeapon: weapon => {\r\n if (!weapon.system.traits.value.includes('trip')) {\r\n weapon.system.traits.value.push('trip')\r\n }\r\n },\r\n },\r\n ],\r\n },\r\n impactful: {\r\n damage: {\r\n dice: [{ damageType: 'force', diceNumber: 1, dieSize: 'd6' }],\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.impactful.Name',\r\n text: 'PF2E.WeaponPropertyRune.impactful.Note.criticalSuccess',\r\n },\r\n ],\r\n },\r\n level: 10,\r\n name: 'PF2E.WeaponPropertyRune.impactful.Name',\r\n price: 1000,\r\n rarity: 'common',\r\n slug: 'impactful',\r\n traits: ['force', 'magical'],\r\n },\r\n impossible: {\r\n level: 20,\r\n name: 'PF2E.WeaponPropertyRune.impossible.Name',\r\n price: 70_000,\r\n rarity: 'common',\r\n slug: 'impossible',\r\n traits: ['magical'],\r\n strikeAdjustments: [\r\n {\r\n // Double the base range increment\r\n adjustWeapon: weapon => {\r\n if (weapon.isOfType('weapon') && weapon.system.range && weapon._source.system.range) {\r\n const sourceRange = weapon._source.system.range\r\n const preparedRange = weapon.system.range\r\n weapon.system.range = sourceRange * 2 + Math.abs(preparedRange - sourceRange)\r\n }\r\n },\r\n },\r\n ],\r\n },\r\n keen: {\r\n attack: {\r\n dosAdjustments: [\r\n {\r\n adjustments: { success: { label: 'PF2E.WeaponPropertyRune.keen.Name', amount: 'criticalSuccess' } },\r\n predicate: new PredicatePF2e([\r\n 'check:total:natural:19',\r\n { or: ['item:damage:type:slashing', 'item:damage:type:piercing'] },\r\n ]),\r\n },\r\n ],\r\n },\r\n level: 13,\r\n name: 'PF2E.WeaponPropertyRune.keen.Name',\r\n price: 3000,\r\n rarity: 'uncommon',\r\n slug: 'keen',\r\n traits: ['magical'],\r\n },\r\n kinWarding: {\r\n level: 3,\r\n name: 'PF2E.WeaponPropertyRune.kinWarding.Name',\r\n price: 52,\r\n rarity: 'uncommon',\r\n slug: 'kinWarding',\r\n traits: ['dwarf', 'magical'],\r\n },\r\n majorFanged: {\r\n level: 15,\r\n name: 'PF2E.WeaponPropertyRune.majorFanged.Name',\r\n price: 6000,\r\n rarity: 'uncommon',\r\n slug: 'majorFanged',\r\n traits: ['magical'],\r\n },\r\n majorRooting: {\r\n level: 15,\r\n name: 'PF2E.WeaponPropertyRune.majorRooting.Name',\r\n price: 6500,\r\n rarity: 'common',\r\n slug: 'majorRooting',\r\n traits: ['plant', 'magical', 'wood'],\r\n damage: {\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.majorRooting.Name',\r\n text: 'PF2E.WeaponPropertyRune.majorRooting.Note.criticalSuccess',\r\n },\r\n ],\r\n },\r\n },\r\n merciful: {\r\n strikeAdjustments: [\r\n {\r\n adjustWeapon: weapon => {\r\n if (!weapon.system.traits.value.includes('nonlethal')) {\r\n weapon.system.traits.value.push('nonlethal')\r\n }\r\n },\r\n },\r\n ],\r\n level: 4,\r\n name: 'PF2E.WeaponPropertyRune.merciful.Name',\r\n price: 70,\r\n rarity: 'common',\r\n slug: 'merciful',\r\n traits: ['magical', 'mental'],\r\n },\r\n pacifying: {\r\n level: 5,\r\n name: 'PF2E.WeaponPropertyRune.pacifying.Name',\r\n price: 150,\r\n rarity: 'uncommon',\r\n slug: 'pacifying',\r\n traits: ['magical'],\r\n },\r\n returning: {\r\n attack: {\r\n notes: [{ title: 'PF2E.WeaponPropertyRune.returning.Name', text: 'PF2E.WeaponPropertyRune.returning.Note' }],\r\n },\r\n level: 3,\r\n name: 'PF2E.WeaponPropertyRune.returning.Name',\r\n price: 55,\r\n rarity: 'common',\r\n slug: 'returning',\r\n traits: ['magical'],\r\n },\r\n rooting: {\r\n level: 7,\r\n name: 'PF2E.WeaponPropertyRune.rooting.Name',\r\n price: 360,\r\n rarity: 'common',\r\n slug: 'rooting',\r\n traits: ['plant', 'magical', 'wood'],\r\n damage: {\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.rooting.Name',\r\n text: 'PF2E.WeaponPropertyRune.rooting.Note.criticalSuccess',\r\n },\r\n ],\r\n },\r\n },\r\n serrating: {\r\n damage: {\r\n dice: [{ damageType: 'slashing', diceNumber: 1, dieSize: 'd4' }],\r\n },\r\n level: 10,\r\n name: 'PF2E.WeaponPropertyRune.serrating.Name',\r\n price: 1000,\r\n rarity: 'uncommon',\r\n slug: 'serrating',\r\n traits: ['magical'],\r\n },\r\n shifting: {\r\n level: 6,\r\n name: 'PF2E.WeaponPropertyRune.shifting.Name',\r\n price: 225,\r\n rarity: 'common',\r\n slug: 'shifting',\r\n traits: ['magical'],\r\n },\r\n shock: {\r\n damage: {\r\n dice: [{ damageType: 'electricity', diceNumber: 1, dieSize: 'd6' }],\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.shock.Name',\r\n text: 'PF2E.WeaponPropertyRune.shock.Note.criticalSuccess',\r\n },\r\n ],\r\n },\r\n level: 8,\r\n name: 'PF2E.WeaponPropertyRune.shock.Name',\r\n price: 500,\r\n rarity: 'common',\r\n slug: 'shock',\r\n traits: ['electricity', 'magical'],\r\n },\r\n speed: {\r\n level: 16,\r\n name: 'PF2E.Actor.Speed.Label',\r\n price: 10_000,\r\n rarity: 'rare',\r\n slug: 'speed',\r\n traits: ['magical'],\r\n },\r\n spellStoring: {\r\n level: 13,\r\n name: 'PF2E.WeaponPropertyRune.spellStoring.Name',\r\n price: 2700,\r\n rarity: 'uncommon',\r\n slug: 'spellStoring',\r\n traits: ['magical'],\r\n },\r\n swarming: {\r\n level: 9,\r\n name: 'PF2E.WeaponPropertyRune.swarming.Name',\r\n price: 700,\r\n rarity: 'common',\r\n slug: 'swarming',\r\n traits: ['magical'],\r\n },\r\n thundering: {\r\n damage: {\r\n dice: [{ damageType: 'sonic', diceNumber: 1, dieSize: 'd6' }],\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.thundering.Name',\r\n text: 'PF2E.WeaponPropertyRune.thundering.Note.criticalSuccess',\r\n },\r\n ],\r\n },\r\n level: 8,\r\n name: 'PF2E.WeaponPropertyRune.thundering.Name',\r\n price: 500,\r\n rarity: 'common',\r\n slug: 'thundering',\r\n traits: ['magical', 'sonic'],\r\n },\r\n trueRooting: {\r\n level: 19,\r\n name: 'PF2E.WeaponPropertyRune.trueRooting.Name',\r\n price: 40_000,\r\n rarity: 'common',\r\n slug: 'trueRooting',\r\n traits: ['plant', 'magical', 'wood'],\r\n damage: {\r\n notes: [\r\n {\r\n outcome: ['criticalSuccess'],\r\n title: 'PF2E.WeaponPropertyRune.trueRooting.Name',\r\n text: 'PF2E.WeaponPropertyRune.trueRooting.Note.criticalSuccess',\r\n },\r\n ],\r\n },\r\n },\r\n underwater: {\r\n level: 3,\r\n name: 'PF2E.WeaponPropertyRune.underwater.Name',\r\n price: 50,\r\n rarity: 'common',\r\n slug: 'underwater',\r\n traits: ['magical', 'water'],\r\n },\r\n unholy: {\r\n level: 11,\r\n name: 'PF2E.WeaponPropertyRune.unholy.Name',\r\n price: 1400,\r\n rarity: 'common',\r\n slug: 'unholy',\r\n traits: ['unholy', 'magical'],\r\n damage: {\r\n dice: [\r\n {\r\n damageType: 'spirit',\r\n diceNumber: 1,\r\n dieSize: 'd4',\r\n predicate: [{ not: 'target:trait:holy' }],\r\n },\r\n {\r\n damageType: 'spirit',\r\n diceNumber: 2,\r\n dieSize: 'd4',\r\n predicate: ['target:trait:holy'],\r\n },\r\n ],\r\n },\r\n strikeAdjustments: [\r\n {\r\n adjustTraits: (_weapon, traits) => {\r\n if (!traits.includes('unholy')) traits.push('unholy')\r\n },\r\n },\r\n ],\r\n },\r\n vorpal: {\r\n level: 17,\r\n name: 'PF2E.WeaponPropertyRune.vorpal.Name',\r\n price: 15_000,\r\n rarity: 'rare',\r\n slug: 'vorpal',\r\n traits: ['magical'],\r\n },\r\n wounding: {\r\n damage: {\r\n dice: [{ damageType: 'bleed', diceNumber: 1, dieSize: 'd6' }],\r\n },\r\n level: 7,\r\n name: 'PF2E.WeaponPropertyRune.wounding.Name',\r\n price: 340,\r\n rarity: 'common',\r\n slug: 'wounding',\r\n traits: ['magical'],\r\n },\r\n}\r\n\r\nexport function getPropertyRuneStrikeAdjustments(runes) {\r\n return runes.flatMap(r => WEAPON_PROPERTY_RUNES[r].strikeAdjustments ?? [])\r\n}\r\n", "import { COVER_VALUES, VISIBILITY_VALUES } from '../constants'\r\nimport { createCoverSource, createFlatFootedSource } from '../effect'\r\nimport { R } from '../remeda'\r\nimport { getPerception, perceptionRules } from '../rule-element'\r\nimport { getCover, getVisibility } from '../token'\r\nimport { asNumberOnly } from '../utils'\r\nimport { extractEphemeralEffects, getRangeIncrement, isOffGuardFromFlanking } from './helpers'\r\nimport { getPropertyRuneStrikeAdjustments } from './rune'\r\n\r\nexport async function getRollContext(params) {\r\n const [selfToken, targetToken] =\r\n canvas.ready && !params.viewOnly\r\n ? [\r\n canvas.tokens.controlled.find(t => t.actor === this) ?? this.getActiveTokens().shift() ?? null,\r\n params.target?.token ?? params.target?.actor?.getActiveTokens().shift() ?? null,\r\n ]\r\n : [null, null]\r\n\r\n const isAttackAction = ['attack', 'attack-roll', 'attack-damage'].some(d => params.domains.includes(d))\r\n const isMelee = !!(params.melee || (params.item?.isOfType('weapon', 'melee') && params.item.isMelee))\r\n const reach =\r\n isMelee && params.item?.isOfType('action', 'weapon', 'melee')\r\n ? this.getReach({ action: 'attack', weapon: params.item })\r\n : this.getReach({ action: 'attack' })\r\n const isFlankingAttack = !!(\r\n isAttackAction &&\r\n isMelee &&\r\n typeof reach === 'number' &&\r\n targetToken?.actor &&\r\n selfToken?.isFlanking(targetToken, { reach })\r\n )\r\n\r\n // Get ephemeral effects from the target that affect this actor while attacking\r\n const originEphemeralEffects = await extractEphemeralEffects({\r\n affects: 'origin',\r\n origin: this,\r\n target: params.target?.actor ?? targetToken?.actor ?? null,\r\n item: params.item ?? null,\r\n domains: params.domains,\r\n options: [...params.options, ...(params.item?.getRollOptions('item') ?? [])],\r\n })\r\n\r\n const targetMarkOption = (() => {\r\n const tokenMark = targetToken ? this.synthetics.tokenMarks.get(targetToken.document.uuid) : null\r\n return tokenMark ? `target:mark:${tokenMark}` : null\r\n })()\r\n const initialActionOptions = params.traits?.map(t => `self:action:trait:${t}`) ?? []\r\n\r\n const selfActor =\r\n params.viewOnly || !targetToken?.actor\r\n ? this\r\n : this.getContextualClone(\r\n R.compact([\r\n ...Array.from(params.options),\r\n ...targetToken.actor.getSelfRollOptions('target'),\r\n targetMarkOption,\r\n ...initialActionOptions,\r\n isFlankingAttack ? 'self:flanking' : null,\r\n ]),\r\n originEphemeralEffects\r\n )\r\n\r\n const isStrike = params.statistic instanceof game.pf2e.StatisticModifier\r\n const strikeActions = isStrike ? selfActor.system.actions?.flatMap(a => [a, a.altUsages ?? []].flat()) ?? [] : []\r\n\r\n const statistic = params.viewOnly\r\n ? params.statistic\r\n : isStrike\r\n ? strikeActions.find(action => {\r\n // Find the matching weapon or melee item\r\n if (params.item?.id !== action.item.id || params?.item.name !== action.item.name) return false\r\n if (params.item.isOfType('melee') && action.item.isOfType('melee')) return true\r\n\r\n // Discriminate between melee/thrown usages by checking that both are either melee or ranged\r\n return (\r\n params.item.isOfType('weapon') && action.item.isOfType('weapon') && params.item.isMelee === action.item.isMelee\r\n )\r\n }) ?? params.statistic\r\n : params.statistic\r\n\r\n const selfItem = (() => {\r\n // 1. Simplest case: no context clone, so used the item passed to this method\r\n if (selfActor === this) return params.item ?? null\r\n\r\n // 2. Get the item from the statistic if it's stored therein\r\n if (\r\n statistic &&\r\n 'item' in statistic &&\r\n statistic.item instanceof Item &&\r\n statistic.item.isOfType('action', 'melee', 'spell', 'weapon')\r\n ) {\r\n return statistic.item\r\n }\r\n\r\n // 3. Get the item directly from the context clone\r\n const itemClone = selfActor.items.get(params.item?.id ?? '')\r\n if (itemClone?.isOfType('melee', 'weapon')) return itemClone\r\n\r\n // 4 Give up :(\r\n return params.item ?? null\r\n })()\r\n\r\n const itemOptions = selfItem?.getRollOptions('item') ?? []\r\n\r\n const actionTraits = (() => {\r\n const traits = R.compact([params.traits].flat())\r\n if (selfItem?.isOfType('weapon', 'melee')) {\r\n const strikeAdjustments = [\r\n selfActor.synthetics.strikeAdjustments,\r\n getPropertyRuneStrikeAdjustments(selfItem.system.runes.property),\r\n ].flat()\r\n for (const adjustment of strikeAdjustments) {\r\n adjustment.adjustTraits?.(selfItem, traits)\r\n }\r\n }\r\n\r\n return R.uniq(traits).sort()\r\n })()\r\n\r\n // Calculate distance and range increment, set as a roll option\r\n const distance = selfToken && targetToken ? selfToken.distanceTo(targetToken) : null\r\n const [originDistance, targetDistance] =\r\n typeof distance === 'number' ? [`origin:distance:${distance}`, `target:distance:${distance}`] : [null, null]\r\n\r\n const originMarkOption = (() => {\r\n const tokenMark = selfToken ? targetToken?.actor?.synthetics.tokenMarks.get(selfToken.document.uuid) : null\r\n return tokenMark ? `origin:mark:${tokenMark}` : null\r\n })()\r\n const originRollOptions =\r\n selfToken && targetToken\r\n ? R.compact(\r\n R.uniq([\r\n ...selfActor.getSelfRollOptions('origin'),\r\n ...actionTraits.map(t => `origin:action:trait${t}`),\r\n ...(originDistance ? [originDistance] : []),\r\n originMarkOption,\r\n ])\r\n )\r\n : []\r\n\r\n // Target roll options\r\n const getTargetRollOptions = actor => {\r\n const targetOptions = actor?.getSelfRollOptions('target') ?? []\r\n if (targetToken) {\r\n targetOptions.push('target') // An indicator that there is a target of any kind\r\n if (targetMarkOption) targetOptions.push(targetMarkOption)\r\n }\r\n return targetOptions.sort()\r\n }\r\n const targetRollOptions = getTargetRollOptions(targetToken?.actor)\r\n\r\n // Get ephemeral effects from this actor that affect the target while being attacked\r\n const targetEphemeralEffects = await extractEphemeralEffects({\r\n affects: 'target',\r\n origin: selfActor,\r\n target: targetToken?.actor ?? null,\r\n item: selfItem,\r\n domains: params.domains,\r\n options: [...params.options, ...itemOptions, ...targetRollOptions],\r\n })\r\n\r\n /**\r\n * WE ADDED STUFF HERE\r\n */\r\n if (selfToken?.actor && targetToken?.actor && !params.viewOnly) {\r\n const perception = perceptionRules(selfToken, targetToken, {\r\n extraOptions: itemOptions,\r\n distance,\r\n })\r\n\r\n let visibility = getVisibility(selfToken, targetToken, { perception, affects: 'origin' })\r\n\r\n if (visibility && getPerception(perception, 'target', 'visibility', 'noff', visibility)) {\r\n visibility = undefined\r\n }\r\n\r\n if (VISIBILITY_VALUES[visibility] > VISIBILITY_VALUES.concealed)\r\n targetEphemeralEffects.push(createFlatFootedSource(visibility))\r\n\r\n let cover = getCover(selfToken, targetToken, { perception, affects: 'target', options: itemOptions })\r\n let coverBonus = undefined\r\n\r\n if (cover) {\r\n let ac = getPerception(perception, 'target', 'cover', 'ac', cover)?.first()\r\n if (ac != null) ac = Math.clamped(asNumberOnly(ac), 0, 4)\r\n if (ac === 0) cover = undefined\r\n else if (ac) coverBonus = ac\r\n }\r\n\r\n if (COVER_VALUES[cover] > COVER_VALUES.none) targetEphemeralEffects.push(createCoverSource(cover, coverBonus))\r\n }\r\n /**\r\n * END OF THE ADDED STUFF\r\n */\r\n\r\n // Add an epehemeral effect from flanking\r\n if (isFlankingAttack && isOffGuardFromFlanking(targetToken.actor, selfActor, originRollOptions)) {\r\n const name = game.i18n.localize('PF2E.Item.Condition.Flanked')\r\n const condition = game.pf2e.ConditionManager.getCondition('off-guard', { name })\r\n targetEphemeralEffects.push(condition.toObject())\r\n }\r\n\r\n // Clone the actor to recalculate its AC with contextual roll options\r\n const targetActor = params.viewOnly\r\n ? null\r\n : (params.target?.actor ?? targetToken?.actor)?.getContextualClone(\r\n R.compact([...params.options, ...itemOptions, ...originRollOptions]),\r\n targetEphemeralEffects\r\n ) ?? null\r\n\r\n const rollOptions = new Set(\r\n R.compact([\r\n ...params.options,\r\n ...selfActor.getRollOptions(params.domains),\r\n ...(targetActor ? getTargetRollOptions(targetActor) : targetRollOptions),\r\n ...actionTraits.map(t => `self:action:trait:${t}`),\r\n ...itemOptions,\r\n // Backward compatibility for predication looking for an \"attack\" trait by its lonesome\r\n isAttackAction ? 'attack' : null,\r\n ]).sort()\r\n )\r\n\r\n if (targetDistance) rollOptions.add(targetDistance)\r\n const rangeIncrement = selfItem ? getRangeIncrement(selfItem, distance) : null\r\n if (rangeIncrement) rollOptions.add(`target:range-increment:${rangeIncrement}`)\r\n\r\n const self = {\r\n actor: selfActor,\r\n token: selfToken?.document ?? null,\r\n statistic,\r\n item: selfItem,\r\n modifiers: [],\r\n }\r\n\r\n const target =\r\n targetActor && targetToken && distance !== null\r\n ? { actor: targetActor, token: targetToken.document, distance, rangeIncrement }\r\n : null\r\n\r\n return {\r\n options: rollOptions,\r\n self,\r\n target,\r\n traits: actionTraits,\r\n }\r\n}\r\n", "import { ICONS_PATHS } from '../constants.js'\r\nimport { getSetting, localize, setSetting, templatePath } from '../module.js'\r\n\r\nconst ICONS = ['cover', 'concealed', 'hidden', 'undetected', 'unnoticed']\r\n\r\nexport class IconPathMenu extends FormApplication {\r\n static get defaultOptions() {\r\n return foundry.utils.mergeObject(super.defaultOptions, {\r\n template: templatePath('icon-path-menu'),\r\n title: localize('settings.icon-path.name'),\r\n width: 500,\r\n })\r\n }\r\n\r\n getData() {\r\n const saved = getSetting('icon-path')\r\n\r\n const icons = ICONS.map(name => ({\r\n name,\r\n placeholder: ICONS_PATHS[name],\r\n value: saved[name] ?? '',\r\n label: name === 'cover' ? localize('icon-path.cover') : game.i18n.localize(CONFIG.PF2E.conditionTypes[name]),\r\n }))\r\n\r\n return {\r\n icons,\r\n i18n: localize,\r\n }\r\n }\r\n\r\n activateListeners(html) {\r\n super.activateListeners(html)\r\n\r\n html.find('button[name=cancel]').on('click', event => {\r\n event.prefentDefault()\r\n this.close()\r\n })\r\n }\r\n\r\n async _updateObject(event, formData) {\r\n setSetting('icon-path', formData)\r\n }\r\n}\r\n", "import { IconPathMenu } from './apps/icon-path-menu.js'\r\nimport { MODULE_ID } from './module.js'\r\n\r\nexport function registerSettings() {\r\n register('icon-path', Object, {}, { config: false })\r\n game.settings.registerMenu(MODULE_ID, 'icon-path-menu', {\r\n name: path('icon-path', 'name'),\r\n label: path('icon-path', 'label'),\r\n icon: 'fa-solid fa-list',\r\n restricted: true,\r\n type: IconPathMenu,\r\n })\r\n\r\n register('permission', String, CONST.USER_ROLES.GAMEMASTER, {\r\n choices: {\r\n 1: path('permission', 'choices.1'),\r\n 2: path('permission', 'choices.2'),\r\n 3: path('permission', 'choices.3'),\r\n 4: path('permission', 'choices.4'),\r\n },\r\n })\r\n\r\n register('npc-vision', Boolean, false)\r\n\r\n register('target', Boolean, true, {\r\n onChange: () => ui.combat?.render(),\r\n })\r\n\r\n register('lesser', String, 'ten', {\r\n choices: {\r\n none: path('lesser', 'choices.none'),\r\n cross: path('lesser', 'choices.cross'),\r\n zero: path('lesser', 'choices.zero'),\r\n ten: path('lesser', 'choices.ten'),\r\n twenty: path('lesser', 'choices.twenty'),\r\n },\r\n })\r\n\r\n register('standard', Boolean, true)\r\n\r\n register('dead-cover', Boolean, true)\r\n\r\n register('prone-cover', Boolean, true)\r\n\r\n register('standard-type', String, 'center', {\r\n choices: {\r\n center: path('standard-type', 'choices.center'),\r\n points: path('standard-type', 'choices.points'),\r\n },\r\n })\r\n\r\n register('skip-cover', Boolean, true)\r\n\r\n register('validation', String, 'all', {\r\n choices: {\r\n all: path('validation', 'choices.all'),\r\n selected: path('validation', 'choices.selected'),\r\n changed: path('validation', 'choices.changed'),\r\n },\r\n })\r\n\r\n register('flat-check', String, 'roll', {\r\n choices: {\r\n none: path('flat-check', 'choices.none'),\r\n roll: path('flat-check', 'choices.roll'),\r\n cancel: path('flat-check', 'choices.cancel'),\r\n },\r\n })\r\n\r\n register('encounter', Boolean, false)\r\n\r\n register('icon-size', Number, 26, {\r\n scope: 'client',\r\n range: {\r\n min: 26,\r\n max: 52,\r\n },\r\n })\r\n\r\n register('seek-template', Boolean, true, {\r\n scope: 'client',\r\n })\r\n}\r\n\r\nfunction path(setting, key) {\r\n return `${MODULE_ID}.settings.${setting}.${key}`\r\n}\r\n\r\nfunction register(name, type, defValue, extra = {}) {\r\n game.settings.register(MODULE_ID, name, {\r\n name: path(name, 'name'),\r\n hint: path(name, 'hint'),\r\n scope: 'world',\r\n config: true,\r\n type,\r\n default: defValue,\r\n ...extra,\r\n })\r\n}\r\n", "import { setupActions } from './action.js'\r\nimport { API } from './api.js'\r\nimport { renderChatMessage } from './chat.js'\r\nimport { checkRoll, renderCheckModifiersDialog } from './check.js'\r\nimport { renderCombatTracker, renderCombatTrackerConfig } from './combat.js'\r\nimport { basicSightCanDetect, detectionModeTestVisibility, feelTremorCanDetect, hearingCanDetect } from './detection.js'\r\nimport { MODULE_ID } from './module.js'\r\nimport { getRollContext } from './pf2e/rollcontext.js'\r\nimport { setupRuleElement } from './rule-element.js'\r\nimport { renderSceneConfig } from './scene.js'\r\nimport { registerSettings } from './settings.js'\r\nimport { highlightTemplateGrid, onMeasuredTemplate, preCreateMeasuredTemplate } from './template.js'\r\nimport {\r\n clearConditionals,\r\n controlToken,\r\n deleteToken,\r\n hoverToken,\r\n pasteToken,\r\n preCreateToken,\r\n renderTokenHUD,\r\n rulesBasedVision,\r\n updateToken,\r\n} from './token.js'\r\n\r\nconst CHECK_ROLL = 'game.pf2e.Check.roll'\r\n\r\nconst RULES_BASED_VISION = 'CONFIG.Token.documentClass.prototype.rulesBasedVision'\r\n\r\nconst HIGHLIGHT_TEMPLATE_GRID = 'CONFIG.MeasuredTemplate.objectClass.prototype.highlightGrid'\r\n\r\nconst GET_ROLL_CONTEXT = 'CONFIG.Actor.documentClass.prototype.getRollContext'\r\n\r\nconst DETECTION_MODE_TEST_VISIBILITY = 'DetectionMode.prototype.testVisibility'\r\nconst BASIC_SIGHT_CAN_DETECT = 'CONFIG.Canvas.detectionModes.basicSight._canDetect'\r\nconst HEARING_CAN_DETECT = 'CONFIG.Canvas.detectionModes.hearing._canDetect'\r\nconst FEEL_TREMOR_CAN_DETECT = 'CONFIG.Canvas.detectionModes.feelTremor._canDetect'\r\n\r\nHooks.once('init', () => {\r\n registerSettings()\r\n setupActions()\r\n setupRuleElement()\r\n\r\n libWrapper.register(MODULE_ID, CHECK_ROLL, checkRoll)\r\n\r\n libWrapper.register(MODULE_ID, HIGHLIGHT_TEMPLATE_GRID, highlightTemplateGrid, 'OVERRIDE')\r\n\r\n libWrapper.register(MODULE_ID, RULES_BASED_VISION, rulesBasedVision, 'OVERRIDE')\r\n\r\n libWrapper.register(MODULE_ID, GET_ROLL_CONTEXT, getRollContext, 'OVERRIDE')\r\n\r\n libWrapper.register(MODULE_ID, DETECTION_MODE_TEST_VISIBILITY, detectionModeTestVisibility, 'OVERRIDE')\r\n libWrapper.register(MODULE_ID, BASIC_SIGHT_CAN_DETECT, basicSightCanDetect, 'OVERRIDE')\r\n libWrapper.register(MODULE_ID, HEARING_CAN_DETECT, hearingCanDetect, 'OVERRIDE')\r\n libWrapper.register(MODULE_ID, FEEL_TREMOR_CAN_DETECT, feelTremorCanDetect, 'OVERRIDE')\r\n\r\n const isGM = game.data.users.find(x => x._id === game.data.userId).role >= CONST.USER_ROLES.GAMEMASTER\r\n if (isGM) {\r\n Hooks.on('renderSceneConfig', renderSceneConfig)\r\n Hooks.on('renderCombatTrackerConfig', renderCombatTrackerConfig)\r\n } else {\r\n Hooks.on('renderCombatTracker', renderCombatTracker)\r\n }\r\n\r\n game.modules.get(MODULE_ID).custom = {\r\n getWallCover: undefined,\r\n getCreatureCover: undefined,\r\n }\r\n})\r\n\r\nHooks.once('ready', () => {\r\n game.modules.get(MODULE_ID).api = API\r\n\r\n Hooks.on('renderChatMessage', renderChatMessage)\r\n\r\n for (const el of document.querySelectorAll('#chat-log .chat-message')) {\r\n const message = game.messages.get(el.dataset.messageId)\r\n if (!message) continue\r\n renderChatMessage(message, $(el))\r\n }\r\n\r\n if (game.user.isGM && game.modules.get('pf2e-rules-based-npc-vision')?.active) {\r\n ui.notifications.error(`${MODULE_ID}.warning.npc-vision`, { permanent: true, localize: true })\r\n }\r\n})\r\n\r\nHooks.on('hoverToken', hoverToken)\r\nHooks.on('pasteToken', pasteToken)\r\nHooks.on('updateToken', updateToken)\r\nHooks.on('deleteToken', deleteToken)\r\nHooks.on('controlToken', controlToken)\r\nHooks.on('renderTokenHUD', renderTokenHUD)\r\nHooks.on('preCreateToken', preCreateToken)\r\n\r\nHooks.on('canvasPan', () => clearConditionals())\r\n\r\nHooks.on('renderCheckModifiersDialog', renderCheckModifiersDialog)\r\n\r\nHooks.on('preCreateMeasuredTemplate', preCreateMeasuredTemplate)\r\nHooks.on('createMeasuredTemplate', onMeasuredTemplate)\r\nHooks.on('updateMeasuredTemplate', onMeasuredTemplate)\r\nHooks.on('deleteMeasuredTemplate', onMeasuredTemplate)\r\n"], + "mappings": "miBAAO,IAAMA,GAAa,sDAEbC,EAAoB,CAC7B,CAAC,MAAS,EAAG,EACb,SAAU,EACV,UAAW,EACX,OAAQ,EACR,WAAY,EACZ,UAAW,CACf,EAEaC,GAAe,CAAC,WAAY,YAAa,SAAU,aAAc,WAAW,EAE5EC,EAAS,CAAC,OAAQ,SAAU,WAAY,UAAW,eAAe,EAElEC,EAAe,CACxB,CAAC,MAAS,EAAG,EACb,KAAM,EACN,OAAQ,EACR,SAAU,EACV,QAAS,EACT,gBAAiB,CACrB,EAEaC,EAAgB,CACzB,MAAO,OACP,WAAY,UAChB,EAEaC,GAAkB,CAAC,cAAe,mBAAmB,EAErDC,GAAiB,CAAC,GAAGD,GAAiB,cAAe,kBAAkB,EAEvEE,GAAc,CACvB,MAAO,4CACP,UAAW,+CACX,OAAQ,4CACR,WAAY,gDACZ,UAAW,8CACf,EASO,IAAMC,GAAiB,UACjBC,GAAa,UACbC,GAAe,UAEfC,GAAiB,CAAC,WAAY,oBAAqB,mBAAmB,EACtEC,GAAa,CAAC,iBAAkB,iBAAkB,gBAAgB,ECrDxE,IAAMC,EAAY,kBAElB,SAASC,EAAaC,EAAU,CACnC,MAAO,WAAWF,eAAuBE,OAC7C,CAFgBC,EAAAF,EAAA,gBAIT,SAASG,KAAYC,EAAM,CAC9B,IAAMC,EAAOD,EAAK,GAAG,EAAE,EACjBE,EAAY,OAAOD,GAAS,SAE5BE,EAAOD,EAAYF,EAAK,MAAM,EAAG,EAAE,EAAIA,EAC7C,OAAAG,EAAK,QAAQR,CAAS,EAEf,KAAK,KAAKO,EAAY,SAAW,UAAU,EAAEC,EAAK,KAAK,GAAG,EAAGF,CAAI,CAC5E,CARgBH,EAAAC,EAAA,YAUT,SAASK,EAAQC,EAAKC,EAAM,CAC/B,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AElC,MAAM,GAAG,oBAAqBC,EAAiB,EAE/C,QAAWC,KAAM,SAAS,iBAAiB,yBAAyB,EAAG,CACnE,IAAMC,EAAU,KAAK,SAAS,IAAID,EAAG,QAAQ,SAAS,EACjDC,GACLF,GAAkBE,EAAS,EAAED,CAAE,CAAC,EAGhC,KAAK,KAAK,MAAQ,KAAK,QAAQ,IAAI,6BAA6B,GAAG,QACnE,GAAG,cAAc,MAAM,GAAGf,uBAAgC,CAAE,UAAW,GAAM,SAAU,EAAK,CAAC,CAErG,CAAC,EAED,MAAM,GAAG,aAAciB,EAAU,EACjC,MAAM,GAAG,aAAcC,EAAU,EACjC,MAAM,GAAG,cAAeC,EAAW,EACnC,MAAM,GAAG,cAAeC,EAAW,EACnC,MAAM,GAAG,eAAgBC,EAAY,EACrC,MAAM,GAAG,iBAAkBC,EAAc,EACzC,MAAM,GAAG,iBAAkBC,EAAc,EAEzC,MAAM,GAAG,YAAa,IAAMC,GAAkB,CAAC,EAE/C,MAAM,GAAG,6BAA8BC,EAA0B,EAEjE,MAAM,GAAG,4BAA6BC,EAAyB,EAC/D,MAAM,GAAG,yBAA0BC,EAAkB,EACrD,MAAM,GAAG,yBAA0BA,EAAkB,EACrD,MAAM,GAAG,yBAA0BA,EAAkB", "names": ["COVER_UUID", "VISIBILITY_VALUES", "VISIBILITIES", "COVERS", "COVER_VALUES", "defaultValues", "attackCheckRoll", "validCheckRoll", "ICONS_PATHS", "DARKNESS_COLOR", "MIST_COLOR", "POISON_GREEN", "DARKNESS_SLUGS", "MIST_SLUGS", "MODULE_ID", "templatePath", "template", "__name", "localize", "args", "data", "useFormat", "keys", "getFlag", "doc", "flag", "setFlag", "value", "unsetFlag", "getFlags", "getSetting", "setting", "setSetting", "hasPermission", "getActionName", "action", "createFlatFootedSource", "visibility", "source", "__name", "createCoverSource", "level", "bonus", "COVER_VALUES", "localize", "COVER_UUID", "MODULE_ID", "findChoiceSetRule", "item", "flag", "rule", "getActorToken", "actor", "target", "actorId", "isToken", "token", "__name", "isProne", "item", "getCoverEffect", "selection", "effect", "x", "COVER_UUID", "findChoiceSetRule", "hasSense", "actor", "sense", "type", "__name", "hasGreaterDarkvision", "seeInvisibility", "DEGREE_ADJUSTMENT_AMOUNTS", "DEGREE_OF_SUCCESS_STRINGS", "_getDegreeAdjustment", "getDegreeAdjustment_fn", "_adjustDegreeOfSuccess", "adjustDegreeOfSuccess_fn", "_adjustDegreeByDieValue", "adjustDegreeByDieValue_fn", "_calculateDegreeOfSuccess", "calculateDegreeOfSuccess_fn", "_DegreeOfSuccess", "roll", "dc", "dosAdjustments", "__privateAdd", "t", "d", "__privateMethod", "DegreeOfSuccess", "__name", "degree", "adjustments", "outcome", "label", "amount", "degreeOfSuccess", "__publicField", "renderSceneConfig", "config", "html", "settings", "list", "setting", "checked", "getSceneSetting", "localize", "addedHeight", "height", "el", "__name", "getValidTokens", "token", "tokens", "t", "getSetting", "combat", "actor", "traits", "validateTokens", "validToken", "id", "scene", "getFlag", "extractEphemeralEffects", "affects", "origin", "target", "item", "domains", "options", "effectsFrom", "effectsTo", "fullOptions", "resolvables", "s", "e", "__name", "getRangeIncrement", "attackItem", "distance", "increment", "__name", "isOffGuardFromFlanking", "target", "origin", "flanking", "isObject", "value", "tupleHasValue", "array", "measureDistance", "p0", "p1", "measureDistanceOnGrid", "__name", "segment", "reach", "gridSize", "gridDistance", "nx", "ny", "nz", "sortedDistance", "a", "b", "squares", "reduction", "highlightGrid", "areaType", "object", "colors", "document", "collisionType", "preview", "collisionOrigin", "grid", "dimensions", "angle", "direction", "highlightLayer", "cx", "cy", "col0", "row0", "minAngle", "maxAngle", "snappedOrigin", "withinAngle", "min", "max", "value", "coneOriginOffset", "dir", "xOffset", "yOffset", "padding", "docDistance", "padded", "rowCount", "columnCount", "offsetEmanationOrigin", "destination", "offset", "getCoordinate", "centerCoord", "destCoord", "gx", "gy", "emanationOriginOffset", "origin", "ray", "rayAngle", "templateConversion", "createSeekTemplate", "type", "token", "distance", "checkScene", "createTemplate", "__name", "createDarknessTemplate", "conceal", "DARKNESS_COLOR", "createMistTemplate", "MIST_COLOR", "getTemplates", "t", "getFlag", "getDarknessTemplates", "getMistTemplates", "getSeekTemplateTokens", "template", "tokenDoc", "getTemplateTokens", "deleteSeekTemplate", "templates", "localize", "traits", "fillColor", "width", "flags", "templateType", "templateData", "MODULE_ID", "collisionOrigin", "collisionType", "templateObj", "grid", "dimensions", "gridHighlight", "origin", "tokens", "containedTokens", "tokenPositions", "h", "w", "position", "gx", "gy", "s", "destination", "highlightTemplateGrid", "isCircleOrCone", "hasSquareGrid", "highlightGrid", "tupleHasValue", "preCreateMeasuredTemplate", "slug", "castLevel", "DARKNESS_SLUGS", "MIST_SLUGS", "POISON_GREEN", "onMeasuredTemplate", "getPrototype", "obj", "depth", "prototype", "__name", "sortByName", "a", "b", "asNumberOnly", "value", "BaseMenu", "#token", "#resolve", "#selected", "#_currentData", "#hoverTokenListener", "token", "resolve", "selected", "options", "hover", "tokenId", "tokens", "params", "localize", "MODULE_ID", "win", "x", "original", "current", "property", "defaultValue", "defaultValues", "originalValue", "currentValue", "validateTokens", "#currentData", "data", "getTokenData", "id", "COVERS", "value", "VISIBILITIES", "html", "event", "target", "tokenIds", "currentData", "setTokenData", "el", "allies", "enemies", "neutral", "alliance", "opposition", "actorAlliance", "sortByName", "__name", "PerceptionMenu", "BaseMenu", "localize", "templatePath", "options", "selected", "currentData", "originalData", "tokens", "getValidTokens", "id", "name", "actor", "current", "original", "html", "event", "section", "allSelected", "t", "__name", "RECT_SPREAD", "getRectEdges", "rect", "margin", "opposite", "getRectPoint", "__name", "lineIntersectWall", "origin", "target", "debug", "drawDebugLine", "pointToTokenIntersectWall", "token", "point", "rectSpread", "clearDebug", "color", "hex", "getLightExposure", "token", "debug", "scene", "clearDebug", "center", "exposure", "light", "bright", "dim", "drawDebugLine", "__name", "DATA", "SELECTORS", "setupRuleElement", "rollOptionSchema", "PredicateField", "ResolvableValueField", "PF2ePerceptionRuleElement", "source", "options", "selectorType", "selector", "selectorWarn", "__name", "msg", "name", "uuid", "targetsType", "joinedTargets", "t", "joinedValues", "sourcevalueType", "fields", "rollOptions", "password", "affects", "perception", "root", "verificator", "targets", "target", "path", "value", "perceptionRules", "origin", "distance", "extraOptions", "originActor", "targetActor", "rules", "r", "selfOptions", "otherOptions", "distances", "prefix", "testOptions", "rule", "getIgnoredPerception", "token", "actor", "getPerception", "type", "cursor", "updateFromPerceptionRules", "list", "COVERS", "VISIBILITIES", "setValue", "index", "renderTokenHUD", "hud", "html", "hasPermission", "event", "openHUD", "__name", "token", "PerceptionMenu", "pasteToken", "originals", "sources", "source", "MODULE_ID", "getTokenData", "path", "getFlag", "clearTokenData", "unsetFlag", "setTokenData", "data", "valid", "getValidTokens", "t", "updates", "tokenId", "current", "original", "defaultValues", "property", "getWallCover", "origin", "target", "debug", "scene", "getSceneSetting", "clearDebug", "getSetting", "pointToTokenIntersectWall", "lineIntersectWall", "SIZES", "getCover", "perception", "options", "affects", "prone", "isProne", "returnValue", "value", "updateFromPerceptionRules", "systemCover", "getCoverEffect", "COVER_VALUES", "cover", "api", "custom", "wallCover", "customCover", "COVERS", "creatureCover", "getCreatureCover", "originToken", "targetToken", "setting", "ignoreIds", "originIds", "targetIds", "originActor", "targetActor", "drawDebugLine", "isExtraLarge", "size", "originSize", "targetSize", "originAlliance", "deadCover", "proneCover", "tokens", "actor", "ignored", "getIgnoredPerception", "a", "b", "extralarges", "margin", "intersectsEdge", "edge", "intersectsWith", "edges", "tokenDocument", "getRectEdges", "getVisibility", "systemVisibility", "visibility", "condition", "VISIBILITY_VALUES", "isInvisible", "seeInvisibility", "getPerception", "mergedVisibility", "targetLowlight", "targetDarkvision", "targetGreaterDarkvision", "hasGreaterDarkvision", "inDarkness", "darknessTemplates", "getDarknessTemplates", "darknessVisibility", "template", "darknessTokens", "getTemplateTokens", "mistTemplates", "getMistTemplates", "mistTokens", "exposure", "getLightExposure", "exposedVisibility", "updateToken", "context", "userId", "flags", "hk", "refreshed", "hoverToken", "hovered", "showAllConditionals", "clearConditionals", "deleteToken", "controlToken", "controlled", "showConditionals", "scale", "coords", "iconSize", "style", "content", "savedPaths", "icon", "ICONS_PATHS", "rulesBasedVision", "preCreateToken", "targets", "ValidationMenu", "BaseMenu", "params", "options", "validated", "validateMessage", "localize", "templatePath", "selected", "token", "alliance", "getValidTokens", "t", "converted", "data", "property", "scene", "defaultValue", "defaultValues", "propertyList", "COVERS", "VISIBILITIES", "tokenId", "fullProperty", "currentValue", "processedValue", "covers", "visibilities", "i18n", "currentData", "originalData", "tokens", "id", "name", "actor", "current", "original", "validation", "getSetting", "html", "event", "__name", "CoverValidationMenu", "#value", "VisibilityValidationMenu", "#roll", "HideValidationMenu", "value", "roll", "dc", "visibility", "VISIBILITY_VALUES", "success", "DegreeOfSuccess", "CreateADiversionMenu", "UnHideValidationMenu", "PointOutValidationMenu", "#originator", "originatorId", "getTokenData", "ReverseVisibilityValidationMenu", "thisId", "tokenData", "parentData", "updates", "update", "MODULE_ID", "SeekValidationMenu", "#fromTemplate", "deleteSeekTemplate", "renderChatMessage", "message", "html", "token", "isGM", "hasPlayerOwner", "cover", "selected", "skipWait", "validated", "pointOut", "getFlags", "pf2eContext", "button", "createValidateButton", "CoverValidationMenu", "hint", "createWaitHint", "flavor", "msg", "localize", "createHint", "type", "createChatButton", "setFlag", "HideValidationMenu", "CreateADiversionMenu", "addBlindSkillCheckFlavor", "addSkillCheckFlavor", "buttons", "createValidateCombo", "SeekValidationMenu", "deleteSeekTemplate", "selectedToken", "PointOutValidationMenu", "t", "attackCheckRoll", "event", "UnHideValidationMenu", "__name", "validateMessage", "getFlag", "smallIcon", "smallAction", "smallSlashed", "actionTitle", "action", "modifier", "skillName", "check", "getActionName", "title", "property", "label", "icon", "tooltip", "slashed", "createTokenMessage", "content", "flags", "secret", "data", "MODULE_ID", "setupActions", "hide", "BaseAction", "getPrototype", "BaseActionVariant", "SingleCheckAction", "SingleCheckActionVariant", "setupCover", "setupHide", "setupCreateADiversion", "setupSneak", "setupSeek", "setupPointOut", "__name", "PointOutVariant", "options", "action", "localize", "token", "getSelectedToken", "pointOut", "PointOut", "MODULE_ID", "data", "name", "traits", "target", "t", "visibility", "getTokenData", "isVisible", "VISIBILITY_VALUES", "description", "dc", "content", "templatePath", "slug", "flags", "createTokenMessage", "SeekVariant", "getActionName", "getSetting", "seek", "deleteSeekTemplate", "Seek", "unit", "createButton", "html", "event", "createSeekTemplate", "SneakVariant", "Sneak", "CreateADiversionVariant", "CreateADiversion", "HideVariant", "Hide", "TakeCoverVariant", "takeCover", "TakeCover", "actor", "cover", "getCoverEffect", "targets", "validateTokens", "covers", "tokenId", "id", "isProne", "dialog", "level", "skip", "process", "isSelected", "selected", "flavor", "defaultValues", "clearTokenData", "setTokenData", "source", "createCoverSource", "tokens", "actors", "getActorToken", "icon", "label", "API", "clearDebug", "getRectEdges", "lineIntersectWall", "pointToTokenIntersectWall", "getCreatureCover", "getWallCover", "getVisibility", "clearConditionals", "showConditionals", "showAllConditionals", "getTokenData", "getCover", "openHUD", "getLightExposure", "isProne", "getCoverEffect", "seeInvisibility", "hasGreaterDarkvision", "getValidTokens", "validateTokens", "getSceneSetting", "createSeekTemplate", "createDarknessTemplate", "createMistTemplate", "getDarknessTemplates", "getMistTemplates", "getSeekTemplateTokens", "deleteSeekTemplate", "getTemplateTokens", "perceptionRules", "getPerception", "updateFromPerceptionRules", "checkRoll", "wrapped", "args", "context", "actor", "createMessage", "type", "token", "target", "isReroll", "originToken", "getActorToken", "targetToken", "isAttackRoll", "attackCheckRoll", "flatCheck", "getSetting", "validCheckRoll", "event", "perception", "perceptionRules", "o", "visibility", "getVisibility", "dc", "getPerception", "numberedDC", "asNumberOnly", "sign", "isUndetected", "VISIBILITY_VALUES", "isBlind", "isSuccess", "highlighted", "getSeekTemplateTokens", "tokens", "selected", "validateTokens", "t", "__name", "renderCheckModifiersDialog", "dialog", "html", "options", "targetActor", "coverEffect", "getCoverEffect", "currentCover", "findChoiceSetRule", "getFlag", "coverOverride", "MODULE_ID", "template", "localize", "covers", "isProne", "COVERS", "slug", "label", "value", "modified", "items", "coverIndex", "i", "COVER_UUID", "source", "createCoverSource", "statistic", "renderCombatTracker", "tracker", "html", "getSetting", "setupToggleTarget", "__name", "setupToggleTarget", "html", "_", "el", "event", "combatantId", "token", "isTargeted", "t", "__name", "renderCombatTrackerConfig", "config", "checked", "getSetting", "localize", "setSetting", "detectionModeTestVisibility", "visionSource", "mode", "config", "test", "__name", "basicSightCanDetect", "target", "origin", "originDocument", "reachesThreshold", "VISIBILITY_VALUES", "hearingCanDetect", "feelTremorCanDetect", "threshold", "perception", "perceptionRules", "getVisibility", "purry", "fn", "args", "lazy", "diff", "arrayArgs", "ret", "__name", "data", "_reduceLazy", "array", "indexed", "newArray", "index", "item", "result", "uniqLazy", "set", "value", "_uniq", "R", "arr", "PredicatePF2e", "statements", "s", "StatementValidator", "predicate", "options", "domain", "#isTrue", "statement", "#testBinaryOp", "#testCompound", "operator", "left", "right", "domainArray", "getValues", "__name", "operand", "maybeNumber", "pattern", "values", "v", "leftValues", "rightValues", "l", "r", "subProp", "_binaryOperators", "isObject", "entries", "operands", "__privateGet", "__privateAdd", "WEAPON_PROPERTY_RUNES", "options", "PredicatePF2e", "current", "_weapon", "traits", "weapon", "sourceRange", "preparedRange", "getPropertyRuneStrikeAdjustments", "runes", "r", "__name", "getRollContext", "params", "selfToken", "targetToken", "t", "isAttackAction", "d", "isMelee", "reach", "isFlankingAttack", "originEphemeralEffects", "extractEphemeralEffects", "targetMarkOption", "tokenMark", "initialActionOptions", "selfActor", "R", "isStrike", "strikeActions", "a", "statistic", "action", "selfItem", "itemClone", "itemOptions", "actionTraits", "traits", "strikeAdjustments", "getPropertyRuneStrikeAdjustments", "adjustment", "distance", "originDistance", "targetDistance", "originMarkOption", "originRollOptions", "getTargetRollOptions", "__name", "actor", "targetOptions", "targetRollOptions", "targetEphemeralEffects", "perception", "perceptionRules", "visibility", "getVisibility", "getPerception", "VISIBILITY_VALUES", "createFlatFootedSource", "cover", "getCover", "coverBonus", "ac", "asNumberOnly", "COVER_VALUES", "createCoverSource", "isOffGuardFromFlanking", "name", "condition", "targetActor", "rollOptions", "rangeIncrement", "getRangeIncrement", "self", "target", "ICONS", "IconPathMenu", "templatePath", "localize", "saved", "getSetting", "name", "ICONS_PATHS", "html", "event", "formData", "setSetting", "__name", "registerSettings", "register", "MODULE_ID", "path", "IconPathMenu", "__name", "setting", "key", "name", "type", "defValue", "extra", "CHECK_ROLL", "RULES_BASED_VISION", "HIGHLIGHT_TEMPLATE_GRID", "GET_ROLL_CONTEXT", "DETECTION_MODE_TEST_VISIBILITY", "BASIC_SIGHT_CAN_DETECT", "HEARING_CAN_DETECT", "FEEL_TREMOR_CAN_DETECT", "registerSettings", "setupActions", "setupRuleElement", "MODULE_ID", "checkRoll", "highlightTemplateGrid", "rulesBasedVision", "getRollContext", "detectionModeTestVisibility", "basicSightCanDetect", "hearingCanDetect", "feelTremorCanDetect", "x", "renderSceneConfig", "renderCombatTrackerConfig", "renderCombatTracker", "API", "renderChatMessage", "el", "message", "hoverToken", "pasteToken", "updateToken", "deleteToken", "controlToken", "renderTokenHUD", "preCreateToken", "clearConditionals", "renderCheckModifiersDialog", "preCreateMeasuredTemplate", "onMeasuredTemplate"] }