|
|
|
@ -261,25 +261,8 @@ export class RdDUtility {
|
|
|
|
|
'systems/foundryvtt-reve-de-dragon/templates/chat-fabriquer-potion-base.html',
|
|
|
|
|
'systems/foundryvtt-reve-de-dragon/templates/chat-signe-draconique-actor.html'
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
// foundry et options
|
|
|
|
|
Handlebars.registerHelper('RDD_CONFIG', path => RDD_CONFIG[path])
|
|
|
|
|
Handlebars.registerHelper('linkCompendium', (pack, id, name) => RdDUtility.linkCompendium(pack, id, name));
|
|
|
|
|
Handlebars.registerHelper('regle-optionnelle', (option) => ReglesOptionnelles.isUsing(option));
|
|
|
|
|
|
|
|
|
|
Handlebars.registerHelper('plusMoins', diff => (diff > 0 ? '+' : '') + Math.round(diff))
|
|
|
|
|
|
|
|
|
|
// Handle v12 removal of this helper
|
|
|
|
|
Handlebars.registerHelper('select', function (selected, options) {
|
|
|
|
|
const escapedValue = RegExp.escape(Handlebars.escapeExpression(selected));
|
|
|
|
|
const rgx = new RegExp(' value=[\"\']' + escapedValue + '[\"\']');
|
|
|
|
|
const html = options.fn(this);
|
|
|
|
|
return html.replace(rgx, "$& selected");
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// logic
|
|
|
|
|
Handlebars.registerHelper('either', (a, b) => a ?? b);
|
|
|
|
|
// string manipulation
|
|
|
|
|
Handlebars.registerHelper('upperFirst', str => Misc.upperFirst(str ?? 'Null'));
|
|
|
|
|
Handlebars.registerHelper('lowerFirst', str => Misc.lowerFirst(str ?? 'Null'));
|
|
|
|
|
Handlebars.registerHelper('uppercase', str => str?.toUpperCase() ?? '');
|
|
|
|
@ -288,53 +271,48 @@ export class RdDUtility {
|
|
|
|
|
Handlebars.registerHelper('grammar-apostrophe', (article, str) => Grammar.apostrophe(article, str));
|
|
|
|
|
Handlebars.registerHelper('grammar-un', str => Grammar.articleIndetermine(str));
|
|
|
|
|
Handlebars.registerHelper('grammar-accord', (genre, ...args) => Grammar.accord(genre, args));
|
|
|
|
|
|
|
|
|
|
// math
|
|
|
|
|
Handlebars.registerHelper('min', (...args) => Math.min(...args.slice(0, -1)));
|
|
|
|
|
Handlebars.registerHelper('repeat', function(n, block) {
|
|
|
|
|
let accum = '';
|
|
|
|
|
for(let i = 0; i < n; ++i){
|
|
|
|
|
accum += block.fn(i)
|
|
|
|
|
}
|
|
|
|
|
return accum
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// tableaux, listes
|
|
|
|
|
Handlebars.registerHelper('array-includes', (array, value) => array.includes(value));
|
|
|
|
|
Handlebars.registerHelper('isLastIndex', (index, list) => index + 1 >= list.length);
|
|
|
|
|
Handlebars.registerHelper('trier', list => list.sort((a, b) => a.name.localeCompare(b.name)));
|
|
|
|
|
|
|
|
|
|
// table de résolution
|
|
|
|
|
|
|
|
|
|
Handlebars.registerHelper('RDD_CONFIG', path => RDD_CONFIG[path])
|
|
|
|
|
Handlebars.registerHelper('computeResolutionScore', (row, col) => RdDResolutionTable.computePercentage(row, col));
|
|
|
|
|
Handlebars.registerHelper('computeResolutionChances', (row, col) => RdDResolutionTable.computeChances(row, col));
|
|
|
|
|
Handlebars.registerHelper('buildLigneInventaire', (item, options) => { return new Handlebars.SafeString(RdDUtility.buildLigneInventaire(item, options)); });
|
|
|
|
|
Handlebars.registerHelper('buildInventaireConteneur', (actorId, itemId, options) => { return new Handlebars.SafeString(RdDUtility.buildInventaireConteneur(actorId, itemId, options)); });
|
|
|
|
|
Handlebars.registerHelper('buildContenuConteneur', (item, options) => { return new Handlebars.SafeString(RdDUtility.buildContenuConteneur(item, options)); });
|
|
|
|
|
Handlebars.registerHelper('calculerPrixCommercant', item => item.calculerPrixCommercant());
|
|
|
|
|
Handlebars.registerHelper('caseTmr-label', coord => TMRUtility.getTMRLabel(coord));
|
|
|
|
|
Handlebars.registerHelper('caseTmr-type', coord => TMRUtility.getTMRType(coord));
|
|
|
|
|
Handlebars.registerHelper('typeTmr-name', type => TMRUtility.typeTmrName(type));
|
|
|
|
|
Handlebars.registerHelper('effetRencontre-name', coord => TMRUtility.typeTmrName(coord));
|
|
|
|
|
|
|
|
|
|
// gestion des dates et heures
|
|
|
|
|
Handlebars.registerHelper('timestamp-imgSigneHeure', (heure) => { return new Handlebars.SafeString(RdDTimestamp.imgSigneHeure(heure)) });
|
|
|
|
|
Handlebars.registerHelper('timestamp-imgSigne', (heure) => { return new Handlebars.SafeString(RdDTimestamp.imgSigne(heure)) });
|
|
|
|
|
Handlebars.registerHelper('timestamp-extract', timestamp => new RdDTimestamp(timestamp).toCalendrier());
|
|
|
|
|
Handlebars.registerHelper('timestamp-formulesDuree', () => RdDTimestamp.formulesDuree());
|
|
|
|
|
Handlebars.registerHelper('timestamp-formulesPeriode', () => RdDTimestamp.formulesPeriode());
|
|
|
|
|
|
|
|
|
|
// informations sur les acteurs
|
|
|
|
|
|
|
|
|
|
Handlebars.registerHelper('actor-default', (actorType, ...path) => RdDBaseActor.getDefaultValue(actorType, path.slice(0, -1)));
|
|
|
|
|
|
|
|
|
|
Handlebars.registerHelper('array-includes', (array, value) => array.includes(value));
|
|
|
|
|
Handlebars.registerHelper('min', (...args) => Math.min(...args.slice(0, -1)));
|
|
|
|
|
Handlebars.registerHelper('isLastIndex', (index, list) => index + 1 >= list.length);
|
|
|
|
|
Handlebars.registerHelper('regle-optionnelle', (option) => ReglesOptionnelles.isUsing(option));
|
|
|
|
|
Handlebars.registerHelper('trier', list => list.sort((a, b) => a.name.localeCompare(b.name)));
|
|
|
|
|
Handlebars.registerHelper('filtreTriCompetences', competences => RdDItemCompetence.triVisible(competences));
|
|
|
|
|
Handlebars.registerHelper('experienceLog-topic', topic => ExperienceLog.labelTopic(topic));
|
|
|
|
|
|
|
|
|
|
// inventaire et marchands
|
|
|
|
|
Handlebars.registerHelper('buildLigneInventaire', (item, options) => { return new Handlebars.SafeString(RdDUtility.buildLigneInventaire(item, options)); });
|
|
|
|
|
Handlebars.registerHelper('buildInventaireConteneur', (actorId, itemId, options) => { return new Handlebars.SafeString(RdDUtility.buildInventaireConteneur(actorId, itemId, options)); });
|
|
|
|
|
Handlebars.registerHelper('buildContenuConteneur', (item, options) => { return new Handlebars.SafeString(RdDUtility.buildContenuConteneur(item, options)); });
|
|
|
|
|
Handlebars.registerHelper('calculerPrixCommercant', item => item.calculerPrixCommercant());
|
|
|
|
|
Handlebars.registerHelper('linkCompendium', (pack, id, name) => RdDUtility.linkCompendium(pack, id, name));
|
|
|
|
|
Handlebars.registerHelper('uniteQuantite', (itemId, actorId) => RdDUtility.getItem(itemId, actorId)?.getUniteQuantite());
|
|
|
|
|
Handlebars.registerHelper('isFieldInventaireModifiable', (type, field) => RdDItem.isFieldInventaireModifiable(type, field));
|
|
|
|
|
// Items
|
|
|
|
|
Handlebars.registerHelper('rarete-getChamp', (rarete, field) => RdDRaretes.getChamp(rarete, field));
|
|
|
|
|
|
|
|
|
|
// TMRs
|
|
|
|
|
Handlebars.registerHelper('caseTmr-label', coord => TMRUtility.getTMRLabel(coord));
|
|
|
|
|
Handlebars.registerHelper('caseTmr-type', coord => TMRUtility.getTMRType(coord));
|
|
|
|
|
Handlebars.registerHelper('typeTmr-name', type => TMRUtility.typeTmrName(type));
|
|
|
|
|
Handlebars.registerHelper('effetRencontre-name', coord => TMRUtility.typeTmrName(coord));
|
|
|
|
|
|
|
|
|
|
Handlebars.registerHelper('plusMoins', diff => (diff > 0 ? '+' : '') + Math.round(diff))
|
|
|
|
|
Handlebars.registerHelper('experienceLog-topic', topic => ExperienceLog.labelTopic(topic));
|
|
|
|
|
|
|
|
|
|
// Handle v12 removal of this helper
|
|
|
|
|
Handlebars.registerHelper('select', function (selected, options) {
|
|
|
|
|
const escapedValue = RegExp.escape(Handlebars.escapeExpression(selected));
|
|
|
|
|
const rgx = new RegExp(' value=[\"\']' + escapedValue + '[\"\']');
|
|
|
|
|
const html = options.fn(this);
|
|
|
|
|
return html.replace(rgx, "$& selected");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return loadTemplates(templatePaths);
|
|
|
|
|
}
|
|
|
|
|