Fix: détermination niveau de base
simplification: déterminer les catégories en fonction du type d'Item
This commit is contained in:
parent
599fdc752d
commit
9c17f85fa8
@ -65,7 +65,6 @@ export class ExportScriptarium {
|
||||
getActorLine(actor) {
|
||||
const context = Mapping.prepareContext(actor)
|
||||
return this.mapping.map(it => it.getter(actor, context))
|
||||
//.map(it => JSON.stringify(it))
|
||||
.map(it => this.$escapeQuotes(it))
|
||||
.map(it => it.replaceAll("\n", " ").replaceAll("\r", ""))
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { Grammar } from "./grammar.js";
|
||||
import { RdDItem } from "./item.js";
|
||||
import { Misc } from "./misc.js";
|
||||
|
||||
const competenceTroncs = [["Esquive", "Dague", "Corps à corps"],
|
||||
@ -23,12 +24,12 @@ const limitesArchetypes = [
|
||||
];
|
||||
|
||||
/* -------------------------------------------- */
|
||||
const categoriesCompetences = {
|
||||
export const CATEGORIES_COMPETENCES = {
|
||||
"generale": { base: -4, label: "Générales" },
|
||||
"particuliere": { base: -8, label: "Particulières" },
|
||||
"specialisee": { base: -11, label: "Spécialisées" },
|
||||
"connaissance": { base: -11, label: "Connaissances" },
|
||||
"draconic": { base: -11, label: "Draconics" },
|
||||
"draconic": { base: -11, label: "Draconic" },
|
||||
"melee": { base: -6, label: "Mêlée" },
|
||||
"tir": { base: -8, label: "Tir" },
|
||||
"lancer": { base: -8, label: "Lancer" }
|
||||
@ -48,16 +49,14 @@ function _buildCumulXP() {
|
||||
const competence_xp_cumul = _buildCumulXP();
|
||||
|
||||
export class RdDItemCompetence extends Item {
|
||||
/* -------------------------------------------- */
|
||||
static getCategories() {
|
||||
return categoriesCompetences;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
static getLabelCategorie(category) {
|
||||
return categoriesCompetences[category].label;
|
||||
return CATEGORIES_COMPETENCES[category].label;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
static getNiveauBase(category, categories = categoriesCompetences) {
|
||||
/* -------------------------------------------- */
|
||||
static getNiveauBase(category, itemType) {
|
||||
let categories = RdDItem.getCategories(itemType)
|
||||
return categories[category]?.base ?? 0;
|
||||
}
|
||||
|
||||
@ -191,7 +190,7 @@ export class RdDItemCompetence extends Item {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static isNiveauBase(item) {
|
||||
return Number(item.system.niveau) == RdDItemCompetence.getNiveauBase(item.system.categorie, item.getCategories());
|
||||
return Number(item.system.niveau) == RdDItemCompetence.getNiveauBase(item.system.categorie, item.type);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
@ -2,7 +2,7 @@
|
||||
import { ITEM_TYPES } from "./item.js";
|
||||
import { RdDCombatManager } from "./rdd-combat.js";
|
||||
|
||||
const categories = {
|
||||
export const CATEGORIES_COMPETENCES_CREATURES = {
|
||||
"generale": { base: 0, label: "Générale" },
|
||||
"naturelle": { base: 0, label: "Arme naturelle" },
|
||||
"melee": { base: 0, label: "Mêlée" },
|
||||
@ -15,10 +15,6 @@ const categories = {
|
||||
/* -------------------------------------------- */
|
||||
export class RdDItemCompetenceCreature extends Item {
|
||||
|
||||
static getCategories() {
|
||||
return categories;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static setRollDataCreature(rollData) {
|
||||
rollData.carac = { "carac_creature": { label: rollData.competence.name, value: rollData.competence.system.carac_value } }
|
||||
|
@ -12,7 +12,7 @@ import { SystemCompendiums } from "./settings/system-compendiums.js";
|
||||
import { Misc } from "./misc.js";
|
||||
import { RdDTimestamp } from "./time/rdd-timestamp.js";
|
||||
import { RdDItemCompetenceCreature } from "./item-competencecreature.js";
|
||||
import { ITEM_TYPES } from "./item.js";
|
||||
import { ITEM_TYPES, RdDItem } from "./item.js";
|
||||
|
||||
/**
|
||||
* Extend the basic ItemSheet for RdD specific items
|
||||
@ -107,7 +107,7 @@ export class RdDItemSheet extends ItemSheet {
|
||||
}
|
||||
|
||||
const competences = await SystemCompendiums.getCompetences('personnage');
|
||||
formData.categories = this.item.getCategories()
|
||||
formData.categories = RdDItem.getCategories(this.item.type)
|
||||
if (this.item.type == 'tache' || this.item.type == 'livre' || this.item.type == 'meditation' || this.item.type == 'oeuvre') {
|
||||
formData.caracList = foundry.utils.duplicate(game.model.Actor.personnage.carac)
|
||||
formData.caracList["reve-actuel"] = foundry.utils.duplicate(game.model.Actor.personnage.reve.reve)
|
||||
@ -258,7 +258,7 @@ export class RdDItemSheet extends ItemSheet {
|
||||
|
||||
if (this.item.isCompetence()) {
|
||||
const categorie = event.currentTarget.value;
|
||||
const level = RdDItemCompetence.getNiveauBase(categorie, this.item.getCategories());
|
||||
const level = RdDItemCompetence.getNiveauBase(categorie, this.item.type);
|
||||
this.item.system.base = level;
|
||||
this.html.find('[name="system.base"]').val(level);
|
||||
}
|
||||
|
@ -6,8 +6,8 @@ import { RdDTimestamp } from "./time/rdd-timestamp.js";
|
||||
import { RdDUtility } from "./rdd-utility.js";
|
||||
import { SystemCompendiums } from "./settings/system-compendiums.js";
|
||||
import { RdDRaretes } from "./item/raretes.js";
|
||||
import { RdDItemCompetence } from "./item-competence.js";
|
||||
import { RdDItemCompetenceCreature } from "./item-competencecreature.js";
|
||||
import { CATEGORIES_COMPETENCES } from "./item-competence.js";
|
||||
import { CATEGORIES_COMPETENCES_CREATURES } from "./item-competencecreature.js";
|
||||
|
||||
export const ACTOR_TYPES = {
|
||||
personnage: 'personnage',
|
||||
@ -172,9 +172,11 @@ export class RdDItem extends Item {
|
||||
static getItemTypesInventaire(mode = 'materiel') {
|
||||
return typesInventaire[mode ?? 'materiel']
|
||||
}
|
||||
|
||||
static getItemTypesDraconiques() {
|
||||
return typesObjetsDraconiques;
|
||||
}
|
||||
|
||||
static getItemTypesEnvironnement() {
|
||||
return typesEnvironnement;
|
||||
}
|
||||
@ -183,6 +185,16 @@ export class RdDItem extends Item {
|
||||
return typesObjetsOeuvres
|
||||
}
|
||||
|
||||
static getCategories(itemType) {
|
||||
switch (itemType) {
|
||||
case ITEM_TYPES.competence:
|
||||
return CATEGORIES_COMPETENCES
|
||||
case ITEM_TYPES.competencecreature:
|
||||
return CATEGORIES_COMPETENCES_CREATURES
|
||||
}
|
||||
return {}
|
||||
}
|
||||
|
||||
constructor(docData, context = {}) {
|
||||
if (!context.rdd?.ready) {
|
||||
foundry.utils.mergeObject(context, { rdd: { ready: true } });
|
||||
@ -262,13 +274,6 @@ export class RdDItem extends Item {
|
||||
isPresentDansMilieux(milieux) {
|
||||
return this.getEnvironnements(milieux).length > 0
|
||||
}
|
||||
getCategories() {
|
||||
switch (this.type) {
|
||||
case ITEM_TYPES.competence: return RdDItemCompetence.getCategories()
|
||||
case ITEM_TYPES.competencecreature: return RdDItemCompetenceCreature.getCategories()
|
||||
}
|
||||
return {}
|
||||
}
|
||||
|
||||
getEnvironnements(milieux = undefined) {
|
||||
const environnements = this.isInventaire() ? this.system.environnement : undefined;
|
||||
|
Loading…
Reference in New Issue
Block a user