mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
j
This commit is contained in:
parent
7cbe4b7580
commit
4bdafeff6d
10 changed files with 89 additions and 36 deletions
|
|
@ -34,7 +34,8 @@
|
|||
}
|
||||
},
|
||||
"EFFECT": {
|
||||
"ChangeFilter": "Filter"
|
||||
"ChangeFilter": "Filter",
|
||||
"ChangeNegate": "Negate"
|
||||
},
|
||||
"DAGGERHEART": {
|
||||
"ACTIONS": {
|
||||
|
|
@ -1945,6 +1946,11 @@
|
|||
"basics": "Basics",
|
||||
"bonus": "Bonus",
|
||||
"burden": "Burden",
|
||||
"conditional": {
|
||||
"label": "Condition",
|
||||
"hint": "(Optionnal) Set a condition that need to be verified to apply effects below.",
|
||||
"notMet": "Condition Not Met"
|
||||
},
|
||||
"continue": "Continue",
|
||||
"criticalSuccess": "Critical Success",
|
||||
"criticalShort": "Critical",
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ export default class DhTokenPlaceable extends foundry.canvas.placeables.Token {
|
|||
|
||||
// Categorize effects
|
||||
const statusMap = new Map(foundry.CONFIG.statusEffects.map(status => [status.id, status]));
|
||||
const activeEffects = (this.actor ? this.actor.effects.filter(x => !x.disabled) : []).reduce((acc, effect) => {
|
||||
const activeEffects = (this.actor ? this.actor.effects.filter(x => !x.disabled && x.verifyCondition(this.actor)) : []).reduce((acc, effect) => {
|
||||
acc.push(effect);
|
||||
|
||||
const currentStatusActiveEffects = acc.filter(
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { range } from '../config/generalConfig.mjs';
|
||||
import { capitalize } from '../helpers/utils.mjs';
|
||||
|
||||
export const valueTypes = {
|
||||
numberString: {
|
||||
|
|
@ -62,3 +63,9 @@ export const effectTypes = {
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const conditionalTypes = () => {
|
||||
const operators = {};
|
||||
Object.entries(foundry.applications.ux.SearchFilter.OPERATORS).forEach(([key, value]) => operators[value] = key.replaceAll('_', ' ').toLowerCase().capitalize());
|
||||
return operators;
|
||||
}
|
||||
|
|
@ -5,8 +5,9 @@ export default class BaseEffect extends foundry.abstract.TypeDataModel {
|
|||
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})
|
||||
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({
|
||||
enabled: new fields.BooleanField({
|
||||
|
|
|
|||
|
|
@ -2,18 +2,6 @@ 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 */
|
||||
/* -------------------------------------------- */
|
||||
|
|
@ -101,9 +89,7 @@ export default class DhActiveEffect extends foundry.documents.ActiveEffect {
|
|||
|
||||
/**@inheritdoc*/
|
||||
apply(actor, change) {
|
||||
if(!this.verifyConditional(actor)) return {};
|
||||
// const changes = super.apply(actor, change);
|
||||
// console.log(actor, change, changes);
|
||||
if(!this.verifyCondition(actor)) return {};
|
||||
return super.apply(actor, change);
|
||||
}
|
||||
|
||||
|
|
@ -125,10 +111,8 @@ 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;
|
||||
verifyCondition(actor) {
|
||||
if(!this.system.conditional?.field) return true;
|
||||
return foundry.applications.ux.SearchFilter.evaluateFilter(actor, this.system.conditional);
|
||||
}
|
||||
|
||||
|
|
@ -143,6 +127,9 @@ export default class DhActiveEffect extends foundry.documents.ActiveEffect {
|
|||
this.isTemporary ? 'DAGGERHEART.EFFECTS.Duration.temporary' : 'DAGGERHEART.EFFECTS.Duration.passive'
|
||||
)
|
||||
];
|
||||
|
||||
if(this.target instanceof CONFIG.Actor.documentClass && !this.verifyCondition(this.target))
|
||||
tags.push(`<i>${game.i18n.localize('DAGGERHEART.GENERAL.conditional.notMet')}</i>`);
|
||||
|
||||
for (const statusId of this.statuses) {
|
||||
const status = CONFIG.statusEffects.find(s => s.id === statusId);
|
||||
|
|
|
|||
|
|
@ -132,6 +132,12 @@
|
|||
background: light-dark(@dark-15, @beige-15);
|
||||
border: 1px solid light-dark(@dark, @beige);
|
||||
border-radius: 3px;
|
||||
|
||||
&:has(i) {
|
||||
color: @red;
|
||||
border-color: @red;
|
||||
background-color: @medium-red-10;
|
||||
}
|
||||
}
|
||||
|
||||
.label {
|
||||
|
|
|
|||
|
|
@ -58,6 +58,31 @@ body.game:is(.performance-low, .noblur) {
|
|||
|
||||
.tab {
|
||||
padding: 0 10px;
|
||||
|
||||
&.changes {
|
||||
fieldset {
|
||||
gap: 0;
|
||||
padding-top: .5rem;
|
||||
|
||||
header {
|
||||
width: 100%;
|
||||
scrollbar-gutter: stable;
|
||||
overflow: hidden auto;
|
||||
}
|
||||
|
||||
header, ol {
|
||||
grid-template-columns: 12fr 7fr 7fr 4fr 1fr;
|
||||
}
|
||||
|
||||
&.conditional {
|
||||
header, ol {
|
||||
grid-template-columns: 12fr 7fr 10fr 3fr;
|
||||
scrollbar-gutter: unset;
|
||||
overflow: unset;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,27 +1,32 @@
|
|||
<section class="tab changes{{#if tab.active}} active{{/if}}" data-group="{{tab.group}}" data-tab="{{tab.id}}">
|
||||
{{!-- <fieldset>
|
||||
<legend>Conditional</legend>
|
||||
<fieldset class="conditional">
|
||||
<legend>{{localize "DAGGERHEART.GENERAL.conditional.label"}}</legend>
|
||||
<p class="hint">{{localize "DAGGERHEART.GENERAL.conditional.hint"}}</p>
|
||||
<header>
|
||||
<div class="key">{{localize "EFFECT.ChangeKey"}}</div>
|
||||
<div class="filter">{{localize "EFFECT.ChangeFilter"}}</div>
|
||||
<div class="field">{{localize "EFFECT.ChangeKey"}}</div>
|
||||
<div class="operator">{{localize "EFFECT.ChangeFilter"}}</div>
|
||||
<div class="value">{{localize "EFFECT.ChangeValue"}}</div>
|
||||
<div class="negate">{{localize "EFFECT.ChangeNegate"}}</div>
|
||||
</header>
|
||||
<ol>{{log @root}}{{log this}}
|
||||
<ol>
|
||||
<li>
|
||||
<div class="key">
|
||||
{{formInput document.system.schema.fields.conditional.fields.key value=source.system.conditional.key localize=true }}
|
||||
<div class="field">
|
||||
{{formInput document.system.schema.fields.conditional.fields.field value=source.system.conditional.field localize=true }}
|
||||
</div>
|
||||
<div class="filter">
|
||||
{{formInput document.system.schema.fields.conditional.fields.filter value=source.system.conditional.filter localize=true }}
|
||||
<div class="operator">
|
||||
{{formInput document.system.schema.fields.conditional.fields.operator value=source.system.conditional.operator localize=true }}
|
||||
</div>
|
||||
<div class="value">
|
||||
{{formInput document.system.schema.fields.conditional.fields.value value=source.system.conditional.value localize=true }}
|
||||
</div>
|
||||
<div class="negate">
|
||||
{{formInput document.system.schema.fields.conditional.fields.negate value=source.system.conditional.negate localize=true }}
|
||||
</div>
|
||||
</li>
|
||||
</ol>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>Effects</legend> --}}
|
||||
<legend>{{localize "DAGGERHEART.GENERAL.Effect.plural"}}</legend>
|
||||
<header>
|
||||
<div class="key">{{localize "EFFECT.ChangeKey"}}</div>
|
||||
<div class="mode">{{localize "EFFECT.ChangeMode"}}</div>
|
||||
|
|
@ -51,5 +56,5 @@
|
|||
{{/with}}
|
||||
{{/each}}
|
||||
</ol>
|
||||
{{!-- </fieldset> --}}
|
||||
</fieldset>
|
||||
</section>
|
||||
|
|
@ -62,7 +62,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
{{#if document.system.armor.system.marks}}
|
||||
{{!-- {{#if document.system.armor.system.marks}}
|
||||
<div class="status-bar armor-slots">
|
||||
<div class='status-value'>
|
||||
<p><input class="bar-input armor-marks-input" value="{{document.system.armor.system.marks.value}}" type="number"></p>
|
||||
|
|
@ -77,6 +77,22 @@
|
|||
<div class="status-label">
|
||||
<h4>{{localize "DAGGERHEART.GENERAL.armorSlots"}}</h4>
|
||||
</div>
|
||||
</div> --}}
|
||||
{{#if document.system.resources.armor.max}}
|
||||
<div class="status-bar armor-slots">
|
||||
<div class='status-value'>
|
||||
<p><input class="bar-input armor-marks-input" value="{{document.system.resources.armor.value}}" type="number"></p>
|
||||
<p>/</p>
|
||||
<p class="bar-label">{{document.system.resources.armor.max}}</p>
|
||||
</div>
|
||||
<progress
|
||||
class='progress-bar stress-color'
|
||||
value='{{document.system.resources.armor.value}}'
|
||||
max='{{document.system.resources.armor.max}}'
|
||||
></progress>
|
||||
<div class="status-label">
|
||||
<h4>{{localize "DAGGERHEART.GENERAL.armorSlots"}}</h4>
|
||||
</div>
|
||||
</div>
|
||||
{{else}}
|
||||
<div class="status-number armor-slots">
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ Parameters:
|
|||
<div class="item-tags">
|
||||
{{#each this._getTags as |tag|}}
|
||||
<div class="tag">
|
||||
{{tag}}
|
||||
{{{tag}}}
|
||||
</div>
|
||||
{{/each}}
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue