|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Stu\Module\Game\Lib; |
|
4
|
|
|
|
|
5
|
|
|
use Stu\Component\Game\GameEnum; |
|
|
|
|
|
|
6
|
|
|
use Stu\Module\Control\GameControllerInterface; |
|
7
|
|
|
use Stu\Module\Control\ViewContext; |
|
8
|
|
|
use Stu\Orm\Repository\TutorialStepRepositoryInterface; |
|
9
|
|
|
use Stu\Orm\Repository\UserTutorialRepositoryInterface; |
|
10
|
|
|
|
|
11
|
|
|
final class TutorialProvider |
|
12
|
|
|
{ |
|
13
|
4 |
|
public function __construct(private TutorialStepRepositoryInterface $tutorialStepRepository, private UserTutorialRepositoryInterface $userTutorialRepository) {} |
|
14
|
|
|
|
|
15
|
|
|
public function setTemplateVariables( |
|
16
|
|
|
ViewContext $viewContext, |
|
17
|
|
|
GameControllerInterface $game |
|
18
|
|
|
): void { |
|
19
|
|
|
|
|
20
|
|
|
/** @var array<int, array{elementIds: array<string>, title: string, text: string}> */ |
|
21
|
|
|
$dummyarray = [ |
|
|
|
|
|
|
22
|
|
|
['elementIds' => ['colsurface', 'submenu'], 'title' => 'Oberfläche und Kolonieinformationen', 'text' => 'Willkommen auf der Seite deiner Kolonie. Hier links siehst du die Oberfläche deiner Kolo mit allen Gebäuden bla bla bla. Hier findest du wichtige Informationen zu deiner Kolonie. Blub'], |
|
23
|
|
|
['elementIds' => ['colonystorage'], 'title' => 'Kolonielager', 'text' => 'Ja und hier ist dein Lager mit allem Krams'], |
|
24
|
|
|
['elementIds' => ['colmenubutton_1'], 'title' => 'Baumenü', 'text' => 'Klick mal aufs Baumenü und danach auf weiter. Dann können wir mal endlich was bauen.', 'innerUpdate' => 'switchColonySubmenu'], |
|
25
|
|
|
['elementIds' => ['Baumaterialfabrik'], 'title' => 'Bau ne Baumaterialfabrik', 'text' => 'BM Fabriken sind mega dufte am anfang. Klick sie an und dann bau eine auf einem Gebäude auf deiner Oberfläche. Denk dran auf weiter zu klicken.', 'innerUpdate' => 'openBuildingInfo', 'fallbackIndex' => 2], |
|
26
|
|
|
['elementIds' => ['buildinginfo'], 'title' => 'Gebäudeinformationen', 'text' => 'Hier siehst du alle Infos zu deinem Gebäude. Klick mal weiter.', 'fallbackIndex' => 2], |
|
27
|
|
|
['elementIds' => ['colsurface'], 'title' => 'Bau jetzt endlich!', 'text' => 'Ja genau hier auf irgendeinem Feld das hier passend erscheint.', 'innerUpdate' => 'fieldMouseClick', 'fallbackIndex' => 2], |
|
28
|
|
|
['elementIds' => ['colmenubutton_2'], 'title' => 'Infomenü', 'text' => 'Naja test'] |
|
29
|
|
|
]; |
|
30
|
|
|
|
|
31
|
|
|
$user = $game->getUser(); |
|
32
|
|
|
if ($user->getTutorials()->isEmpty()) { |
|
33
|
|
|
return; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
$tutorialSteps = $this->tutorialStepRepository->findByUserAndViewContext( |
|
37
|
|
|
$game->getUser(), |
|
38
|
|
|
$viewContext |
|
39
|
|
|
|
|
40
|
|
|
); |
|
41
|
|
|
if (!$tutorialSteps) { |
|
|
|
|
|
|
42
|
|
|
return; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
$userTutorial = $this->userTutorialRepository->findUserTutorialByUserAndViewContext( |
|
46
|
|
|
$game->getUser(), |
|
47
|
|
|
$viewContext |
|
48
|
|
|
); |
|
49
|
|
|
|
|
50
|
|
|
if (!$userTutorial) { |
|
51
|
|
|
return; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
|
|
55
|
|
|
$currentStep = $userTutorial->getTutorialStep()->getSort(); |
|
56
|
|
|
|
|
57
|
|
|
$payloadArray = []; |
|
58
|
|
|
foreach ($tutorialSteps as $tutorialStep) { |
|
59
|
|
|
$result = []; |
|
60
|
|
|
|
|
61
|
|
|
if ($tutorialStep->getElementIds() !== null) { |
|
62
|
|
|
$result['elementIds'] = array_map('trim', explode(',', $tutorialStep->getElementIds())); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
if ($tutorialStep->getTitle() !== null) { |
|
66
|
|
|
$result['title'] = trim((string)json_encode($tutorialStep->getTitle()), '"'); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
if ($tutorialStep->getText() !== null) { |
|
70
|
|
|
$result['text'] = trim((string)json_encode($tutorialStep->getText()), '"'); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
if ($tutorialStep->getInnerUpdate() !== null) { |
|
74
|
|
|
$result['innerUpdate'] = $tutorialStep->getInnerUpdate(); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
if ($tutorialStep->getFallbackIndex() !== null) { |
|
78
|
|
|
$result['fallbackIndex'] = $tutorialStep->getFallbackIndex(); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
$result['id'] = $tutorialStep->getId(); |
|
82
|
|
|
$result['sort'] = $tutorialStep->getSort(); |
|
83
|
|
|
|
|
84
|
|
|
$payloadArray[] = $result; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
$game->addExecuteJS(sprintf( |
|
88
|
|
|
"updateTutorialStep('%s', %d);", |
|
89
|
|
|
json_encode($payloadArray), |
|
90
|
|
|
$currentStep |
|
91
|
|
|
|
|
92
|
|
|
), GameEnum::JS_EXECUTION_AFTER_RENDER); |
|
93
|
|
|
} |
|
94
|
|
|
} |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths