25d7a447a8
Ajout de méthode Misc.data pour accéder aux data des Actor/Item Dans le cas où on est sur un Actor/Item, retourne le document (noeud data) Dans les autres cas, retourne l'objet lkui même (donc, le document) Du coup, on devrait pouvoir facilement changer en 0.8.0
51 lines
1.7 KiB
JavaScript
51 lines
1.7 KiB
JavaScript
import { Misc } from "./misc.js";
|
|
|
|
/* -------------------------------------------- */
|
|
export class RdDItemCompetenceCreature extends Item {
|
|
|
|
/* -------------------------------------------- */
|
|
static setRollDataCreature(rollData) {
|
|
rollData.carac = { "carac_creature": { label: rollData.competence.name, value: rollData.competence.data.carac_value } };
|
|
rollData.competence = duplicate(rollData.competence);
|
|
rollData.competence.data.defaut_carac = "carac_creature";
|
|
rollData.competence.data.categorie = "creature";
|
|
rollData.selectedCarac = rollData.carac.carac_creature;
|
|
if (rollData.competence.data.iscombat) {
|
|
rollData.arme = RdDItemCompetenceCreature.toArme(rollData.competence);
|
|
}
|
|
|
|
}
|
|
|
|
/* -------------------------------------------- */
|
|
static toArme(itemData) {
|
|
if (RdDItemCompetenceCreature.isCompetenceAttaque(itemData)) {
|
|
itemData = Misc.data(itemData);
|
|
let arme = { name: itemData.name, data: duplicate(itemData) };
|
|
mergeObject(arme.data,
|
|
{
|
|
competence: itemData.name,
|
|
resistance: 100,
|
|
equipe: true,
|
|
penetration: 0,
|
|
force: 0,
|
|
rapide: true
|
|
});
|
|
return arme;
|
|
}
|
|
console.error("RdDItemCompetenceCreature.toArme(", itemData, ") : impossible de transformer l'Item en arme");
|
|
return undefined;
|
|
}
|
|
|
|
/* -------------------------------------------- */
|
|
static isCompetenceAttaque(itemData) {
|
|
itemData = Misc.data(itemData);
|
|
return itemData.type == 'competencecreature' && itemData.data.iscombat;
|
|
}
|
|
|
|
/* -------------------------------------------- */
|
|
static isCompetenceParade(itemData) {
|
|
itemData = Misc.data(itemData);
|
|
return itemData.type == 'competencecreature' && itemData.data.isparade;
|
|
}
|
|
}
|