|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace eXpansion\Framework\GameTrackmania\DataProviders\ScriptBaseRounds; |
|
4
|
|
|
|
|
5
|
|
|
use eXpansion\Framework\Core\DataProviders\AbstractDataProvider; |
|
6
|
|
|
use eXpansion\Framework\Core\DataProviders\MethodScriptDataProviderInterface; |
|
7
|
|
|
use eXpansion\Framework\Core\Storage\MapStorage; |
|
8
|
|
|
use Maniaplanet\DedicatedServer\Connection; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Class MethodGetNumberLapsDataProvider |
|
12
|
|
|
* |
|
13
|
|
|
* @author de Cramer Oliver<[email protected]> |
|
14
|
|
|
* @copyright 2017 eXpansion |
|
15
|
|
|
* @package eXpansion\Framework\GameTrackmania\DataProviders |
|
16
|
|
|
*/ |
|
17
|
|
|
class MethodGetNumberLapsDataProvider extends AbstractDataProvider implements MethodScriptDataProviderInterface |
|
18
|
|
|
{ |
|
19
|
|
|
/** @var Connection */ |
|
20
|
|
|
protected $connection; |
|
21
|
|
|
|
|
22
|
|
|
/** @var MapStorage */ |
|
23
|
|
|
protected $mapStorage; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* MethodGetNumberLapsDataProvider constructor. |
|
27
|
|
|
* |
|
28
|
|
|
* @param Connection $connection |
|
29
|
|
|
* @param MapStorage $mapStorage |
|
30
|
|
|
*/ |
|
31
|
|
|
public function __construct(Connection $connection, MapStorage $mapStorage) |
|
32
|
|
|
{ |
|
33
|
|
|
$this->connection = $connection; |
|
34
|
|
|
$this->mapStorage = $mapStorage; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @inheritdoc |
|
39
|
|
|
* |
|
40
|
|
|
* @param string $pluginId |
|
41
|
|
|
* @param mixed $pluginService |
|
42
|
|
|
*/ |
|
43
|
|
|
public function registerPlugin($pluginId, $pluginService) |
|
44
|
|
|
{ |
|
45
|
|
|
parent::registerPlugin($pluginId, $pluginService); |
|
46
|
|
|
|
|
47
|
|
|
$pluginService->setCurrentDataProvider($this); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Request call to fetch something.. |
|
52
|
|
|
* |
|
53
|
|
|
* @return void |
|
54
|
|
|
*/ |
|
55
|
|
|
public function request() |
|
56
|
|
|
{ |
|
57
|
|
|
$scriptSettings = $this->connection->getModeScriptSettings(); |
|
58
|
|
|
$currentMap = $this->mapStorage->getCurrentMap(); |
|
59
|
|
|
|
|
60
|
|
|
$nbLaps = 1; |
|
61
|
|
|
if ($currentMap->lapRace) { |
|
62
|
|
|
$nbLaps = $currentMap->nbLaps; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
if ($scriptSettings['S_ForceLapsNb'] != -1) { |
|
66
|
|
|
$nbLaps = $scriptSettings['S_ForceLapsNb']; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
$this->dispatch('set', [$nbLaps]); |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|