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

52 lines
1.8 KiB
JavaScript
Raw Permalink Normal View History

import { Misc } from "./misc.js";
/* -------------------------------------------- */
export class RdDItemCompetenceCreature extends Item {
/* -------------------------------------------- */
static setRollDataCreature(rollData) {
2022-06-12 09:46:58 +02:00
rollData.competence = rollData.competence
2022-06-12 12:14:55 +02:00
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"
2022-06-12 08:17:59 +02:00
rollData.selectedCarac = rollData.carac.carac_creature
2022-06-12 12:14:55 +02:00
if (rollData.competence.system.iscombat) {
rollData.arme = RdDItemCompetenceCreature.toActionArme(rollData.competence);
}
}
/* -------------------------------------------- */
static toActionArme(item) {
if (RdDItemCompetenceCreature.isCompetenceAttaque(item)) {
// si c'est un Item compétence: cloner pour ne pas modifier lma compétence
2022-06-12 09:46:58 +02:00
let arme = (item instanceof Item) ? item.clone(): item;
mergeObject(arme.system,
{
competence: arme.name,
resistance: 100,
equipe: true,
2022-06-12 09:46:58 +02:00
dommagesReels: arme.system.dommages,
penetration: 0,
force: 0,
rapide: true,
action: 'attaque'
});
return arme;
}
console.error("RdDItemCompetenceCreature.toActionArme(", item, ") : impossible de transformer l'Item en arme");
return undefined;
}
2021-02-14 09:31:52 +01:00
/* -------------------------------------------- */
static isCompetenceAttaque(itemData) {
2022-06-12 09:46:58 +02:00
itemData = itemData
2022-06-12 12:14:55 +02:00
return itemData.type == 'competencecreature' && itemData.system.iscombat;
}
2021-02-14 09:31:52 +01:00
/* -------------------------------------------- */
static isCompetenceParade(itemData) {
2022-06-12 09:46:58 +02:00
itemData = itemData
2022-06-12 12:14:55 +02:00
return itemData.type == 'competencecreature' && itemData.system.isparade;
}
}