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": {
|
"DAGGERHEART": {
|
||||||
"ACTIONS": {
|
"ACTIONS": {
|
||||||
"TYPES": {
|
"TYPES": {
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,11 @@ export default class BaseEffect extends foundry.abstract.TypeDataModel {
|
||||||
const fields = foundry.data.fields;
|
const fields = foundry.data.fields;
|
||||||
|
|
||||||
return {
|
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({
|
rangeDependence: new fields.SchemaField({
|
||||||
enabled: new fields.BooleanField({
|
enabled: new fields.BooleanField({
|
||||||
required: true,
|
required: true,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,19 @@
|
||||||
import { itemAbleRollParse } from '../helpers/utils.mjs';
|
import { itemAbleRollParse } from '../helpers/utils.mjs';
|
||||||
|
|
||||||
export default class DhActiveEffect extends foundry.documents.ActiveEffect {
|
export default class DhActiveEffect extends foundry.documents.ActiveEffect {
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
|
||||||
|
/** @inheritdoc */
|
||||||
|
// static defineSchema() {
|
||||||
|
// const fields = foundry.data.fields;
|
||||||
|
|
||||||
|
// return {
|
||||||
|
// ...super.defineSchema(),
|
||||||
|
// test: new fields.StringField()
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
/* Properties */
|
/* Properties */
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
|
@ -85,6 +98,14 @@ export default class DhActiveEffect extends foundry.documents.ActiveEffect {
|
||||||
change.value = evalValue ?? change.value;
|
change.value = evalValue ?? change.value;
|
||||||
super.applyField(model, change, field);
|
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
|
* Altered Foundry safeEval to allow non-numeric return
|
||||||
|
|
@ -104,6 +125,13 @@ export default class DhActiveEffect extends foundry.documents.ActiveEffect {
|
||||||
return result;
|
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.
|
* Generates a list of localized tags based on this item's type-specific properties.
|
||||||
* @returns {string[]} An array of localized tag strings.
|
* @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}}">
|
<section class="tab changes{{#if tab.active}} active{{/if}}" data-group="{{tab.group}}" data-tab="{{tab.id}}">
|
||||||
<header>
|
{{!-- <fieldset>
|
||||||
<div class="key">{{localize "EFFECT.ChangeKey"}}</div>
|
<legend>Conditional</legend>
|
||||||
<div class="mode">{{localize "EFFECT.ChangeMode"}}</div>
|
<header>
|
||||||
<div class="value">{{localize "EFFECT.ChangeValue"}}</div>
|
<div class="key">{{localize "EFFECT.ChangeKey"}}</div>
|
||||||
<div class="priority">{{localize "EFFECT.ChangePriority"}}</div>
|
<div class="filter">{{localize "EFFECT.ChangeFilter"}}</div>
|
||||||
<div class="controls"><a data-action="addChange"><i class="fa-regular fa-square-plus"></i></a></div>
|
<div class="value">{{localize "EFFECT.ChangeValue"}}</div>
|
||||||
</header>
|
</header>
|
||||||
<ol class="scrollable" data-changes>
|
<ol>{{log @root}}{{log this}}
|
||||||
{{#each source.changes as |change i|}}
|
<li>
|
||||||
{{#with ../fields.changes.element.fields as |changeFields|}}
|
|
||||||
<li data-index="{{i}}">
|
|
||||||
<div class="key">
|
<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>
|
||||||
<div class="mode">
|
<div class="filter">
|
||||||
{{formInput changeFields.mode name=(concat "changes." i ".mode") value=change.mode choices=@root.modes}}
|
{{formInput document.system.schema.fields.conditional.fields.filter value=source.system.conditional.filter localize=true }}
|
||||||
</div>
|
</div>
|
||||||
<div class="value">
|
<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>
|
||||||
<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>
|
</li>
|
||||||
{{/with}}
|
</ol>
|
||||||
{{/each}}
|
</fieldset>
|
||||||
</ol>
|
<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>
|
</section>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue