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

Infocovid random sign

parent 26870388
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -15,10 +15,15 @@ class CommandInfoCovid{
return Math.floor(Math.random()*(y-x) +x)
}
replaceRandomIntString(str, min, max){
return str.replaceAll('<random_int>', ()=>this.getRandomInt(min,max));
}
replaceAllSign(str){
return str.replaceAll('<signe>', ()=>{ return Math.floor(Math.random()*2)? '+' : '-'});
}
replaceSmallRandomIntString(str){
const smallRandom = this.getRandomInt(1,5);
const plur = (smallRandom > 1) ? 's' : '';
......@@ -40,7 +45,7 @@ class CommandInfoCovid{
getRandomAction(){
const action = this.actions[Math.floor(Math.random()*this.actions.length)];
return this.replaceRandomIntString(this.replaceSmallRandomIntString(action), 1, 24);
return this.replaceAllSign(this.replaceRandomIntString(this.replaceSmallRandomIntString(action), 1, 24));
}
getRandomTemps(){
......
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