mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
j
This commit is contained in:
parent
7cbe4b7580
commit
4bdafeff6d
10 changed files with 89 additions and 36 deletions
|
|
@ -11,7 +11,7 @@ export default class DhTokenPlaceable extends foundry.canvas.placeables.Token {
|
|||
|
||||
// Categorize effects
|
||||
const statusMap = new Map(foundry.CONFIG.statusEffects.map(status => [status.id, status]));
|
||||
const activeEffects = (this.actor ? this.actor.effects.filter(x => !x.disabled) : []).reduce((acc, effect) => {
|
||||
const activeEffects = (this.actor ? this.actor.effects.filter(x => !x.disabled && x.verifyCondition(this.actor)) : []).reduce((acc, effect) => {
|
||||
acc.push(effect);
|
||||
|
||||
const currentStatusActiveEffects = acc.filter(
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { range } from '../config/generalConfig.mjs';
|
||||
import { capitalize } from '../helpers/utils.mjs';
|
||||
|
||||
export const valueTypes = {
|
||||
numberString: {
|
||||
|
|
@ -62,3 +63,9 @@ export const effectTypes = {
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const conditionalTypes = () => {
|
||||
const operators = {};
|
||||
Object.entries(foundry.applications.ux.SearchFilter.OPERATORS).forEach(([key, value]) => operators[value] = key.replaceAll('_', ' ').toLowerCase().capitalize());
|
||||
return operators;
|
||||
}
|
||||
|
|
@ -5,8 +5,9 @@ export default class BaseEffect extends foundry.abstract.TypeDataModel {
|
|||
return {
|
||||
conditional: new fields.SchemaField({
|
||||
field: new fields.StringField({required: true, nullable: true}),
|
||||
operator: new fields.StringField({required: true, choices: foundry.applications.ux.SearchFilter.OPERATORS, initial: 'EQUALS'}),
|
||||
value: new fields.StringField({required: true})
|
||||
operator: new fields.StringField({required: true, choices: CONFIG.DH.EFFECTS.conditionalTypes(), initial: 'equals'}),
|
||||
value: new fields.StringField({required: true}),
|
||||
negate: new fields.BooleanField({initial: false})
|
||||
}),
|
||||
rangeDependence: new fields.SchemaField({
|
||||
enabled: new fields.BooleanField({
|
||||
|
|
|
|||
|
|
@ -2,18 +2,6 @@ import { itemAbleRollParse } from '../helpers/utils.mjs';
|
|||
|
||||
export default class DhActiveEffect extends foundry.documents.ActiveEffect {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/** @inheritdoc */
|
||||
// static defineSchema() {
|
||||
// const fields = foundry.data.fields;
|
||||
|
||||
// return {
|
||||
// ...super.defineSchema(),
|
||||
// test: new fields.StringField()
|
||||
// }
|
||||
// }
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/* Properties */
|
||||
/* -------------------------------------------- */
|
||||
|
|
@ -101,9 +89,7 @@ export default class DhActiveEffect extends foundry.documents.ActiveEffect {
|
|||
|
||||
/**@inheritdoc*/
|
||||
apply(actor, change) {
|
||||
if(!this.verifyConditional(actor)) return {};
|
||||
// const changes = super.apply(actor, change);
|
||||
// console.log(actor, change, changes);
|
||||
if(!this.verifyCondition(actor)) return {};
|
||||
return super.apply(actor, change);
|
||||
}
|
||||
|
||||
|
|
@ -125,10 +111,8 @@ export default class DhActiveEffect extends foundry.documents.ActiveEffect {
|
|||
return result;
|
||||
}
|
||||
|
||||
verifyConditional(actor) {
|
||||
if(!this.system.conditional.key) return true;
|
||||
// const prop = foundry.utils.getProperty(actor, this.system.conditional.key);
|
||||
// if(prop === undefined) return false;
|
||||
verifyCondition(actor) {
|
||||
if(!this.system.conditional?.field) return true;
|
||||
return foundry.applications.ux.SearchFilter.evaluateFilter(actor, this.system.conditional);
|
||||
}
|
||||
|
||||
|
|
@ -143,6 +127,9 @@ export default class DhActiveEffect extends foundry.documents.ActiveEffect {
|
|||
this.isTemporary ? 'DAGGERHEART.EFFECTS.Duration.temporary' : 'DAGGERHEART.EFFECTS.Duration.passive'
|
||||
)
|
||||
];
|
||||
|
||||
if(this.target instanceof CONFIG.Actor.documentClass && !this.verifyCondition(this.target))
|
||||
tags.push(`<i>${game.i18n.localize('DAGGERHEART.GENERAL.conditional.notMet')}</i>`);
|
||||
|
||||
for (const statusId of this.statuses) {
|
||||
const status = CONFIG.statusEffects.find(s => s.id === statusId);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue