Set the max try for code generation as a constant

This commit is contained in:
Gregory Trolliet 2020-11-26 17:10:20 +01:00
parent 12045275d5
commit 4d5f50109c

5
db.php
View file

@ -14,6 +14,7 @@ class DataBase
const DEFAULT_SIZE = 3; const DEFAULT_SIZE = 3;
const MAX_SIZE = 9; const MAX_SIZE = 9;
const CLOUD_CODE_LENGTH = 6; const CLOUD_CODE_LENGTH = 6;
const CLOUD_CODE_MAXTRY = 10;
private $db; private $db;
private $cloud; private $cloud;
@ -217,10 +218,10 @@ class DataBase
$duration = self::DEFAULT_DURATION; $duration = self::DEFAULT_DURATION;
} }
for ($i = 0; $i < 10; $i++) { for ($i = 0; $i < self::CLOUD_CODE_MAXTRY; $i++) {
$code = bin2hex(random_bytes(self::CLOUD_CODE_LENGTH)); $code = bin2hex(random_bytes(self::CLOUD_CODE_LENGTH));
$code = '2ae606bfb6d2';
if (!$this->loadCloudByCode($code)) { if (!$this->loadCloudByCode($code)) {
echo 'LOAD CLOUD';
break; break;
} }
} }