foundryvtt-reve-de-dragon/module/item-competencecreature.js

46 lines
1.6 KiB
JavaScript
Raw Permalink Normal View History

/* -------------------------------------------- */
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) {
2021-01-14 00:35:55 +01:00
rollData.arme = RdDItemCompetenceCreature.toArme(rollData.competence);
}
}
/* -------------------------------------------- */
static toArme(item) {
if (RdDItemCompetenceCreature.isCompetenceAttaque(item)) {
let arme = { name: item.name, data: duplicate(item.data) };
mergeObject(arme.data,
{
competence: item.name,
resistance: 100,
equipe: true,
penetration: 0,
force: 0,
rapide: true
});
return arme;
}
console.error("RdDItemCompetenceCreature.toArme(", item, ") : impossible de transformer l'Item en arme");
return undefined;
}
2021-02-14 09:31:52 +01:00
/* -------------------------------------------- */
static isCompetenceAttaque(item) {
return item.type == 'competencecreature' && item.data.iscombat;
}
2021-02-14 09:31:52 +01:00
/* -------------------------------------------- */
static isCompetenceParade(item) {
return item.type == 'competencecreature' && item.data.isparade;
}
}