1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Application\Controller; |
4
|
|
|
|
5
|
|
|
use Zend\Mvc\Controller\AbstractActionController; |
6
|
|
|
use Zend\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
|
|
|
$all_events = $this->params()->fromRoute('mod', null); |
41
|
|
|
if (null === $nick) { |
42
|
|
|
return $this->redirect()->toRoute('home'); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
$player_info = $this->parser->getDatabase($nick); |
46
|
|
|
if (0 === $player_info) { |
47
|
|
|
return $this->redirect()->toRoute('home'); |
48
|
|
|
} |
49
|
|
|
$player_info['items'] = $this->parser->getItemsList(); |
50
|
|
|
$player_info['penalties'] = $this->parser->getPenaltiesList(); |
51
|
|
|
|
52
|
|
|
if ($all_events) { |
53
|
|
|
$player_info['mod'] = $this->parser->getEvents(0, $nick); |
54
|
|
|
$player_info['mod']['link'] = false; |
55
|
|
|
} else { |
56
|
|
|
$player_info['mod'] = $this->parser->getEvents(5, $nick); |
57
|
|
|
$player_info['mod']['link'] = true; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
$player_info['map_image'] = $this->config['map_image']; |
61
|
|
|
$player_info['dimensions'] = $this->parser->getMapDimensions(); |
62
|
|
|
|
63
|
|
|
return new ViewModel($player_info); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
public function databaseAction() |
67
|
|
|
{ |
68
|
|
|
return new ViewModel(); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
public function worldMapAction() |
72
|
|
|
{ |
73
|
|
|
return new ViewModel([ |
74
|
|
|
'map_image' => $this->config['map_image'], |
75
|
|
|
'coords' => $this->parser->getCoordinates(), |
76
|
|
|
'dimensions' => $this->parser->getMapDimensions() |
77
|
|
|
]); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
public function questInfoAction() |
81
|
|
|
{ |
82
|
|
|
return new ViewModel([ |
83
|
|
|
'map_image' => $this->config['map_image'], |
84
|
|
|
'quest' => $this->parser->getQuestData(), |
85
|
|
|
'dimensions' => $this->parser->getMapDimensions(), |
86
|
|
|
]); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
public function recentEventsAction() |
90
|
|
|
{ |
91
|
|
|
return new ViewModel($this->parser->getEvents(15)); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
public function adminInfoAction() |
95
|
|
|
{ |
96
|
|
|
return new ViewModel([ |
97
|
|
|
'bot_nick' => $this->config['bot_nick'], |
98
|
|
|
]); |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
|