|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Stu\Module\Maindesk\Action\LastTutorial; |
|
6
|
|
|
|
|
7
|
|
|
use Stu\Exception\AccessViolation; |
|
8
|
|
|
use Stu\Module\Control\ActionControllerInterface; |
|
9
|
|
|
use Stu\Module\Control\GameControllerInterface; |
|
10
|
|
|
use Stu\Module\PlayerSetting\Lib\UserEnum; |
|
11
|
|
|
use Stu\Orm\Repository\UserRepositoryInterface; |
|
12
|
|
|
|
|
13
|
|
|
final class LastTutorial implements ActionControllerInterface |
|
14
|
|
|
{ |
|
15
|
|
|
public const ACTION_IDENTIFIER = 'B_TUTORIAL_BACK'; |
|
16
|
|
|
|
|
17
|
|
|
|
|
18
|
|
|
private UserRepositoryInterface $userRepository; |
|
19
|
|
|
|
|
20
|
|
|
public function __construct( |
|
21
|
|
|
UserRepositoryInterface $userRepository |
|
22
|
|
|
) { |
|
23
|
|
|
$this->userRepository = $userRepository; |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
public function handle(GameControllerInterface $game): void |
|
27
|
|
|
{ |
|
28
|
|
|
$user = $game->getUser(); |
|
29
|
|
|
|
|
30
|
|
|
if ((int) $user->getState() !== UserEnum::USER_STATE_TUTORIAL2 || (int) $user->getState() !== UserEnum::USER_STATE_TUTORIAL3 || (int) $user->getState() !== UserEnum::USER_STATE_TUTORIAL4) { |
|
31
|
|
|
throw new AccessViolation(); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
if ((int) $user->getState() !== UserEnum::USER_STATE_TUTORIAL2) { |
|
35
|
|
|
$user->setState(UserEnum::USER_STATE_TUTORIAL1); |
|
36
|
|
|
$this->userRepository->save($user); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
if ((int) $user->getState() !== UserEnum::USER_STATE_TUTORIAL3) { |
|
40
|
|
|
$user->setState(UserEnum::USER_STATE_TUTORIAL2); |
|
41
|
|
|
$this->userRepository->save($user); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
if ((int) $user->getState() !== UserEnum::USER_STATE_TUTORIAL4) { |
|
45
|
|
|
$user->setState(UserEnum::USER_STATE_TUTORIAL3); |
|
46
|
|
|
$this->userRepository->save($user); |
|
47
|
|
|
} |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
|
|
51
|
|
|
public function performSessionCheck(): bool |
|
52
|
|
|
{ |
|
53
|
|
|
return false; |
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
|