import { ITEM_TYPES } from "./constants.js"; import { RdDItem } from "./item.js"; import { RdDInitiative } from "./initiative.mjs"; import { RdDItemArme } from "./item/arme.js"; /* -------------------------------------------- */ export class RdDItemCompetenceCreature extends RdDItem { static get ITEM_TYPE() { return ITEM_TYPES.competencecreature } static get defaultIcon() { return "systems/foundryvtt-reve-de-dragon/icons/competence_defaut.webp" } isAttaque() { return this.getCategorieAttaque() != undefined } isParade() { return this.system.iscombat && (this.system.categorie_parade ?? '') != '' } isBouclier() { return this.system.categorie_parade.includes('bouclier') } attaqueCreature() { const categorieAttaque = this.getCategorieAttaque() if (categorieAttaque != undefined) { const initative = RdDInitiative.getRollInitiative(this.system.carac_value, this.system.niveau); const attaque = { label: this.name, action: this.isCompetencePossession() ? 'possession' : 'attaque', initOnly: false, arme: new RdDItemArme({ name: this.name, type: ITEM_TYPES.arme, img: this.img, system: { competence: this.name, cac: categorieAttaque == "naturelle" ? "naturelle" : "", niveau: this.system.niveau, initiative: initative, mortalite: this.system.mortalite, dommages: this.system.dommages, equipe: true, resistance: 100, penetration: 0, force: 0, rapide: true, } }), comp: this, carac: { key: this.name, value: this.system.carac_value }, equipe: true, mortalite: this.system.mortalite, dmg: this.system.dommages, initiative: initative }; return attaque } return undefined; } getCategorieAttaque() { switch (this.system.categorie) { case "melee": case "tir": case "lancer": case "naturelle": case "possession": return this.system.categorie } } isDommages() { switch (this.system.categorie) { case "melee": case "tir": case "lancer": case "naturelle": return true } return false } }