1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Application\Controller; |
4
|
|
|
|
5
|
|
|
use Laminas\Mvc\Controller\AbstractActionController; |
6
|
|
|
use Laminas\View\Model\ViewModel; |
7
|
|
|
use Application\Service\BotParserCache; |
8
|
|
|
|
9
|
|
|
class IndexController extends AbstractActionController |
10
|
|
|
{ |
11
|
|
|
private $config; |
12
|
|
|
private $parser; |
13
|
|
|
|
14
|
|
|
public function __construct(array $config, BotParserCache $parser) |
15
|
|
|
{ |
16
|
|
|
$this->config = $config; |
17
|
|
|
$this->parser = $parser; |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
public function gameInfoAction() |
21
|
|
|
{ |
22
|
|
|
return new ViewModel([ |
23
|
|
|
'bot_nick' => $this->config['bot_nick'], |
24
|
|
|
'bot_channel' => $this->config['bot_channel'], |
25
|
|
|
'network_name' => $this->config['network_name'], |
26
|
|
|
'network_host' => $this->config['network_host'], |
27
|
|
|
]); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public function scoreBoardAction() |
31
|
|
|
{ |
32
|
|
|
return new ViewModel([ |
33
|
|
|
'score' => $this->parser->getScoreboard() |
34
|
|
|
]); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function playerInfoAction() |
38
|
|
|
{ |
39
|
|
|
$nick = $this->params()->fromRoute('nick', null); |
40
|
|
|
$allEvents = $this->params()->fromRoute('mod', null); |
41
|
|
|
if (null === $nick) { |
42
|
|
|
return $this->redirect()->toRoute('home'); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
$playerInfo = $this->parser->getDatabase($nick); |
46
|
|
|
if (0 === $playerInfo) { |
47
|
|
|
return $this->redirect()->toRoute('home'); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
$playerInfo['items'] = $this->parser->getItemsList(); |
51
|
|
|
$playerInfo['penalties'] = $this->parser->getPenaltiesList(); |
52
|
|
|
|
53
|
|
|
if ($allEvents) { |
54
|
|
|
$playerInfo['mod'] = $this->parser->getEvents(0, $nick); |
55
|
|
|
$playerInfo['mod']['link'] = false; |
56
|
|
|
} else { |
57
|
|
|
$playerInfo['mod'] = $this->parser->getEvents(5, $nick); |
58
|
|
|
$playerInfo['mod']['link'] = true; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
$playerInfo['map_image'] = $this->config['map_image']; |
62
|
|
|
$playerInfo['dimensions'] = $this->parser->getMapDimensions(); |
63
|
|
|
|
64
|
|
|
return new ViewModel($playerInfo); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
public function databaseAction() |
68
|
|
|
{ |
69
|
|
|
return new ViewModel(); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
public function worldMapAction() |
73
|
|
|
{ |
74
|
|
|
return new ViewModel([ |
75
|
|
|
'map_image' => $this->config['map_image'], |
76
|
|
|
'coords' => $this->parser->getCoordinates(), |
77
|
|
|
'dimensions' => $this->parser->getMapDimensions() |
78
|
|
|
]); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
public function questInfoAction() |
82
|
|
|
{ |
83
|
|
|
$quest = $this->parser->getQuestData(); |
84
|
|
|
if ($quest['type'] == 2) { |
85
|
|
|
$goal = [ |
86
|
|
|
'x_pos' => $quest['stages'][$quest['objective'] - 1]['x_pos'], |
87
|
|
|
'y_pos' => $quest['stages'][$quest['objective'] - 1]['y_pos'], |
88
|
|
|
'color' => $quest['stages'][$quest['objective'] - 1]['color'] |
89
|
|
|
]; |
90
|
|
|
} |
91
|
|
|
return new ViewModel([ |
92
|
|
|
'map_image' => $this->config['map_image'], |
93
|
|
|
'quest' => $quest, |
94
|
|
|
'dimensions' => $this->parser->getMapDimensions(), |
95
|
|
|
'goal' => isset($goal) ? $goal : null |
96
|
|
|
]); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
public function recentEventsAction() |
100
|
|
|
{ |
101
|
|
|
return new ViewModel($this->parser->getEvents(15)); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
public function adminInfoAction() |
105
|
|
|
{ |
106
|
|
|
return new ViewModel([ |
107
|
|
|
'bot_nick' => $this->config['bot_nick'], |
108
|
|
|
]); |
109
|
|
|
} |
110
|
|
|
} |
111
|
|
|
|