mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-18 07:59:03 +01:00
FEAT: add _gettags and _getLabels to armor, domainCard, weapons and ActiveEffect
This commit is contained in:
parent
faa412bfc1
commit
e5c617d62e
6 changed files with 140 additions and 133 deletions
|
|
@ -115,4 +115,26 @@ export default class DHArmor extends AttachableItem {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a list of localized tags based on this item's type-specific properties.
|
||||
* @returns {string[]} An array of localized tag strings.
|
||||
*/
|
||||
_getTags() {
|
||||
const tags = [
|
||||
`${game.i18n.localize('DAGGERHEART.ITEMS.Armor.baseScore')}: ${this.baseScore}`,
|
||||
`${game.i18n.localize('DAGGERHEART.ITEMS.Armor.baseThresholds.base')}: ${this.baseThresholds.major} / ${this.baseThresholds.severe}`
|
||||
];
|
||||
|
||||
return tags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a localized label array for this item subtype.
|
||||
* @returns {(string | { value: string, icons: string[] })[]} An array of localized strings and damage label objects.
|
||||
*/
|
||||
_getLabels() {
|
||||
const labels = [`${game.i18n.localize('DAGGERHEART.ITEMS.Armor.baseScore')}: ${this.baseScore}`];
|
||||
return labels;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import BaseDataItem from './base.mjs';
|
||||
import { ActionField } from '../fields/actionField.mjs';
|
||||
|
||||
export default class DHDomainCard extends BaseDataItem {
|
||||
/** @inheritDoc */
|
||||
|
|
@ -34,6 +33,7 @@ export default class DHDomainCard extends BaseDataItem {
|
|||
};
|
||||
}
|
||||
|
||||
/**@inheritdoc */
|
||||
async _preCreate(data, options, user) {
|
||||
const allowed = await super._preCreate(data, options, user);
|
||||
if (allowed === false) return;
|
||||
|
|
@ -55,4 +55,35 @@ export default class DHDomainCard extends BaseDataItem {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a list of localized tags based on this item's type-specific properties.
|
||||
* @returns {string[]} An array of localized tag strings.
|
||||
*/
|
||||
_getTags() {
|
||||
const tags = [
|
||||
game.i18n.localize(`DAGGERHEART.CONFIG.DomainCardTypes.${this.type}`),
|
||||
game.i18n.localize(`DAGGERHEART.GENERAL.Domain.${this.domain}.label`),
|
||||
`${game.i18n.localize('DAGGERHEART.ITEMS.DomainCard.recallCost')}: ${this.recallCost}`
|
||||
];
|
||||
|
||||
return tags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a localized label array for this item subtype.
|
||||
* @returns {(string | { value: string, icons: string[] })[]} An array of localized strings and damage label objects.
|
||||
*/
|
||||
_getLabels() {
|
||||
const labels = [
|
||||
game.i18n.localize(`DAGGERHEART.CONFIG.DomainCardTypes.${this.type}`),
|
||||
game.i18n.localize(`DAGGERHEART.GENERAL.Domain.${this.domain}.label`),
|
||||
{
|
||||
value: `${this.recallCost}`, //converts the number to a string
|
||||
icons: ['fa-bolt']
|
||||
}
|
||||
];
|
||||
|
||||
return labels;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -167,15 +167,13 @@ export default class DHWeapon extends AttachableItem {
|
|||
* Generates a list of localized tags based on this item's type-specific properties.
|
||||
* @returns {string[]} An array of localized tag strings.
|
||||
*/
|
||||
getTags() {
|
||||
_getTags() {
|
||||
const { attack, burden } = this;
|
||||
const tags = [];
|
||||
|
||||
const traitTag = game.i18n.localize(`DAGGERHEART.CONFIG.Traits.${attack.roll.trait}.name`);
|
||||
const rangeTag = game.i18n.localize(`DAGGERHEART.CONFIG.Range.${attack.range}.name`);
|
||||
const burdenTag = game.i18n.localize(`DAGGERHEART.CONFIG.Burden.${burden}`);
|
||||
|
||||
tags.push(traitTag, rangeTag, burdenTag);
|
||||
const tags = [
|
||||
game.i18n.localize(`DAGGERHEART.CONFIG.Traits.${attack.roll.trait}.name`),
|
||||
game.i18n.localize(`DAGGERHEART.CONFIG.Range.${attack.range}.name`),
|
||||
game.i18n.localize(`DAGGERHEART.CONFIG.Burden.${burden}`)
|
||||
];
|
||||
|
||||
for (const { value, type } of attack.damage.parts) {
|
||||
const parts = [value.dice];
|
||||
|
|
@ -184,14 +182,13 @@ export default class DHWeapon extends AttachableItem {
|
|||
if (type.size > 0) {
|
||||
const typeTags = Array.from(type)
|
||||
.map(t => game.i18n.localize(`DAGGERHEART.CONFIG.DamageType.${t}.abbreviation`))
|
||||
.join(" | ");
|
||||
.join(' | ');
|
||||
parts.push(` (${typeTags})`); // Add a space in front and put it inside a ().
|
||||
}
|
||||
|
||||
tags.push(parts.join(""));
|
||||
tags.push(parts.join(''));
|
||||
}
|
||||
|
||||
|
||||
return tags;
|
||||
}
|
||||
|
||||
|
|
@ -199,12 +196,13 @@ export default class DHWeapon extends AttachableItem {
|
|||
* Generate a localized label array for this item subtype.
|
||||
* @returns {(string | { value: string, icons: string[] })[]} An array of localized strings and damage label objects.
|
||||
*/
|
||||
getLabels() {
|
||||
const labels = [];
|
||||
|
||||
_getLabels() {
|
||||
const { roll, range, damage } = this.attack;
|
||||
labels.push(game.i18n.localize(`DAGGERHEART.CONFIG.Traits.${roll.trait}.short`));
|
||||
labels.push(game.i18n.localize(`DAGGERHEART.CONFIG.Range.${range}.short`));
|
||||
|
||||
const labels = [
|
||||
game.i18n.localize(`DAGGERHEART.CONFIG.Traits.${roll.trait}.short`),
|
||||
game.i18n.localize(`DAGGERHEART.CONFIG.Range.${range}.short`)
|
||||
];
|
||||
|
||||
for (const { value, type } of damage.parts) {
|
||||
const str = [value.dice];
|
||||
|
|
@ -214,7 +212,7 @@ export default class DHWeapon extends AttachableItem {
|
|||
.map(t => CONFIG.DH.GENERAL.damageTypes[t]?.icon)
|
||||
.filter(Boolean);
|
||||
|
||||
const labelValue = str.join("");
|
||||
const labelValue = str.join('');
|
||||
if (icons.length === 0) {
|
||||
labels.push(labelValue);
|
||||
} else {
|
||||
|
|
@ -224,7 +222,4 @@ export default class DHWeapon extends AttachableItem {
|
|||
|
||||
return labels;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue