Merge branch 'type-compendium' into 'v1.3'

Ajout du type dans le compendium

See merge request LeRatierBretonnien/foundryvtt-reve-de-dragon!134
This commit is contained in:
Leratier Bretonnien 2021-01-26 06:48:39 +00:00
commit 11a34382a3
2 changed files with 67 additions and 0 deletions

View 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>`);
}
}

View File

@ -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();
}); });
/* -------------------------------------------- */ /* -------------------------------------------- */