2022-11-22 02:12:37 +01:00
|
|
|
|
2022-09-20 00:12:25 +02:00
|
|
|
import { RdDCombatManager } from "./rdd-combat.js";
|
2021-03-22 20:10:37 +01:00
|
|
|
|
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-11-22 02:12:37 +01:00
|
|
|
rollData.arme = RdDItemCompetenceCreature.armeNaturelle(rollData.competence);
|
2021-01-13 23:47:12 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-04 00:17:22 +01:00
|
|
|
/* -------------------------------------------- */
|
2022-11-22 02:12:37 +01:00
|
|
|
static armeNaturelle(competencecreature) {
|
2022-09-20 00:12:25 +02:00
|
|
|
if (RdDItemCompetenceCreature.isCompetenceAttaque(competencecreature)) {
|
2021-10-09 00:21:26 +02:00
|
|
|
// si c'est un Item compétence: cloner pour ne pas modifier lma compétence
|
2022-09-20 00:12:25 +02:00
|
|
|
let arme = (competencecreature instanceof Item) ? competencecreature.clone(): competencecreature;
|
2022-06-12 09:46:58 +02:00
|
|
|
mergeObject(arme.system,
|
2021-01-04 00:17:22 +01:00
|
|
|
{
|
2021-10-09 00:21:26 +02:00
|
|
|
competence: arme.name,
|
2022-09-20 00:12:25 +02:00
|
|
|
initiative: RdDCombatManager.calculInitiative(competencecreature.system.niveau, competencecreature.system.carac_value),
|
|
|
|
niveau: competencecreature.system.niveau,
|
2021-01-04 00:17:22 +01:00
|
|
|
equipe: true,
|
2022-09-20 00:12:25 +02:00
|
|
|
resistance: 100,
|
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,
|
2022-09-20 00:12:25 +02:00
|
|
|
cac: competencecreature.system.isnaturelle ? "naturelle" : "",
|
2022-07-03 15:32:20 +02:00
|
|
|
action: 'attaque'
|
2021-01-04 00:17:22 +01:00
|
|
|
});
|
|
|
|
return arme;
|
|
|
|
}
|
2022-09-20 00:12:25 +02:00
|
|
|
console.error("RdDItemCompetenceCreature.toActionArme(", competencecreature, ") : 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
|
|
|
/* -------------------------------------------- */
|
2022-09-07 18:47:56 +02:00
|
|
|
static isCompetenceAttaque(item) {
|
|
|
|
return item.type == 'competencecreature' && item.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
|
|
|
/* -------------------------------------------- */
|
2022-09-07 18:47:56 +02:00
|
|
|
static isCompetenceParade(item) {
|
2022-09-20 00:12:25 +02:00
|
|
|
return item.type == 'competencecreature' && item.system.categorie_parade !== "";
|
2021-01-28 00:27:44 +01:00
|
|
|
}
|
2021-01-04 00:17:22 +01:00
|
|
|
}
|