Completed
Pull Request — master (#191)
by De Cramer
38:49 queued 31:55
created

GameDataStorage::setScriptOptions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 0
cts 3
cp 0
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
3
namespace eXpansion\Framework\Core\Storage;
4
5
use Maniaplanet\DedicatedServer\Structures\GameInfos;
6
use Maniaplanet\DedicatedServer\Structures\ServerOptions;
7
use Maniaplanet\DedicatedServer\Structures\SystemInfos;
8
use Maniaplanet\DedicatedServer\Structures\Version;
9
use oliverde8\AssociativeArraySimplified\AssociativeArray;
10
11
/**
12
 * Class GameDataStorage
13
 *
14
 * @author    de Cramer Oliver<[email protected]>
15
 * @copyright 2017 eXpansion
16
 * @package eXpansion\Framework\Core\Storage
17
 */
18
class GameDataStorage
19
{
20
    /**
21
     * Constant used for unknown game modes.
22
     */
23
    const GAME_MODE_CODE_UNKNOWN = 'unknown';
24
25
    /**
26
     * Constant used for unknown titles.
27
     */
28
    const TITLE_UNKNOWN = 'unknown';
29
30
    /** @var  SystemInfos */
31
    protected $systemInfo;
32
33
    /** @var  ServerOptions */
34
    protected $serverOptions;
35
36
    /** @var array */
37
    protected $scriptOptions;
38
39
    /** @var  GameInfos */
40
    protected $gameInfos;
41
42
    /** @var Version */
43
    protected $version;
44
45
    /**
46
     * @var AssociativeArray
47
     */
48
    protected $gameModeCodes;
49
50
    /** @var string */
51
    protected $mapFolder;
52
53
    /**
54
     * @var AssociativeArray
55
     */
56
    protected $titles;
57
58
    /**
59
     * GameDataStorage constructor.
60
     *
61
     * @param array $gameModeCodes
62
     */
63 138
    public function __construct(array $gameModeCodes, array $titles)
64
    {
65 138
        $this->gameModeCodes = new AssociativeArray($gameModeCodes);
66 138
        $this->titles = new AssociativeArray($titles);
67 138
    }
68
69
70
    /**
71
     * @return GameInfos
72
     */
73
    public function getGameInfos()
74
    {
75
        return $this->gameInfos;
76
    }
77
78
    /**
79
     * @param GameInfos $gameInfos
80
     */
81
    public function setGameInfos($gameInfos)
82
    {
83
        $this->gameInfos = $gameInfos;
84
    }
85
86
    /**
87
     * @return Version
88
     */
89
    public function getVersion()
90
    {
91
        return $this->version;
92
    }
93
94
    /**
95
     * @param Version $version
96
     */
97
    public function setVersion($version)
98
    {
99
        $this->version = $version;
100
    }
101
102
    /**
103
     * Get code of the game mode.
104
     *
105
     * @return mixed
106
     */
107
    public function getGameModeCode()
108
    {
109
        return $this->gameModeCodes->get($this->getGameInfos()->gameMode, self::GAME_MODE_CODE_UNKNOWN);
110
    }
111
112
    /**
113
     * Get the title name, this returns a simplified title name such as TM
114
     *
115
     * @return mixed
116
     */
117
    public function getTitle()
118
    {
119
        return $this->titles->get($this->getVersion()->titleId, self::TITLE_UNKNOWN);
120
    }
121
122
    /**
123
     * @return ServerOptions
124
     */
125
    public function getServerOptions()
126
    {
127
        return $this->serverOptions;
128
    }
129
130
    /**
131
     * @param ServerOptions $serverOptions
132
     */
133
    public function setServerOptions($serverOptions)
134
    {
135
        $this->serverOptions = $serverOptions;
136
    }
137
138
    /**
139
     * @return array
140
     */
141
    public function getScriptOptions(): array
142
    {
143
        return $this->scriptOptions;
144
    }
145
146
    /**
147
     * @param array $scriptOptions
148
     */
149
    public function setScriptOptions(array $scriptOptions)
150
    {
151
        $this->scriptOptions = $scriptOptions;
152
    }
153
154
    /**
155
     * @param Systeminfos $systemInfo
156
     */
157
    public function setSystemInfo(Systeminfos $systemInfo)
158
    {
159
160
        $this->systemInfo = $systemInfo;
161
    }
162
163
    /**
164
     * @return SystemInfos
165
     */
166
    public function getSystemInfo()
167
    {
168
        return $this->systemInfo;
169
    }
170
171
    /**
172
     * @return string
173
     */
174
    public function getMapFolder(): string
175
    {
176
        return $this->mapFolder;
177
    }
178
179
    /**
180
     * @param string $mapFolder
181
     */
182
    public function setMapFolder(string $mapFolder)
183
    {
184
        $this->mapFolder = $mapFolder;
185
    }
186
}
187