feat: add functionality to apply Active Affects to owned Items

In the Active Effect Config, there are now additional inputs to configure the effect
to be applied to items owned by the actor instead of the actor itself. It is possible
to select the items to which to apply the effect via matching by name, or via a condition
expression, that provides similar capabilities as the evaluation of mathematical
expressions in rolls. Data from the Actor, Item, and Active Effect can be accessed
similar to how properties are accessed in roll formulas (using the prefixes `@actor`,
`@item`, and `@effect`). For example, in order to apply an effect to all ranged
weapons, the conditions would be
```js
'@item.type' === 'weapon' && '@item.data.attackType' === 'ranged'
```
This commit is contained in:
Johannes Loher 2022-08-25 03:31:30 +02:00
parent 27b6506847
commit b1ed05a796
14 changed files with 414 additions and 42 deletions

View file

@ -0,0 +1,178 @@
{{!--
SPDX-FileCopyrightText: 2022 Johannes Loher
SPDX-License-Identifier: MIT
--}}
<form autocomplete="off">
<!-- Effect Header -->
<header class="sheet-header">
<img class="effect-icon" src="{{ data.icon }}" data-edit="icon">
<h1 class="effect-title">{{ data.label }}</h1>
</header>
<!-- Effect Configuration Tabs -->
<nav class="sheet-tabs tabs">
<a class="item" data-tab="details"><i class="fas fa-book"></i> {{localize "EFFECT.TabDetails"}}</a>
<a class="item" data-tab="duration"><i class="fas fa-clock"></i> {{localize "EFFECT.TabDuration"}}</a>
<a class="item" data-tab="effects"><i class="fas fa-cogs"></i> {{localize "EFFECT.TabEffects"}}</a>
</nav>
<!-- Details Tab -->
<section class="tab" data-tab="details">
<div class="form-group">
<label>{{ localize "EFFECT.Label" }}</label>
<div class="form-fields">
<input type="text" name="label" value="{{ data.label }}" />
</div>
</div>
<div class="form-group">
<label>{{ localize "EFFECT.Icon" }}</label>
<div class="form-fields">
{{filePicker target="icon" type="image"}}
<input class="image" type="text" name="icon" placeholder="path/image.png" value="{{data.icon}}" />
</div>
</div>
<div class="form-group">
<label>{{ localize "EFFECT.IconTint" }}</label>
<div class="form-fields">
<input class="color" type="text" name="tint" value="{{data.tint}}" />
<input type="color" value="{{data.tint}}" data-edit="tint" />
</div>
</div>
<div class="form-group">
<label>{{ localize "EFFECT.Disabled" }}</label>
<div class="form-fields">
<input type="checkbox" name="disabled" {{ checked data.disabled }} />
</div>
</div>
{{#if isActorEffect}}
<div class="form-group">
<label>{{ localize "EFFECT.Origin" }}</label>
<div class="form-fields">
<input type="text" name="origin" value="{{ data.origin }}" disabled />
</div>
</div>
{{/if}}
{{#if isItemEffect}}
<div class="form-group">
<label>{{ localize "EFFECT.Transfer" }}</label>
<div class="form-fields">
<input type="checkbox" name="transfer" {{checked data.transfer}} />
</div>
</div>
{{/if}}
<div class="form-group">
<label>{{ localize "DS4.ActiveEffectApplyToItems" }}</label>
<div class="form-fields">
<input type="checkbox" name="flags.ds4.itemEffectConfig.applyToItems" {{checked
data.flags.ds4.itemEffectConfig.applyToItems}} />
</div>
</div>
<div
class="form-group ds4-item-effect-config{{#unless data.flags.ds4.itemEffectConfig.applyToItems}} ds4-hidden{{/unless}}">
<label>{{ localize "DS4.ActiveEffectItemName" }}</label>
<div class="form-fields">
<input type="text" name="flags.ds4.itemEffectConfig.itemName"
value="{{ data.flags.ds4.itemEffectConfig.itemName }}" />
</div>
</div>
<div
class="form-group ds4-item-effect-config{{#unless data.flags.ds4.itemEffectConfig.applyToItems}} ds4-hidden{{/unless}}">
<label>{{ localize "DS4.ActiveEffectItemCondition" }}</label>
<div class="form-fields">
<input class="ds4-code-input" type="text" name="flags.ds4.itemEffectConfig.condition"
value="{{ data.flags.ds4.itemEffectConfig.condition }}" />
</div>
</div>
</section>
<!-- Duration Tab -->
<section class="tab" data-tab="duration">
<div class="form-group">
<label>{{ localize "EFFECT.DurationSecs" }}</label>
<div class="form-fields">
<input type="number" name="duration.seconds" value="{{ data.duration.seconds }}" />
</div>
</div>
<div class="form-group">
<label>{{ localize "EFFECT.StartTime" }}</label>
<div class="form-fields">
<input type="number" name="duration.startTime" value="{{ data.duration.startTime }}" />
</div>
</div>
<hr />
<div class="form-group">
<label>{{ localize "EFFECT.DurationTurns" }}</label>
<div class="form-fields">
<label>{{ localize "COMBAT.Rounds" }}</label>
<input type="number" name="duration.rounds" value="{{ data.duration.rounds }}" />
<label>{{ localize "COMBAT.Turns" }}</label>
<input type="number" name="duration.turns" value="{{ data.duration.turns }}" />
</div>
</div>
<div class="form-group">
<label>{{ localize "EFFECT.Combat" }}</label>
<div class="form-fields">
<input type="text" name="duration.combat" value="{{ data.duration.combat }}" disabled />
</div>
</div>
<div class="form-group">
<label>{{ localize "EFFECT.StartTurns" }}</label>
<div class="form-fields">
<label>{{ localize "COMBAT.Round" }}</label>
<input type="number" name="duration.startRound" value="{{ data.duration.startRound }}" />
<label>{{ localize "COMBAT.Turn" }}</label>
<input type="number" name="duration.startTurn" value="{{ data.duration.startTurn }}" />
</div>
</div>
</section>
<!-- Effects Tab -->
<section class="tab" data-tab="effects">
<header class="effect-change effects-header flexrow">
<div class="key">{{ localize "EFFECT.ChangeKey" }}</div>
<div class="mode">{{ localize "EFFECT.ChangeMode" }}</div>
<div class="value">{{ localize "EFFECT.ChangeValue" }}</div>
<div class="effect-controls">
<a class="effect-control" data-action="add"><i class="far fa-plus-square"></i></a>
</div>
</header>
<ol class="changes-list">
{{#each data.changes as |change i|}}
<li class="effect-change flexrow" data-index="{{i}}">
<div class="key">
<input type="text" name="changes.{{i}}.key" value="{{change.key}}" />
</div>
<div class="mode">
<select name="changes.{{i}}.mode" data-dtype="Number">
{{selectOptions ../modes selected=change.mode}}
</select>
</div>
<div class="value">
<input type="text" name="changes.{{i}}.value" value="{{change.value}}" />
</div>
<div class="effect-controls">
<a class="effect-control" data-action="delete"><i class="fas fa-trash"></i></a>
</div>
</li>
{{/each}}
</ol>
</section>
<footer class="sheet-footer">
<button type="submit"><i class="fas fa-save"></i> {{localize submitText}}</button>
</footer>
</form>