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
Branches
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -15,10 +15,15 @@ class CommandInfoCovid{ ...@@ -15,10 +15,15 @@ class CommandInfoCovid{
return Math.floor(Math.random()*(y-x) +x) return Math.floor(Math.random()*(y-x) +x)
} }
replaceRandomIntString(str, min, max){ replaceRandomIntString(str, min, max){
return str.replaceAll('<random_int>', ()=>this.getRandomInt(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){ replaceSmallRandomIntString(str){
const smallRandom = this.getRandomInt(1,5); const smallRandom = this.getRandomInt(1,5);
const plur = (smallRandom > 1) ? 's' : ''; const plur = (smallRandom > 1) ? 's' : '';
...@@ -40,7 +45,7 @@ class CommandInfoCovid{ ...@@ -40,7 +45,7 @@ class CommandInfoCovid{
getRandomAction(){ getRandomAction(){
const action = this.actions[Math.floor(Math.random()*this.actions.length)]; 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(){ getRandomTemps(){
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter