81 lines
2.2 KiB
JavaScript
81 lines
2.2 KiB
JavaScript
import { ITEM_TYPES } from "./constants.js";
|
|
import { RdDItem } from "./item.js";
|
|
import { RdDInitiative } from "./initiative.mjs";
|
|
|
|
/* -------------------------------------------- */
|
|
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" }
|
|
|
|
isParade() { return this.system.iscombat && (this.system.categorie_parade ?? '') != '' }
|
|
isBouclier() { return this.system.categorie_parade.includes('bouclier') }
|
|
|
|
static attaqueCreature(comp) {
|
|
const categorieAttaque = comp.getCategorieAttaque()
|
|
if (categorieAttaque != undefined) {
|
|
const initative = RdDInitiative.calculInitiative(comp.system.niveau, comp.system.carac_value);
|
|
const armeComp = new RdDItem({
|
|
name: comp.name,
|
|
type: ITEM_TYPES.arme,
|
|
img: comp.img,
|
|
system: {
|
|
competence: comp.name,
|
|
cac: categorieAttaque == "naturelle" ? "naturelle" : "",
|
|
niveau: comp.system.niveau,
|
|
initiative: initative,
|
|
mortalite: comp.system.mortalite,
|
|
dommages: comp.system.dommages,
|
|
equipe: true,
|
|
resistance: 100,
|
|
penetration: 0,
|
|
force: 0,
|
|
rapide: true,
|
|
}
|
|
});
|
|
const attaque = {
|
|
name: comp.name,
|
|
action: comp.isCompetencePossession() ? 'possession' : 'attaque',
|
|
initOnly: false,
|
|
arme: armeComp,
|
|
comp: comp,
|
|
carac: { key: comp.name, value: comp.system.carac_value },
|
|
equipe: true,
|
|
mortalite: comp.system.mortalite,
|
|
dmg: comp.system.dommages,
|
|
initiative: initative
|
|
};
|
|
return attaque
|
|
}
|
|
return undefined;
|
|
}
|
|
|
|
isAttaque() {
|
|
return this.getCategorieAttaque() != 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
|
|
}
|
|
|
|
}
|