|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Stu\Module\Config\Model; |
|
4
|
|
|
|
|
5
|
|
|
use Stu\Module\Config\StuConfigException; |
|
6
|
|
|
|
|
7
|
|
|
final class GameSettings extends AbstractSettings implements GameSettingsInterface |
|
8
|
|
|
{ |
|
9
|
|
|
private const CONFIG_PATH = 'game'; |
|
10
|
|
|
|
|
11
|
|
|
private const SETTING_ADMINS = 'admins'; |
|
12
|
|
|
private const SETTING_TEMP_DIR = 'temp_dir'; |
|
13
|
|
|
private const SETTING_USE_SEMAPHORES = 'useSemaphores'; |
|
14
|
|
|
private const SETTING_VERSION = 'version'; |
|
15
|
|
|
private const SETTING_WEBROOT = 'webroot'; |
|
16
|
|
|
private const SETTING_PIRATE_LOGFILE_PATH = 'pirate_logfile_path'; |
|
17
|
|
|
|
|
18
|
3 |
|
public function getAdminIds(): array |
|
19
|
|
|
{ |
|
20
|
3 |
|
return array_map('intval', $this->getArrayConfigValue(self::SETTING_ADMINS, [])); |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
public function getAdminSettings(): AdminSettingsInterface |
|
24
|
|
|
{ |
|
25
|
|
|
return new AdminSettings($this->getPath(), $this->getConfig()); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
public function getColonySettings(): ColonySettingsInterface |
|
29
|
|
|
{ |
|
30
|
|
|
return new ColonySettings($this->getPath(), $this->getConfig()); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
public function getMapSettings(): MapSettingsInterface |
|
34
|
|
|
{ |
|
35
|
|
|
return new MapSettings($this->getPath(), $this->getConfig()); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
2 |
|
public function getTempDir(): string |
|
39
|
|
|
{ |
|
40
|
2 |
|
return $this->getStringConfigValue(self::SETTING_TEMP_DIR); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
3 |
|
public function useSemaphores(): bool |
|
44
|
|
|
{ |
|
45
|
3 |
|
return $this->getBooleanConfigValue(self::SETTING_USE_SEMAPHORES, false); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
3 |
|
public function getVersion(): string|int |
|
49
|
|
|
{ |
|
50
|
|
|
try { |
|
51
|
3 |
|
return $this->getIntegerConfigValue(self::SETTING_VERSION); |
|
52
|
1 |
|
} catch (StuConfigException $e) { |
|
53
|
1 |
|
return $this->getStringConfigValue(self::SETTING_VERSION); |
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
7 |
|
public function getWebroot(): string |
|
58
|
|
|
{ |
|
59
|
7 |
|
return $this->getStringConfigValue(self::SETTING_WEBROOT); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
3 |
|
public function getPirateLogfilePath(): string |
|
63
|
|
|
{ |
|
64
|
3 |
|
return $this->getStringConfigValue(self::SETTING_PIRATE_LOGFILE_PATH); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
21 |
|
public function getConfigPath(): string |
|
68
|
|
|
{ |
|
69
|
21 |
|
return self::CONFIG_PATH; |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|