|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
|
|
4
|
|
|
namespace eXpansion\Bundle\LocalRecords\Plugins; |
|
5
|
|
|
|
|
6
|
|
|
use eXpansion\Bundle\LocalRecords\DataProviders\Listener\RecordsDataListener; |
|
7
|
|
|
use eXpansion\Bundle\LocalRecords\Model\Record; |
|
8
|
|
|
use eXpansion\Bundle\LocalRecords\Services\RecordHandler; |
|
9
|
|
|
use eXpansion\Framework\GameManiaplanet\DataProviders\Listener\ListenerInterfaceMpLegacyMap; |
|
10
|
|
|
use Maniaplanet\DedicatedServer\Structures\Map; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Class AllRecords |
|
14
|
|
|
* |
|
15
|
|
|
* @package eXpansion\Bundle\LocalRecords\Plugins; |
|
16
|
|
|
* @author oliver de Cramer <[email protected]> |
|
17
|
|
|
*/ |
|
18
|
|
|
class AllRecords implements RecordsDataListener, ListenerInterfaceMpLegacyMap |
|
19
|
|
|
{ |
|
20
|
|
|
/** @var RecordHandler[] */ |
|
21
|
|
|
protected $recordHandlers; |
|
22
|
|
|
|
|
23
|
|
|
public function getMapRecords() |
|
24
|
|
|
{ |
|
25
|
|
|
$mergedRecords = []; |
|
26
|
|
|
|
|
27
|
|
|
foreach ($this->recordHandlers[1]->getRecords() as $i => $record) { |
|
28
|
|
|
$recordData = [ |
|
29
|
|
|
'position' => $i + 1, |
|
30
|
|
|
'player' => $record->getPlayer(), |
|
31
|
|
|
'record' => ['1' => $record], |
|
32
|
|
|
]; |
|
33
|
|
|
|
|
34
|
|
|
foreach ($this->recordHandlers as $nbLaps => $recordHandler) { |
|
35
|
|
|
if ($nbLaps != 1) { |
|
36
|
|
|
$position = $recordHandler->getPlayerPosition($record->getPlayer()->getLogin()); |
|
37
|
|
|
if ($position !== null) { |
|
38
|
|
|
$recordData["record"][$nbLaps] = $recordHandler->getPlayerRecord($record->getPlayer()->getLogin()); |
|
39
|
|
|
$recordData["record"]["other"] = $recordHandler->getPlayerRecord($record->getPlayer()->getLogin()); |
|
40
|
|
|
} |
|
41
|
|
|
} |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
$mergedRecords[] = $recordData; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
return $mergedRecords; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @inheritdoc |
|
52
|
|
|
*/ |
|
53
|
|
|
public function onBeginMap(Map $map) |
|
54
|
|
|
{ |
|
55
|
|
|
$this->recordHandlers = []; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* @inheritdoc |
|
60
|
|
|
*/ |
|
61
|
|
|
public function onLocalRecordsLoaded($records, BaseRecords $baseRecords) |
|
62
|
|
|
{ |
|
63
|
|
|
$this->recordHandlers[$baseRecords->getRecordsHandler()->getCurrentNbLaps()] = $baseRecords->getRecordsHandler(); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* @inheritdoc |
|
68
|
|
|
*/ |
|
69
|
|
|
public function onEndMap(Map $map) |
|
70
|
|
|
{ |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @inheritdoc |
|
75
|
|
|
*/ |
|
76
|
|
|
public function onLocalRecordsFirstRecord(Record $record, $records, $position, BaseRecords $baseRecords) |
|
77
|
|
|
{ |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* @inheritdoc |
|
82
|
|
|
*/ |
|
83
|
|
|
public function onLocalRecordsSameScore(Record $record, Record $oldRecord, $records, BaseRecords $baseRecords) |
|
84
|
|
|
{ |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* @inheritdoc |
|
89
|
|
|
*/ |
|
90
|
|
|
public function onLocalRecordsBetterPosition(Record $record, Record $oldRecord, $records, $position, $oldPosition, BaseRecords $baseRecords) |
|
91
|
|
|
{ |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* @inheritdoc |
|
96
|
|
|
*/ |
|
97
|
|
|
public function onLocalRecordsSamePosition(Record $record, Record $oldRecord, $records, $position, BaseRecords $baseRecords) |
|
98
|
|
|
{ |
|
99
|
|
|
} |
|
100
|
|
|
} |