Skip to content
Extraits de code Groupes Projets
Valider 2cfb06d8 rédigé par Adrien NUNES's avatar Adrien NUNES
Parcourir les fichiers

Some fix

parent d6ee8396
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -5,9 +5,9 @@ class CommandInfoCovid{
this.infoCovidRegExp = new RegExp('info[ -]covid', 'i');
this.situations = ["êtes cas contact","êtes muni d'un schéma vaccinal complet","êtes positif","êtes non vacciné","avez contracté la covid il y a plus de <random_int> mois", "avez contracté le virus il y a moins de <random_int> mois"];
this.actions = ["effectuer <random_int_m> test<s> à J<signe><random_int>","vous confiner pendant <random_int_f> semaine<s>", "Effectuer <random_int_m> autotest<s>", "Recevoir <random_int_f> dose<s> vaccinale<s> supplémentaire<s>"];
this.actions = ["effectuer <random_int_m> test<s> à J<signe><random_int>","vous confiner pendant <random_int_f> semaine<s>", "effectuer <random_int_m> autotest<s>", "recevoir <random_int_f> dose<s> vaccinale<s> supplémentaire<s>"];
this.temps = ["dans les prochaines <random_int>h", "dans les dernières <random_int>h", "il y a moins de <random_int> mois", "il y a plus de <random_int> mois", "il y a entre <random_int> et <random_int> mois", "dans les <random_int> à <random_int> prochaines heures"];
this.connecteurs = ["et", "ou", "et / ou", "mais également"];
this.connecteurs = ["et", "ou", "et/ou", "mais également", "ou bien"];
this.amplificateurs = ["sauf si vous <situation>", "à moins que vous <situation>", "sauf si vous avez déjà <action> <temps>"];
}
......@@ -16,11 +16,11 @@ class CommandInfoCovid{
}
replaceRandomIntString(str, min, max){
return str.replaceAll('<random_int>', ()=>getRandomInt(min,max));
return str.replaceAll('<random_int>', ()=>this.getRandomInt(min,max));
}
replaceSmallRandomIntString(str){
const smallRandom = getRandomInt(1,5);
const smallRandom = this.getRandomInt(1,5);
const plur = (smallRandom > 1) ? 's' : '';
let newStr = null;
......@@ -40,7 +40,7 @@ class CommandInfoCovid{
getRandomAction(){
const action = this.actions[Math.floor(Math.random()*this.actions.length)];
return this.replaceRandomIntString(replaceSmallRandomIntString(action), 1, 24);
return this.replaceRandomIntString(this.replaceSmallRandomIntString(action), 1, 24);
}
getRandomTemps(){
......@@ -53,7 +53,7 @@ class CommandInfoCovid{
}
getRandomAmplificateur(){
const amplificateur = this.amplificateurs[Math.floor(Math.random()*this.amplificateur.length)];
const amplificateur = this.amplificateurs[Math.floor(Math.random()*this.amplificateurs.length)];
const action = this.getRandomAction();
const situation = this.getRandomSituation();
const temps = this.getRandomTemps();
......@@ -62,7 +62,7 @@ class CommandInfoCovid{
getRandomOptionalPart(getRandomPart){
const connecteur = this.getRandomConnecteur();
const part = this.getRandomPart();
const part = getRandomPart();
const amplificateur = this.getRandomInt(0,2) ? ` ${this.getRandomAmplificateur()}` : '';
return `${connecteur} ${part}${amplificateur}`;
}
......@@ -70,7 +70,7 @@ class CommandInfoCovid{
getAllOptionalPart(getRandomPart){
const optionalPartCount = this.getRandomInt(0,4); //0 à 3
let output = (optionalPartCount > 0) ? ' ' : ''; //On commence avec un espace si on a quelque chose
for(let i = 0; i < optionalSituationCount; i++){
for(let i = 0; i < optionalPartCount; i++){
output += this.getRandomOptionalPart(getRandomPart) + (i < (optionalPartCount - 1) ? ' ' : '');
}
return output;
......@@ -78,9 +78,9 @@ class CommandInfoCovid{
getRandomInfo(){
const situation = this.getRandomSituation();
const optionalSituations = this.getAllOptionalPart(this.getRandomSituation);
const optionalSituations = this.getAllOptionalPart(this.getRandomSituation.bind(this));
const action = this.getRandomAction();
const optionalsActions = this.getAllOptionalPart(this.getRandomAction);
const optionalsActions = this.getAllOptionalPart(this.getRandomAction.bind(this));
return `Si vous ${situation}${optionalSituations}, alors vous devez ${action}${optionalsActions}.` ;
}
......@@ -91,8 +91,7 @@ class CommandInfoCovid{
}
shouldRespond(message){
const resRE = message.content.match(this.quiRegExp);
return resRE !== null;
return message.content.test(this.quiRegExp);
}
}
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter