|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace PanicLabCore\Services\Debug; |
|
6
|
|
|
|
|
7
|
|
|
use PanicLabCore\Services\CalcService; |
|
8
|
|
|
use PanicLabCore\Services\Debug\Log\DebugLoggerInterface; |
|
9
|
|
|
use PanicLabCore\Services\Handlers\TileHandlerCollectorInterface; |
|
10
|
|
|
use PanicLabCore\Structs; |
|
11
|
|
|
|
|
12
|
|
|
class DebugCalcService extends CalcService |
|
13
|
|
|
{ |
|
14
|
|
|
/** @var DebugLoggerInterface */ |
|
15
|
|
|
private $debugLogger; |
|
16
|
|
|
|
|
17
|
10 |
|
public function __construct( |
|
18
|
|
|
DebugLoggerInterface $debugLogger, |
|
19
|
|
|
TileHandlerCollectorInterface $tileHandlerCollector, |
|
20
|
|
|
int $maxSteps |
|
21
|
|
|
) { |
|
22
|
10 |
|
$this->debugLogger = $debugLogger; |
|
23
|
|
|
|
|
24
|
10 |
|
parent::__construct($tileHandlerCollector, $maxSteps); |
|
25
|
10 |
|
} |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* {@inheritdoc} |
|
29
|
|
|
*/ |
|
30
|
2 |
|
public function calculate(array $tiles, Structs\Dice $diceResult): Structs\GermTile |
|
31
|
|
|
{ |
|
32
|
2 |
|
$this->debugLogger->logBefore('calculate', ['tiles' => $tiles, 'dice' => $diceResult]); |
|
33
|
2 |
|
$foundTile = parent::calculate($tiles, $diceResult); |
|
34
|
2 |
|
$this->debugLogger->logAfter('calculate', ['foundTile' => $foundTile]); |
|
35
|
|
|
|
|
36
|
2 |
|
return $foundTile; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
4 |
|
public function prepare(Structs\Dice $diceResult): void |
|
40
|
|
|
{ |
|
41
|
4 |
|
$this->debugLogger->logBefore('prepare', ['tiles' => $this->tiles, 'dice' => $diceResult]); |
|
42
|
4 |
|
parent::prepare($diceResult); |
|
43
|
4 |
|
$this->debugLogger->logAfter('prepare', ['tiles' => $this->tiles]); |
|
44
|
4 |
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* {@inheritdoc} |
|
48
|
|
|
*/ |
|
49
|
2 |
|
public function reverseTiles(): void |
|
50
|
|
|
{ |
|
51
|
2 |
|
$this->debugLogger->logBefore('reverseTiles', ['tiles' => $this->tiles]); |
|
52
|
2 |
|
parent::reverseTiles(); |
|
53
|
2 |
|
$this->debugLogger->logAfter('reverseTiles', ['tiles' => $this->tiles]); |
|
54
|
2 |
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* {@inheritdoc} |
|
58
|
|
|
*/ |
|
59
|
6 |
|
public function findStartIndex(string $entryColor): int |
|
60
|
|
|
{ |
|
61
|
6 |
|
$this->debugLogger->logBefore('findStartIndex', ['entryColor' => $entryColor]); |
|
62
|
6 |
|
$startIndex = parent::findStartIndex($entryColor); |
|
63
|
6 |
|
$this->debugLogger->logAfter('findStartIndex', ['startIndex' => $startIndex]); |
|
64
|
|
|
|
|
65
|
6 |
|
return $startIndex; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* {@inheritdoc} |
|
70
|
|
|
*/ |
|
71
|
4 |
|
public function isTargetTile(Structs\Tile $tile): bool |
|
72
|
|
|
{ |
|
73
|
4 |
|
$this->debugLogger->logBefore('isTargetTile', ['searchedTile' => $tile, 'targetTile' => $this->target]); |
|
74
|
4 |
|
$isTargetTile = parent::isTargetTile($tile); |
|
75
|
4 |
|
$this->debugLogger->logAfter('isTargetTile', ['isTargetTile' => $isTargetTile]); |
|
76
|
|
|
|
|
77
|
4 |
|
return $isTargetTile; |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
|