swade-fr-content/module/modules/swade-fr-init.js

54 lines
1.8 KiB
JavaScript
Raw Normal View History

2021-03-15 09:22:27 +01:00
/************************************************************************************/
Hooks.once('init', () => {
if(typeof Babele !== 'undefined') {
console.log("BABELE LOADED !!!");
Babele.get().register({
module: 'swade-fr',
lang: 'fr',
dir: 'compendiums'
});
}
});
/************************************************************************************/
const transFolder = { "Actor": "Acteur", "Edges": "Atouts"}
const subFolder = { 'Social Edges': 'Atouts sociaux', 'Background Edges': 'Atouts de Background', 'Combat Edges': 'Atouts de combat',
'Leadership Edges': 'Atouts de commandement', 'Legendary Edges': 'Atouts légendaires', 'Power Edges': 'Atouts de pouvoir',
'Professional Edges': 'Atouts professionnels', 'Weird Edges': 'Atouts étranges', 'Edges': 'Atouts' }
/************************************************************************************/
const __fix_folder_names = async ( ) => {
if ( game.customFolders.compendium.folders ) {
for ( let [key, trans] in transFolder) {
for ( let folder of game.customFolders.compendium.folders.entries) {
folder.name = trans;
folder.save(false);
}
}
}
let pack = game.packs.get("swade-core-rules.swade-edges")
pack.locked = false;
let folderEntityIds = pack.index.filter(x => x.name === "#[CF_tempEntity]");
for ( let index of folderEntityIds) {
//console.log("Fold1", index);
let folderEntity = await pack.getEntity(index._id);
let newName = subFolder[folderEntity.data.flags.cf.name];
if ( newName) {
await pack.updateEntity({ _id: index._id, 'flags.cf.name': newName } );
}
}
}
/************************************************************************************/
Hooks.once('ready', () => {
if (game.user.isGM) {
setTimeout( __fix_folder_names, 4000, true, false);
}
2021-03-17 18:10:14 +01:00
});