2020-12-12 21:58:44 +01:00
|
|
|
|
|
|
|
export class RdDItemArme extends Item {
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
static getCategorieArme(arme) {
|
|
|
|
if (arme.data.competence == undefined) {
|
|
|
|
return 'competencecreature';
|
|
|
|
}
|
|
|
|
let compname = arme.data.competence.toLowerCase();
|
|
|
|
|
|
|
|
if (compname.match("hache")) return "hache";
|
|
|
|
if (compname.match("hast")) return "hast";
|
|
|
|
if (compname.match("lance")) return "lance";
|
|
|
|
if (compname.match("bouclier")) return "bouclier";
|
|
|
|
if (compname.match("masse")) return "masse";
|
|
|
|
if (compname.match("fléau")) return "fleau";
|
|
|
|
if (compname.match("epée") || compname.match("épée")) {
|
|
|
|
let armename = arme.name.toLowerCase();
|
|
|
|
if (armename.match("gnome"))
|
|
|
|
return "epee_courte";
|
|
|
|
return "epee_longue";
|
|
|
|
}
|
|
|
|
if (compname.match("dague")) {
|
|
|
|
return "epee_courte";
|
|
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
static needParadeSignificative(armeAttaque, armeParade) {
|
|
|
|
let attCategory = RdDItemArme.getCategorieArme(armeAttaque);
|
|
|
|
let defCategory = RdDItemArme.getCategorieArme(armeParade);
|
|
|
|
if (defCategory == "bouclier" || attCategory == defCategory) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
let armeParadeName = armeParade.name.toLowerCase();
|
|
|
|
let armeAttaqueName = armeAttaque.name.toLowerCase();
|
|
|
|
if (armeParadeName.match("dague") && armeAttaqueName.match(/((e|é)pée dragone|esparlongue|demi-dragonne)/)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
// Manage weapon categories when parrying (cf. page 115 )
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
static armeUneOuDeuxMains(arme, aUneMain) {
|
|
|
|
arme.data.unemain = arme.data.unemain || !arme.data.deuxmains;
|
|
|
|
const uneOuDeuxMains = arme.data.unemain && arme.data.deuxmains;
|
2020-12-15 02:20:24 +01:00
|
|
|
const containsSlash = !Number.isInteger(arme.data.dommages) && arme.data.dommages.includes("/");
|
|
|
|
if (containsSlash) { // Sanity check
|
2020-12-12 21:58:44 +01:00
|
|
|
arme = duplicate(arme);
|
|
|
|
|
|
|
|
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-15 02:20:24 +01:00
|
|
|
if (uneOuDeuxMains != containsSlash) {
|
2020-12-12 21:58:44 +01:00
|
|
|
ui.notifications.info("Les dommages de l'arme à 1/2 mains " + arme.name + " ne sont pas corrects (ie sous la forme X/Y)");
|
|
|
|
}
|
|
|
|
return arme;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|