|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace eXpansion\Core\DataProviders; |
|
4
|
|
|
|
|
5
|
|
|
use eXpansion\Core\Storage\PlayerStorage; |
|
6
|
|
|
use Maniaplanet\DedicatedServer\Connection; |
|
7
|
|
|
use Maniaplanet\DedicatedServer\Structures\Map; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* ChatDataProvider provides chat information to plugins. |
|
11
|
|
|
* |
|
12
|
|
|
* @package eXpansion\Core\DataProviders |
|
13
|
|
|
*/ |
|
14
|
|
|
class MatchDataProvider extends AbstractDataProvider |
|
15
|
|
|
{ |
|
16
|
|
|
/** @var PlayerStorage */ |
|
17
|
|
|
protected $playerStorage; |
|
18
|
|
|
|
|
19
|
|
|
|
|
20
|
|
|
/** @var Connection */ |
|
21
|
|
|
protected $connection; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* MatchDataProvider constructor. |
|
25
|
|
|
* |
|
26
|
|
|
* @param PlayerStorage $playerStorage |
|
27
|
|
|
* @param Connection $connection |
|
28
|
|
|
*/ |
|
29
|
1 |
|
public function __construct(PlayerStorage $playerStorage, Connection $connection) |
|
30
|
|
|
{ |
|
31
|
1 |
|
$this->playerStorage = $playerStorage; |
|
32
|
1 |
|
$this->connection = $connection; |
|
33
|
1 |
|
} |
|
34
|
|
|
|
|
35
|
|
|
public function onRun() |
|
36
|
|
|
{ |
|
37
|
|
|
|
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
public function onBeginMatch() |
|
41
|
|
|
{ |
|
42
|
|
|
$this->dispatch(__FUNCTION__, []); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function onEndMatch() |
|
46
|
|
|
{ |
|
47
|
|
|
$this->dispatch(__FUNCTION__, []); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
public function onBeginMap($map) |
|
51
|
|
|
{ |
|
52
|
|
|
$this->dispatch(__FUNCTION__, [Map::fromArray($map)]); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public function onEndMap($map) |
|
56
|
|
|
{ |
|
57
|
|
|
|
|
58
|
|
|
$this->dispatch(__FUNCTION__, [Map::fromArray($map)]); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
public function onBeginRound() |
|
62
|
|
|
{ |
|
63
|
|
|
$this->dispatch(__FUNCTION__, []); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
public function onEndRound() |
|
67
|
|
|
{ |
|
68
|
|
|
$this->dispatch(__FUNCTION__, []); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* @param $uid |
|
73
|
|
|
* @param $login |
|
74
|
|
|
* @param $data |
|
75
|
|
|
*/ |
|
76
|
|
|
public function onPlayerFinish($uid, $login, $data) |
|
|
|
|
|
|
77
|
|
|
{ |
|
78
|
|
|
$this->dispatch(__FUNCTION__, [$this->playerStorage->getPlayerInfo($login), (float) $data]); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* @param $uid |
|
83
|
|
|
* @param $login |
|
84
|
|
|
* @param $time |
|
85
|
|
|
* @param $currentLap |
|
86
|
|
|
* @param $index |
|
87
|
|
|
*/ |
|
88
|
|
|
public function onPlayerCheckpoint($uid, $login, $time, $currentLap, $index) |
|
|
|
|
|
|
89
|
|
|
{ |
|
90
|
|
|
$this->dispatch(__FUNCTION__, [$this->playerStorage->getPlayerInfo($login), (float) $time, (int) $currentLap, (int) $index]); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
|
|
94
|
|
|
} |
|
95
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.