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) {
|
2022-07-03 15:32:20 +02:00
|
|
|
rollData.arme = RdDItemCompetenceCreature.toActionArme(rollData.competence);
|
2021-01-13 23:47:12 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-04 00:17:22 +01:00
|
|
|
/* -------------------------------------------- */
|
2022-07-03 15:32:20 +02:00
|
|
|
static toActionArme(item) {
|
2021-10-09 00:21:26 +02:00
|
|
|
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,
|
2022-07-03 15:32:20 +02:00
|
|
|
rapide: true,
|
|
|
|
action: 'attaque'
|
2021-01-04 00:17:22 +01:00
|
|
|
});
|
|
|
|
return arme;
|
|
|
|
}
|
2022-07-03 15:32:20 +02:00
|
|
|
console.error("RdDItemCompetenceCreature.toActionArme(", 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
|
|
|
}
|