2021-03-22 20:10:37 +01:00
|
|
|
import { Misc } from "./misc.js";
|
|
|
|
|
2021-01-04 00:17:22 +01:00
|
|
|
/* -------------------------------------------- */
|
|
|
|
export class RdDItemCompetenceCreature extends Item {
|
|
|
|
|
2021-01-13 23:47:12 +01:00
|
|
|
/* -------------------------------------------- */
|
|
|
|
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) {
|
2021-01-14 00:35:55 +01:00
|
|
|
rollData.arme = RdDItemCompetenceCreature.toArme(rollData.competence);
|
2021-01-13 23:47:12 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-04 00:17:22 +01:00
|
|
|
/* -------------------------------------------- */
|
2021-10-09 00:21:26 +02:00
|
|
|
static toArme(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,
|
2021-01-04 00:17:22 +01:00
|
|
|
{
|
2021-10-09 00:21:26 +02:00
|
|
|
competence: arme.name,
|
2021-01-04 00:17:22 +01:00
|
|
|
resistance: 100,
|
|
|
|
equipe: true,
|
2022-06-12 09:46:58 +02:00
|
|
|
dommagesReels: arme.system.dommages,
|
2021-01-04 00:17:22 +01:00
|
|
|
penetration: 0,
|
|
|
|
force: 0,
|
|
|
|
rapide: true
|
|
|
|
});
|
|
|
|
return arme;
|
|
|
|
}
|
2021-10-09 00:21:26 +02:00
|
|
|
console.error("RdDItemCompetenceCreature.toArme(", item, ") : impossible de transformer l'Item en arme");
|
2021-01-04 00:17:22 +01:00
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
|
2021-02-14 09:31:52 +01:00
|
|
|
/* -------------------------------------------- */
|
2021-03-22 20:10:37 +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-01-28 00:27:44 +01:00
|
|
|
}
|
2021-03-22 20:10:37 +01:00
|
|
|
|
2021-02-14 09:31:52 +01:00
|
|
|
/* -------------------------------------------- */
|
2021-03-22 20:10:37 +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;
|
2021-01-28 00:27:44 +01:00
|
|
|
}
|
2021-01-04 00:17:22 +01:00
|
|
|
}
|