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) {
|
2021-03-31 01:21:53 +02:00
|
|
|
rollData.competence = Misc.data(rollData.competence);
|
2021-01-13 23:47:12 +01:00
|
|
|
rollData.carac = { "carac_creature": { label: rollData.competence.name, value: rollData.competence.data.carac_value } };
|
|
|
|
rollData.competence.data.defaut_carac = "carac_creature";
|
|
|
|
rollData.competence.data.categorie = "creature";
|
2021-11-21 12:04:42 +01:00
|
|
|
rollData.selectedCarac = rollData.carac.carac_creature;
|
2021-01-13 23:47:12 +01:00
|
|
|
if (rollData.competence.data.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
|
|
|
|
let arme = Misc.data( (item instanceof Item) ? item.clone(): item);
|
2021-01-04 00:17:22 +01:00
|
|
|
mergeObject(arme.data,
|
|
|
|
{
|
2021-10-09 00:21:26 +02:00
|
|
|
competence: arme.name,
|
2021-01-04 00:17:22 +01:00
|
|
|
resistance: 100,
|
|
|
|
equipe: true,
|
2021-10-09 00:21:26 +02:00
|
|
|
dommagesReels: arme.data.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) {
|
|
|
|
itemData = Misc.data(itemData);
|
|
|
|
return itemData.type == 'competencecreature' && itemData.data.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) {
|
|
|
|
itemData = Misc.data(itemData);
|
|
|
|
return itemData.type == 'competencecreature' && itemData.data.isparade;
|
2021-01-28 00:27:44 +01:00
|
|
|
}
|
2021-01-04 00:17:22 +01:00
|
|
|
}
|