mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-04-21 23:13:39 +02:00
Made baseEffect.stacking nullable instead of having an enabled property
This commit is contained in:
parent
0fbe027d7d
commit
5ff1d0c71f
14 changed files with 70 additions and 43 deletions
|
|
@ -151,6 +151,10 @@ export default class DhActiveEffectConfig extends foundry.applications.sheets.Ac
|
|||
});
|
||||
});
|
||||
|
||||
htmlElement
|
||||
.querySelector('.stacking-change-checkbox')
|
||||
?.addEventListener('change', this.stackingChangeToggle.bind(this));
|
||||
|
||||
htmlElement
|
||||
.querySelector('.armor-change-checkbox')
|
||||
?.addEventListener('change', this.armorChangeToggle.bind(this));
|
||||
|
|
@ -209,6 +213,16 @@ export default class DhActiveEffectConfig extends foundry.applications.sheets.Ac
|
|||
return partContext;
|
||||
}
|
||||
|
||||
stackingChangeToggle(event) {
|
||||
const stackingFields = this.document.system.schema.fields.stacking.fields;
|
||||
const systemData = {
|
||||
stacking: event.target.checked
|
||||
? { value: stackingFields.value.initial, max: stackingFields.max.initial }
|
||||
: null
|
||||
};
|
||||
return this.submit({ updateData: { system: systemData } });
|
||||
}
|
||||
|
||||
armorChangeToggle(event) {
|
||||
if (event.target.checked) {
|
||||
this.addArmorChange();
|
||||
|
|
|
|||
|
|
@ -89,12 +89,12 @@ export default class DhEffectsDisplay extends HandlebarsApplicationMixin(Applica
|
|||
const element = event.target.closest('.effect-container');
|
||||
const effects = DhEffectsDisplay.getTokenEffects();
|
||||
const effect = effects.find(x => x.id === element.dataset.effectId);
|
||||
if (!effect || (delta >= 0 && !effect.system.stacking?.enabled)) {
|
||||
if (!effect || (delta >= 0 && !effect.system.stacking)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const maxValue = effect.system.stacking.max ?? Infinity;
|
||||
const newValue = Math.clamp((effect.system.stacking.value ?? 1) + delta, 0, maxValue);
|
||||
const maxValue = effect.system.stacking?.max ?? Infinity;
|
||||
const newValue = Math.clamp((effect.system.stacking?.value ?? 1) + delta, 0, maxValue);
|
||||
if (newValue > 0) {
|
||||
await effect.update({ 'system.stacking.value': newValue });
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ export default class DhTokenPlaceable extends foundry.canvas.placeables.Token {
|
|||
const icon = new PIXI.Sprite(tex);
|
||||
icon.tint = tint ?? 0xffffff;
|
||||
|
||||
if (effect?.system?.stacking?.enabled && effect.system.stacking.value > 1) {
|
||||
if (effect.system.stacking?.value > 1) {
|
||||
const stackOverlay = new PIXI.Text(effect.system.stacking.value, {
|
||||
fill: '#f3c267',
|
||||
stroke: '#000000',
|
||||
|
|
|
|||
|
|
@ -81,8 +81,8 @@ export default class BaseEffect extends foundry.data.ActiveEffectTypeDataModel {
|
|||
label: 'DAGGERHEART.GENERAL.range'
|
||||
})
|
||||
}),
|
||||
stacking: new fields.SchemaField({
|
||||
enabled: new fields.BooleanField({ initial: false, label: 'DAGGERHEART.GENERAL.enabled' }),
|
||||
stacking: new fields.SchemaField(
|
||||
{
|
||||
value: new fields.NumberField({
|
||||
initial: 1,
|
||||
min: 1,
|
||||
|
|
@ -91,7 +91,9 @@ export default class BaseEffect extends foundry.data.ActiveEffectTypeDataModel {
|
|||
label: 'DAGGERHEART.GENERAL.value'
|
||||
}),
|
||||
max: new fields.NumberField({ integer: true, label: 'DAGGERHEART.GENERAL.max' })
|
||||
})
|
||||
},
|
||||
{ nullable: true, initial: null }
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -109,15 +109,13 @@ export default class DhActiveEffect extends foundry.documents.ActiveEffect {
|
|||
}
|
||||
|
||||
const existingEffect = this.actor.effects.find(x => x.origin === data.origin);
|
||||
const stacks = data.system?.stacking?.enabled;
|
||||
const stacks = Boolean(data.system?.stacking);
|
||||
if (existingEffect && !stacks) return false;
|
||||
|
||||
if (existingEffect && stacks) {
|
||||
const incrementedValue = existingEffect.system.stacking.value + 1;
|
||||
await existingEffect.update({
|
||||
'system.stacking.value': existingEffect.system.stacking.max
|
||||
? Math.min(incrementedValue, existingEffect.system.stacking.max)
|
||||
: incrementedValue
|
||||
'system.stacking.value': Math.min(incrementedValue, existingEffect.system.stacking.max ?? Infinity)
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
|
@ -198,17 +196,13 @@ export default class DhActiveEffect extends foundry.documents.ActiveEffect {
|
|||
} catch (_) {}
|
||||
}
|
||||
|
||||
const evalValue = this.effectSafeEval(this.effectRollParse(key, parseModel, effect.parent, effect));
|
||||
const stackingParsedValue = effect.system.stacking
|
||||
? Roll.replaceFormulaData(key, { stacks: effect.system.stacking.value })
|
||||
: key;
|
||||
const evalValue = itemAbleRollParse(stackingParsedValue, parseModel, effect.parent);
|
||||
return evalValue ?? key;
|
||||
}
|
||||
|
||||
static effectRollParse(value, actor, item, effect) {
|
||||
const stackingParsedValue = effect.system.stacking?.enabled
|
||||
? Roll.replaceFormulaData(value, { stacks: effect.system.stacking.value })
|
||||
: value;
|
||||
return itemAbleRollParse(stackingParsedValue, actor, item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Altered Foundry safeEval to allow non-numeric return
|
||||
* @param {string} expression
|
||||
|
|
|
|||
|
|
@ -81,7 +81,6 @@
|
|||
"type": "shortRest"
|
||||
},
|
||||
"stacking": {
|
||||
"enabled": true,
|
||||
"max": null
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -80,7 +80,6 @@
|
|||
"description": "<p><span style=\"color: rgb(239, 230, 216); font-family: Montserrat, sans-serif; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgba(24, 22, 46, 0.565); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;\">Until the next time an attack succeeds against you.</span></p>"
|
||||
},
|
||||
"stacking": {
|
||||
"enabled": true,
|
||||
"max": null
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -150,7 +150,6 @@
|
|||
}
|
||||
],
|
||||
"stacking": {
|
||||
"enabled": true,
|
||||
"max": null
|
||||
},
|
||||
"duration": {
|
||||
|
|
|
|||
|
|
@ -88,7 +88,6 @@
|
|||
}
|
||||
],
|
||||
"stacking": {
|
||||
"enabled": true,
|
||||
"max": 2
|
||||
},
|
||||
"duration": {
|
||||
|
|
|
|||
|
|
@ -293,6 +293,20 @@
|
|||
}
|
||||
}
|
||||
|
||||
&.optional,
|
||||
&.one-column.optional {
|
||||
padding-top: 0;
|
||||
padding-bottom: 4px;
|
||||
min-height: auto;
|
||||
row-gap: 0;
|
||||
|
||||
legend {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding-left: 3px;
|
||||
}
|
||||
}
|
||||
|
||||
.list-w-img {
|
||||
padding: 5px;
|
||||
label {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,11 @@
|
|||
</ol>
|
||||
|
||||
<fieldset class="armor-change-container">
|
||||
<legend>{{localize "DAGGERHEART.GENERAL.armor"}} <input type="checkbox" class="armor-change-checkbox" data-index="{{typedChanges.armor.index}}" {{checked typedChanges.armor}} /></legend>
|
||||
<legend>
|
||||
{{localize "DAGGERHEART.GENERAL.armor"}}
|
||||
<input type="checkbox" class="armor-change-checkbox" data-index="{{typedChanges.armor.index}}" {{checked typedChanges.armor}} />
|
||||
</legend>
|
||||
|
||||
{{#if typedChanges.armor}}
|
||||
{{> "systems/daggerheart/templates/sheets/activeEffect/typeChanges/armorChange.hbs" typedChanges.armor fields=@root.systemFields.changes.element.types.armor.fields}}
|
||||
{{/if}}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,16 @@
|
|||
<section class="tab{{#if tab.active}} active{{/if}}" data-group="{{tab.group}}" data-tab="{{tab.id}}">
|
||||
<fieldset class="one-column">
|
||||
<legend>{{localize "DAGGERHEART.ACTIVEEFFECT.Config.stacking.title"}}</legend>
|
||||
|
||||
{{formGroup systemFields.stacking.fields.enabled value=source.system.stacking.enabled localize=true }}
|
||||
<fieldset class="one-column optional">
|
||||
<legend>
|
||||
{{localize "DAGGERHEART.ACTIVEEFFECT.Config.stacking.title"}}
|
||||
<input type="checkbox" class="stacking-change-checkbox" {{checked source.system.stacking}} />
|
||||
</legend>
|
||||
|
||||
{{#if source.system.stacking}}
|
||||
<div class="two-columns even full-width">
|
||||
{{formGroup systemFields.stacking.fields.value value=source.system.stacking.value localize=true }}
|
||||
{{formGroup systemFields.stacking.fields.max value=source.system.stacking.max localize=true }}
|
||||
</div>
|
||||
{{/if}}
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="one-column">
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
<a {{#if effect.condition}}disabled{{/if}}>
|
||||
<img src="{{effect.img}}" />
|
||||
</a>
|
||||
{{#if (and effect.system.stacking.enabled (gt effect.system.stacking.value 1))}}
|
||||
{{#if (gt effect.system.stacking.value 1)}}
|
||||
<span class="stacking-value">{{effect.system.stacking.value}}</span>
|
||||
{{/if}}
|
||||
{{#if effect.condition}}<i class="effect-locked fa-solid fa-lock"></i>{{/if}}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
</div>
|
||||
{{/if}}
|
||||
|
||||
{{#if (and effect.system.stacking.enabled effect.system.stacking.max)}}
|
||||
{{#if effect.system.stacking}}
|
||||
<div class="effect-stacks-outer-container">
|
||||
<div class="effect-stacks-title">{{localize "Stacks"}}</div>
|
||||
<div class="effect-stacks-container">
|
||||
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
{{#unless effect.isLockedCondition}}
|
||||
<div class="close-hints">
|
||||
{{#if effect.system.stacking.enabled}}
|
||||
{{#if effect.system.stacking}}
|
||||
<p class="close-hint">
|
||||
<i class="fa-solid fa-computer-mouse"></i> {{localize "DAGGERHEART.UI.EffectsDisplay.increaseStacks"}}
|
||||
</p>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue