2020-12-12 21:58:44 +01:00
|
|
|
|
|
|
|
export class RdDItemArme extends Item {
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
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-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é
|
|
|
|
if (defCategory == 'bouclier') {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (attCategory == defCategory) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
// les épées se parent entre elles
|
|
|
|
if (attCategory.match(/epees-/) && defCategory.match(/epees-/)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (attCategory == 'dagues' && defCategory == 'epees-courtes') {
|
2020-12-12 21:58:44 +01:00
|
|
|
return false;
|
|
|
|
}
|
2021-01-01 22:23:58 +01:00
|
|
|
if (attCategory.match(/epees-(courtes|legeres)/) && defCategory == 'dagues') {
|
2020-12-12 21:58:44 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
// Manage weapon categories when parrying (cf. page 115 )
|
|
|
|
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
|
|
|
}
|