Chargement depuis les compendium sélectionnés
Fix, les compendiums systèmes n'étaient pas utilisés pour les herbes et les compétences
This commit is contained in:
parent
97ee5bc331
commit
e78ae3b292
@ -35,6 +35,7 @@ import { ENTITE_BLURETTE, ENTITE_INCARNE, ENTITE_NONINCARNE, HIDE_DICE, SHOW_DIC
|
|||||||
import { RdDConfirm } from "./rdd-confirm.js";
|
import { RdDConfirm } from "./rdd-confirm.js";
|
||||||
import { DialogValidationEncaissement } from "./dialog-validation-encaissement.js";
|
import { DialogValidationEncaissement } from "./dialog-validation-encaissement.js";
|
||||||
import { RdDRencontre } from "./item-rencontre.js";
|
import { RdDRencontre } from "./item-rencontre.js";
|
||||||
|
import { SystemCompendiums } from "./settings/system-compendiums.js";
|
||||||
import { Targets } from "./targets.js";
|
import { Targets } from "./targets.js";
|
||||||
|
|
||||||
const POSSESSION_SANS_DRACONIC = {
|
const POSSESSION_SANS_DRACONIC = {
|
||||||
@ -125,9 +126,9 @@ export class RdDActor extends Actor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isPersonnage) {
|
if (isPersonnage) {
|
||||||
const competences = await RdDUtility.loadItems(it => it.isCompetencePersonnage(), 'foundryvtt-reve-de-dragon.competences');
|
const competences = await SystemCompendiums.getCompetences(actorData.type);
|
||||||
actorData.items = competences.map(i => i.toObject());
|
actorData.items = competences.map(i => i.toObject())
|
||||||
actorData.items = actorData.items.concat(Monnaie.monnaiesStandard());
|
.concat(Monnaie.monnaiesStandard());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
actorData.items = [];
|
actorData.items = [];
|
||||||
|
@ -34,13 +34,6 @@ const categorieCompetences = {
|
|||||||
"lancer": { base: -8, label: "Lancer" }
|
"lancer": { base: -8, label: "Lancer" }
|
||||||
}
|
}
|
||||||
|
|
||||||
const compendiumCompetences = {
|
|
||||||
"personnage": "foundryvtt-reve-de-dragon.competences",
|
|
||||||
"creature": "foundryvtt-reve-de-dragon.competences-creatures",
|
|
||||||
"entite": "foundryvtt-reve-de-dragon.competences-entites"
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
function _buildCumulXP() {
|
function _buildCumulXP() {
|
||||||
let cumulXP = { "-11": 0 };
|
let cumulXP = { "-11": 0 };
|
||||||
let cumul = 0;
|
let cumul = 0;
|
||||||
@ -55,12 +48,6 @@ function _buildCumulXP() {
|
|||||||
const competence_xp_cumul = _buildCumulXP();
|
const competence_xp_cumul = _buildCumulXP();
|
||||||
|
|
||||||
export class RdDItemCompetence extends Item {
|
export class RdDItemCompetence extends Item {
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
|
||||||
static actorCompendium(actorType = undefined) {
|
|
||||||
return compendiumCompetences[actorType ?? 'personnage'];
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static getCategorieCompetences() {
|
static getCategorieCompetences() {
|
||||||
return categorieCompetences;
|
return categorieCompetences;
|
||||||
|
@ -8,6 +8,7 @@ import { HtmlUtility } from "./html-utility.js";
|
|||||||
import { ReglesOptionelles } from "./settings/regles-optionelles.js";
|
import { ReglesOptionelles } from "./settings/regles-optionelles.js";
|
||||||
import { SYSTEM_RDD } from "./constants.js";
|
import { SYSTEM_RDD } from "./constants.js";
|
||||||
import { RdDSheetUtility } from "./rdd-sheet-utility.js";
|
import { RdDSheetUtility } from "./rdd-sheet-utility.js";
|
||||||
|
import { SystemCompendiums } from "./settings/system-compendiums.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extend the basic ItemSheet with some very simple modifications
|
* Extend the basic ItemSheet with some very simple modifications
|
||||||
@ -83,17 +84,18 @@ export class RdDItemSheet extends ItemSheet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const competences = await SystemCompendiums.getCompetences(this.actor?.type);
|
||||||
formData.categorieCompetences = RdDItemCompetence.getCategorieCompetences()
|
formData.categorieCompetences = RdDItemCompetence.getCategorieCompetences()
|
||||||
if (this.item.type == 'tache' || this.item.type == 'livre' || this.item.type == 'meditation' || this.item.type == 'oeuvre') {
|
if (this.item.type == 'tache' || this.item.type == 'livre' || this.item.type == 'meditation' || this.item.type == 'oeuvre') {
|
||||||
formData.caracList = duplicate(game.system.model.Actor.personnage.carac)
|
formData.caracList = duplicate(game.system.model.Actor.personnage.carac)
|
||||||
formData.caracList["reve-actuel"] = duplicate(game.system.model.Actor.personnage.reve.reve)
|
formData.caracList["reve-actuel"] = duplicate(game.system.model.Actor.personnage.reve.reve)
|
||||||
formData.competences = await RdDUtility.loadItems(it => it.isCompetencePersonnage(), RdDItemCompetence.actorCompendium(this.actor?.type))
|
formData.competences = competences;
|
||||||
}
|
}
|
||||||
if (this.item.type == 'arme') {
|
if (this.item.type == 'arme') {
|
||||||
formData.competences = await RdDUtility.loadItems(it => RdDItemCompetence.isCompetenceArme(it), RdDItemCompetence.actorCompendium(this.actor?.type))
|
formData.competences = competences.filter(it => RdDItemCompetence.isCompetenceArme(it));
|
||||||
}
|
}
|
||||||
if (['sort', 'sortreserve'].includes(this.item.type)) {
|
if (['sort', 'sortreserve'].includes(this.item.type)) {
|
||||||
formData.competences = await RdDUtility.loadItems(it => RdDItemCompetence.isDraconic(it), RdDItemCompetence.actorCompendium(this.actor?.type))
|
formData.competences = competences.filter(it => RdDItemCompetence.isDraconic(it));
|
||||||
}
|
}
|
||||||
if (this.item.type == 'recettecuisine') {
|
if (this.item.type == 'recettecuisine') {
|
||||||
formData.ingredients = await TextEditor.enrichHTML(this.object.system.ingredients, {async: true})
|
formData.ingredients = await TextEditor.enrichHTML(this.object.system.ingredients, {async: true})
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { RdDUtility } from "./rdd-utility.js";
|
import { RdDUtility } from "./rdd-utility.js";
|
||||||
import { RdDCalendrier } from "./rdd-calendrier.js";
|
import { RdDCalendrier } from "./rdd-calendrier.js";
|
||||||
import { Grammar } from "./grammar.js";
|
import { Grammar } from "./grammar.js";
|
||||||
|
import { SystemCompendiums } from "./settings/system-compendiums.js";
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
export class RdDHerbes extends Item {
|
export class RdDHerbes extends Item {
|
||||||
@ -12,9 +13,8 @@ export class RdDHerbes extends Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static async listCategorieHerbes(categorie) {
|
static async listCategorieHerbes(categorie) {
|
||||||
return await RdDUtility.loadItems(
|
const herbes = await SystemCompendiums.getWorldOrCompendiumItems('herbe', 'botanique');
|
||||||
it => it.type == 'herbe' && it.system.categorie.toLowerCase() == categorie.toLowerCase(),
|
return herbes.filter(it => Grammar.equalsInsensitive(it.system.categorie, categorie));
|
||||||
'foundryvtt-reve-de-dragon.botanique');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
@ -759,29 +759,6 @@ export class RdDUtility {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
|
||||||
static async loadItems(filter, compendium) {
|
|
||||||
let items = game.items.filter(filter);
|
|
||||||
if (compendium) {
|
|
||||||
const ids = items.map(it => it.id);
|
|
||||||
const names = items.map(it => it.name.toLowerCase());
|
|
||||||
items = items.concat(await RdDUtility.loadCompendium(compendium, it => !ids.includes(it.id) && !names.includes(it.name.toLowerCase()) && filter(it)));
|
|
||||||
}
|
|
||||||
return items;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
|
||||||
static async loadCompendium(compendium, filter = it => true) {
|
|
||||||
let compendiumData = await RdDUtility.loadCompendiumData(compendium);
|
|
||||||
return compendiumData.filter(filter);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
|
||||||
static async loadCompendiumData(compendium) {
|
|
||||||
const pack = game.packs.get(compendium);
|
|
||||||
return await pack?.getDocuments() ?? [];
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static async responseNombreAstral(callData) {
|
static async responseNombreAstral(callData) {
|
||||||
let actor = game.actors.get(callData.id);
|
let actor = game.actors.get(callData.id);
|
||||||
|
@ -55,6 +55,29 @@ export class SystemCompendiums extends FormApplication {
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static async getCompetences(actorType) {
|
||||||
|
switch (actorType ?? 'personnage') {
|
||||||
|
case 'personnage': return await SystemCompendiums.getWorldOrCompendiumItems('competence', 'competences');
|
||||||
|
case 'creature': return await SystemCompendiums.getWorldOrCompendiumItems('competencecreature', 'competences-creatures');
|
||||||
|
case 'entite': return await SystemCompendiums.getWorldOrCompendiumItems('competencecreature', 'competences-entites');
|
||||||
|
case 'vehicule': return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
static async getWorldOrCompendiumItems(itemType, compendium) {
|
||||||
|
let items = game.items.filter(it => it.type == itemType);
|
||||||
|
if (compendium) {
|
||||||
|
const ids = items.map(it => it.id);
|
||||||
|
const names = items.map(it => it.name.toLowerCase());
|
||||||
|
const compendiumItems = await SystemCompendiums.getItems(compendium);
|
||||||
|
items = items.concat(compendiumItems
|
||||||
|
.filter(it => it.type == itemType)
|
||||||
|
.filter(it => !ids.includes(it.id))
|
||||||
|
.filter(it => !names.includes(it.name.toLowerCase())));
|
||||||
|
}
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
static async getItems(compendium, itemType = undefined) {
|
static async getItems(compendium, itemType = undefined) {
|
||||||
const items = await SystemCompendiums.getContent(compendium, 'Item');
|
const items = await SystemCompendiums.getContent(compendium, 'Item');
|
||||||
return itemType ? items.filter(it => it.type == itemType) : items;
|
return itemType ? items.filter(it => it.type == itemType) : items;
|
||||||
|
Loading…
Reference in New Issue
Block a user