diff --git a/commands/CommandInfoCovid.js b/commands/CommandInfoCovid.js index ca1915d9c023624c43eb33ff4327ac19b170ba73..1109bcd7c27110d91eac46881df96b9bc24ef3a4 100644 --- a/commands/CommandInfoCovid.js +++ b/commands/CommandInfoCovid.js @@ -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(){