mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-14 20:51: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": {
|
"EFFECT": {
|
||||||
"ChangeFilter": "Filter"
|
"ChangeFilter": "Filter",
|
||||||
|
"ChangeNegate": "Negate"
|
||||||
},
|
},
|
||||||
"DAGGERHEART": {
|
"DAGGERHEART": {
|
||||||
"ACTIONS": {
|
"ACTIONS": {
|
||||||
|
|
@ -1945,6 +1946,11 @@
|
||||||
"basics": "Basics",
|
"basics": "Basics",
|
||||||
"bonus": "Bonus",
|
"bonus": "Bonus",
|
||||||
"burden": "Burden",
|
"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",
|
"continue": "Continue",
|
||||||
"criticalSuccess": "Critical Success",
|
"criticalSuccess": "Critical Success",
|
||||||
"criticalShort": "Critical",
|
"criticalShort": "Critical",
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ export default class DhTokenPlaceable extends foundry.canvas.placeables.Token {
|
||||||
|
|
||||||
// Categorize effects
|
// Categorize effects
|
||||||
const statusMap = new Map(foundry.CONFIG.statusEffects.map(status => [status.id, status]));
|
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);
|
acc.push(effect);
|
||||||
|
|
||||||
const currentStatusActiveEffects = acc.filter(
|
const currentStatusActiveEffects = acc.filter(
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { range } from '../config/generalConfig.mjs';
|
import { range } from '../config/generalConfig.mjs';
|
||||||
|
import { capitalize } from '../helpers/utils.mjs';
|
||||||
|
|
||||||
export const valueTypes = {
|
export const valueTypes = {
|
||||||
numberString: {
|
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 {
|
return {
|
||||||
conditional: new fields.SchemaField({
|
conditional: new fields.SchemaField({
|
||||||
field: new fields.StringField({required: true, nullable: true}),
|
field: new fields.StringField({required: true, nullable: true}),
|
||||||
operator: new fields.StringField({required: true, choices: foundry.applications.ux.SearchFilter.OPERATORS, initial: 'EQUALS'}),
|
operator: new fields.StringField({required: true, choices: CONFIG.DH.EFFECTS.conditionalTypes(), initial: 'equals'}),
|
||||||
value: new fields.StringField({required: true})
|
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({
|
||||||
|
|
|
||||||
|
|
@ -2,18 +2,6 @@ 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 */
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
|
@ -101,9 +89,7 @@ export default class DhActiveEffect extends foundry.documents.ActiveEffect {
|
||||||
|
|
||||||
/**@inheritdoc*/
|
/**@inheritdoc*/
|
||||||
apply(actor, change) {
|
apply(actor, change) {
|
||||||
if(!this.verifyConditional(actor)) return {};
|
if(!this.verifyCondition(actor)) return {};
|
||||||
// const changes = super.apply(actor, change);
|
|
||||||
// console.log(actor, change, changes);
|
|
||||||
return super.apply(actor, change);
|
return super.apply(actor, change);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -125,10 +111,8 @@ export default class DhActiveEffect extends foundry.documents.ActiveEffect {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
verifyConditional(actor) {
|
verifyCondition(actor) {
|
||||||
if(!this.system.conditional.key) return true;
|
if(!this.system.conditional?.field) 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);
|
return foundry.applications.ux.SearchFilter.evaluateFilter(actor, this.system.conditional);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -144,6 +128,9 @@ export default class DhActiveEffect extends foundry.documents.ActiveEffect {
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
|
|
||||||
|
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) {
|
for (const statusId of this.statuses) {
|
||||||
const status = CONFIG.statusEffects.find(s => s.id === statusId);
|
const status = CONFIG.statusEffects.find(s => s.id === statusId);
|
||||||
if (status) tags.push(game.i18n.localize(status.name));
|
if (status) tags.push(game.i18n.localize(status.name));
|
||||||
|
|
|
||||||
|
|
@ -132,6 +132,12 @@
|
||||||
background: light-dark(@dark-15, @beige-15);
|
background: light-dark(@dark-15, @beige-15);
|
||||||
border: 1px solid light-dark(@dark, @beige);
|
border: 1px solid light-dark(@dark, @beige);
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
|
|
||||||
|
&:has(i) {
|
||||||
|
color: @red;
|
||||||
|
border-color: @red;
|
||||||
|
background-color: @medium-red-10;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.label {
|
.label {
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,31 @@ body.game:is(.performance-low, .noblur) {
|
||||||
|
|
||||||
.tab {
|
.tab {
|
||||||
padding: 0 10px;
|
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}}">
|
<section class="tab changes{{#if tab.active}} active{{/if}}" data-group="{{tab.group}}" data-tab="{{tab.id}}">
|
||||||
{{!-- <fieldset>
|
<fieldset class="conditional">
|
||||||
<legend>Conditional</legend>
|
<legend>{{localize "DAGGERHEART.GENERAL.conditional.label"}}</legend>
|
||||||
|
<p class="hint">{{localize "DAGGERHEART.GENERAL.conditional.hint"}}</p>
|
||||||
<header>
|
<header>
|
||||||
<div class="key">{{localize "EFFECT.ChangeKey"}}</div>
|
<div class="field">{{localize "EFFECT.ChangeKey"}}</div>
|
||||||
<div class="filter">{{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>
|
||||||
</header>
|
</header>
|
||||||
<ol>{{log @root}}{{log this}}
|
<ol>
|
||||||
<li>
|
<li>
|
||||||
<div class="key">
|
<div class="field">
|
||||||
{{formInput document.system.schema.fields.conditional.fields.key value=source.system.conditional.key localize=true }}
|
{{formInput document.system.schema.fields.conditional.fields.field value=source.system.conditional.field localize=true }}
|
||||||
</div>
|
</div>
|
||||||
<div class="filter">
|
<div class="operator">
|
||||||
{{formInput document.system.schema.fields.conditional.fields.filter value=source.system.conditional.filter localize=true }}
|
{{formInput document.system.schema.fields.conditional.fields.operator value=source.system.conditional.operator localize=true }}
|
||||||
</div>
|
</div>
|
||||||
<div class="value">
|
<div class="value">
|
||||||
{{formInput document.system.schema.fields.conditional.fields.value value=source.system.conditional.value localize=true }}
|
{{formInput document.system.schema.fields.conditional.fields.value value=source.system.conditional.value localize=true }}
|
||||||
</div>
|
</div>
|
||||||
|
<div class="negate">
|
||||||
|
{{formInput document.system.schema.fields.conditional.fields.negate value=source.system.conditional.negate localize=true }}
|
||||||
|
</div>
|
||||||
</li>
|
</li>
|
||||||
</ol>
|
</ol>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>Effects</legend> --}}
|
<legend>{{localize "DAGGERHEART.GENERAL.Effect.plural"}}</legend>
|
||||||
<header>
|
<header>
|
||||||
<div class="key">{{localize "EFFECT.ChangeKey"}}</div>
|
<div class="key">{{localize "EFFECT.ChangeKey"}}</div>
|
||||||
<div class="mode">{{localize "EFFECT.ChangeMode"}}</div>
|
<div class="mode">{{localize "EFFECT.ChangeMode"}}</div>
|
||||||
|
|
@ -51,5 +56,5 @@
|
||||||
{{/with}}
|
{{/with}}
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</ol>
|
</ol>
|
||||||
{{!-- </fieldset> --}}
|
</fieldset>
|
||||||
</section>
|
</section>
|
||||||
|
|
@ -62,7 +62,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{#if document.system.armor.system.marks}}
|
{{!-- {{#if document.system.armor.system.marks}}
|
||||||
<div class="status-bar armor-slots">
|
<div class="status-bar armor-slots">
|
||||||
<div class='status-value'>
|
<div class='status-value'>
|
||||||
<p><input class="bar-input armor-marks-input" value="{{document.system.armor.system.marks.value}}" type="number"></p>
|
<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">
|
<div class="status-label">
|
||||||
<h4>{{localize "DAGGERHEART.GENERAL.armorSlots"}}</h4>
|
<h4>{{localize "DAGGERHEART.GENERAL.armorSlots"}}</h4>
|
||||||
</div>
|
</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>
|
</div>
|
||||||
{{else}}
|
{{else}}
|
||||||
<div class="status-number armor-slots">
|
<div class="status-number armor-slots">
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ Parameters:
|
||||||
<div class="item-tags">
|
<div class="item-tags">
|
||||||
{{#each this._getTags as |tag|}}
|
{{#each this._getTags as |tag|}}
|
||||||
<div class="tag">
|
<div class="tag">
|
||||||
{{tag}}
|
{{{tag}}}
|
||||||
</div>
|
</div>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue