|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Klass SekvensAjax. |
|
5
|
|
|
* @author Niklas Dougherty |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
declare(strict_types=1); |
|
9
|
|
|
|
|
10
|
|
|
namespace Tips\Ajax; |
|
11
|
|
|
|
|
12
|
|
|
use Tips\Klasser\Preludium; |
|
13
|
|
|
use Tips\Klasser\Speltyp; |
|
14
|
|
|
use Tips\Klasser\Spel; |
|
15
|
|
|
use Tips\Klasser\Tips; |
|
16
|
|
|
use Tips\Egenskaper\Ajax; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Ajaxanrop ligger utanför ordinarie ordning. |
|
20
|
|
|
*/ |
|
21
|
1 |
|
require_once dirname(__FILE__) . '/../../vendor/autoload.php'; |
|
22
|
1 |
|
new Preludium(); |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Klass SekvensAjax. |
|
26
|
|
|
* @SuppressWarnings("PHPMD.UnusedPrivateMethod") |
|
27
|
|
|
*/ |
|
28
|
|
|
final class SekvensAjax { |
|
29
|
|
|
use Ajax; |
|
|
|
|
|
|
30
|
|
|
|
|
31
|
|
|
private Spel $spel; |
|
32
|
|
|
private Tips $tips; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Inititiera. |
|
36
|
|
|
*/ |
|
37
|
1 |
|
public function __construct() { |
|
38
|
1 |
|
$this->spel = new Spel(); |
|
39
|
1 |
|
$this->tips = new Tips($this->spel); |
|
40
|
1 |
|
$this->förgrena(); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* Radera sekvens. |
|
45
|
|
|
* js/funktioner.js: radera_sekvens, omgång, speltyp |
|
46
|
|
|
*/ |
|
47
|
1 |
|
private function radera_sekvens(): void { |
|
48
|
1 |
|
$sekvens = (int) filter_var($_REQUEST['radera_sekvens'], FILTER_VALIDATE_INT); |
|
49
|
1 |
|
$omgång = (int) filter_var($_REQUEST['omgång'], FILTER_VALIDATE_INT); |
|
50
|
1 |
|
$speltyp = Speltyp::From((int) filter_var($_REQUEST['speltyp'], FILTER_VALIDATE_INT)); |
|
51
|
|
|
|
|
52
|
1 |
|
foreach ($this->tips->moduler->m_moduler as $m) { |
|
53
|
1 |
|
if (method_exists($m, 'radera_sekvens')) { |
|
54
|
1 |
|
$m->radera_sekvens($omgång, $speltyp, $sekvens); |
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
1 |
|
$this->tips->spelade->radera_sekvens($omgång, $speltyp, $sekvens); |
|
59
|
1 |
|
$this->spel->db->radera_sekvens('spel', $omgång, $speltyp, $sekvens); |
|
60
|
1 |
|
$this->spel->hämta_sekvenser(); |
|
61
|
1 |
|
$this->spel->spara_spel(); |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
new SekvensAjax(); |
|
66
|
|
|
|