We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
Total Complexity | 114 |
Total Lines | 599 |
Duplicated Lines | 0 % |
Changes | 3 | ||
Bugs | 1 | Features | 1 |
Complex classes like SmrAlliance often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use SmrAlliance, and based on these observations, apply Extract Interface, too.
1 | <?php declare(strict_types=1); |
||
3 | class SmrAlliance { |
||
4 | protected static $CACHE_ALLIANCES = array(); |
||
5 | |||
6 | protected $db; |
||
7 | protected $SQL; |
||
8 | |||
9 | protected $gameID; |
||
10 | protected $allianceID; |
||
11 | protected $allianceName; |
||
12 | protected $description; |
||
13 | protected $password; |
||
14 | protected $recruiting; |
||
15 | protected $leaderID; |
||
16 | protected $bank; |
||
17 | protected $kills; |
||
18 | protected $deaths; |
||
19 | protected $motd; |
||
20 | protected $imgSrc; |
||
21 | protected $discordServer; |
||
22 | protected $discordChannel; |
||
23 | protected $ircChannel; |
||
24 | protected $flagshipID; |
||
25 | |||
26 | protected $memberList; |
||
27 | protected $seedlist; |
||
28 | |||
29 | // Recruit type constants |
||
30 | const RECRUIT_OPEN = "open"; |
||
31 | const RECRUIT_CLOSED = "closed"; |
||
32 | const RECRUIT_PASSWORD = "password"; |
||
33 | |||
34 | public static function getAlliance($allianceID, $gameID, $forceUpdate = false) { |
||
35 | if ($forceUpdate || !isset(self::$CACHE_ALLIANCES[$gameID][$allianceID])) { |
||
36 | self::$CACHE_ALLIANCES[$gameID][$allianceID] = new SmrAlliance($allianceID, $gameID); |
||
37 | } |
||
38 | return self::$CACHE_ALLIANCES[$gameID][$allianceID]; |
||
39 | } |
||
40 | |||
41 | public static function getAllianceByDiscordChannel($channel, $forceUpdate = false) { |
||
42 | $db = new SmrMySqlDatabase(); |
||
43 | $db->query('SELECT alliance_id, game_id FROM alliance JOIN game USING(game_id) WHERE discord_channel = ' . $db->escapeString($channel) . ' AND game.end_time > ' . $db->escapeNumber(time()) . ' ORDER BY game_id DESC LIMIT 1'); |
||
44 | if ($db->nextRecord()) { |
||
45 | return self::getAlliance($db->getInt('alliance_id'), $db->getInt('game_id'), $forceUpdate); |
||
46 | } else { |
||
47 | return null; |
||
48 | } |
||
49 | } |
||
50 | |||
51 | public static function getAllianceByIrcChannel($channel, $forceUpdate = false) { |
||
52 | $db = new SmrMySqlDatabase(); |
||
53 | $db->query('SELECT alliance_id, game_id FROM irc_alliance_has_channel WHERE channel = ' . $db->escapeString($channel) . ' LIMIT 1'); |
||
54 | if ($db->nextRecord()) { |
||
55 | return self::getAlliance($db->getInt('alliance_id'), $db->getInt('game_id'), $forceUpdate); |
||
56 | } |
||
57 | $return = null; |
||
58 | return $return; |
||
59 | } |
||
60 | |||
61 | public static function getAllianceByName($name, $gameID, $forceUpdate = false) { |
||
62 | $db = new SmrMySqlDatabase(); |
||
63 | $db->query('SELECT alliance_id FROM alliance WHERE alliance_name = ' . $db->escapeString($name) . ' AND game_id = ' . $db->escapeNumber($gameID) . ' LIMIT 1'); |
||
64 | if ($db->nextRecord()) { |
||
65 | return self::getAlliance($db->getInt('alliance_id'), $gameID, $forceUpdate); |
||
66 | } else { |
||
67 | return null; |
||
68 | } |
||
69 | } |
||
70 | |||
71 | protected function __construct($allianceID, $gameID) { |
||
72 | $this->db = new SmrMySqlDatabase(); |
||
73 | |||
74 | $this->allianceID = $allianceID; |
||
75 | $this->gameID = $gameID; |
||
76 | $this->SQL = 'alliance_id=' . $this->db->escapeNumber($allianceID) . ' AND game_id=' . $this->db->escapeNumber($gameID); |
||
77 | |||
78 | if ($allianceID != 0) { |
||
79 | $this->db->query('SELECT * FROM alliance WHERE ' . $this->SQL); |
||
80 | $this->db->nextRecord(); |
||
81 | $this->allianceName = $this->db->getField('alliance_name'); |
||
82 | $this->password = stripslashes($this->db->getField('alliance_password')); |
||
83 | $this->recruiting = $this->db->getBoolean('recruiting'); |
||
84 | $this->description = $this->db->getField('alliance_description'); |
||
85 | $this->leaderID = $this->db->getInt('leader_id'); |
||
86 | $this->bank = $this->db->getInt('alliance_account'); |
||
87 | $this->kills = $this->db->getInt('alliance_kills'); |
||
88 | $this->deaths = $this->db->getInt('alliance_deaths'); |
||
89 | $this->motd = $this->db->getField('mod'); |
||
90 | $this->imgSrc = $this->db->getField('img_src'); |
||
91 | $this->discordServer = $this->db->getField('discord_server'); |
||
92 | $this->discordChannel = $this->db->getField('discord_channel'); |
||
93 | $this->flagshipID = $this->db->getInt('flagship_id'); |
||
94 | |||
95 | if (empty($this->kills)) { |
||
96 | $this->kills = 0; |
||
97 | } |
||
98 | if (empty($this->deaths)) { |
||
99 | $this->deaths = 0; |
||
100 | } |
||
101 | } |
||
102 | } |
||
103 | |||
104 | /** |
||
105 | * Create an alliance and return the new object. |
||
106 | * Starts alliance with "closed" recruitment (for safety). |
||
107 | */ |
||
108 | public static function createAlliance($gameID, $name) { |
||
109 | $db = new SmrMySqlDatabase(); |
||
110 | |||
111 | // check if the alliance name already exists |
||
112 | $db->query('SELECT 1 FROM alliance WHERE alliance_name = ' . $db->escapeString($name) . ' AND game_id = ' . $db->escapeNumber($gameID) . ' LIMIT 1'); |
||
113 | if ($db->getNumRows() > 0) { |
||
114 | create_error('That alliance name already exists!'); |
||
115 | } |
||
116 | |||
117 | // get the next alliance id (ignoring reserved ID's) |
||
118 | $db->query('SELECT max(alliance_id) FROM alliance WHERE game_id = ' . $db->escapeNumber($gameID) . ' AND (alliance_id < ' . $db->escapeNumber(NHA_ID) . ' OR alliance_id > ' . $db->escapeNumber(NHA_ID + 7) . ') LIMIT 1'); |
||
119 | $db->requireRecord(); |
||
120 | $allianceID = $db->getInt('max(alliance_id)') + 1; |
||
121 | if ($allianceID >= NHA_ID && $allianceID <= NHA_ID + 7) { |
||
122 | $allianceID = NHA_ID + 8; |
||
123 | } |
||
124 | |||
125 | // actually create the alliance here |
||
126 | $db->query('INSERT INTO alliance (alliance_id, game_id, alliance_name, alliance_password, recruiting) VALUES(' . $db->escapeNumber($allianceID) . ', ' . $db->escapeNumber($gameID) . ', ' . $db->escapeString($name) . ', \'\', \'FALSE\')'); |
||
127 | |||
128 | return self::getAlliance($allianceID, $gameID); |
||
129 | } |
||
130 | |||
131 | /** |
||
132 | * Returns true if the alliance ID is associated with allianceless players. |
||
133 | */ |
||
134 | public function isNone() { |
||
135 | return $this->allianceID == 0; |
||
136 | } |
||
137 | |||
138 | public function getAllianceID() { |
||
139 | return $this->allianceID; |
||
140 | } |
||
141 | |||
142 | public function getAllianceBBLink() { |
||
143 | return '[alliance=' . $this->allianceID . ']'; |
||
144 | } |
||
145 | |||
146 | public function getAllianceDisplayName($linked = false, $includeAllianceID = false) { |
||
147 | $name = htmlentities($this->allianceName); |
||
148 | if ($includeAllianceID) { |
||
149 | $name .= ' (' . $this->allianceID . ')'; |
||
150 | } |
||
151 | if ($linked === true && !$this->hasDisbanded()) { |
||
152 | return create_link(Globals::getAllianceRosterHREF($this->getAllianceID()), $name); |
||
153 | } |
||
154 | return $name; |
||
155 | } |
||
156 | |||
157 | /** |
||
158 | * Returns the alliance name. |
||
159 | * Use getAllianceDisplayName for an HTML-safe version. |
||
160 | */ |
||
161 | public function getAllianceName() { |
||
162 | return $this->allianceName; |
||
163 | } |
||
164 | |||
165 | public function getGameID() { |
||
166 | return $this->gameID; |
||
167 | } |
||
168 | |||
169 | public function getGame() { |
||
170 | return SmrGame::getGame($this->gameID); |
||
171 | } |
||
172 | |||
173 | public function hasDisbanded() { |
||
174 | return !$this->hasLeader(); |
||
175 | } |
||
176 | |||
177 | public function hasLeader() { |
||
178 | return $this->getLeaderID() != 0; |
||
179 | } |
||
180 | |||
181 | public function getLeaderID() { |
||
182 | return $this->leaderID; |
||
183 | } |
||
184 | |||
185 | public function getLeader() { |
||
186 | return SmrPlayer::getPlayer($this->getLeaderID(), $this->getGameID()); |
||
187 | } |
||
188 | |||
189 | public function setLeaderID($leaderID) { |
||
190 | $this->leaderID = $leaderID; |
||
191 | } |
||
192 | |||
193 | public function getDiscordServer() { |
||
194 | return $this->discordServer; |
||
195 | } |
||
196 | |||
197 | public function setDiscordServer($serverId) { |
||
198 | $this->discordServer = $serverId; |
||
199 | } |
||
200 | |||
201 | public function getDiscordChannel() { |
||
202 | return $this->discordChannel; |
||
203 | } |
||
204 | |||
205 | public function setDiscordChannel($channelId) { |
||
206 | $this->discordChannel = $channelId; |
||
207 | } |
||
208 | |||
209 | public function getIrcChannel() { |
||
210 | if (!isset($this->ircChannel)) { |
||
211 | $this->db->query('SELECT channel FROM irc_alliance_has_channel WHERE ' . $this->SQL); |
||
212 | if ($this->db->nextRecord()) { |
||
213 | $this->ircChannel = $this->db->getField('channel'); |
||
214 | } else { |
||
215 | $this->ircChannel = ''; |
||
216 | } |
||
217 | } |
||
218 | return $this->ircChannel; |
||
219 | } |
||
220 | |||
221 | public function setIrcChannel($ircChannel) { |
||
222 | if ($this->ircChannel == $ircChannel) { |
||
223 | return; |
||
224 | } |
||
225 | if (strlen($ircChannel) > 0 && $ircChannel != '#') { |
||
226 | if ($ircChannel[0] != '#') { |
||
227 | $ircChannel = '#' . $ircChannel; |
||
228 | } |
||
229 | if ($ircChannel == '#smr' || $ircChannel == '#smr-bar') { |
||
230 | create_error('Please enter a valid irc channel for your alliance.'); |
||
231 | } |
||
232 | |||
233 | $this->db->query('REPLACE INTO irc_alliance_has_channel (channel,alliance_id,game_id) values (' . $this->db->escapeString($ircChannel) . ',' . $this->db->escapeNumber($this->getAllianceID()) . ',' . $this->db->escapeNumber($this->getGameID()) . ');'); |
||
234 | } else { |
||
235 | $this->db->query('DELETE FROM irc_alliance_has_channel WHERE ' . $this->SQL); |
||
236 | } |
||
237 | $this->ircChannel = $ircChannel; |
||
238 | } |
||
239 | |||
240 | public function hasImageURL() { |
||
242 | } |
||
243 | |||
244 | public function getImageURL() { |
||
245 | return $this->imgSrc; |
||
246 | } |
||
247 | |||
248 | public function setImageURL($url) { |
||
253 | } |
||
254 | |||
255 | /** |
||
256 | * Get the total credits in the alliance bank account. |
||
257 | */ |
||
258 | public function getBank() { |
||
260 | } |
||
261 | |||
262 | /** |
||
263 | * Increases alliance bank account up to the maximum allowed credits. |
||
264 | * Returns the amount that was actually added to handle overflow. |
||
265 | */ |
||
266 | public function increaseBank(int $credits) : int { |
||
267 | $newTotal = min($this->bank + $credits, MAX_MONEY); |
||
268 | $actualAdded = $newTotal - $this->bank; |
||
269 | $this->setBank($newTotal); |
||
270 | return $actualAdded; |
||
271 | } |
||
272 | |||
273 | public function decreaseBank(int $credits) : void { |
||
274 | $newTotal = $this->bank - $credits; |
||
275 | $this->setBank($newTotal); |
||
276 | } |
||
277 | |||
278 | public function setBank(int $credits) : void { |
||
279 | $this->bank = $credits; |
||
280 | } |
||
281 | |||
282 | /** |
||
283 | * Get (HTML-safe) alliance Message of the Day for display. |
||
284 | */ |
||
285 | public function getMotD() { |
||
286 | return htmlentities($this->motd); |
||
287 | } |
||
288 | |||
289 | public function setMotD($motd) { |
||
290 | $this->motd = $motd; |
||
291 | } |
||
292 | |||
293 | public function getPassword() { |
||
294 | return $this->password; |
||
295 | } |
||
296 | |||
297 | public function isRecruiting() : bool { |
||
298 | return $this->recruiting; |
||
299 | } |
||
300 | |||
301 | /** |
||
302 | * Set the password and recruiting attributes. |
||
303 | * The input $password is ignored except for the "password" $type. |
||
304 | */ |
||
305 | public function setRecruitType(string $type, string $password) : void { |
||
306 | if ($type == self::RECRUIT_CLOSED) { |
||
307 | $this->recruiting = false; |
||
308 | $this->password = ''; |
||
309 | } elseif ($type == self::RECRUIT_OPEN) { |
||
310 | $this->recruiting = true; |
||
311 | $this->password = ''; |
||
312 | } elseif ($type == self::RECRUIT_PASSWORD) { |
||
313 | if (empty($password)) { |
||
314 | throw new Exception('Password must not be empty here'); |
||
315 | } |
||
316 | $this->recruiting = true; |
||
317 | $this->password = $password; |
||
318 | } else { |
||
319 | throw new Exception('Unknown recruit type: ' . $type); |
||
320 | } |
||
321 | } |
||
322 | |||
323 | public function getRecruitType() : string { |
||
324 | if (!$this->isRecruiting()) { |
||
325 | return self::RECRUIT_CLOSED; |
||
326 | } elseif (empty($this->getPassword())) { |
||
327 | return self::RECRUIT_OPEN; |
||
328 | } else { |
||
329 | return self::RECRUIT_PASSWORD; |
||
330 | } |
||
331 | } |
||
332 | |||
333 | /** |
||
334 | * List of all recruitment types and their descriptions. |
||
335 | * Do not change the order of elements in the list! |
||
336 | */ |
||
337 | public static function allRecruitTypes() : array { |
||
338 | // The first type is the default option when creating new alliances |
||
339 | return [ |
||
340 | self::RECRUIT_PASSWORD => "Players can join by password or invitation", |
||
341 | self::RECRUIT_CLOSED => "Players can join by invitation only", |
||
342 | self::RECRUIT_OPEN => "Anyone can join (no password needed)", |
||
343 | ]; |
||
344 | } |
||
345 | |||
346 | public function getKills() { |
||
347 | return $this->kills; |
||
348 | } |
||
349 | |||
350 | public function getDeaths() { |
||
351 | return $this->deaths; |
||
352 | } |
||
353 | |||
354 | /** |
||
355 | * Get (HTML-safe) alliance description for display. |
||
356 | */ |
||
357 | public function getDescription() { |
||
358 | if (empty($this->description)) { |
||
359 | return ''; |
||
360 | } else { |
||
361 | return htmlentities($this->description); |
||
362 | } |
||
363 | } |
||
364 | |||
365 | public function setAllianceDescription($description) { |
||
366 | $description = word_filter($description); |
||
367 | if ($description == $this->description) { |
||
368 | return; |
||
369 | } |
||
370 | global $player, $account; |
||
371 | $boxDescription = 'Alliance ' . $this->getAllianceBBLink() . ' had their description changed to:' . EOL . EOL . $description; |
||
372 | if (is_object($player)) { |
||
373 | $player->sendMessageToBox(BOX_ALLIANCE_DESCRIPTIONS, $boxDescription); |
||
374 | } else { |
||
375 | $account->sendMessageToBox(BOX_ALLIANCE_DESCRIPTIONS, $boxDescription); |
||
376 | } |
||
377 | $this->description = $description; |
||
378 | } |
||
379 | |||
380 | public function hasFlagship() { |
||
381 | return $this->flagshipID != 0; |
||
382 | } |
||
383 | |||
384 | /** |
||
385 | * Get account ID of the player designated as the alliance flagship. |
||
386 | * Returns 0 if no flagship. |
||
387 | */ |
||
388 | public function getFlagshipID() { |
||
389 | return $this->flagshipID; |
||
390 | } |
||
391 | |||
392 | /** |
||
393 | * Designate a player as the alliance flagship by their account ID. |
||
394 | */ |
||
395 | public function setFlagshipID($accountID) { |
||
396 | if ($this->flagshipID == $accountID) { |
||
397 | return; |
||
398 | } |
||
399 | $this->flagshipID = $accountID; |
||
400 | } |
||
401 | |||
402 | public function canJoinAlliance(SmrPlayer $player, $doAllianceCheck = true) { |
||
403 | if (!$player->getAccount()->isValidated()) { |
||
404 | return 'You cannot join an alliance until you validate your account.'; |
||
405 | } |
||
406 | if ($this->hasDisbanded()) { |
||
407 | return 'This alliance has disbanded!'; |
||
408 | } |
||
409 | if ($doAllianceCheck && $player->hasAlliance()) { |
||
410 | return 'You are already in an alliance!'; |
||
411 | } |
||
412 | if (!$this->isRecruiting()) { |
||
413 | return 'This alliance is not currently accepting new recruits.'; |
||
414 | } |
||
415 | if ($player->getAllianceJoinable() > TIME) { |
||
416 | return 'You cannot join another alliance for ' . format_time($player->getAllianceJoinable() - TIME) . '.'; |
||
417 | } |
||
418 | if ($this->getNumMembers() < $this->getGame()->getAllianceMaxPlayers()) { |
||
419 | if ($player->hasNewbieStatus()) { |
||
420 | return true; |
||
421 | } |
||
422 | $maxVets = $this->getGame()->getAllianceMaxVets(); |
||
423 | if ($this->getNumMembers() < $maxVets) { |
||
424 | return true; |
||
425 | } |
||
426 | $this->db->query('SELECT status FROM player_joined_alliance WHERE account_id=' . $this->db->escapeNumber($player->getAccountID()) . ' AND ' . $this->SQL); |
||
427 | if ($this->db->nextRecord()) { |
||
428 | if ($this->db->getField('status') == 'NEWBIE') { |
||
429 | return true; |
||
430 | } |
||
431 | } |
||
432 | $this->db->query('SELECT COUNT(*) AS num_orig_vets |
||
433 | FROM player_joined_alliance |
||
434 | JOIN player USING (account_id, alliance_id, game_id) |
||
435 | WHERE ' . $this->SQL . ' AND status=\'VETERAN\''); |
||
436 | if (!$this->db->nextRecord() || $this->db->getInt('num_orig_vets') < $maxVets) { |
||
437 | return true; |
||
438 | } |
||
439 | } |
||
440 | return 'There is not currently enough room for you in this alliance.'; |
||
441 | } |
||
442 | |||
443 | public function getNumVeterans() { |
||
444 | $numVeterans = 0; |
||
445 | foreach ($this->getMembers() as $player) { |
||
446 | if (!$player->hasNewbieStatus()) { |
||
447 | $numVeterans++; |
||
448 | } |
||
449 | } |
||
450 | return $numVeterans; |
||
451 | } |
||
452 | |||
453 | public function getNumMembers() { |
||
454 | return count($this->getMemberPlayerIDs()); |
||
455 | } |
||
456 | |||
457 | public function update() { |
||
458 | $this->db->query('UPDATE alliance SET |
||
459 | alliance_password = ' . $this->db->escapeString($this->password) . ', |
||
460 | recruiting = ' . $this->db->escapeBoolean($this->recruiting) . ', |
||
461 | alliance_account = ' . $this->db->escapeNumber($this->bank) . ', |
||
462 | alliance_description = ' . $this->db->escapeString($this->description, true, true) . ', |
||
463 | `mod` = ' . $this->db->escapeString($this->motd) . ', |
||
464 | img_src = ' . $this->db->escapeString($this->imgSrc) . ', |
||
465 | alliance_kills = ' . $this->db->escapeNumber($this->kills) . ', |
||
466 | alliance_deaths = ' . $this->db->escapeNumber($this->deaths) . ', |
||
467 | discord_server = ' . $this->db->escapeString($this->discordServer, true, true) . ', |
||
468 | discord_channel = ' . $this->db->escapeString($this->discordChannel, true, true) . ', |
||
469 | flagship_id = ' . $this->db->escapeNumber($this->flagshipID) . ', |
||
470 | leader_id = ' . $this->db->escapeNumber($this->leaderID) . ' |
||
471 | WHERE ' . $this->SQL); |
||
472 | } |
||
473 | |||
474 | /** |
||
475 | * Returns the members of this alliance as an array of SmrPlayer objects. |
||
476 | */ |
||
477 | public function getMembers() { |
||
479 | } |
||
480 | |||
481 | public function getMemberPlayerIDs() { |
||
482 | if (!isset($this->memberList)) { |
||
483 | $this->db->query('SELECT player_id FROM player WHERE ' . $this->SQL); |
||
484 | |||
485 | //we have the list of players put them in an array now |
||
486 | $this->memberList = array(); |
||
487 | while ($this->db->nextRecord()) { |
||
488 | $this->memberList[] = $this->db->getInt('player_id'); |
||
489 | } |
||
490 | } |
||
491 | return $this->memberList; |
||
492 | } |
||
493 | |||
494 | public function getActivePlayerIDs() { |
||
495 | $activeIDs = array(); |
||
|
|||
496 | |||
497 | $this->db->query('SELECT player_id |
||
498 | FROM active_session |
||
499 | JOIN player USING(account_id, game_id) |
||
500 | WHERE '.$this->SQL . ' AND last_accessed >= ' . $this->db->escapeNumber(TIME - 600)); |
||
501 | |||
502 | while ($this->db->nextRecord()) { |
||
503 | $activePlayerIDs[] = $this->db->getInt('account_id'); |
||
504 | } |
||
505 | |||
506 | return $activePlayerIDs; |
||
507 | } |
||
508 | |||
509 | /** |
||
510 | * Return all planets owned by members of this alliance. |
||
511 | */ |
||
512 | public function getPlanets() { |
||
513 | $this->db->query('SELECT planet.* |
||
514 | FROM player |
||
515 | JOIN planet ON player.game_id = planet.game_id AND player.account_id = planet.owner_id |
||
516 | WHERE player.game_id=' . $this->db->escapeNumber($this->gameID) . ' |
||
517 | AND player.alliance_id=' . $this->db->escapeNumber($this->allianceID) . ' |
||
518 | ORDER BY planet.sector_id |
||
519 | '); |
||
520 | $planets = array(); |
||
521 | while ($this->db->nextRecord()) { |
||
522 | $planets[] = SmrPlanet::getPlanet($this->gameID, $this->db->getInt('sector_id'), false, $this->db); |
||
523 | } |
||
524 | return $planets; |
||
525 | } |
||
526 | |||
527 | /** |
||
528 | * Return array of sector_id for sectors in the alliance seedlist. |
||
529 | */ |
||
530 | public function getSeedlist() { |
||
531 | if (!isset($this->seedlist)) { |
||
532 | $this->db->query('SELECT sector_id FROM alliance_has_seedlist WHERE ' . $this->SQL); |
||
533 | $this->seedlist = array(); |
||
534 | while ($this->db->nextRecord()) { |
||
535 | $this->seedlist[] = $this->db->getInt('sector_id'); |
||
536 | } |
||
537 | } |
||
538 | return $this->seedlist; |
||
539 | } |
||
540 | |||
541 | /** |
||
542 | * Is the given sector in the alliance seedlist? |
||
543 | */ |
||
544 | public function isInSeedlist(SmrSector $sector) { |
||
546 | } |
||
547 | |||
548 | /** |
||
549 | * Create the default roles for this alliance. |
||
550 | * This should only be called once after the alliance is created. |
||
551 | */ |
||
552 | public function createDefaultRoles($newMemberPermission = 'basic') { |
||
553 | $db = $this->db; //for convenience |
||
554 | |||
555 | $withPerDay = ALLIANCE_BANK_UNLIMITED; |
||
556 | $removeMember = TRUE; |
||
557 | $changePass = TRUE; |
||
558 | $changeMOD = TRUE; |
||
559 | $changeRoles = TRUE; |
||
560 | $planetAccess = TRUE; |
||
561 | $exemptWith = TRUE; |
||
562 | $mbMessages = TRUE; |
||
563 | $sendAllMsg = TRUE; |
||
564 | $opLeader = TRUE; |
||
565 | $viewBonds = TRUE; |
||
566 | $db->query('INSERT INTO alliance_has_roles (alliance_id, game_id, role_id, role, with_per_day, remove_member, change_pass, change_mod, change_roles, planet_access, exempt_with, mb_messages, send_alliance_msg, op_leader, view_bonds) ' . |
||
567 | 'VALUES (' . $db->escapeNumber($this->getAllianceID()) . ', ' . $db->escapeNumber($this->getGameID()) . ', ' . $db->escapeNumber(ALLIANCE_ROLE_LEADER) . ', \'Leader\', ' . $db->escapeNumber($withPerDay) . ', ' . $db->escapeBoolean($removeMember) . ', ' . $db->escapeBoolean($changePass) . ', ' . $db->escapeBoolean($changeMOD) . ', ' . $db->escapeBoolean($changeRoles) . ', ' . $db->escapeBoolean($planetAccess) . ', ' . $db->escapeBoolean($exemptWith) . ', ' . $db->escapeBoolean($mbMessages) . ', ' . $db->escapeString($sendAllMsg) . ', ' . $db->escapeBoolean($opLeader) . ', ' . $db->escapeBoolean($viewBonds) . ')'); |
||
602 | |||
603 | } |
||
604 | |||
605 | } |
||
606 |