|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Klass DistributionAjax. |
|
5
|
|
|
* @author Niklas Dougherty |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
declare(strict_types=1); |
|
9
|
|
|
|
|
10
|
|
|
namespace Tips\Moduler\Ajax; |
|
11
|
|
|
|
|
12
|
|
|
use Tips\Klasser\Preludium; |
|
13
|
|
|
use Tips\Klasser\Spel; |
|
14
|
|
|
use Tips\Klasser\Tips; |
|
15
|
|
|
use Tips\Moduler\Distribution; |
|
16
|
|
|
use Tips\Egenskaper\Ajax; |
|
17
|
|
|
use Tips\Moduler\Distribution\Konstanter; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Ajaxanrop ligger utanför ordinarie ordning. |
|
21
|
|
|
*/ |
|
22
|
|
|
require_once dirname(__FILE__) . '/../../../vendor/autoload.php'; |
|
23
|
|
|
new Preludium(); |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Klass DistributionAjax. |
|
27
|
|
|
* @SuppressWarnings("PHPMD.UnusedPrivateMethod") |
|
28
|
|
|
*/ |
|
29
|
|
|
final class DistributionAjax { |
|
30
|
|
|
use Ajax; |
|
|
|
|
|
|
31
|
|
|
use Konstanter; |
|
32
|
|
|
|
|
33
|
|
|
private Spel $spel; |
|
34
|
|
|
private Tips $tips; |
|
35
|
|
|
private Distribution $distribution; |
|
36
|
|
|
|
|
37
|
|
|
public function __construct() { |
|
38
|
|
|
$this->spel = new Spel(); |
|
39
|
|
|
$this->tips = new Tips($this->spel); |
|
40
|
|
|
$this->distribution = new Distribution($this->tips->utdelning, $this->tips->odds, $this->tips->streck, $this->tips->matcher); |
|
41
|
|
|
$this->förgrena(); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* Håll minprocent inom godtagbara intervall. |
|
46
|
|
|
*/ |
|
47
|
|
|
private function distribution_minprocent(): void { |
|
|
|
|
|
|
48
|
|
|
$this->distribution->minprocent = (float) $this->db_preferenser->validera_indata('distribution_minprocent', self::DISTRIBUTION_GRUND_MIN_MIN, self::DISTRIBUTION_GRUND_MIN_MAX, self::DISTRIBUTION_GRUND_MIN_STD, 'distribution.minprocent'); |
|
|
|
|
|
|
49
|
|
|
$this->distribution->maxprocent = (float) $this->db_preferenser->validera_indata('distribution_maxprocent', self::DISTRIBUTION_GRUND_MAX_MIN, self::DISTRIBUTION_GRUND_MAX_MAX, self::DISTRIBUTION_GRUND_MAX_STD, 'distribution.maxprocent'); |
|
|
|
|
|
|
50
|
|
|
$this->db_preferenser->komparera_preferenser($this->distribution->minprocent, $this->distribution->maxprocent, self::DISTRIBUTION_GRUND_MIN_STD, self::DISTRIBUTION_GRUND_MAX_STD, 'distribution.minprocent', 'distribution.maxprocent'); |
|
51
|
|
|
$this->distribution->spara_omgång($this->tips); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* Håll grundläggande minprocent inom godtagbara intervall. |
|
56
|
|
|
*/ |
|
57
|
|
|
private function grund_minprocent(): void { |
|
|
|
|
|
|
58
|
|
|
$grund_minprocent = (float) $this->db_preferenser->validera_indata('grund_minprocent', self::DISTRIBUTION_GRUND_MIN_MIN, self::DISTRIBUTION_GRUND_MIN_MAX, self::DISTRIBUTION_GRUND_MIN_STD, 'distribution.grund_minprocent'); |
|
|
|
|
|
|
59
|
|
|
$grund_maxprocent = (float) $this->db_preferenser->validera_indata('grund_maxprocent', self::DISTRIBUTION_GRUND_MAX_MIN, self::DISTRIBUTION_GRUND_MAX_MAX, self::DISTRIBUTION_GRUND_MAX_STD, 'distribution.grund_maxprocent'); |
|
|
|
|
|
|
60
|
|
|
$this->db_preferenser->komparera_preferenser($grund_minprocent, $grund_maxprocent, self::DISTRIBUTION_GRUND_MIN_STD, self::DISTRIBUTION_GRUND_MAX_STD, 'distribution.grund_minprocent', 'distribution.grund_maxprocent'); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* Spara attraktionsfaktor. |
|
65
|
|
|
*/ |
|
66
|
|
|
private function attraktionsfaktor(): void { |
|
|
|
|
|
|
67
|
|
|
$this->ändra_attraktionsfaktor('distribution'); |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
new DistributionAjax(); |
|
72
|
|
|
|