16b92b4586
Après le travail sur les ChatMessage, centraliser les difficultés pour les dialog-roll afin d'afficher tous les ajustements sous forme de tooltips Les ajustements à améliorer: * malus armure * sur-encombrement * encombrement total + fix regression tâches + fix méditation isisPuritication
44 lines
1.1 KiB
JavaScript
44 lines
1.1 KiB
JavaScript
|
|
|
|
/**
|
|
* This class is intended as a placeholder for utility methods unrelated
|
|
* to actual classes of the game system or of FoundryVTT
|
|
*/
|
|
export class Misc {
|
|
static isFunction(v) {
|
|
return v && {}.toString.call(v) === '[object Function]';
|
|
}
|
|
|
|
static upperFirst(text) {
|
|
return text.charAt(0).toUpperCase() + text.slice(1);
|
|
}
|
|
|
|
static toSignedString(number){
|
|
const value = parseInt(number)
|
|
const isPositiveNumber = value != NaN && value > 0;
|
|
return isPositiveNumber ? "+"+number : number
|
|
}
|
|
|
|
/**
|
|
* Converts the value to an integer, or to 0 if undefined/null/not representing integer
|
|
* @param {*} value value to convert to an integer using parseInt
|
|
*/
|
|
static toInt(value)
|
|
{
|
|
if (value == undefined)
|
|
{
|
|
return 0;
|
|
}
|
|
const parsed = parseInt(value);
|
|
return isNaN(parsed) ? 0 : parsed;
|
|
}
|
|
|
|
static getFractionHtml(diviseur) {
|
|
if (!diviseur || diviseur <= 1) return undefined;
|
|
switch (diviseur || 1) {
|
|
case 2: return '½';
|
|
case 4: return '¼';
|
|
default: return '1/' + diviseur;
|
|
}
|
|
}
|
|
} |