2022-11-22 02:12:37 +01:00
|
|
|
|
2024-09-25 22:56:24 +02:00
|
|
|
import { ITEM_TYPES } from "./item.js";
|
2022-09-20 00:12:25 +02:00
|
|
|
import { RdDCombatManager } from "./rdd-combat.js";
|
2021-03-22 20:10:37 +01:00
|
|
|
|
2024-09-27 22:39:49 +02:00
|
|
|
export const CATEGORIES_COMPETENCES_CREATURES = {
|
2023-06-13 01:55:38 +02:00
|
|
|
"generale": { base: 0, label: "Générale" },
|
|
|
|
"naturelle": { base: 0, label: "Arme naturelle" },
|
|
|
|
"melee": { base: 0, label: "Mêlée" },
|
|
|
|
"parade": { base: 0, label: "Parade" },
|
|
|
|
"tir": { base: 0, label: "Tir" },
|
|
|
|
"lancer": { base: 0, label: "Lancer" },
|
|
|
|
"possession": { base: 0, label: "Possession" },
|
|
|
|
}
|
|
|
|
|
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 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"
|
2023-06-13 01:55:38 +02:00
|
|
|
rollData.selectedCarac = rollData.carac.carac_creature
|
|
|
|
rollData.arme = RdDItemCompetenceCreature.armeCreature(rollData.competence);
|
2021-01-13 23:47:12 +01:00
|
|
|
}
|
|
|
|
|
2021-01-04 00:17:22 +01:00
|
|
|
/* -------------------------------------------- */
|
2023-06-13 01:55:38 +02:00
|
|
|
static armeCreature(item) {
|
|
|
|
const categorieAttaque = RdDItemCompetenceCreature.getCategorieAttaque(item)
|
|
|
|
if (categorieAttaque != undefined) {
|
|
|
|
// si c'est un Item compétence: cloner pour ne pas modifier la compétence
|
|
|
|
let arme = item.clone();
|
2024-06-01 01:53:14 +02:00
|
|
|
return foundry.utils.mergeObject(arme, {
|
2023-06-13 01:55:38 +02:00
|
|
|
action: item.isCompetencePossession() ? 'possession' : 'attaque',
|
|
|
|
system: {
|
|
|
|
competence: arme.name,
|
|
|
|
cac: categorieAttaque == "naturelle" ? "naturelle" : "",
|
|
|
|
niveau: item.system.niveau,
|
|
|
|
initiative: RdDCombatManager.calculInitiative(item.system.niveau, item.system.carac_value),
|
|
|
|
equipe: true,
|
|
|
|
resistance: 100,
|
|
|
|
dommagesReels: arme.system.dommages,
|
|
|
|
penetration: 0,
|
|
|
|
force: 0,
|
|
|
|
rapide: true,
|
|
|
|
}
|
2024-06-01 01:53:14 +02:00
|
|
|
}, { inplace: false });
|
2021-01-04 00:17:22 +01:00
|
|
|
}
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
|
2021-02-14 09:31:52 +01:00
|
|
|
/* -------------------------------------------- */
|
2023-11-04 03:42:39 +01:00
|
|
|
static isCompetenceAttaque(item) {
|
2024-09-25 22:56:24 +02:00
|
|
|
if (item.type == ITEM_TYPES.competencecreature) {
|
2023-11-04 03:42:39 +01:00
|
|
|
switch (item.system.categorie) {
|
|
|
|
case "melee":
|
|
|
|
case "tir":
|
|
|
|
case "lancer":
|
|
|
|
case "naturelle":
|
|
|
|
case "possession":
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return undefined
|
|
|
|
}
|
|
|
|
|
2023-06-13 01:55:38 +02:00
|
|
|
static getCategorieAttaque(item) {
|
2024-09-25 22:56:24 +02:00
|
|
|
if (item.type == ITEM_TYPES.competencecreature) {
|
2023-06-13 01:55:38 +02:00
|
|
|
switch (item.system.categorie) {
|
|
|
|
case "melee":
|
|
|
|
case "tir":
|
|
|
|
case "lancer":
|
|
|
|
case "naturelle":
|
|
|
|
case "possession":
|
2023-11-04 03:42:39 +01:00
|
|
|
case "parade":
|
2023-06-13 01:55:38 +02:00
|
|
|
return item.system.categorie
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return undefined
|
2021-01-28 00:27:44 +01:00
|
|
|
}
|
2023-06-13 01:55:38 +02:00
|
|
|
static isDommages(item) {
|
2024-09-25 22:56:24 +02:00
|
|
|
if (item.type == ITEM_TYPES.competencecreature) {
|
2023-06-13 01:55:38 +02:00
|
|
|
switch (item.system.categorie) {
|
|
|
|
case "melee":
|
|
|
|
case "tir":
|
|
|
|
case "lancer":
|
|
|
|
case "naturelle":
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
static isParade(item) {
|
2024-09-25 22:56:24 +02:00
|
|
|
if (item.type == ITEM_TYPES.competencecreature) {
|
2023-06-13 01:55:38 +02:00
|
|
|
switch (item.system.categorie) {
|
|
|
|
case "melee":
|
|
|
|
case "naturelle":
|
|
|
|
case "parade":
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|