mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
f
This commit is contained in:
parent
c6741b1c7a
commit
7cbe4b7580
4 changed files with 83 additions and 24 deletions
|
|
@ -33,7 +33,9 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
|
||||
"EFFECT": {
|
||||
"ChangeFilter": "Filter"
|
||||
},
|
||||
"DAGGERHEART": {
|
||||
"ACTIONS": {
|
||||
"TYPES": {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,11 @@ export default class BaseEffect extends foundry.abstract.TypeDataModel {
|
|||
const fields = foundry.data.fields;
|
||||
|
||||
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})
|
||||
}),
|
||||
rangeDependence: new fields.SchemaField({
|
||||
enabled: new fields.BooleanField({
|
||||
required: true,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,19 @@
|
|||
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 */
|
||||
/* -------------------------------------------- */
|
||||
|
|
@ -86,6 +99,14 @@ export default class DhActiveEffect extends foundry.documents.ActiveEffect {
|
|||
super.applyField(model, change, field);
|
||||
}
|
||||
|
||||
/**@inheritdoc*/
|
||||
apply(actor, change) {
|
||||
if(!this.verifyConditional(actor)) return {};
|
||||
// const changes = super.apply(actor, change);
|
||||
// console.log(actor, change, changes);
|
||||
return super.apply(actor, change);
|
||||
}
|
||||
|
||||
/**
|
||||
* Altered Foundry safeEval to allow non-numeric return
|
||||
* @param {string} expression
|
||||
|
|
@ -104,6 +125,13 @@ 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;
|
||||
return foundry.applications.ux.SearchFilter.evaluateFilter(actor, this.system.conditional);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a list of localized tags based on this item's type-specific properties.
|
||||
* @returns {string[]} An array of localized tag strings.
|
||||
|
|
|
|||
|
|
@ -1,31 +1,55 @@
|
|||
<section class="tab changes{{#if tab.active}} active{{/if}}" data-group="{{tab.group}}" data-tab="{{tab.id}}">
|
||||
<header>
|
||||
<div class="key">{{localize "EFFECT.ChangeKey"}}</div>
|
||||
<div class="mode">{{localize "EFFECT.ChangeMode"}}</div>
|
||||
<div class="value">{{localize "EFFECT.ChangeValue"}}</div>
|
||||
<div class="priority">{{localize "EFFECT.ChangePriority"}}</div>
|
||||
<div class="controls"><a data-action="addChange"><i class="fa-regular fa-square-plus"></i></a></div>
|
||||
</header>
|
||||
<ol class="scrollable" data-changes>
|
||||
{{#each source.changes as |change i|}}
|
||||
{{#with ../fields.changes.element.fields as |changeFields|}}
|
||||
<li data-index="{{i}}">
|
||||
{{!-- <fieldset>
|
||||
<legend>Conditional</legend>
|
||||
<header>
|
||||
<div class="key">{{localize "EFFECT.ChangeKey"}}</div>
|
||||
<div class="filter">{{localize "EFFECT.ChangeFilter"}}</div>
|
||||
<div class="value">{{localize "EFFECT.ChangeValue"}}</div>
|
||||
</header>
|
||||
<ol>{{log @root}}{{log this}}
|
||||
<li>
|
||||
<div class="key">
|
||||
<input type="text" class="effect-change-input" name="{{concat "changes." i ".key"}}" value="{{change.key}}" />
|
||||
{{formInput document.system.schema.fields.conditional.fields.key value=source.system.conditional.key localize=true }}
|
||||
</div>
|
||||
<div class="mode">
|
||||
{{formInput changeFields.mode name=(concat "changes." i ".mode") value=change.mode choices=@root.modes}}
|
||||
<div class="filter">
|
||||
{{formInput document.system.schema.fields.conditional.fields.filter value=source.system.conditional.filter localize=true }}
|
||||
</div>
|
||||
<div class="value">
|
||||
{{formInput changeFields.value name=(concat "changes." i ".value") value=change.value}}
|
||||
{{formInput document.system.schema.fields.conditional.fields.value value=source.system.conditional.value localize=true }}
|
||||
</div>
|
||||
<div class="priority">
|
||||
{{formInput changeFields.priority name=(concat "changes." i ".priority") value=change.priority
|
||||
placeholder=(lookup ../../priorities change.mode)}}
|
||||
</div>
|
||||
<div class="controls"><a data-action="deleteChange"><i class="fa-solid fa-trash"></i></a></div>
|
||||
</li>
|
||||
{{/with}}
|
||||
{{/each}}
|
||||
</ol>
|
||||
</ol>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>Effects</legend> --}}
|
||||
<header>
|
||||
<div class="key">{{localize "EFFECT.ChangeKey"}}</div>
|
||||
<div class="mode">{{localize "EFFECT.ChangeMode"}}</div>
|
||||
<div class="value">{{localize "EFFECT.ChangeValue"}}</div>
|
||||
<div class="priority">{{localize "EFFECT.ChangePriority"}}</div>
|
||||
<div class="controls"><a data-action="addChange"><i class="fa-regular fa-square-plus"></i></a></div>
|
||||
</header>
|
||||
<ol class="scrollable" data-changes>
|
||||
{{#each source.changes as |change i|}}
|
||||
{{#with ../fields.changes.element.fields as |changeFields|}}
|
||||
<li data-index="{{i}}">
|
||||
<div class="key">
|
||||
<input type="text" class="effect-change-input" name="{{concat "changes." i ".key"}}" value="{{change.key}}" />
|
||||
</div>
|
||||
<div class="mode">
|
||||
{{formInput changeFields.mode name=(concat "changes." i ".mode") value=change.mode choices=@root.modes}}
|
||||
</div>
|
||||
<div class="value">
|
||||
{{formInput changeFields.value name=(concat "changes." i ".value") value=change.value}}
|
||||
</div>
|
||||
<div class="priority">
|
||||
{{formInput changeFields.priority name=(concat "changes." i ".priority") value=change.priority
|
||||
placeholder=(lookup ../../priorities change.mode)}}
|
||||
</div>
|
||||
<div class="controls"><a data-action="deleteChange"><i class="fa-solid fa-trash"></i></a></div>
|
||||
</li>
|
||||
{{/with}}
|
||||
{{/each}}
|
||||
</ol>
|
||||
{{!-- </fieldset> --}}
|
||||
</section>
|
||||
Loading…
Add table
Add a link
Reference in a new issue