Merged with development

This commit is contained in:
WBHarry 2025-08-23 18:17:32 +02:00
commit bd76e22e8d
1096 changed files with 11080 additions and 5102 deletions

View file

@ -13,7 +13,8 @@ export default class RegisterHandlebarsHelpers {
hasProperty: foundry.utils.hasProperty,
getProperty: foundry.utils.getProperty,
setVar: this.setVar,
empty: this.empty
empty: this.empty,
pluralize: this.pluralize
});
}
static add(a, b) {
@ -64,7 +65,7 @@ export default class RegisterHandlebarsHelpers {
return isNumerical ? (!result ? 0 : Number(result)) : result;
}
static setVar(name, value, context) {
static setVar(name, value) {
this[name] = value;
}
@ -72,4 +73,20 @@ export default class RegisterHandlebarsHelpers {
if (!(typeof object === 'object')) return true;
return Object.keys(object).length === 0;
}
/**
* Pluralize helper that returns the appropriate localized string based on count
* @param {number} count - The number to check for plurality
* @param {string} baseKey - The base localization key (e.g., "DAGGERHEART.GENERAL.Target")
* @returns {string} The localized singular or plural string
*
* Usage: {{pluralize currentTargets.length "DAGGERHEART.GENERAL.Target"}}
* Returns: "Target" if count is exactly 1, "Targets" if count is 0, 2+, or invalid
*/
static pluralize(count, baseKey) {
const numericCount = Number(count);
const isSingular = !isNaN(numericCount) && numericCount === 1;
const key = isSingular ? `${baseKey}.single` : `${baseKey}.plural`;
return game.i18n.localize(key);
}
}

View file

@ -371,17 +371,15 @@ export function getScrollTextData(resources, resource, key) {
return { text, stroke, fill, direction };
}
export function createScrollText(actor, optionsData) {
if (actor && optionsData?.length) {
export function createScrollText(actor, data) {
if (actor) {
actor.getActiveTokens().forEach(token => {
optionsData.forEach(data => {
const { text, ...options } = data;
canvas.interface.createScrollingText(token.getCenterPoint(), data.text, {
duration: 2000,
distance: token.h,
jitter: 0,
...options
});
const { text, ...options } = data;
canvas.interface.createScrollingText(token.getCenterPoint(), data.text, {
duration: 2000,
distance: token.h,
jitter: 0,
...options
});
});
}
@ -420,3 +418,14 @@ export async function createEmbeddedItemsWithEffects(actor, baseData) {
export const slugify = name => {
return name.toLowerCase().replaceAll(' ', '-').replaceAll('.', '');
};
export const versionCompare = (current, target) => {
const currentSplit = current.split('.').map(x => Number.parseInt(x));
const targetSplit = target.split('.').map(x => Number.parseInt(x));
for (var i = 0; i < currentSplit.length; i++) {
if (currentSplit[i] < targetSplit[i]) return true;
if (currentSplit[i] > targetSplit[i]) return false;
}
return false;
};