Update random generator reference

Signed-off-by: Rahul Rudragoudar <rr83019@gmail.com>
This commit is contained in:
Rahul Rudragoudar 2021-04-24 19:37:44 +05:30
parent 0d33f51f9e
commit 30bb26473e
No known key found for this signature in database
GPG Key ID: 0D2CE231A7287EBC
2 changed files with 4 additions and 2 deletions

View File

@ -4,6 +4,7 @@ import lc.database.Statements
import java.util.concurrent.{ScheduledThreadPoolExecutor, TimeUnit}
import lc.core.{Captcha, Config}
import lc.core.{Parameters, Size}
import lc.misc.HelperFunctions
class BackgroundTask(throttle: Int, timeLimit: Int) {
@ -39,7 +40,7 @@ class BackgroundTask(throttle: Int, timeLimit: Int) {
}
private def pickRandom[T](list: List[T]): T = {
list(Config.getNextRandomInt(list.size))
list(HelperFunctions.randomNumber(list.size))
}
def beginThread(delay: Int): Unit = {

View File

@ -4,6 +4,7 @@ import lc.captchas._
import lc.captchas.interfaces.ChallengeProvider
import lc.captchas.interfaces.Challenge
import scala.collection.mutable.Map
import lc.misc.HelperFunctions
object CaptchaProviders {
private val providers = Map(
@ -51,7 +52,7 @@ object CaptchaProviders {
def getProvider(param: Parameters): Option[ChallengeProvider] = {
val providerConfig = filterProviderByParam(param).toList
if (providerConfig.length > 0) {
val randomIndex = Config.getNextRandomInt(providerConfig.length)
val randomIndex = HelperFunctions.randomNumber(providerConfig.length)
val providerIndex = providerConfig(randomIndex)._1
val selectedProvider = providers(providerIndex)
selectedProvider.configure(providerConfig(randomIndex)._2)