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.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 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, action: 'attaque' }); return arme; } console.error("RdDItemCompetenceCreature.toActionArme(", 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; } }