forked from public/foundryvtt-reve-de-dragon
Ajout categorie_parade
Pour gérer les parades des créatures et améliorer la gestion des armes pouvant parer ou pas
This commit is contained in:
@ -2,40 +2,61 @@
|
||||
export class RdDItemArme extends Item {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static getCategorieArme(arme) {
|
||||
/* -------------------------------------------- */
|
||||
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 '';
|
||||
}
|
||||
if (arme.data.competence == undefined) {
|
||||
return 'competencecreature';
|
||||
}
|
||||
let compname = arme.data.competence.toLowerCase();
|
||||
if (compname.match(/^(dague de jet|javelot|fouet|arc|arbalête|fronde|hache de jet|fléau)$/)) return '';
|
||||
|
||||
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('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';
|
||||
}
|
||||
if (compname.match("dague")) {
|
||||
return "epee_courte";
|
||||
if (compname.match('dague')) {
|
||||
return 'dagues';
|
||||
}
|
||||
return "";
|
||||
return 'sans-armes';
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static needParadeSignificative(armeAttaque, armeParade) {
|
||||
let attCategory = RdDItemArme.getCategorieArme(armeAttaque);
|
||||
let defCategory = RdDItemArme.getCategorieArme(armeParade);
|
||||
if (defCategory == "bouclier" || attCategory == defCategory) {
|
||||
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;
|
||||
}
|
||||
let armeParadeName = armeParade.name.toLowerCase();
|
||||
let armeAttaqueName = armeAttaque.name.toLowerCase();
|
||||
if (armeParadeName.match("dague") && armeAttaqueName.match(/((e|é)pée dragone|esparlongue|demi-dragonne)/)) {
|
||||
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') {
|
||||
return false;
|
||||
}
|
||||
if (attCategory.match(/epees-(courtes|legeres)/) && defCategory == 'dagues') {
|
||||
return false;
|
||||
}
|
||||
// Manage weapon categories when parrying (cf. page 115 )
|
||||
@ -70,8 +91,8 @@ export class RdDItemArme extends Item {
|
||||
|
||||
static mainsNues() {
|
||||
const mainsNues = {
|
||||
name: "Mains nues",
|
||||
data: { unemain: true, deuxmains: false, dommages: 0, dommagesReels: 0, mortalite: 'non-mortel', competence: 'Corps à corps', sansArme:true }
|
||||
name: 'Mains nues',
|
||||
data: { unemain: true, deuxmains: false, dommages: 0, dommagesReels: 0, mortalite: 'non-mortel', competence: 'Corps à corps', categorie_parade: 'sans-armes' }
|
||||
};
|
||||
return mainsNues
|
||||
}
|
||||
|
Reference in New Issue
Block a user