mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-11 19:25:21 +01:00
Add multiple conditions handler + update Bare Bones domain card
This commit is contained in:
parent
af3a415e56
commit
4a63836c0d
8 changed files with 213 additions and 38 deletions
11
lang/en.json
11
lang/en.json
|
|
@ -1935,6 +1935,7 @@
|
||||||
},
|
},
|
||||||
"actorName": "Actor Name",
|
"actorName": "Actor Name",
|
||||||
"amount": "Amount",
|
"amount": "Amount",
|
||||||
|
"and": "AND",
|
||||||
"any": "Any",
|
"any": "Any",
|
||||||
"armor": "Armor",
|
"armor": "Armor",
|
||||||
"armors": "Armors",
|
"armors": "Armors",
|
||||||
|
|
@ -1947,9 +1948,12 @@
|
||||||
"bonus": "Bonus",
|
"bonus": "Bonus",
|
||||||
"burden": "Burden",
|
"burden": "Burden",
|
||||||
"conditional": {
|
"conditional": {
|
||||||
"label": "Condition",
|
"label": {
|
||||||
"hint": "(Optionnal) Set a condition that need to be verified to apply effects below.",
|
"single": "Condition",
|
||||||
"notMet": "Condition Not Met"
|
"plural": "Conditions"
|
||||||
|
},
|
||||||
|
"hint": "(Optionnal) Set one or more conditions that need to be verified to apply effects below.",
|
||||||
|
"notMet": "Conditions Not Met"
|
||||||
},
|
},
|
||||||
"continue": "Continue",
|
"continue": "Continue",
|
||||||
"criticalSuccess": "Critical Success",
|
"criticalSuccess": "Critical Success",
|
||||||
|
|
@ -2014,6 +2018,7 @@
|
||||||
"newCategory": "New Category",
|
"newCategory": "New Category",
|
||||||
"none": "None",
|
"none": "None",
|
||||||
"noTarget": "No current target",
|
"noTarget": "No current target",
|
||||||
|
"or": "OR",
|
||||||
"partner": "Partner",
|
"partner": "Partner",
|
||||||
"player": {
|
"player": {
|
||||||
"single": "Player",
|
"single": "Player",
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,12 @@ export default class DhActiveEffectConfig extends foundry.applications.sheets.Ac
|
||||||
}
|
}
|
||||||
|
|
||||||
static DEFAULT_OPTIONS = {
|
static DEFAULT_OPTIONS = {
|
||||||
classes: ['daggerheart', 'sheet', 'dh-style']
|
classes: ['daggerheart', 'sheet', 'dh-style'],
|
||||||
|
actions: {
|
||||||
|
addCondition: DhActiveEffectConfig.#onAddCondition,
|
||||||
|
deleteCondition: DhActiveEffectConfig.#onDeleteCondition,
|
||||||
|
setAndOr: DhActiveEffectConfig.#setAndOr
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static PARTS = {
|
static PARTS = {
|
||||||
|
|
@ -115,4 +120,46 @@ export default class DhActiveEffectConfig extends foundry.applications.sheets.Ac
|
||||||
|
|
||||||
return partContext;
|
return partContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ----------------------------------------- */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a new condition to the effect's conditions array.
|
||||||
|
* @this {DhActiveEffectConfig}
|
||||||
|
* @type {ApplicationClickAction}
|
||||||
|
*/
|
||||||
|
static async #onAddCondition() {
|
||||||
|
const submitData = this._processFormData(null, this.form, new foundry.applications.ux.FormDataExtended(this.form));
|
||||||
|
const conditions = Object.values(submitData.system.conditional?.condition ?? {});
|
||||||
|
conditions.push({});
|
||||||
|
return this.submit({updateData: {'system.conditional.condition': conditions}});
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ----------------------------------------- */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a new condition to the effect's conditions array.
|
||||||
|
* @this {DhActiveEffectConfig}
|
||||||
|
* @type {ApplicationClickAction}
|
||||||
|
*/
|
||||||
|
static async #onDeleteCondition(event) {
|
||||||
|
const submitData = this._processFormData(null, this.form, new FormDataExtended(this.form));
|
||||||
|
const conditions = Object.values(submitData.system.conditional.condition ?? {});
|
||||||
|
const row = event.target.closest("li");
|
||||||
|
const index = Number(row.dataset.index) || 0;
|
||||||
|
conditions.splice(index, 1);
|
||||||
|
return this.submit({updateData: {'system.conditional.condition': conditions}});
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ----------------------------------------- */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a new condition to the effect's conditions array.
|
||||||
|
* @this {DhActiveEffectConfig}
|
||||||
|
* @type {ApplicationClickAction}
|
||||||
|
*/
|
||||||
|
static async #setAndOr(event) {
|
||||||
|
const value = event.target.dataset.value;
|
||||||
|
return this.submit({updateData: {'system.conditional.andOr': value === 'true'}});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,15 @@ export default class BaseEffect extends foundry.abstract.TypeDataModel {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
conditional: new fields.SchemaField({
|
conditional: new fields.SchemaField({
|
||||||
field: new fields.StringField({required: true, nullable: true}),
|
andOr: new fields.BooleanField({ initial: true }),
|
||||||
operator: new fields.StringField({required: true, choices: CONFIG.DH.EFFECTS.conditionalTypes(), initial: 'equals'}),
|
condition: new fields.ArrayField(
|
||||||
value: new fields.StringField({required: true}),
|
new fields.SchemaField({
|
||||||
negate: new fields.BooleanField({initial: false})
|
field: new fields.StringField({required: true, nullable: 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({
|
rangeDependence: new fields.SchemaField({
|
||||||
enabled: new fields.BooleanField({
|
enabled: new fields.BooleanField({
|
||||||
|
|
|
||||||
|
|
@ -112,8 +112,12 @@ export default class DhActiveEffect extends foundry.documents.ActiveEffect {
|
||||||
}
|
}
|
||||||
|
|
||||||
verifyCondition(actor) {
|
verifyCondition(actor) {
|
||||||
if(!this.system.conditional?.field) return true;
|
if(!this.system.conditional?.condition.length) return true;
|
||||||
return foundry.applications.ux.SearchFilter.evaluateFilter(actor, this.system.conditional);
|
return this.system.conditional.condition.filter(c => c.field).map(c => {
|
||||||
|
if(!isNaN(c.value))
|
||||||
|
c.value = Number(c.value);
|
||||||
|
return c;
|
||||||
|
})[this.system.conditional.andOr ? 'every' : 'some'](c => foundry.applications.ux.SearchFilter.evaluateFilter(actor, c));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
"type": "domainCard",
|
"type": "domainCard",
|
||||||
"folder": "QpOL7jPbMBzH96qR",
|
"folder": "QpOL7jPbMBzH96qR",
|
||||||
"system": {
|
"system": {
|
||||||
"description": "<p class=\"Body-Foundation\">When you choose not to equip armor, you have a base Armor Score of 3 + your Strength and use the following as your base damage thresholds:</p><ul><li class=\"vertical-card-list-found\"><em><strong>Tier 1:</strong></em> 9/19</li><li class=\"vertical-card-list-found\"><em><strong>Tier 2:</strong></em> 11/24</li><li class=\"vertical-card-list-found\"><em><strong>Tier 3:</strong></em> 13/31</li><li class=\"vertical-card-list-found\"><em><strong>Tier 4:</strong></em> 15/38</li></ul><p>Equip the below armor to use Bare Bones.</p><p>@UUID[Compendium.daggerheart.armors.Item.ITAjcigTcUw5pMCN]{Bare Bones}</p>",
|
"description": "<p class=\"Body-Foundation\">When you choose not to equip armor, you have a base Armor Score of 3 + your Strength and use the following as your base damage thresholds:</p><ul><li class=\"vertical-card-list-found\"><em><strong>Tier 1:</strong></em> 9/19</li><li class=\"vertical-card-list-found\"><em><strong>Tier 2:</strong></em> 11/24</li><li class=\"vertical-card-list-found\"><em><strong>Tier 3:</strong></em> 13/31</li><li class=\"vertical-card-list-found\"><em><strong>Tier 4:</strong></em> 15/38</li></ul>",
|
||||||
"domain": "valor",
|
"domain": "valor",
|
||||||
"recallCost": 0,
|
"recallCost": 0,
|
||||||
"level": 1,
|
"level": 1,
|
||||||
|
|
@ -25,12 +25,83 @@
|
||||||
"exportSource": null,
|
"exportSource": null,
|
||||||
"coreVersion": "13.347",
|
"coreVersion": "13.347",
|
||||||
"systemId": "daggerheart",
|
"systemId": "daggerheart",
|
||||||
"systemVersion": "1.0.5",
|
"systemVersion": "1.1.2",
|
||||||
"createdTime": 1754067006722,
|
"createdTime": 1754067006722,
|
||||||
"modifiedTime": 1755429823165,
|
"modifiedTime": 1756823636026,
|
||||||
"lastModifiedBy": "VZIeX2YDvX338Zvr"
|
"lastModifiedBy": "8iAdslq1c1LfHXVb"
|
||||||
},
|
},
|
||||||
"effects": [],
|
"effects": [
|
||||||
|
{
|
||||||
|
"name": "Bare Bones",
|
||||||
|
"type": "base",
|
||||||
|
"system": {
|
||||||
|
"conditional": {
|
||||||
|
"andOr": true,
|
||||||
|
"condition": [
|
||||||
|
{
|
||||||
|
"field": "system.armor",
|
||||||
|
"operator": "is_empty",
|
||||||
|
"value": "",
|
||||||
|
"negate": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"rangeDependence": {
|
||||||
|
"enabled": false,
|
||||||
|
"type": "withinRange",
|
||||||
|
"target": "hostile",
|
||||||
|
"range": "melee"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"_id": "c8XXojizrnP1IHHK",
|
||||||
|
"img": "systems/daggerheart/assets/icons/domains/domain-card/valor.png",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"key": "system.armorScore",
|
||||||
|
"mode": 5,
|
||||||
|
"value": "3 + @system.traits.strength.value",
|
||||||
|
"priority": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "system.damageThresholds.major",
|
||||||
|
"mode": 5,
|
||||||
|
"value": "9 + (@tier -1)*2",
|
||||||
|
"priority": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "system.damageThresholds.severe",
|
||||||
|
"mode": 5,
|
||||||
|
"value": "19 + (@tier - 1) * 5 + max(0, (@tier -2) * 2 )",
|
||||||
|
"priority": 0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"disabled": false,
|
||||||
|
"duration": {
|
||||||
|
"startTime": null,
|
||||||
|
"combat": null,
|
||||||
|
"seconds": null,
|
||||||
|
"rounds": null,
|
||||||
|
"turns": null,
|
||||||
|
"startRound": null,
|
||||||
|
"startTurn": null
|
||||||
|
},
|
||||||
|
"description": "<p>When you choose not to equip armor, you have a base Armor Score of 3 + your Strength and use the following as your base damage thresholds:</p><ul><li class=\"vertical-card-list-found\"><em><strong>Tier 1:</strong></em> 9/19</li><li class=\"vertical-card-list-found\"><em><strong>Tier 2:</strong></em> 11/24</li><li class=\"vertical-card-list-found\"><em><strong>Tier 3:</strong></em> 13/31</li><li class=\"vertical-card-list-found\"><em><strong>Tier 4:</strong></em> 15/38</li></ul>",
|
||||||
|
"origin": null,
|
||||||
|
"tint": "#ffffff",
|
||||||
|
"transfer": true,
|
||||||
|
"statuses": [],
|
||||||
|
"sort": 0,
|
||||||
|
"flags": {},
|
||||||
|
"_stats": {
|
||||||
|
"coreVersion": "13.347",
|
||||||
|
"systemId": "daggerheart",
|
||||||
|
"systemVersion": "1.1.2",
|
||||||
|
"createdTime": 1756823269943,
|
||||||
|
"modifiedTime": 1756823587199,
|
||||||
|
"lastModifiedBy": "8iAdslq1c1LfHXVb"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
"ownership": {
|
"ownership": {
|
||||||
"default": 0,
|
"default": 0,
|
||||||
"MQSznptE5yLT7kj8": 3
|
"MQSznptE5yLT7kj8": 3
|
||||||
|
|
|
||||||
|
|
@ -530,6 +530,39 @@
|
||||||
font-size: var(--font-size-12);
|
font-size: var(--font-size-12);
|
||||||
padding-left: 3px;
|
padding-left: 3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.double-buttons {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 1fr;
|
||||||
|
margin-left: auto;
|
||||||
|
margin-bottom: .5rem;
|
||||||
|
margin-right: .5rem;
|
||||||
|
|
||||||
|
> button {
|
||||||
|
height: calc(var(--input-height) / 1.5);
|
||||||
|
min-height: calc(var(--input-height) / 1.5);
|
||||||
|
font-size: var(--font-size-12);
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: light-dark(transparent, #f3c267);
|
||||||
|
color: light-dark(#18162e, #18162e);
|
||||||
|
}
|
||||||
|
|
||||||
|
&.inactive {
|
||||||
|
background-color: @medium-red;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:first-child {
|
||||||
|
border-top-right-radius: 0;
|
||||||
|
border-bottom-right-radius: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:last-child {
|
||||||
|
border-top-left-radius: 0;
|
||||||
|
border-bottom-left-radius: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.application.setting.dh-style {
|
.application.setting.dh-style {
|
||||||
|
|
|
||||||
|
|
@ -74,13 +74,13 @@ body.game:is(.performance-low, .noblur) {
|
||||||
grid-template-columns: 12fr 7fr 7fr 4fr 1fr;
|
grid-template-columns: 12fr 7fr 7fr 4fr 1fr;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.conditional {
|
// &.conditional {
|
||||||
header, ol {
|
// header, ol {
|
||||||
grid-template-columns: 12fr 7fr 10fr 3fr;
|
// grid-template-columns: 12fr 7fr 10fr 3fr;
|
||||||
scrollbar-gutter: unset;
|
// scrollbar-gutter: unset;
|
||||||
overflow: unset;
|
// overflow: unset;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,28 +1,38 @@
|
||||||
<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}}">
|
||||||
<fieldset class="conditional">
|
<fieldset class="conditional">
|
||||||
<legend>{{localize "DAGGERHEART.GENERAL.conditional.label"}}</legend>
|
<legend>{{localize "DAGGERHEART.GENERAL.conditional.label.plural"}}</legend>
|
||||||
<p class="hint">{{localize "DAGGERHEART.GENERAL.conditional.hint"}}</p>
|
<p class="hint">{{localize "DAGGERHEART.GENERAL.conditional.hint"}}</p>
|
||||||
|
<div class="double-buttons">
|
||||||
|
<button type="button" data-action="setAndOr" data-value="true"{{#unless source.system.conditional.andOr}} class="inactive"{{/unless}}>{{localize 'DAGGERHEART.GENERAL.and'}}</button>
|
||||||
|
<button type="button" data-action="setAndOr" data-value="false"{{#if source.system.conditional.andOr}} class="inactive"{{/if}}>{{localize 'DAGGERHEART.GENERAL.or'}}</button>
|
||||||
|
</div>
|
||||||
<header>
|
<header>
|
||||||
<div class="field">{{localize "EFFECT.ChangeKey"}}</div>
|
<div class="field">{{localize "EFFECT.ChangeKey"}}</div>
|
||||||
<div class="operator">{{localize "EFFECT.ChangeFilter"}}</div>
|
<div class="operator">{{localize "EFFECT.ChangeFilter"}}</div>
|
||||||
<div class="value">{{localize "EFFECT.ChangeValue"}}</div>
|
<div class="value">{{localize "EFFECT.ChangeValue"}}</div>
|
||||||
<div class="negate">{{localize "EFFECT.ChangeNegate"}}</div>
|
<div class="negate">{{localize "EFFECT.ChangeNegate"}}</div>
|
||||||
|
<div class="controls"><a data-action="addCondition"><i class="fa-regular fa-square-plus"></i></a></div>
|
||||||
</header>
|
</header>
|
||||||
<ol>
|
<ol class="scrollable">
|
||||||
<li>
|
{{#each source.system.conditional.condition as |condition i|}}
|
||||||
<div class="field">
|
{{#with ../document.system.schema.fields.conditional.fields.condition.element.fields as |conditionFields|}}
|
||||||
{{formInput document.system.schema.fields.conditional.fields.field value=source.system.conditional.field localize=true }}
|
<li data-index="{{i}}">
|
||||||
</div>
|
<div class="field">
|
||||||
<div class="operator">
|
{{formInput conditionFields.field value=condition.field name=(concat "system.conditional.condition." i ".field") localize=true }}
|
||||||
{{formInput document.system.schema.fields.conditional.fields.operator value=source.system.conditional.operator localize=true }}
|
</div>
|
||||||
</div>
|
<div class="operator">
|
||||||
<div class="value">
|
{{formInput conditionFields.operator value=condition.operator name=(concat "system.conditional.condition." i ".operator") localize=true }}
|
||||||
{{formInput document.system.schema.fields.conditional.fields.value value=source.system.conditional.value localize=true }}
|
</div>
|
||||||
</div>
|
<div class="value">
|
||||||
<div class="negate">
|
{{formInput conditionFields.value value=condition.value name=(concat "system.conditional.condition." i ".value") localize=true }}
|
||||||
{{formInput document.system.schema.fields.conditional.fields.negate value=source.system.conditional.negate localize=true }}
|
</div>
|
||||||
</div>
|
<div class="negate">
|
||||||
</li>
|
{{formInput conditionFields.negate value=condition.negate name=(concat "system.conditional.condition." i ".negate") localize=true }}
|
||||||
|
</div>
|
||||||
|
<div class="controls"><a data-action="deleteCondition"><i class="fa-solid fa-trash"></i></a></div>
|
||||||
|
</li>
|
||||||
|
{{/with}}
|
||||||
|
{{/each}}
|
||||||
</ol>
|
</ol>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue