Ajout du type dans le compendium
This commit is contained in:
parent
63ca47027c
commit
4fb34b51a3
65
module/rdd-compendium-organiser.js
Normal file
65
module/rdd-compendium-organiser.js
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
import { Misc } from "./misc.js";
|
||||||
|
|
||||||
|
const typeDisplayName = {
|
||||||
|
"objet": "Objet",
|
||||||
|
"arme": "Arme",
|
||||||
|
"armure": "Armure",
|
||||||
|
"conteneur": "Conteneur",
|
||||||
|
"competence": "Compétence",
|
||||||
|
"sort": "Sort",
|
||||||
|
"herbe": "Plante",
|
||||||
|
"ingredient": "Ingrédient",
|
||||||
|
"livre": "Livre",
|
||||||
|
"potion": "Potion",
|
||||||
|
"munition": "Munition",
|
||||||
|
"queue": "Queue de dragon",
|
||||||
|
"ombre": "Ombre de Thanatos",
|
||||||
|
"souffle": "Souffle de Dragon",
|
||||||
|
"tete": "Tête de Dragon",
|
||||||
|
"ingredient": "Ingrédient",
|
||||||
|
"rencontresTMR": "Rencontre des TMR",
|
||||||
|
"competencecreature": "Compétence de créature",
|
||||||
|
"nombreastral": "Nombre astral",
|
||||||
|
"casetmr": "Case des TMR",
|
||||||
|
"recettealchimique": "Recette alchimique",
|
||||||
|
"recettecuisine": "Recette de cuisine",
|
||||||
|
"tarot": "Carte de tarot draconique",
|
||||||
|
"tache": "Tâche",
|
||||||
|
"meditation": "Méditation",
|
||||||
|
"monnaie": "Monnaie",
|
||||||
|
"musique": "Morceau de musique",
|
||||||
|
"chant": "Chanson",
|
||||||
|
"danse": "Danse",
|
||||||
|
"jeu": "Jeu",
|
||||||
|
"personnage": "Personnage",
|
||||||
|
"creature": "Créature",
|
||||||
|
"entite": "Entité de cauchemar",
|
||||||
|
"vehicule": "Véhicule"
|
||||||
|
}
|
||||||
|
|
||||||
|
export class RddCompendiumOrganiser {
|
||||||
|
static init() {
|
||||||
|
Hooks.on('renderCompendium', async (pack, html, data) => RddCompendiumOrganiser.onRenderCompendium(pack, html, data))
|
||||||
|
}
|
||||||
|
|
||||||
|
static async onRenderCompendium(pack, html, data) {
|
||||||
|
console.log('onRenderCompendium', pack, html, data);
|
||||||
|
if (pack.metadata.system === 'foundryvtt-reve-de-dragon') {
|
||||||
|
const content = await pack.getContent();
|
||||||
|
|
||||||
|
html.find('.directory-item').each((i, element) => {
|
||||||
|
let entity = content.find(it => it._id === element.dataset.entryId);
|
||||||
|
|
||||||
|
if (entity?.entity === 'Actor' || entity?.entity === 'Item') {
|
||||||
|
const typeName = typeDisplayName[entity.data.type] ?? Misc.upperFirst(entity.data.type);
|
||||||
|
RddCompendiumOrganiser.insertEntityType(element, typeName);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static insertEntityType(element, type) {
|
||||||
|
element.children[1].insertAdjacentHTML('afterbegin', `<label>${type}: </label>`);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -24,6 +24,7 @@ import { RdDCombat } from "./rdd-combat.js";
|
|||||||
import { ChatUtility } from "./chat-utility.js";
|
import { ChatUtility } from "./chat-utility.js";
|
||||||
import { RdDItemCompetence } from "./item-competence.js";
|
import { RdDItemCompetence } from "./item-competence.js";
|
||||||
import { StatusEffects } from "./status-effects.js";
|
import { StatusEffects } from "./status-effects.js";
|
||||||
|
import { RddCompendiumOrganiser } from "./rdd-compendium-organiser.js";
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
/* Foundry VTT Initialization */
|
/* Foundry VTT Initialization */
|
||||||
@ -220,6 +221,7 @@ Hooks.once("init", async function () {
|
|||||||
RdDCombat.init();
|
RdDCombat.init();
|
||||||
RdDTokenHud.init();
|
RdDTokenHud.init();
|
||||||
RdDActor.init();
|
RdDActor.init();
|
||||||
|
RddCompendiumOrganiser.init();
|
||||||
});
|
});
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
Loading…
Reference in New Issue
Block a user