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
|
|
@ -3,6 +3,7 @@ import * as applications from './module/applications/_module.mjs';
|
|||
import * as data from './module/data/_module.mjs';
|
||||
import * as models from './module/data/_module.mjs';
|
||||
import * as documents from './module/documents/_module.mjs';
|
||||
import * as regionBehaviors from './module/data/regionBehavior/_module.mjs';
|
||||
import { macros } from './module/_module.mjs';
|
||||
import * as collections from './module/documents/collections/_module.mjs';
|
||||
import * as dice from './module/dice/_module.mjs';
|
||||
|
|
@ -45,6 +46,8 @@ CONFIG.ActiveEffect.documentClass = documents.DhActiveEffect;
|
|||
CONFIG.ActiveEffect.dataModels = models.activeEffects.config;
|
||||
CONFIG.ActiveEffect.changeTypes = { ...CONFIG.ActiveEffect.changeTypes, ...models.activeEffects.changeEffects };
|
||||
|
||||
CONFIG.RegionBehavior.documentClass = documents.DhRegionBehavior;
|
||||
|
||||
CONFIG.Combat.documentClass = documents.DhpCombat;
|
||||
CONFIG.Combat.dataModels = { base: models.DhCombat };
|
||||
CONFIG.Combatant.documentClass = documents.DHCombatant;
|
||||
|
|
|
|||
|
|
@ -1103,3 +1103,9 @@ export const fallAndCollisionDamage = {
|
|||
damageFormula: '1d20 + 5'
|
||||
}
|
||||
};
|
||||
|
||||
export const simpleDispositions = {
|
||||
HOSTILE: -1,
|
||||
NEUTRAL: 0,
|
||||
FRIENDLY: 1
|
||||
};
|
||||
|
|
@ -112,6 +112,9 @@ export default class BaseEffect extends foundry.data.ActiveEffectTypeDataModel {
|
|||
initial: CONFIG.DH.GENERAL.range.veryClose.id,
|
||||
label: 'DAGGERHEART.ACTIVEEFFECT.Config.area.size'
|
||||
}),
|
||||
targetDispositions: new fields.SetField(new fields.NumberField({
|
||||
|
||||
})),
|
||||
}, { nullable: true, initial: null })
|
||||
};
|
||||
}
|
||||
|
|
|
|||
1
module/data/regionBehavior/_module.mjs
Normal file
1
module/data/regionBehavior/_module.mjs
Normal file
|
|
@ -0,0 +1 @@
|
|||
export { default as applyActiveEffect } from './applyActiveEffect.mjs';
|
||||
14
module/data/regionBehavior/applyActiveEffect.mjs
Normal file
14
module/data/regionBehavior/applyActiveEffect.mjs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
export default class DhApplyActiveEffect extends CONFIG.RegionBehavior.dataModels.applyActiveEffect {
|
||||
static #tokenDispositionChecker = (eventFunction) => (event) => {
|
||||
const { token } = event.data;
|
||||
if (token.disposition === -1) {
|
||||
eventFunction.bind(this)(event);
|
||||
}
|
||||
}
|
||||
|
||||
/** @override */
|
||||
static events = Object.entries(super.events).reduce((acc, [key, func]) => {
|
||||
acc[key] = DhApplyActiveEffect.#tokenDispositionChecker(func);
|
||||
return acc;
|
||||
}, {});
|
||||
}
|
||||
|
|
@ -9,3 +9,4 @@ export { default as DhScene } from './scene.mjs';
|
|||
export { default as DhToken } from './token.mjs';
|
||||
export { default as DhTooltipManager } from './tooltipManager.mjs';
|
||||
export { default as DhTokenManager } from './tokenManager.mjs';
|
||||
export { default as DhRegionBehavior } from './regionBehavior.mjs';
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -55,7 +55,6 @@
|
|||
</legend>
|
||||
|
||||
{{#if document.system.area}}
|
||||
|
||||
{{formGroup systemFields.area.fields.type value=source.system.area.type localize=true blank=false }}
|
||||
{{formGroup systemFields.area.fields.shape value=source.system.area.shape localize=true blank=false }}
|
||||
<div class="form-group">
|
||||
|
|
@ -69,7 +68,6 @@
|
|||
<input type="checkbox" class="area-range-type-input" {{checked areaDaggerheartRange}} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{/if}}
|
||||
</fieldset>
|
||||
</section>
|
||||
Loading…
Add table
Add a link
Reference in a new issue