2020-12-12 21:58:44 +01:00
|
|
|
|
|
2021-01-02 04:28:43 +01:00
|
|
|
|
|
|
|
|
|
const nomCcategorieParade = {
|
|
|
|
|
"sans-armes": "Sans arme / armes naturelles",
|
|
|
|
|
"hast": "Armes d'hast",
|
|
|
|
|
"batons": "Bâtons",
|
|
|
|
|
"boucliers": "Boucliers",
|
|
|
|
|
"dagues": "Dagues",
|
|
|
|
|
"epees-courtes": "Epées courtes",
|
|
|
|
|
"epees-longues": "Epées longues",
|
|
|
|
|
"epees-lourdes": "Epées lourdes",
|
|
|
|
|
"haches": "Haches",
|
|
|
|
|
"lances": "Lances",
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2020-12-12 21:58:44 +01:00
|
|
|
|
export class RdDItemArme extends Item {
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
2021-01-01 22:25:32 +01:00
|
|
|
|
static getArmeData(item) {
|
|
|
|
|
switch (item ? item.data.type : '') {
|
|
|
|
|
case 'arme': return item.data;
|
|
|
|
|
case 'competencecreature':
|
|
|
|
|
return RdDItemArme._getArmeCompetenceCreature(item);
|
|
|
|
|
}
|
|
|
|
|
return RdDItemArme.mainsNues();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
static _getArmeCompetenceCreature(competenceCreature) {
|
|
|
|
|
let armeData = duplicate(competenceCreature.data);
|
|
|
|
|
armeData.data.resistance = 100;
|
|
|
|
|
armeData.data.competence = armeData.name;
|
|
|
|
|
armeData.data.dommagesReels = armeData.data.dommagesReels || armeData.data.dommages;
|
|
|
|
|
return armeData;
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-02 04:28:43 +01:00
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
static getNomCategorieParade(it) {
|
|
|
|
|
const categorie = it.data? RdDItemArme.getCategorieParade(it) : it;
|
|
|
|
|
return nomCcategorieParade[categorie];
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-01 22:23:58 +01:00
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
static getCategorieParade(arme) {
|
|
|
|
|
if (arme.data.categorie_parade) {
|
|
|
|
|
return arme.data.categorie_parade;
|
|
|
|
|
}
|
|
|
|
|
// pour compatibilité avec des personnages existants
|
|
|
|
|
if (arme.type == 'competencecreature') {
|
|
|
|
|
return arme.data.categorie_parade || (arme.data.isparade ? 'sans-armes' : '');
|
|
|
|
|
}
|
|
|
|
|
if (!arme.type.match(/arme|competencecreature/)) {
|
|
|
|
|
return '';
|
|
|
|
|
}
|
2020-12-12 21:58:44 +01:00
|
|
|
|
if (arme.data.competence == undefined) {
|
|
|
|
|
return 'competencecreature';
|
|
|
|
|
}
|
|
|
|
|
let compname = arme.data.competence.toLowerCase();
|
2021-01-01 22:23:58 +01:00
|
|
|
|
if (compname.match(/^(dague de jet|javelot|fouet|arc|arbalête|fronde|hache de jet|fléau)$/)) return '';
|
2020-12-12 21:58:44 +01:00
|
|
|
|
|
2021-01-01 22:23:58 +01:00
|
|
|
|
if (compname.match('hache')) return 'haches';
|
|
|
|
|
if (compname.match('hast')) return 'hast';
|
|
|
|
|
if (compname.match('lance')) return 'lances';
|
|
|
|
|
if (compname.match('bouclier')) return 'boucliers';
|
|
|
|
|
if (compname.match('masse')) return 'masses';
|
|
|
|
|
if (compname.match('epée') || compname.match('épée')) {
|
|
|
|
|
if (arme.name.toLowerCase().match(/(gnome)/))
|
|
|
|
|
return 'epees-courtes';
|
|
|
|
|
if (arme.name.toLowerCase().match(/((e|é)pée dragone|esparlongue|demi-dragonne)/))
|
|
|
|
|
return 'epees-longues';
|
|
|
|
|
return 'epees-lourdes';
|
2020-12-12 21:58:44 +01:00
|
|
|
|
}
|
2021-01-01 22:23:58 +01:00
|
|
|
|
if (compname.match('dague')) {
|
|
|
|
|
return 'dagues';
|
2020-12-12 21:58:44 +01:00
|
|
|
|
}
|
2021-01-01 22:23:58 +01:00
|
|
|
|
return 'sans-armes';
|
2020-12-12 21:58:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
static needParadeSignificative(armeAttaque, armeParade) {
|
2021-01-02 04:28:43 +01:00
|
|
|
|
// categories d'armes à la parade (cf. page 115 )
|
2021-01-01 22:23:58 +01:00
|
|
|
|
let attCategory = RdDItemArme.getCategorieParade(armeAttaque);
|
|
|
|
|
let defCategory = RdDItemArme.getCategorieParade(armeParade);
|
|
|
|
|
// bouclier et mêmes catégorie: peuvent se parer sans difficulté
|
2021-01-02 04:28:43 +01:00
|
|
|
|
if (defCategory == 'boucliers') {
|
2021-01-01 22:23:58 +01:00
|
|
|
|
return false;
|
|
|
|
|
}
|
2021-01-02 04:28:43 +01:00
|
|
|
|
// Parer avec une hache ou une arme d’hast exige toujours une signi$cative
|
|
|
|
|
if (defCategory.match(/(hast|haches)/)) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
if (defCategory == attCategory) {
|
2021-01-01 22:23:58 +01:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
// les épées se parent entre elles
|
2021-01-02 04:28:43 +01:00
|
|
|
|
if (defCategory.match(/epees-/) && attCategory.match(/epees-/)) {
|
2021-01-01 22:23:58 +01:00
|
|
|
|
return false;
|
|
|
|
|
}
|
2021-01-02 04:28:43 +01:00
|
|
|
|
// l'épée gnome pare la dague
|
|
|
|
|
if (defCategory == 'epees-courtes' && attCategory == 'dagues') {
|
2020-12-12 21:58:44 +01:00
|
|
|
|
return false;
|
|
|
|
|
}
|
2021-01-02 04:28:43 +01:00
|
|
|
|
// la dague pare les épées courtes et légères
|
|
|
|
|
if (defCategory == 'dagues' && attCategory.match(/epees-(courtes|legeres)/)) {
|
2020-12-12 21:58:44 +01:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
static armeUneOuDeuxMains(arme, aUneMain) {
|
2020-12-16 23:02:15 +01:00
|
|
|
|
if (arme) {
|
|
|
|
|
arme.data.unemain = arme.data.unemain || !arme.data.deuxmains;
|
|
|
|
|
const uneOuDeuxMains = arme.data.unemain && arme.data.deuxmains;
|
|
|
|
|
const containsSlash = !Number.isInteger(arme.data.dommages) && arme.data.dommages.includes("/");
|
|
|
|
|
if (containsSlash) { // Sanity check
|
|
|
|
|
arme = duplicate(arme);
|
2020-12-12 21:58:44 +01:00
|
|
|
|
|
2020-12-16 23:02:15 +01:00
|
|
|
|
const tableauDegats = arme.data.dommages.split("/");
|
|
|
|
|
if (aUneMain)
|
|
|
|
|
arme.data.dommagesReels = Number(tableauDegats[0]);
|
|
|
|
|
else // 2 mains
|
|
|
|
|
arme.data.dommagesReels = Number(tableauDegats[1]);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
arme.data.dommagesReels = Number(arme.data.dommages);
|
|
|
|
|
}
|
2020-12-12 21:58:44 +01:00
|
|
|
|
|
2020-12-16 23:02:15 +01:00
|
|
|
|
if (uneOuDeuxMains != containsSlash) {
|
|
|
|
|
ui.notifications.info("Les dommages de l'arme à 1/2 mains " + arme.name + " ne sont pas corrects (ie sous la forme X/Y)");
|
|
|
|
|
}
|
2020-12-12 21:58:44 +01:00
|
|
|
|
}
|
|
|
|
|
return arme;
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-16 23:02:15 +01:00
|
|
|
|
static mainsNues() {
|
2020-12-17 00:23:40 +01:00
|
|
|
|
const mainsNues = {
|
2021-01-01 22:23:58 +01:00
|
|
|
|
name: 'Mains nues',
|
|
|
|
|
data: { unemain: true, deuxmains: false, dommages: 0, dommagesReels: 0, mortalite: 'non-mortel', competence: 'Corps à corps', categorie_parade: 'sans-armes' }
|
2020-12-17 00:23:40 +01:00
|
|
|
|
};
|
|
|
|
|
return mainsNues
|
2020-12-16 23:02:15 +01:00
|
|
|
|
}
|
2020-12-12 21:58:44 +01:00
|
|
|
|
}
|