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

50 lines
1.7 KiB
JavaScript
Raw Normal View History

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) {
2021-01-14 00:35:55 +01:00
rollData.arme = RdDItemCompetenceCreature.toArme(rollData.competence);
}
}
/* -------------------------------------------- */
static toArme(itemData) {
if (RdDItemCompetenceCreature.isCompetenceAttaque(itemData)) {
2021-04-03 13:03:58 +02:00
let arme = duplicate(Misc.data(itemData));
mergeObject(arme.data,
{
2021-04-03 13:03:58 +02:00
competence: arme.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;
}
2021-02-14 09:31:52 +01:00
/* -------------------------------------------- */
static isCompetenceAttaque(itemData) {
itemData = Misc.data(itemData);
return itemData.type == 'competencecreature' && itemData.data.iscombat;
}
2021-02-14 09:31:52 +01:00
/* -------------------------------------------- */
static isCompetenceParade(itemData) {
itemData = Misc.data(itemData);
return itemData.type == 'competencecreature' && itemData.data.isparade;
}
}