foundryvtt-reve-de-dragon/module/item-competencecreature.js
2022-06-12 12:14:55 +02:00

51 lines
1.8 KiB
JavaScript

import { Misc } from "./misc.js";
/* -------------------------------------------- */
export class RdDItemCompetenceCreature extends Item {
/* -------------------------------------------- */
static setRollDataCreature(rollData) {
rollData.competence = rollData.competence
rollData.carac = { "carac_creature": { label: rollData.competence.name, value: rollData.competence.system.carac_value } }
rollData.competence.system.defaut_carac = "carac_creature"
rollData.competence.system.categorie = "creature"
rollData.selectedCarac = rollData.carac.carac_creature
if (rollData.competence.system.iscombat) {
rollData.arme = RdDItemCompetenceCreature.toArme(rollData.competence);
}
}
/* -------------------------------------------- */
static toArme(item) {
if (RdDItemCompetenceCreature.isCompetenceAttaque(item)) {
// si c'est un Item compétence: cloner pour ne pas modifier lma compétence
let arme = (item instanceof Item) ? item.clone(): item;
mergeObject(arme.system,
{
competence: arme.name,
resistance: 100,
equipe: true,
dommagesReels: arme.system.dommages,
penetration: 0,
force: 0,
rapide: true
});
return arme;
}
console.error("RdDItemCompetenceCreature.toArme(", item, ") : impossible de transformer l'Item en arme");
return undefined;
}
/* -------------------------------------------- */
static isCompetenceAttaque(itemData) {
itemData = itemData
return itemData.type == 'competencecreature' && itemData.system.iscombat;
}
/* -------------------------------------------- */
static isCompetenceParade(itemData) {
itemData = itemData
return itemData.type == 'competencecreature' && itemData.system.isparade;
}
}