mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-04-21 23:13:39 +02:00
Completed functionality
This commit is contained in:
parent
5e608dea99
commit
f6aa3dc750
8 changed files with 68 additions and 14 deletions
28
module/documents/regionBehavior.mjs
Normal file
28
module/documents/regionBehavior.mjs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
export default class DhRegionBehavior extends RegionBehavior {
|
||||
/**@inheritDoc */
|
||||
async _handleRegionEvent(event) {
|
||||
if (!(this.system instanceof foundry.data.regionBehaviors.RegionBehaviorType)) return;
|
||||
|
||||
// Optionally prevent event if not applicable
|
||||
// Currently only caring about statically registered events
|
||||
if (event.name in this.system.constructor.events) {
|
||||
if (this.isEventApplicable(event) === false) return;
|
||||
super._handleRegionEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
isEventApplicable(event) {
|
||||
switch(this.type) {
|
||||
case 'applyActiveEffect':
|
||||
/* If reworked to an area, we'll probably still have to override the onEnter/onExit methods to filter which effects apply */
|
||||
const effects = this.system.effects.map(effect => foundry.utils.fromUuidSync(effect)).filter(x => x);
|
||||
const applicableDispositions = effects.first().system.area?.targetDispositions??[];
|
||||
if(!applicableDispositions.size) return true;
|
||||
|
||||
return event.data.token.disposition === CONST.TOKEN_DISPOSITIONS.SECRET ||
|
||||
applicableDispositions.has(event.data.token.disposition);
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue