Support /astro avec noms partiels ou numériques
=> fix /astro Château Dromant => support /astro chat => support /astro 12
This commit is contained in:
@ -325,11 +325,26 @@ export class RdDCalendrier extends Application {
|
||||
}
|
||||
}
|
||||
|
||||
findHeure(heure) {
|
||||
heure = Grammar.toLowerCaseNoAccent(heure);
|
||||
let parHeureOuLabel = Object.values(heuresDef).filter(it => (it.heure+1) == heure || Grammar.toLowerCaseNoAccent(it.label) == heure);
|
||||
if (parHeureOuLabel.length == 1) {
|
||||
return parHeureOuLabel[0];
|
||||
}
|
||||
let parLabelPartiel = Object.values(heuresDef).filter(it => Grammar.toLowerCaseNoAccent(it.label).includes(heure));
|
||||
const matchLength = heure.length;
|
||||
if(parLabelPartiel.length > 0) {
|
||||
parLabelPartiel.sort((a,b)=> (a.label.length - matchLength)^2 - (b.label.length- matchLength)^2);
|
||||
return parLabelPartiel[0];
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getAjustementAstrologique(heureNaissance, name = 'inconnu') {
|
||||
let heure = Grammar.toLowerCaseNoAccent(heureNaissance);
|
||||
if (heure && heuresDef[heure]) {
|
||||
let hn = heuresDef[heure].heure;
|
||||
getAjustementAstrologique(heureNaissance, name = undefined) {
|
||||
let defHeure = this.findHeure(heureNaissance);
|
||||
if (defHeure) {
|
||||
let hn = defHeure.heure;
|
||||
let chiffreAstral = this.getCurrentNombreAstral() ?? 0;
|
||||
let heureCourante = this.calendrier.heureRdD;
|
||||
let ecartChance = (hn + chiffreAstral - heureCourante) % 12;
|
||||
@ -340,9 +355,12 @@ export class RdDCalendrier extends Application {
|
||||
case 3: case 9: return -2;
|
||||
}
|
||||
}
|
||||
else {
|
||||
else if (name) {
|
||||
ui.notifications.warn(name + " n'a pas d'heure de naissance, ou elle est incorrecte : " + heureNaissance);
|
||||
}
|
||||
else{
|
||||
ui.notifications.warn(heureNaissance+" ne correspond pas à une heure de naissance");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user