|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Klass Rita. |
|
5
|
|
|
* @author Niklas Dougherty |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
declare(strict_types=1); |
|
9
|
|
|
|
|
10
|
|
|
namespace Tips\Moduler\Vinstgraf; |
|
11
|
|
|
|
|
12
|
|
|
use Tips\Klasser\Graf; |
|
13
|
|
|
use Tips\Klasser\DBPreferenser; |
|
14
|
|
|
use Tips\Klasser\Utdelning; |
|
15
|
|
|
use Tips\Klasser\Prediktioner; |
|
16
|
|
|
use Tips\Klasser\Matcher; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Klass Rita. |
|
20
|
|
|
*/ |
|
21
|
|
|
class Rita { |
|
22
|
|
|
use Konstanter; |
|
23
|
|
|
|
|
24
|
|
|
protected Graf $graf; |
|
25
|
|
|
protected DBPreferenser $db_preferenser; |
|
26
|
|
|
public int $utdelning_13_min = self::UTDELNING_13_MIN_STD; |
|
27
|
|
|
public int $utdelning_13_max = self::UTDELNING_13_MAX_STD; |
|
28
|
|
|
|
|
29
|
1 |
|
public function __construct( |
|
30
|
|
|
protected Utdelning $utdelning, |
|
31
|
|
|
protected Prediktioner $odds, |
|
32
|
|
|
protected Prediktioner $streck, |
|
33
|
|
|
protected Matcher $matcher |
|
34
|
|
|
) { |
|
35
|
1 |
|
$this->db_preferenser = new DBPreferenser($this->utdelning->spel->db); |
|
36
|
1 |
|
$this->graf = new Graf(); |
|
37
|
1 |
|
$this->utdelning_13_min = (int) $this->db_preferenser->hämta_preferens('vinstgraf.utdelning_13_min'); |
|
38
|
1 |
|
$this->utdelning_13_max = (int) $this->db_preferenser->hämta_preferens('vinstgraf.utdelning_13_max'); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Rita punkt för vinstrad i projicerat koordinatsystem. |
|
43
|
|
|
* Högvinst i rött eler blått, övriga i gul nyans. |
|
44
|
|
|
*/ |
|
45
|
|
|
protected function rita(string $tipsrad_012, int $utdelning): void { |
|
46
|
|
|
[$x, $y] = $this->graf->tipsgrafskoordinater($tipsrad_012); |
|
47
|
|
|
$färg = match (true) { |
|
48
|
|
|
$utdelning >= self::UTDELNING_13_MIN_MAX => $this->graf->blå, |
|
|
|
|
|
|
49
|
|
|
$utdelning >= $this->utdelning_13_max => $this->graf->röd, |
|
50
|
|
|
default => $this->graf->gul |
|
51
|
|
|
}; |
|
52
|
|
|
$this->graf->sätt_pixel($x, $y, $färg); |
|
53
|
|
|
} |
|
54
|
|
|
} |
|
55
|
|
|
|