We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -50,9 +50,9 @@ discard block |
||
50 | 50 | protected $HOF; |
51 | 51 | protected static $HOFVis; |
52 | 52 | |
53 | - protected $hasChanged=false; |
|
54 | - protected $hasHOFChanged=false; |
|
55 | - protected static $hasHOFVisChanged=array(); |
|
53 | + protected $hasChanged = false; |
|
54 | + protected $hasHOFChanged = false; |
|
55 | + protected static $hasHOFVisChanged = array(); |
|
56 | 56 | protected $hasBountyChanged = array(); |
57 | 57 | |
58 | 58 | protected function __construct() { |
@@ -75,13 +75,13 @@ discard block |
||
75 | 75 | } |
76 | 76 | |
77 | 77 | public function hasNewbieTurns() { |
78 | - return $this->getNewbieTurns()>0; |
|
78 | + return $this->getNewbieTurns() > 0; |
|
79 | 79 | } |
80 | 80 | public function setNewbieTurns($newbieTurns) { |
81 | - if($this->newbieTurns == $newbieTurns) |
|
81 | + if ($this->newbieTurns == $newbieTurns) |
|
82 | 82 | return; |
83 | - $this->newbieTurns=$newbieTurns; |
|
84 | - $this->hasChanged=true; |
|
83 | + $this->newbieTurns = $newbieTurns; |
|
84 | + $this->hasChanged = true; |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | public function getShipTypeID() { |
@@ -89,10 +89,10 @@ discard block |
||
89 | 89 | } |
90 | 90 | |
91 | 91 | public function setShipTypeID($shipID) { |
92 | - if($this->shipID == $shipID) |
|
92 | + if ($this->shipID == $shipID) |
|
93 | 93 | return; |
94 | - $this->shipID=$shipID; |
|
95 | - $this->hasChanged=true; |
|
94 | + $this->shipID = $shipID; |
|
95 | + $this->hasChanged = true; |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -109,11 +109,11 @@ discard block |
||
109 | 109 | } |
110 | 110 | |
111 | 111 | public function &getSectorPlanet() { |
112 | - return SmrPlanet::getPlanet($this->getGameID(),$this->getSectorID()); |
|
112 | + return SmrPlanet::getPlanet($this->getGameID(), $this->getSectorID()); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | public function &getSectorPort() { |
116 | - return SmrPort::getPort($this->getGameID(),$this->getSectorID()); |
|
116 | + return SmrPort::getPort($this->getGameID(), $this->getSectorID()); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | public function getSectorID() { |
@@ -121,15 +121,15 @@ discard block |
||
121 | 121 | } |
122 | 122 | |
123 | 123 | public function &getSector() { |
124 | - return SmrSector::getSector($this->getGameID(),$this->getSectorID()); |
|
124 | + return SmrSector::getSector($this->getGameID(), $this->getSectorID()); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | public function setSectorID($sectorID) { |
128 | 128 | $this->lastSectorID = $this->getSectorID(); |
129 | - $this->actionTaken('LeaveSector',array('Sector'=>$this->getSector())); |
|
129 | + $this->actionTaken('LeaveSector', array('Sector'=>$this->getSector())); |
|
130 | 130 | $this->sectorID = $sectorID; |
131 | - $this->actionTaken('EnterSector',array('Sector'=>$this->getSector())); |
|
132 | - $this->hasChanged=true; |
|
131 | + $this->actionTaken('EnterSector', array('Sector'=>$this->getSector())); |
|
132 | + $this->hasChanged = true; |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | public function getLastSectorID() { |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | } |
165 | 165 | |
166 | 166 | public function isDraftLeader() { |
167 | - if(!isset($this->draftLeader)) { |
|
167 | + if (!isset($this->draftLeader)) { |
|
168 | 168 | $this->draftLeader = false; |
169 | 169 | $this->db->query('SELECT 1 FROM draft_leaders WHERE ' . $this->SQL . ' LIMIT 1'); |
170 | 170 | if ($this->db->nextRecord()) { |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | } |
176 | 176 | |
177 | 177 | public function getGPWriter() { |
178 | - if(!isset($this->gpWriter)) { |
|
178 | + if (!isset($this->gpWriter)) { |
|
179 | 179 | $this->gpWriter = false; |
180 | 180 | $this->db->query('SELECT position FROM galactic_post_writer WHERE ' . $this->SQL); |
181 | 181 | if ($this->db->nextRecord()) { |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | } |
201 | 201 | |
202 | 202 | public function hasFederalProtection() { |
203 | - $sector = SmrSector::getSector($this->getGameID(),$this->getSectorID()); |
|
203 | + $sector = SmrSector::getSector($this->getGameID(), $this->getSectorID()); |
|
204 | 204 | if (!$sector->offersFederalProtection()) { |
205 | 205 | return false; |
206 | 206 | } |
@@ -210,8 +210,8 @@ discard block |
||
210 | 210 | return false; |
211 | 211 | |
212 | 212 | if ($ship->getAttackRating() <= $this->getSafeAttackRating()) { |
213 | - foreach($sector->getFedRaceIDs() as $fedRaceID) { |
|
214 | - if($this->canBeProtectedByRace($fedRaceID)) { |
|
213 | + foreach ($sector->getFedRaceIDs() as $fedRaceID) { |
|
214 | + if ($this->canBeProtectedByRace($fedRaceID)) { |
|
215 | 215 | return true; |
216 | 216 | } |
217 | 217 | } |
@@ -221,15 +221,15 @@ discard block |
||
221 | 221 | } |
222 | 222 | |
223 | 223 | public function canBeProtectedByRace($raceID) { |
224 | - if(!isset($this->canFed)) { |
|
224 | + if (!isset($this->canFed)) { |
|
225 | 225 | $this->canFed = array(); |
226 | 226 | $RACES = Globals::getRaces(); |
227 | - foreach($RACES as $raceID2 => $raceName) { |
|
227 | + foreach ($RACES as $raceID2 => $raceName) { |
|
228 | 228 | $this->canFed[$raceID2] = $this->getRelation($raceID2) >= ALIGN_FED_PROTECTION; |
229 | 229 | } |
230 | 230 | $this->db->query('SELECT race_id, allowed FROM player_can_fed |
231 | 231 | WHERE ' . $this->SQL . ' AND expiry > ' . $this->db->escapeNumber(TIME)); |
232 | - while($this->db->nextRecord()) { |
|
232 | + while ($this->db->nextRecord()) { |
|
233 | 233 | $this->canFed[$this->db->getInt('race_id')] = $this->db->getBoolean('allowed'); |
234 | 234 | } |
235 | 235 | } |
@@ -248,10 +248,10 @@ discard block |
||
248 | 248 | } |
249 | 249 | |
250 | 250 | public function setDead($bool) { |
251 | - if($this->dead == $bool) |
|
251 | + if ($this->dead == $bool) |
|
252 | 252 | return; |
253 | - $this->dead=$bool; |
|
254 | - $this->hasChanged=true; |
|
253 | + $this->dead = $bool; |
|
254 | + $this->hasChanged = true; |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | public function getKills() { |
@@ -259,16 +259,16 @@ discard block |
||
259 | 259 | } |
260 | 260 | |
261 | 261 | public function increaseKills($kills) { |
262 | - if($kills < 0) |
|
262 | + if ($kills < 0) |
|
263 | 263 | throw new Exception('Trying to increase negative kills.'); |
264 | - $this->setKills($this->kills+$kills); |
|
264 | + $this->setKills($this->kills + $kills); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | public function setKills($kills) { |
268 | - if($this->kills == $kills) |
|
268 | + if ($this->kills == $kills) |
|
269 | 269 | return; |
270 | - $this->kills=$kills; |
|
271 | - $this->hasChanged=true; |
|
270 | + $this->kills = $kills; |
|
271 | + $this->hasChanged = true; |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | public function getDeaths() { |
@@ -276,16 +276,16 @@ discard block |
||
276 | 276 | } |
277 | 277 | |
278 | 278 | public function increaseDeaths($deaths) { |
279 | - if($deaths < 0) |
|
279 | + if ($deaths < 0) |
|
280 | 280 | throw new Exception('Trying to increase negative deaths.'); |
281 | - $this->setDeaths($this->getDeaths()+$deaths); |
|
281 | + $this->setDeaths($this->getDeaths() + $deaths); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | public function setDeaths($deaths) { |
285 | - if($this->deaths == $deaths) |
|
285 | + if ($this->deaths == $deaths) |
|
286 | 286 | return; |
287 | 287 | $this->deaths = $deaths; |
288 | - $this->hasChanged=true; |
|
288 | + $this->hasChanged = true; |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | public function getAssists() { |
@@ -305,26 +305,26 @@ discard block |
||
305 | 305 | } |
306 | 306 | |
307 | 307 | public function increaseAlignment($align) { |
308 | - if($align < 0) |
|
308 | + if ($align < 0) |
|
309 | 309 | throw new Exception('Trying to increase negative align.'); |
310 | - if($align == 0) |
|
310 | + if ($align == 0) |
|
311 | 311 | return; |
312 | 312 | $align += $this->alignment; |
313 | 313 | $this->setAlignment($align); |
314 | 314 | } |
315 | 315 | public function decreaseAlignment($align) { |
316 | - if($align < 0) |
|
316 | + if ($align < 0) |
|
317 | 317 | throw new Exception('Trying to decrease negative align.'); |
318 | - if($align == 0) |
|
318 | + if ($align == 0) |
|
319 | 319 | return; |
320 | 320 | $align = $this->alignment - $align; |
321 | 321 | $this->setAlignment($align); |
322 | 322 | } |
323 | 323 | public function setAlignment($align) { |
324 | - if($this->alignment == $align) |
|
324 | + if ($this->alignment == $align) |
|
325 | 325 | return; |
326 | 326 | $this->alignment = $align; |
327 | - $this->hasChanged=true; |
|
327 | + $this->hasChanged = true; |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | public function getCredits() { |
@@ -336,9 +336,9 @@ discard block |
||
336 | 336 | } |
337 | 337 | |
338 | 338 | public function getNextLevelPercentAcquired() { |
339 | - if($this->getNextLevelExperience() == $this->getThisLevelExperience()) |
|
339 | + if ($this->getNextLevelExperience() == $this->getThisLevelExperience()) |
|
340 | 340 | return 100; |
341 | - return max(0,min(100,round(($this->getExperience() - $this->getThisLevelExperience()) / ($this->getNextLevelExperience() - $this->getThisLevelExperience())*100))); |
|
341 | + return max(0, min(100, round(($this->getExperience() - $this->getThisLevelExperience()) / ($this->getNextLevelExperience() - $this->getThisLevelExperience()) * 100))); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | public function getNextLevelPercentRemaining() { |
@@ -347,9 +347,9 @@ discard block |
||
347 | 347 | |
348 | 348 | public function getNextLevelExperience() { |
349 | 349 | $LEVELS_REQUIREMENTS = Globals::getLevelRequirements(); |
350 | - if(!isset($LEVELS_REQUIREMENTS[$this->getLevelID()+1])) |
|
350 | + if (!isset($LEVELS_REQUIREMENTS[$this->getLevelID() + 1])) |
|
351 | 351 | return $this->getThisLevelExperience(); //Return current level experience if on last level. |
352 | - return $LEVELS_REQUIREMENTS[$this->getLevelID()+1]['Requirement']; |
|
352 | + return $LEVELS_REQUIREMENTS[$this->getLevelID() + 1]['Requirement']; |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | public function getThisLevelExperience() { |
@@ -358,14 +358,14 @@ discard block |
||
358 | 358 | } |
359 | 359 | |
360 | 360 | public function setExperience($experience) { |
361 | - if($this->experience == $experience) |
|
361 | + if ($this->experience == $experience) |
|
362 | 362 | return; |
363 | - if($experience<MIN_EXPERIENCE) |
|
363 | + if ($experience < MIN_EXPERIENCE) |
|
364 | 364 | $experience = MIN_EXPERIENCE; |
365 | - if($experience>MAX_EXPERIENCE) |
|
365 | + if ($experience > MAX_EXPERIENCE) |
|
366 | 366 | $experience = MAX_EXPERIENCE; |
367 | 367 | $this->experience = $experience; |
368 | - $this->hasChanged=true; |
|
368 | + $this->hasChanged = true; |
|
369 | 369 | |
370 | 370 | // Since exp has changed, invalidate the player level so that it can |
371 | 371 | // be recomputed next time it is queried (in case it has changed). |
@@ -373,49 +373,49 @@ discard block |
||
373 | 373 | } |
374 | 374 | |
375 | 375 | public function increaseCredits($credits) { |
376 | - if($credits < 0) |
|
376 | + if ($credits < 0) |
|
377 | 377 | throw new Exception('Trying to increase negative credits.'); |
378 | - if($credits == 0) |
|
378 | + if ($credits == 0) |
|
379 | 379 | return; |
380 | 380 | $credits += $this->credits; |
381 | 381 | $this->setCredits($credits); |
382 | 382 | } |
383 | 383 | public function decreaseCredits($credits) { |
384 | - if($credits < 0) |
|
384 | + if ($credits < 0) |
|
385 | 385 | throw new Exception('Trying to decrease negative credits.'); |
386 | - if($credits == 0) |
|
386 | + if ($credits == 0) |
|
387 | 387 | return; |
388 | 388 | $credits = $this->credits - $credits; |
389 | 389 | $this->setCredits($credits); |
390 | 390 | } |
391 | 391 | public function setCredits($credits) { |
392 | - if($this->credits == $credits) |
|
392 | + if ($this->credits == $credits) |
|
393 | 393 | return; |
394 | - if($credits < 0) |
|
394 | + if ($credits < 0) |
|
395 | 395 | throw new Exception('Trying to set negative credits.'); |
396 | - if($credits > MAX_MONEY) |
|
396 | + if ($credits > MAX_MONEY) |
|
397 | 397 | $credits = MAX_MONEY; |
398 | 398 | $this->credits = $credits; |
399 | - $this->hasChanged=true; |
|
399 | + $this->hasChanged = true; |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | public function increaseExperience($experience) { |
403 | - if($experience < 0) |
|
403 | + if ($experience < 0) |
|
404 | 404 | throw new Exception('Trying to increase negative experience.'); |
405 | - if($experience == 0) |
|
405 | + if ($experience == 0) |
|
406 | 406 | return; |
407 | 407 | $newExperience = $this->experience + $experience; |
408 | 408 | $this->setExperience($newExperience); |
409 | - $this->increaseHOF($experience,array('Experience','Total','Gain'), HOF_PUBLIC); |
|
409 | + $this->increaseHOF($experience, array('Experience', 'Total', 'Gain'), HOF_PUBLIC); |
|
410 | 410 | } |
411 | 411 | public function decreaseExperience($experience) { |
412 | - if($experience < 0) |
|
412 | + if ($experience < 0) |
|
413 | 413 | throw new Exception('Trying to decrease negative experience.'); |
414 | - if($experience == 0) |
|
414 | + if ($experience == 0) |
|
415 | 415 | return; |
416 | 416 | $newExperience = $this->experience - $experience; |
417 | 417 | $this->setExperience($newExperience); |
418 | - $this->decreaseHOF($experience,array('Experience','Total','Loss'), HOF_PUBLIC); |
|
418 | + $this->decreaseHOF($experience, array('Experience', 'Total', 'Loss'), HOF_PUBLIC); |
|
419 | 419 | } |
420 | 420 | |
421 | 421 | public function isLandedOnPlanet() { |
@@ -423,10 +423,10 @@ discard block |
||
423 | 423 | } |
424 | 424 | |
425 | 425 | public function setLandedOnPlanet($bool) { |
426 | - if($this->landedOnPlanet == $bool) |
|
426 | + if ($this->landedOnPlanet == $bool) |
|
427 | 427 | return; |
428 | - $this->landedOnPlanet=$bool; |
|
429 | - $this->hasChanged=true; |
|
428 | + $this->landedOnPlanet = $bool; |
|
429 | + $this->hasChanged = true; |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | /** |
@@ -472,24 +472,24 @@ discard block |
||
472 | 472 | $this->hasChanged = true; |
473 | 473 | } |
474 | 474 | |
475 | - public function getDisplayName($includeAlliance=false) { |
|
476 | - $return = get_colored_text($this->getAlignment(),$this->playerName.' ('.$this->getPlayerID().')'); |
|
477 | - if($this->isNPC()) { |
|
475 | + public function getDisplayName($includeAlliance = false) { |
|
476 | + $return = get_colored_text($this->getAlignment(), $this->playerName . ' (' . $this->getPlayerID() . ')'); |
|
477 | + if ($this->isNPC()) { |
|
478 | 478 | $return .= ' <span class="npcColour">[NPC]</span>'; |
479 | 479 | } |
480 | - if($includeAlliance) { |
|
481 | - $return.= ' (' . $this->getAllianceName() . '</a>' . ')'; |
|
480 | + if ($includeAlliance) { |
|
481 | + $return .= ' (' . $this->getAllianceName() . '</a>' . ')'; |
|
482 | 482 | } |
483 | 483 | return $return; |
484 | 484 | } |
485 | 485 | |
486 | 486 | public function getBBLink() { |
487 | - return '[player='.$this->getPlayerID().']'; |
|
487 | + return '[player=' . $this->getPlayerID() . ']'; |
|
488 | 488 | } |
489 | 489 | |
490 | - public function getLinkedDisplayName($includeAlliance=true) { |
|
491 | - $return = '<a href="'.$this->getTraderSearchHREF().'">'.$this->getDisplayName().'</a>'; |
|
492 | - if($includeAlliance) { |
|
490 | + public function getLinkedDisplayName($includeAlliance = true) { |
|
491 | + $return = '<a href="' . $this->getTraderSearchHREF() . '">' . $this->getDisplayName() . '</a>'; |
|
492 | + if ($includeAlliance) { |
|
493 | 493 | $return .= ' (' . $this->getAllianceName(true) . ')'; |
494 | 494 | } |
495 | 495 | return $return; |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | |
506 | 506 | public static function getColouredRaceNameOrDefault($otherRaceID, AbstractSmrPlayer $player = null, $linked = false) { |
507 | 507 | $relations = 0; |
508 | - if($player !== null) { |
|
508 | + if ($player !== null) { |
|
509 | 509 | $relations = $player->getRelation($otherRaceID); |
510 | 510 | } |
511 | 511 | return Globals::getColouredRaceName($otherRaceID, $relations, $linked); |
@@ -516,10 +516,10 @@ discard block |
||
516 | 516 | } |
517 | 517 | |
518 | 518 | public function setRaceID($raceID) { |
519 | - if($this->raceID == $raceID) |
|
519 | + if ($this->raceID == $raceID) |
|
520 | 520 | return; |
521 | - $this->raceID=$raceID; |
|
522 | - $this->hasChanged=true; |
|
521 | + $this->raceID = $raceID; |
|
522 | + $this->hasChanged = true; |
|
523 | 523 | } |
524 | 524 | |
525 | 525 | public function isAllianceLeader($forceUpdate = false) { |
@@ -535,27 +535,27 @@ discard block |
||
535 | 535 | } |
536 | 536 | |
537 | 537 | public function hasAlliance() { |
538 | - return $this->getAllianceID()!=0; |
|
538 | + return $this->getAllianceID() != 0; |
|
539 | 539 | } |
540 | 540 | |
541 | 541 | public function setAllianceID($ID) { |
542 | - if($this->allianceID == $ID) |
|
542 | + if ($this->allianceID == $ID) |
|
543 | 543 | return; |
544 | - $this->allianceID=$ID; |
|
544 | + $this->allianceID = $ID; |
|
545 | 545 | if ($this->allianceID != 0) { |
546 | 546 | $status = $this->hasNewbieStatus() ? 'NEWBIE' : 'VETERAN'; |
547 | 547 | $this->db->query('INSERT IGNORE INTO player_joined_alliance (account_id,game_id,alliance_id,status) ' . |
548 | - 'VALUES ('.$this->db->escapeNumber($this->getAccountID()).','.$this->db->escapeNumber($this->getGameID()).','.$this->db->escapeNumber($this->getAllianceID()).','.$this->db->escapeString($status).')'); |
|
548 | + 'VALUES (' . $this->db->escapeNumber($this->getAccountID()) . ',' . $this->db->escapeNumber($this->getGameID()) . ',' . $this->db->escapeNumber($this->getAllianceID()) . ',' . $this->db->escapeString($status) . ')'); |
|
549 | 549 | } |
550 | - $this->hasChanged=true; |
|
550 | + $this->hasChanged = true; |
|
551 | 551 | } |
552 | 552 | |
553 | 553 | public function getAllianceBBLink() { |
554 | - return $this->hasAlliance()?'[alliance='.$this->getAllianceID().']':$this->getAllianceName(); |
|
554 | + return $this->hasAlliance() ? '[alliance=' . $this->getAllianceID() . ']' : $this->getAllianceName(); |
|
555 | 555 | } |
556 | 556 | |
557 | - public function getAllianceName($linked=false, $includeAllianceID=false) { |
|
558 | - if($this->hasAlliance()) { |
|
557 | + public function getAllianceName($linked = false, $includeAllianceID = false) { |
|
558 | + if ($this->hasAlliance()) { |
|
559 | 559 | return $this->getAlliance()->getAllianceName($linked, $includeAllianceID); |
560 | 560 | } |
561 | 561 | else { |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | if ($allianceID === false) { |
568 | 568 | $allianceID = $this->getAllianceID(); |
569 | 569 | } |
570 | - if(!isset($this->allianceRoles[$allianceID])) { |
|
570 | + if (!isset($this->allianceRoles[$allianceID])) { |
|
571 | 571 | $this->allianceRoles[$allianceID] = 0; |
572 | 572 | $this->db->query('SELECT role_id |
573 | 573 | FROM player_has_alliance_role |
@@ -590,10 +590,10 @@ discard block |
||
590 | 590 | } |
591 | 591 | |
592 | 592 | public function setCombatDronesKamikazeOnMines($bool) { |
593 | - if($this->combatDronesKamikazeOnMines == $bool) |
|
593 | + if ($this->combatDronesKamikazeOnMines == $bool) |
|
594 | 594 | return; |
595 | 595 | $this->combatDronesKamikazeOnMines = $bool; |
596 | - $this->hasChanged=true; |
|
596 | + $this->hasChanged = true; |
|
597 | 597 | } |
598 | 598 | |
599 | 599 | protected abstract function getGadgetsData(); |
@@ -603,19 +603,19 @@ discard block |
||
603 | 603 | } |
604 | 604 | |
605 | 605 | public function getGadget($gadgetID) { |
606 | - if(!is_numeric($gadgetID)) { |
|
606 | + if (!is_numeric($gadgetID)) { |
|
607 | 607 | global $GADGETS; |
608 | 608 | $gadgetID = $GADGETS[$gadgetID]['ID']; |
609 | 609 | } |
610 | 610 | $gadgets = $this->getGadgets(); |
611 | - if(isset($gadgets[$gadgetID])) |
|
611 | + if (isset($gadgets[$gadgetID])) |
|
612 | 612 | return $gadgets[$gadgetID]; |
613 | 613 | return false; |
614 | 614 | } |
615 | 615 | |
616 | 616 | public function isGadgetEquipped($gadgetID) { |
617 | 617 | $gadget = $this->getGadget($gadgetID); |
618 | - if($gadget===false) |
|
618 | + if ($gadget === false) |
|
619 | 619 | return false; |
620 | 620 | return $gadget['Equipped'] > 0 && $gadget['Equipped'] < TIME && ($gadget['Expires'] == 0 || $gadget['Expires'] > TIME) && $gadget['Cooldown'] <= TIME; |
621 | 621 | } |
@@ -636,10 +636,10 @@ discard block |
||
636 | 636 | } |
637 | 637 | |
638 | 638 | public function getRelations() { |
639 | - if(!isset($this->relations)) { |
|
639 | + if (!isset($this->relations)) { |
|
640 | 640 | //get relations |
641 | 641 | $RACES = Globals::getRaces(); |
642 | - $raceRelations = Globals::getRaceRelations($this->getGameID(),$this->getRaceID()); |
|
642 | + $raceRelations = Globals::getRaceRelations($this->getGameID(), $this->getRaceID()); |
|
643 | 643 | $pureRels = $this->getPureRelations(); // make sure they're initialised. |
644 | 644 | $this->relations = array(); |
645 | 645 | foreach ($RACES as $raceID => $raceName) { |
@@ -684,26 +684,26 @@ discard block |
||
684 | 684 | } |
685 | 685 | |
686 | 686 | public function hasMilitaryPayment() { |
687 | - return $this->getMilitaryPayment()>0; |
|
687 | + return $this->getMilitaryPayment() > 0; |
|
688 | 688 | } |
689 | 689 | |
690 | 690 | public function setMilitaryPayment($amount) { |
691 | - if($this->militaryPayment == $amount) |
|
691 | + if ($this->militaryPayment == $amount) |
|
692 | 692 | return; |
693 | 693 | $this->militaryPayment = $amount; |
694 | - $this->hasChanged=true; |
|
694 | + $this->hasChanged = true; |
|
695 | 695 | } |
696 | 696 | |
697 | 697 | public function increaseMilitaryPayment($amount) { |
698 | - if($amount < 0) |
|
698 | + if ($amount < 0) |
|
699 | 699 | throw new Exception('Trying to increase negative military payment.'); |
700 | - $this->setMilitaryPayment($this->getMilitaryPayment()+$amount); |
|
700 | + $this->setMilitaryPayment($this->getMilitaryPayment() + $amount); |
|
701 | 701 | } |
702 | 702 | |
703 | 703 | public function decreaseMilitaryPayment($amount) { |
704 | - if($amount < 0) |
|
704 | + if ($amount < 0) |
|
705 | 705 | throw new Exception('Trying to decrease negative military payment.'); |
706 | - $this->setMilitaryPayment($this->getMilitaryPayment()-$amount); |
|
706 | + $this->setMilitaryPayment($this->getMilitaryPayment() - $amount); |
|
707 | 707 | } |
708 | 708 | |
709 | 709 | abstract protected function getBountiesData(); |
@@ -714,7 +714,7 @@ discard block |
||
714 | 714 | } |
715 | 715 | |
716 | 716 | public function hasBounties() { |
717 | - return count($this->getBounties())>0; |
|
717 | + return count($this->getBounties()) > 0; |
|
718 | 718 | } |
719 | 719 | |
720 | 720 | public function getBounty($bountyID) { |
@@ -723,7 +723,7 @@ discard block |
||
723 | 723 | } |
724 | 724 | |
725 | 725 | public function hasBounty($bountyID) { |
726 | - return $this->getBounty($bountyID)!==false; |
|
726 | + return $this->getBounty($bountyID) !== false; |
|
727 | 727 | } |
728 | 728 | |
729 | 729 | public function getBountyAmount($bountyID) { |
@@ -744,15 +744,15 @@ discard block |
||
744 | 744 | |
745 | 745 | public function getNextBountyID() { |
746 | 746 | $keys = array_keys($this->getBounties()); |
747 | - if(count($keys)>0) |
|
748 | - return max($keys)+1; |
|
747 | + if (count($keys) > 0) |
|
748 | + return max($keys) + 1; |
|
749 | 749 | else |
750 | 750 | return 0; |
751 | 751 | } |
752 | 752 | |
753 | 753 | public function setBounty(array $bounty) { |
754 | 754 | $this->bounties[$bounty['ID']] = $bounty; |
755 | - $this->hasBountyChanged[$bounty['ID']]=true; |
|
755 | + $this->hasBountyChanged[$bounty['ID']] = true; |
|
756 | 756 | } |
757 | 757 | |
758 | 758 | public function setBountyAmount($bountyID, $amount) { |
@@ -761,22 +761,22 @@ discard block |
||
761 | 761 | $this->setBounty($bounty); |
762 | 762 | } |
763 | 763 | |
764 | - public function increaseBountyAmount($bountyID,$amount) { |
|
765 | - if($amount < 0) |
|
764 | + public function increaseBountyAmount($bountyID, $amount) { |
|
765 | + if ($amount < 0) |
|
766 | 766 | throw new Exception('Trying to increase negative bounty.'); |
767 | - $this->setBountyAmount($this->getBountyAmount($bountyID)+$amount); |
|
767 | + $this->setBountyAmount($this->getBountyAmount($bountyID) + $amount); |
|
768 | 768 | } |
769 | 769 | |
770 | - public function decreaseBountyAmount($bountyID,$amount) { |
|
771 | - if($amount < 0) |
|
770 | + public function decreaseBountyAmount($bountyID, $amount) { |
|
771 | + if ($amount < 0) |
|
772 | 772 | throw new Exception('Trying to decrease negative bounty.'); |
773 | - $this->setBountyAmount($this->getBountyAmount($bountyID)+$amount); |
|
773 | + $this->setBountyAmount($this->getBountyAmount($bountyID) + $amount); |
|
774 | 774 | } |
775 | 775 | |
776 | 776 | public function getCurrentBounty($type) { |
777 | 777 | $bounties = $this->getBounties(); |
778 | - foreach($bounties as $bounty) { |
|
779 | - if($bounty['Claimer'] == 0 && $bounty['Type']==$type) |
|
778 | + foreach ($bounties as $bounty) { |
|
779 | + if ($bounty['Claimer'] == 0 && $bounty['Type'] == $type) |
|
780 | 780 | return $bounty; |
781 | 781 | } |
782 | 782 | return $this->createBounty($type); |
@@ -784,8 +784,8 @@ discard block |
||
784 | 784 | |
785 | 785 | public function hasCurrentBounty($type) { |
786 | 786 | $bounties = $this->getBounties(); |
787 | - foreach($bounties as $bounty) { |
|
788 | - if($bounty['Claimer'] == 0 && $bounty['Type']==$type) |
|
787 | + foreach ($bounties as $bounty) { |
|
788 | + if ($bounty['Claimer'] == 0 && $bounty['Type'] == $type) |
|
789 | 789 | return true; |
790 | 790 | } |
791 | 791 | return false; |
@@ -798,22 +798,22 @@ discard block |
||
798 | 798 | |
799 | 799 | public function setCurrentBountyAmount($type, $amount) { |
800 | 800 | $bounty = $this->getCurrentBounty($type); |
801 | - if($bounty['Amount'] == $amount) |
|
801 | + if ($bounty['Amount'] == $amount) |
|
802 | 802 | return; |
803 | 803 | $bounty['Amount'] = $amount; |
804 | 804 | $this->setBounty($bounty); |
805 | 805 | } |
806 | 806 | |
807 | - public function increaseCurrentBountyAmount($type,$amount) { |
|
808 | - if($amount < 0) |
|
807 | + public function increaseCurrentBountyAmount($type, $amount) { |
|
808 | + if ($amount < 0) |
|
809 | 809 | throw new Exception('Trying to increase negative current bounty.'); |
810 | - $this->setCurrentBountyAmount($type,$this->getCurrentBountyAmount($type)+$amount); |
|
810 | + $this->setCurrentBountyAmount($type, $this->getCurrentBountyAmount($type) + $amount); |
|
811 | 811 | } |
812 | 812 | |
813 | - public function decreaseCurrentBountyAmount($type,$amount) { |
|
814 | - if($amount < 0) |
|
813 | + public function decreaseCurrentBountyAmount($type, $amount) { |
|
814 | + if ($amount < 0) |
|
815 | 815 | throw new Exception('Trying to decrease negative current bounty.'); |
816 | - $this->setCurrentBountyAmount($type,$this->getCurrentBountyAmount($type)-$amount); |
|
816 | + $this->setCurrentBountyAmount($type, $this->getCurrentBountyAmount($type) - $amount); |
|
817 | 817 | } |
818 | 818 | |
819 | 819 | public function getCurrentBountySmrCredits($type) { |
@@ -823,29 +823,29 @@ discard block |
||
823 | 823 | |
824 | 824 | public function setCurrentBountySmrCredits($type, $credits) { |
825 | 825 | $bounty = $this->getCurrentBounty($type); |
826 | - if($bounty['SmrCredits'] == $credits) |
|
826 | + if ($bounty['SmrCredits'] == $credits) |
|
827 | 827 | return; |
828 | 828 | $bounty['SmrCredits'] = $credits; |
829 | 829 | $this->setBounty($bounty); |
830 | 830 | } |
831 | 831 | |
832 | - public function increaseCurrentBountySmrCredits($type,$credits) { |
|
833 | - if($credits<0) |
|
832 | + public function increaseCurrentBountySmrCredits($type, $credits) { |
|
833 | + if ($credits < 0) |
|
834 | 834 | throw new Exception('Trying to increase negative current bounty.'); |
835 | - $this->setCurrentBountySmrCredits($type,$this->getCurrentBountySmrCredits($type)+$credits); |
|
835 | + $this->setCurrentBountySmrCredits($type, $this->getCurrentBountySmrCredits($type) + $credits); |
|
836 | 836 | } |
837 | 837 | |
838 | - public function decreaseCurrentBountySmrCredits($type,$credits) { |
|
839 | - if($credits<0) |
|
838 | + public function decreaseCurrentBountySmrCredits($type, $credits) { |
|
839 | + if ($credits < 0) |
|
840 | 840 | throw new Exception('Trying to decrease negative current bounty.'); |
841 | - $this->setCurrentBountySmrCredits($type,$this->getCurrentBountySmrCredits($type)-$credits); |
|
841 | + $this->setCurrentBountySmrCredits($type, $this->getCurrentBountySmrCredits($type) - $credits); |
|
842 | 842 | } |
843 | 843 | |
844 | 844 | public function setBountiesClaimable(AbstractSmrPlayer $claimer) { |
845 | 845 | $bounties = $this->getBounties(); |
846 | - if(is_array($bounties)) { |
|
847 | - foreach($bounties as $bounty) { |
|
848 | - if($bounty['Claimer'] == 0) { |
|
846 | + if (is_array($bounties)) { |
|
847 | + foreach ($bounties as $bounty) { |
|
848 | + if ($bounty['Claimer'] == 0) { |
|
849 | 849 | $bounty['Claimer'] = $claimer->getAccountID(); |
850 | 850 | $this->setBounty($bounty); |
851 | 851 | } |
@@ -858,71 +858,71 @@ discard block |
||
858 | 858 | |
859 | 859 | public function getHOF(array $typeList = null) { |
860 | 860 | $this->getHOFData(); |
861 | - if($typeList==null) |
|
861 | + if ($typeList == null) |
|
862 | 862 | return $this->HOF; |
863 | - $hof=$this->HOF; |
|
864 | - foreach($typeList as $type) { |
|
865 | - if(!isset($hof[$type])) |
|
863 | + $hof = $this->HOF; |
|
864 | + foreach ($typeList as $type) { |
|
865 | + if (!isset($hof[$type])) |
|
866 | 866 | return 0; |
867 | 867 | $hof = $hof[$type]; |
868 | 868 | } |
869 | 869 | return $hof; |
870 | 870 | } |
871 | 871 | |
872 | - public function increaseHOF($amount,array $typeList, $visibility) { |
|
873 | - if($amount < 0) |
|
874 | - throw new Exception('Trying to increase negative HOF: '.implode(':',$typeList)); |
|
875 | - if($amount == 0) |
|
872 | + public function increaseHOF($amount, array $typeList, $visibility) { |
|
873 | + if ($amount < 0) |
|
874 | + throw new Exception('Trying to increase negative HOF: ' . implode(':', $typeList)); |
|
875 | + if ($amount == 0) |
|
876 | 876 | return; |
877 | - $this->setHOF($this->getHOF($typeList)+$amount,$typeList, $visibility); |
|
877 | + $this->setHOF($this->getHOF($typeList) + $amount, $typeList, $visibility); |
|
878 | 878 | } |
879 | 879 | |
880 | - public function decreaseHOF($amount,array $typeList, $visibility) { |
|
881 | - if($amount < 0) |
|
882 | - throw new Exception('Trying to decrease negative HOF: '.implode(':',$typeList)); |
|
883 | - if($amount == 0) |
|
880 | + public function decreaseHOF($amount, array $typeList, $visibility) { |
|
881 | + if ($amount < 0) |
|
882 | + throw new Exception('Trying to decrease negative HOF: ' . implode(':', $typeList)); |
|
883 | + if ($amount == 0) |
|
884 | 884 | return; |
885 | - $this->setHOF($this->getHOF($typeList)-$amount,$typeList, $visibility); |
|
885 | + $this->setHOF($this->getHOF($typeList) - $amount, $typeList, $visibility); |
|
886 | 886 | } |
887 | 887 | |
888 | - public function setHOF($amount,array $typeList, $visibility) { |
|
889 | - if(is_array($this->getHOF($typeList))) |
|
890 | - throw new Exception('Trying to overwrite a HOF type: '.implode(':',$typeList)); |
|
891 | - if($this->isNPC()) { |
|
888 | + public function setHOF($amount, array $typeList, $visibility) { |
|
889 | + if (is_array($this->getHOF($typeList))) |
|
890 | + throw new Exception('Trying to overwrite a HOF type: ' . implode(':', $typeList)); |
|
891 | + if ($this->isNPC()) { |
|
892 | 892 | // Don't store HOF for NPCs. |
893 | 893 | return; |
894 | 894 | } |
895 | - if($this->getHOF($typeList)==$amount) |
|
895 | + if ($this->getHOF($typeList) == $amount) |
|
896 | 896 | return; |
897 | - if($amount < 0) |
|
898 | - $amount=0; |
|
897 | + if ($amount < 0) |
|
898 | + $amount = 0; |
|
899 | 899 | $this->getHOF(); |
900 | 900 | |
901 | - $hofType = implode(':',$typeList); |
|
902 | - if(!isset(self::$HOFVis[$hofType])) { |
|
901 | + $hofType = implode(':', $typeList); |
|
902 | + if (!isset(self::$HOFVis[$hofType])) { |
|
903 | 903 | self::$hasHOFVisChanged[$hofType] = self::HOF_NEW; |
904 | 904 | } |
905 | - else if(self::$HOFVis[$hofType] != $visibility) { |
|
905 | + else if (self::$HOFVis[$hofType] != $visibility) { |
|
906 | 906 | self::$hasHOFVisChanged[$hofType] = self::HOF_CHANGED; |
907 | 907 | } |
908 | 908 | self::$HOFVis[$hofType] = $visibility; |
909 | 909 | |
910 | - $hof =& $this->HOF; |
|
911 | - $hofChanged =& $this->hasHOFChanged; |
|
910 | + $hof = & $this->HOF; |
|
911 | + $hofChanged = & $this->hasHOFChanged; |
|
912 | 912 | $new = false; |
913 | - foreach($typeList as $type) { |
|
914 | - if(!isset($hofChanged[$type])) |
|
913 | + foreach ($typeList as $type) { |
|
914 | + if (!isset($hofChanged[$type])) |
|
915 | 915 | $hofChanged[$type] = array(); |
916 | - if(!isset($hof[$type])) { |
|
916 | + if (!isset($hof[$type])) { |
|
917 | 917 | $hof[$type] = array(); |
918 | 918 | $new = true; |
919 | 919 | } |
920 | - $hof =& $hof[$type]; |
|
921 | - $hofChanged =& $hofChanged[$type]; |
|
920 | + $hof = & $hof[$type]; |
|
921 | + $hofChanged = & $hofChanged[$type]; |
|
922 | 922 | } |
923 | - if($hofChanged==null) { |
|
923 | + if ($hofChanged == null) { |
|
924 | 924 | $hofChanged = self::HOF_CHANGED; |
925 | - if($new) |
|
925 | + if ($new) |
|
926 | 926 | $hofChanged = self::HOF_NEW; |
927 | 927 | } |
928 | 928 | $hof = $amount; |
@@ -940,7 +940,7 @@ discard block |
||
940 | 940 | } |
941 | 941 | |
942 | 942 | public function hasTurns() { |
943 | - return $this->turns>0; |
|
943 | + return $this->turns > 0; |
|
944 | 944 | } |
945 | 945 | |
946 | 946 | public function getMaxTurns() { |
@@ -948,41 +948,41 @@ discard block |
||
948 | 948 | // round(DEFAULT_MAX_TURNS * Globals::getGameSpeed($this->getGameID())); |
949 | 949 | } |
950 | 950 | |
951 | - public function setTurns($turns,$newNoob = false,$updateLastActive = false) { |
|
952 | - if($this->turns == $turns && ($this->newbieTurns == $newNoob || $newNoob==false) && !$updateLastActive) |
|
951 | + public function setTurns($turns, $newNoob = false, $updateLastActive = false) { |
|
952 | + if ($this->turns == $turns && ($this->newbieTurns == $newNoob || $newNoob == false) && !$updateLastActive) |
|
953 | 953 | return; |
954 | 954 | |
955 | 955 | // Make sure turns are in range [0, MaxTurns] |
956 | 956 | $this->turns = max(0, min($turns, $this->getMaxTurns())); |
957 | 957 | |
958 | - if($newNoob !== false) |
|
958 | + if ($newNoob !== false) |
|
959 | 959 | $this->newbieTurns = $newNoob; |
960 | 960 | if ($this->newbieTurns < 0) |
961 | 961 | $this->newbieTurns = 0; |
962 | 962 | |
963 | - $this->hasChanged=true; |
|
964 | - if($updateLastActive === true) { |
|
963 | + $this->hasChanged = true; |
|
964 | + if ($updateLastActive === true) { |
|
965 | 965 | $this->setLastActive(TIME); |
966 | 966 | $this->updateLastCPLAction(); |
967 | 967 | } |
968 | 968 | } |
969 | 969 | |
970 | 970 | public function takeTurns($take, $noob = 0, $updateLastActive = true) { |
971 | - if($take < 0 || $noob < 0) |
|
971 | + if ($take < 0 || $noob < 0) |
|
972 | 972 | throw new Exception('Trying to take negative turns.'); |
973 | 973 | $take = ceil($take); |
974 | 974 | $new_turns = $this->getTurns() - $take; |
975 | - $newbiesTaken = min($this->getNewbieTurns(),$noob); |
|
975 | + $newbiesTaken = min($this->getNewbieTurns(), $noob); |
|
976 | 976 | $new_noob = $this->getNewbieTurns() - $noob; |
977 | 977 | |
978 | 978 | $this->setTurns($new_turns, $new_noob, $updateLastActive); |
979 | - $this->increaseHOF($take,array('Movement','Turns Used','Since Last Death'), HOF_ALLIANCE); |
|
980 | - $this->increaseHOF($take,array('Movement','Turns Used','Total'), HOF_ALLIANCE); |
|
981 | - $this->increaseHOF($newbiesTaken,array('Movement','Turns Used','Newbie'), HOF_ALLIANCE); |
|
979 | + $this->increaseHOF($take, array('Movement', 'Turns Used', 'Since Last Death'), HOF_ALLIANCE); |
|
980 | + $this->increaseHOF($take, array('Movement', 'Turns Used', 'Total'), HOF_ALLIANCE); |
|
981 | + $this->increaseHOF($newbiesTaken, array('Movement', 'Turns Used', 'Newbie'), HOF_ALLIANCE); |
|
982 | 982 | } |
983 | 983 | |
984 | - public function giveTurns($give, $noob = 0,$updateLastActive = false) { |
|
985 | - if($give < 0 || $noob < 0) |
|
984 | + public function giveTurns($give, $noob = 0, $updateLastActive = false) { |
|
985 | + if ($give < 0 || $noob < 0) |
|
986 | 986 | throw new Exception('Trying to give negative turns.'); |
987 | 987 | $give = floor($give); |
988 | 988 | |
@@ -994,10 +994,10 @@ discard block |
||
994 | 994 | } |
995 | 995 | |
996 | 996 | public function setLastActive($lastActive) { |
997 | - if($this->lastActive == $lastActive) |
|
997 | + if ($this->lastActive == $lastActive) |
|
998 | 998 | return; |
999 | - $this->lastActive=$lastActive; |
|
1000 | - $this->hasChanged=true; |
|
999 | + $this->lastActive = $lastActive; |
|
1000 | + $this->hasChanged = true; |
|
1001 | 1001 | } |
1002 | 1002 | |
1003 | 1003 | public function getLastCPLAction() { |
@@ -1005,10 +1005,10 @@ discard block |
||
1005 | 1005 | } |
1006 | 1006 | |
1007 | 1007 | public function setLastCPLAction($time) { |
1008 | - if($this->lastCPLAction == $time) |
|
1008 | + if ($this->lastCPLAction == $time) |
|
1009 | 1009 | return; |
1010 | - $this->lastCPLAction=$time; |
|
1011 | - $this->hasChanged=true; |
|
1010 | + $this->lastCPLAction = $time; |
|
1011 | + $this->hasChanged = true; |
|
1012 | 1012 | } |
1013 | 1013 | |
1014 | 1014 | public function updateLastCPLAction() { |
@@ -1017,7 +1017,7 @@ discard block |
||
1017 | 1017 | |
1018 | 1018 | |
1019 | 1019 | function getCompletedMissions() { |
1020 | - if(!isset($this->completedMissions)) { |
|
1020 | + if (!isset($this->completedMissions)) { |
|
1021 | 1021 | //Get Player missions |
1022 | 1022 | $this->db->query('SELECT mission_id FROM player_completed_mission WHERE ' . $this->SQL); |
1023 | 1023 | $this->completedMissions = array(); |
@@ -1028,7 +1028,7 @@ discard block |
||
1028 | 1028 | } |
1029 | 1029 | |
1030 | 1030 | public function getMissions() { |
1031 | - if(!isset($this->missions)) { |
|
1031 | + if (!isset($this->missions)) { |
|
1032 | 1032 | $this->db->query('SELECT * FROM player_has_mission WHERE ' . $this->SQL); |
1033 | 1033 | $this->missions = array(); |
1034 | 1034 | while ($this->db->nextRecord()) { |
@@ -1049,7 +1049,7 @@ discard block |
||
1049 | 1049 | |
1050 | 1050 | public function getActiveMissions() { |
1051 | 1051 | $missions = $this->getMissions(); |
1052 | - foreach($missions as $missionID => $mission) { |
|
1052 | + foreach ($missions as $missionID => $mission) { |
|
1053 | 1053 | if ($mission['On Step'] >= count(MISSIONS[$missionID]['Steps'])) { |
1054 | 1054 | unset($missions[$missionID]); |
1055 | 1055 | } |
@@ -1059,7 +1059,7 @@ discard block |
||
1059 | 1059 | |
1060 | 1060 | function getMission($missionID) { |
1061 | 1061 | $missions = $this->getMissions(); |
1062 | - if(isset($missions[$missionID])) |
|
1062 | + if (isset($missions[$missionID])) |
|
1063 | 1063 | return $missions[$missionID]; |
1064 | 1064 | return false; |
1065 | 1065 | } |
@@ -1070,7 +1070,7 @@ discard block |
||
1070 | 1070 | |
1071 | 1071 | function updateMission($missionID) { |
1072 | 1072 | $this->getMissions(); |
1073 | - if(isset($this->missions[$missionID])) { |
|
1073 | + if (isset($this->missions[$missionID])) { |
|
1074 | 1074 | $mission = $this->missions[$missionID]; |
1075 | 1075 | $this->db->query(' |
1076 | 1076 | UPDATE player_has_mission |
@@ -1088,15 +1088,15 @@ discard block |
||
1088 | 1088 | } |
1089 | 1089 | |
1090 | 1090 | private function setupMissionStep($missionID) { |
1091 | - $mission =& $this->missions[$missionID]; |
|
1091 | + $mission = & $this->missions[$missionID]; |
|
1092 | 1092 | $step = MISSIONS[$missionID]['Steps'][$mission['On Step']]; |
1093 | - if(isset($step['PickSector'])) { |
|
1093 | + if (isset($step['PickSector'])) { |
|
1094 | 1094 | $realX = Plotter::getX($step['PickSector']['Type'], $step['PickSector']['X'], $this->getGameID()); |
1095 | - if($realX === false) { |
|
1095 | + if ($realX === false) { |
|
1096 | 1096 | throw new Exception('Invalid PickSector definition in mission: ' . $missionID); |
1097 | 1097 | } |
1098 | 1098 | $path = Plotter::findDistanceToX($realX, $this->getSector(), true, null, $this); |
1099 | - if($path === false) { |
|
1099 | + if ($path === false) { |
|
1100 | 1100 | throw new Exception('Cannot find location: ' . $missionID); |
1101 | 1101 | } |
1102 | 1102 | $mission['Sector'] = $path->getEndSectorID(); |
@@ -1106,7 +1106,7 @@ discard block |
||
1106 | 1106 | function addMission($missionID) { |
1107 | 1107 | $this->getMissions(); |
1108 | 1108 | |
1109 | - if(isset($this->missions[$missionID])) |
|
1109 | + if (isset($this->missions[$missionID])) |
|
1110 | 1110 | return; |
1111 | 1111 | $sector = 0; |
1112 | 1112 | |
@@ -1119,13 +1119,13 @@ discard block |
||
1119 | 1119 | 'Starting Sector' => $this->getSectorID() |
1120 | 1120 | ); |
1121 | 1121 | |
1122 | - $this->missions[$missionID] =& $mission; |
|
1122 | + $this->missions[$missionID] = & $mission; |
|
1123 | 1123 | $this->setupMissionStep($missionID); |
1124 | 1124 | $this->rebuildMission($missionID); |
1125 | 1125 | |
1126 | 1126 | $this->db->query(' |
1127 | 1127 | REPLACE INTO player_has_mission (game_id,account_id,mission_id,on_step,progress,unread,starting_sector,mission_sector,step_fails) |
1128 | - VALUES ('.$this->db->escapeNumber($this->gameID).','.$this->db->escapeNumber($this->accountID).','.$this->db->escapeNumber($missionID).','.$this->db->escapeNumber($mission['On Step']).','.$this->db->escapeNumber($mission['Progress']).','.$this->db->escapeBoolean($mission['Unread']).','.$this->db->escapeNumber($mission['Starting Sector']).','.$this->db->escapeNumber($mission['Sector']).','.$this->db->escapeNumber($mission['Expires']).')' |
|
1128 | + VALUES ('.$this->db->escapeNumber($this->gameID) . ',' . $this->db->escapeNumber($this->accountID) . ',' . $this->db->escapeNumber($missionID) . ',' . $this->db->escapeNumber($mission['On Step']) . ',' . $this->db->escapeNumber($mission['Progress']) . ',' . $this->db->escapeBoolean($mission['Unread']) . ',' . $this->db->escapeNumber($mission['Starting Sector']) . ',' . $this->db->escapeNumber($mission['Sector']) . ',' . $this->db->escapeNumber($mission['Expires']) . ')' |
|
1129 | 1129 | ); |
1130 | 1130 | } |
1131 | 1131 | |
@@ -1139,12 +1139,12 @@ discard block |
||
1139 | 1139 | } |
1140 | 1140 | else { |
1141 | 1141 | $currentStep = MISSIONS[$missionID]['Steps'][$mission['On Step']]; |
1142 | - $currentStep['Text'] = str_replace(array('<Race>','<Sector>','<Starting Sector>','<trader>'),array($this->getRaceID(),$mission['Sector'],$mission['Starting Sector'],$this->playerName),$currentStep['Text']); |
|
1142 | + $currentStep['Text'] = str_replace(array('<Race>', '<Sector>', '<Starting Sector>', '<trader>'), array($this->getRaceID(), $mission['Sector'], $mission['Starting Sector'], $this->playerName), $currentStep['Text']); |
|
1143 | 1143 | if (isset($currentStep['Task'])) { |
1144 | - $currentStep['Task'] = str_replace(array('<Race>','<Sector>','<Starting Sector>','<trader>'),array($this->getRaceID(),$mission['Sector'],$mission['Starting Sector'],$this->playerName),$currentStep['Task']); |
|
1144 | + $currentStep['Task'] = str_replace(array('<Race>', '<Sector>', '<Starting Sector>', '<trader>'), array($this->getRaceID(), $mission['Sector'], $mission['Starting Sector'], $this->playerName), $currentStep['Task']); |
|
1145 | 1145 | } |
1146 | 1146 | if (isset($currentStep['Level'])) { |
1147 | - $currentStep['Level'] = str_replace('<Player Level>',$this->levelID,$currentStep['Level']); |
|
1147 | + $currentStep['Level'] = str_replace('<Player Level>', $this->levelID, $currentStep['Level']); |
|
1148 | 1148 | } |
1149 | 1149 | else { |
1150 | 1150 | $currentStep['Level'] = 0; |
@@ -1155,9 +1155,9 @@ discard block |
||
1155 | 1155 | |
1156 | 1156 | function deleteMission($missionID) { |
1157 | 1157 | $this->getMissions(); |
1158 | - if(isset($this->missions[$missionID])) { |
|
1158 | + if (isset($this->missions[$missionID])) { |
|
1159 | 1159 | unset($this->missions[$missionID]); |
1160 | - $this->db->query('DELETE FROM player_has_mission WHERE '.$this->SQL.' AND mission_id = '.$this->db->escapeNumber($missionID).' LIMIT 1'); |
|
1160 | + $this->db->query('DELETE FROM player_has_mission WHERE ' . $this->SQL . ' AND mission_id = ' . $this->db->escapeNumber($missionID) . ' LIMIT 1'); |
|
1161 | 1161 | return true; |
1162 | 1162 | } |
1163 | 1163 | return false; |
@@ -1166,8 +1166,8 @@ discard block |
||
1166 | 1166 | public function markMissionsRead() { |
1167 | 1167 | $this->getMissions(); |
1168 | 1168 | $unreadMissions = array(); |
1169 | - foreach($this->missions as $missionID => &$mission) { |
|
1170 | - if($mission['Unread']) { |
|
1169 | + foreach ($this->missions as $missionID => &$mission) { |
|
1170 | + if ($mission['Unread']) { |
|
1171 | 1171 | $unreadMissions[] = $missionID; |
1172 | 1172 | $mission['Unread'] = false; |
1173 | 1173 | $this->updateMission($missionID); |
@@ -1178,17 +1178,17 @@ discard block |
||
1178 | 1178 | |
1179 | 1179 | public function claimMissionReward($missionID) { |
1180 | 1180 | $this->getMissions(); |
1181 | - $mission =& $this->missions[$missionID]; |
|
1182 | - if($mission === false) { |
|
1181 | + $mission = & $this->missions[$missionID]; |
|
1182 | + if ($mission === false) { |
|
1183 | 1183 | throw new Exception('Unknown mission: ' . $missionID); |
1184 | 1184 | } |
1185 | - if($mission['Task'] === false || $mission['Task']['Step'] != 'Claim') { |
|
1185 | + if ($mission['Task'] === false || $mission['Task']['Step'] != 'Claim') { |
|
1186 | 1186 | throw new Exception('Cannot claim mission: ' . $missionID . ', for step: ' . $mission['On Step']); |
1187 | 1187 | } |
1188 | 1188 | $mission['On Step']++; |
1189 | 1189 | $mission['Unread'] = true; |
1190 | - foreach($mission['Task']['Rewards'] as $rewardItem => $amount) { |
|
1191 | - switch($rewardItem) { |
|
1190 | + foreach ($mission['Task']['Rewards'] as $rewardItem => $amount) { |
|
1191 | + switch ($rewardItem) { |
|
1192 | 1192 | case 'Credits': |
1193 | 1193 | $this->increaseCredits($amount); |
1194 | 1194 | break; |
@@ -1210,14 +1210,14 @@ discard block |
||
1210 | 1210 | public function getAvailableMissions() { |
1211 | 1211 | $availableMissions = array(); |
1212 | 1212 | foreach (MISSIONS as $missionID => $mission) { |
1213 | - if($this->hasMission($missionID)) { |
|
1213 | + if ($this->hasMission($missionID)) { |
|
1214 | 1214 | continue; |
1215 | 1215 | } |
1216 | 1216 | $realX = Plotter::getX($mission['HasX']['Type'], $mission['HasX']['X'], $this->getGameID()); |
1217 | - if($realX === false) { |
|
1217 | + if ($realX === false) { |
|
1218 | 1218 | throw new Exception('Invalid HasX definition in mission: ' . $missionID); |
1219 | 1219 | } |
1220 | - if($this->getSector()->hasX($realX)) { |
|
1220 | + if ($this->getSector()->hasX($realX)) { |
|
1221 | 1221 | $availableMissions[$missionID] = $mission; |
1222 | 1222 | } |
1223 | 1223 | } |
@@ -1229,31 +1229,31 @@ discard block |
||
1229 | 1229 | throw new Exception('Unknown action: ' . $actionID); |
1230 | 1230 | } |
1231 | 1231 | // TODO: Reenable this once tested. if($this->getAccount()->isLoggingEnabled()) |
1232 | - switch($actionID) { |
|
1232 | + switch ($actionID) { |
|
1233 | 1233 | case 'WalkSector': |
1234 | 1234 | $this->getAccount()->log(LOG_TYPE_MOVEMENT, 'Walks to sector: ' . $values['Sector']->getSectorID(), $this->getSectorID()); |
1235 | 1235 | break; |
1236 | 1236 | case 'JoinAlliance': |
1237 | - $this->getAccount()->log(LOG_TYPE_ALLIANCE, 'joined alliance: '.$values['Alliance']->getAllianceName(), $this->getSectorID()); |
|
1237 | + $this->getAccount()->log(LOG_TYPE_ALLIANCE, 'joined alliance: ' . $values['Alliance']->getAllianceName(), $this->getSectorID()); |
|
1238 | 1238 | break; |
1239 | 1239 | case 'LeaveAlliance': |
1240 | - $this->getAccount()->log(LOG_TYPE_ALLIANCE, 'left alliance: '.$values['Alliance']->getAllianceName(), $this->getSectorID()); |
|
1240 | + $this->getAccount()->log(LOG_TYPE_ALLIANCE, 'left alliance: ' . $values['Alliance']->getAllianceName(), $this->getSectorID()); |
|
1241 | 1241 | break; |
1242 | 1242 | case 'DisbandAlliance': |
1243 | - $this->getAccount()->log(LOG_TYPE_ALLIANCE, 'disbanded alliance '.$values['Alliance']->getAllianceName(), $this->getSectorID()); |
|
1243 | + $this->getAccount()->log(LOG_TYPE_ALLIANCE, 'disbanded alliance ' . $values['Alliance']->getAllianceName(), $this->getSectorID()); |
|
1244 | 1244 | break; |
1245 | 1245 | case 'KickPlayer': |
1246 | - $this->getAccount()->log(LOG_TYPE_ALLIANCE, 'kicked '.$values['Player']->getAccount()->getLogin().' ('.$values['Player']->getPlayerName().') from alliance '.$values['Alliance']->getAllianceName(), 0); |
|
1246 | + $this->getAccount()->log(LOG_TYPE_ALLIANCE, 'kicked ' . $values['Player']->getAccount()->getLogin() . ' (' . $values['Player']->getPlayerName() . ') from alliance ' . $values['Alliance']->getAllianceName(), 0); |
|
1247 | 1247 | break; |
1248 | 1248 | case 'PlayerKicked': |
1249 | - $this->getAccount()->log(LOG_TYPE_ALLIANCE, 'was kicked from alliance '.$values['Alliance']->getAllianceName().' by '.$values['Player']->getAccount()->getLogin().' ('.$values['Player']->getPlayerName().')', 0); |
|
1249 | + $this->getAccount()->log(LOG_TYPE_ALLIANCE, 'was kicked from alliance ' . $values['Alliance']->getAllianceName() . ' by ' . $values['Player']->getAccount()->getLogin() . ' (' . $values['Player']->getPlayerName() . ')', 0); |
|
1250 | 1250 | break; |
1251 | 1251 | |
1252 | 1252 | } |
1253 | 1253 | $this->getMissions(); |
1254 | - foreach($this->missions as $missionID => &$mission) { |
|
1255 | - if($mission['Task'] !== false && $mission['Task']['Step'] == $actionID) { |
|
1256 | - if(checkMissionRequirements($values, $mission, $this) === true) { |
|
1254 | + foreach ($this->missions as $missionID => &$mission) { |
|
1255 | + if ($mission['Task'] !== false && $mission['Task']['Step'] == $actionID) { |
|
1256 | + if (checkMissionRequirements($values, $mission, $this) === true) { |
|
1257 | 1257 | $mission['On Step']++; |
1258 | 1258 | $mission['Unread'] = true; |
1259 | 1259 | $this->setupMissionStep($missionID); |
@@ -1265,8 +1265,8 @@ discard block |
||
1265 | 1265 | } |
1266 | 1266 | |
1267 | 1267 | public function canSeeAny(array $otherPlayerArray) { |
1268 | - foreach($otherPlayerArray as $otherPlayer) { |
|
1269 | - if($this->canSee($otherPlayer)) { |
|
1268 | + foreach ($otherPlayerArray as $otherPlayer) { |
|
1269 | + if ($this->canSee($otherPlayer)) { |
|
1270 | 1270 | return true; |
1271 | 1271 | } |
1272 | 1272 | } |
@@ -1274,21 +1274,21 @@ discard block |
||
1274 | 1274 | } |
1275 | 1275 | |
1276 | 1276 | public function canSee(AbstractSmrPlayer $otherPlayer) { |
1277 | - if(!$otherPlayer->getShip()->isCloaked()) |
|
1277 | + if (!$otherPlayer->getShip()->isCloaked()) |
|
1278 | 1278 | return true; |
1279 | - if($this->sameAlliance($otherPlayer)) |
|
1279 | + if ($this->sameAlliance($otherPlayer)) |
|
1280 | 1280 | return true; |
1281 | - if($this->getExperience()>=$otherPlayer->getExperience()) |
|
1281 | + if ($this->getExperience() >= $otherPlayer->getExperience()) |
|
1282 | 1282 | return true; |
1283 | 1283 | return false; |
1284 | 1284 | } |
1285 | 1285 | |
1286 | 1286 | public function equals(AbstractSmrPlayer $otherPlayer = null) { |
1287 | - return $otherPlayer!==null && $this->getAccountID()==$otherPlayer->getAccountID() && $this->getGameID()==$otherPlayer->getGameID(); |
|
1287 | + return $otherPlayer !== null && $this->getAccountID() == $otherPlayer->getAccountID() && $this->getGameID() == $otherPlayer->getGameID(); |
|
1288 | 1288 | } |
1289 | 1289 | |
1290 | 1290 | public function sameAlliance(AbstractSmrPlayer $otherPlayer = null) { |
1291 | - return $otherPlayer != null && ($this->equals($otherPlayer) || ($this->hasAlliance() && $this->getAllianceID()==$otherPlayer->getAllianceID())); |
|
1291 | + return $otherPlayer != null && ($this->equals($otherPlayer) || ($this->hasAlliance() && $this->getAllianceID() == $otherPlayer->getAllianceID())); |
|
1292 | 1292 | } |
1293 | 1293 | |
1294 | 1294 | public function sharedForceAlliance(AbstractSmrPlayer $otherPlayer = null) { |
@@ -1332,10 +1332,10 @@ discard block |
||
1332 | 1332 | } |
1333 | 1333 | |
1334 | 1334 | public function meetsAlignmentRestriction($restriction) { |
1335 | - if($restriction<0) |
|
1336 | - return $this->getAlignment()<=$restriction; |
|
1337 | - if($restriction>0) |
|
1338 | - return $this->getAlignment()>=$restriction; |
|
1335 | + if ($restriction < 0) |
|
1336 | + return $this->getAlignment() <= $restriction; |
|
1337 | + if ($restriction > 0) |
|
1338 | + return $this->getAlignment() >= $restriction; |
|
1339 | 1339 | return true; |
1340 | 1340 | } |
1341 | 1341 | |
@@ -1355,10 +1355,10 @@ discard block |
||
1355 | 1355 | * Will retrieve all visited sectors, use only when you are likely to check a large number of these |
1356 | 1356 | */ |
1357 | 1357 | public function hasVisitedSector($sectorID) { |
1358 | - if(!isset($this->visitedSectors)) { |
|
1358 | + if (!isset($this->visitedSectors)) { |
|
1359 | 1359 | $this->visitedSectors = array(); |
1360 | 1360 | $this->db->query('SELECT sector_id FROM player_visited_sector WHERE ' . $this->SQL); |
1361 | - while($this->db->nextRecord()) |
|
1361 | + while ($this->db->nextRecord()) |
|
1362 | 1362 | $this->visitedSectors[$this->db->getField('sector_id')] = false; |
1363 | 1363 | } |
1364 | 1364 | return !isset($this->visitedSectors[$sectorID]); |
@@ -1369,7 +1369,7 @@ discard block |
||
1369 | 1369 | } |
1370 | 1370 | |
1371 | 1371 | public function getExamineTraderHREF() { |
1372 | - $container = create_container('skeleton.php','trader_examine.php'); |
|
1372 | + $container = create_container('skeleton.php', 'trader_examine.php'); |
|
1373 | 1373 | $container['target'] = $this->getAccountID(); |
1374 | 1374 | return SmrSession::getNewHREF($container); |
1375 | 1375 | } |
@@ -1379,13 +1379,13 @@ discard block |
||
1379 | 1379 | } |
1380 | 1380 | |
1381 | 1381 | public function getPlanetKickHREF() { |
1382 | - $container = create_container('planet_kick_processing.php','trader_attack_processing.php'); |
|
1382 | + $container = create_container('planet_kick_processing.php', 'trader_attack_processing.php'); |
|
1383 | 1383 | $container['account_id'] = $this->getAccountID(); |
1384 | 1384 | return SmrSession::getNewHREF($container); |
1385 | 1385 | } |
1386 | 1386 | |
1387 | 1387 | public function getTraderSearchHREF() { |
1388 | - $container = create_container('skeleton.php','trader_search_result.php'); |
|
1388 | + $container = create_container('skeleton.php', 'trader_search_result.php'); |
|
1389 | 1389 | $container['player_id'] = $this->getPlayerID(); |
1390 | 1390 | return SmrSession::getNewHREF($container); |
1391 | 1391 | } |
@@ -1395,7 +1395,7 @@ discard block |
||
1395 | 1395 | } |
1396 | 1396 | |
1397 | 1397 | public function getToggleWeaponHidingHREF() { |
1398 | - $container = create_container('skeleton.php','toggle_processing.php'); |
|
1398 | + $container = create_container('skeleton.php', 'toggle_processing.php'); |
|
1399 | 1399 | $container['toggle'] = 'WeaponHiding'; |
1400 | 1400 | return SmrSession::getNewHREF($container); |
1401 | 1401 | } |
@@ -4,16 +4,16 @@ discard block |
||
4 | 4 | public function __construct() { |
5 | 5 | } |
6 | 6 | |
7 | - public static function getX($xType, $X, $gameID, $player=null) { |
|
8 | - switch($xType) { |
|
7 | + public static function getX($xType, $X, $gameID, $player = null) { |
|
8 | + switch ($xType) { |
|
9 | 9 | case 'Technology': |
10 | 10 | return Globals::getHardwareTypes($X); |
11 | 11 | case 'Ships': |
12 | - return AbstractSmrShip::getBaseShip(Globals::getGameType($gameID),$X); |
|
12 | + return AbstractSmrShip::getBaseShip(Globals::getGameType($gameID), $X); |
|
13 | 13 | case 'Weapons': |
14 | 14 | return SmrWeapon::getWeapon($X); |
15 | 15 | case 'Locations': |
16 | - if(is_numeric($X)) { |
|
16 | + if (is_numeric($X)) { |
|
17 | 17 | return SmrLocation::getLocation($X); |
18 | 18 | } |
19 | 19 | return $X; |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * is not true for findDistanceToX. If $x is not a SmrSector, then this |
41 | 41 | * function does 2x the work. |
42 | 42 | */ |
43 | - public static function findReversiblePathToX($x, SmrSector $sector, $useFirst, AbstractSmrPlayer $needsToHaveBeenExploredBy=null, AbstractSmrPlayer $player=null) { |
|
43 | + public static function findReversiblePathToX($x, SmrSector $sector, $useFirst, AbstractSmrPlayer $needsToHaveBeenExploredBy = null, AbstractSmrPlayer $player = null) { |
|
44 | 44 | if ($x instanceof SmrSector) { |
45 | 45 | |
46 | 46 | // To ensure reversibility, always plot lowest to highest. |
@@ -53,8 +53,8 @@ discard block |
||
53 | 53 | $end = $x; |
54 | 54 | } |
55 | 55 | $path = Plotter::findDistanceToX($end, $start, $useFirst, $needsToHaveBeenExploredBy, $player); |
56 | - if ($path===false) { |
|
57 | - create_error('Unable to plot from '.$sector->getSectorID().' to '.$x->getSectorID().'.'); |
|
56 | + if ($path === false) { |
|
57 | + create_error('Unable to plot from ' . $sector->getSectorID() . ' to ' . $x->getSectorID() . '.'); |
|
58 | 58 | } |
59 | 59 | // Reverse if we plotted $x -> $sector (since we want $sector -> $x) |
60 | 60 | if ($reverse) { |
@@ -65,13 +65,13 @@ discard block |
||
65 | 65 | |
66 | 66 | // At this point we don't know what sector $x will be at |
67 | 67 | $path = Plotter::findDistanceToX($x, $sector, $useFirst, $needsToHaveBeenExploredBy, $player); |
68 | - if ($path===false) { |
|
68 | + if ($path === false) { |
|
69 | 69 | create_error('Unable to find what you\'re looking for, it either hasn\'t been added to this game or you haven\'t explored it yet.'); |
70 | 70 | } |
71 | 71 | // Now that we know where $x is, make sure path is reversible |
72 | 72 | // (i.e. start sector < end sector) |
73 | 73 | if ($path->getEndSectorID() < $sector->getSectorID()) { |
74 | - $path =& Plotter::findDistanceToX($sector, $path->getEndSector(), true); |
|
74 | + $path = & Plotter::findDistanceToX($sector, $path->getEndSector(), true); |
|
75 | 75 | $path->reversePath(); |
76 | 76 | } |
77 | 77 | |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | * The resulting path prefers neighbors in their order in SmrSector->links, |
86 | 86 | * (i.e. up, down, left, right). |
87 | 87 | */ |
88 | - public static function &findDistanceToX($x, SmrSector $sector, $useFirst, AbstractSmrPlayer $needsToHaveBeenExploredBy=null, AbstractSmrPlayer $player=null, $distanceLimit=10000, $lowLimit=0, $highLimit=100000) { |
|
89 | - $warpAddIndex = TURNS_WARP_SECTOR_EQUIVALENCE-1; |
|
88 | + public static function &findDistanceToX($x, SmrSector $sector, $useFirst, AbstractSmrPlayer $needsToHaveBeenExploredBy = null, AbstractSmrPlayer $player = null, $distanceLimit = 10000, $lowLimit = 0, $highLimit = 100000) { |
|
89 | + $warpAddIndex = TURNS_WARP_SECTOR_EQUIVALENCE - 1; |
|
90 | 90 | |
91 | 91 | $checkSector = $sector; |
92 | 92 | $gameID = $sector->getGameID(); |
@@ -94,57 +94,57 @@ discard block |
||
94 | 94 | $sectorsTravelled = 0; |
95 | 95 | $visitedSectors = array(); |
96 | 96 | $visitedSectors[$checkSector->getSectorID()] = true; |
97 | - if($x=='Distance') |
|
98 | - $distances[0][$checkSector->getSectorID()] = new Distance($gameID,$checkSector->getSectorID()); |
|
97 | + if ($x == 'Distance') |
|
98 | + $distances[0][$checkSector->getSectorID()] = new Distance($gameID, $checkSector->getSectorID()); |
|
99 | 99 | |
100 | 100 | $distanceQ = array(); |
101 | - for($i=0;$i<=TURNS_WARP_SECTOR_EQUIVALENCE;$i++) |
|
101 | + for ($i = 0; $i <= TURNS_WARP_SECTOR_EQUIVALENCE; $i++) |
|
102 | 102 | $distanceQ[] = array(); |
103 | 103 | //Warps first as a slight optimisation due to how visitedSectors is set. |
104 | - if($checkSector->hasWarp()===true) { |
|
105 | - $d = new Distance($gameID,$checkSector->getSectorID()); |
|
104 | + if ($checkSector->hasWarp() === true) { |
|
105 | + $d = new Distance($gameID, $checkSector->getSectorID()); |
|
106 | 106 | $d->addWarpToPath($checkSector->getWarp(), $checkSector->getSectorID()); |
107 | 107 | $distanceQ[$warpAddIndex][] = $d; |
108 | 108 | } |
109 | 109 | foreach ($checkSector->getLinks() as $nextSector) { |
110 | - if($nextSector!==0) { |
|
110 | + if ($nextSector !== 0) { |
|
111 | 111 | $visitedSectors[$nextSector] = true; |
112 | - $d = new Distance($gameID,$checkSector->getSectorID()); |
|
112 | + $d = new Distance($gameID, $checkSector->getSectorID()); |
|
113 | 113 | $d->addToPath($nextSector); |
114 | 114 | $distanceQ[0][] = $d; |
115 | 115 | } |
116 | 116 | } |
117 | - $maybeWarps=0; |
|
118 | - while ($maybeWarps<=TURNS_WARP_SECTOR_EQUIVALENCE) { |
|
117 | + $maybeWarps = 0; |
|
118 | + while ($maybeWarps <= TURNS_WARP_SECTOR_EQUIVALENCE) { |
|
119 | 119 | $sectorsTravelled++; |
120 | 120 | if ($sectorsTravelled > $distanceLimit) |
121 | 121 | return $distances; |
122 | - if($x=='Distance') { |
|
122 | + if ($x == 'Distance') { |
|
123 | 123 | $distances[$sectorsTravelled] = array(); |
124 | 124 | } |
125 | 125 | $distanceQ[] = array(); |
126 | - if(count($q = array_shift($distanceQ))===0) { |
|
126 | + if (count($q = array_shift($distanceQ)) === 0) { |
|
127 | 127 | $maybeWarps++; |
128 | 128 | continue; |
129 | 129 | } |
130 | - $maybeWarps=0; |
|
131 | - while (($distance = array_shift($q))!==null) { |
|
130 | + $maybeWarps = 0; |
|
131 | + while (($distance = array_shift($q)) !== null) { |
|
132 | 132 | $checkSectorID = $distance->getEndSectorID(); |
133 | 133 | $visitedSectors[$checkSectorID] = true; // This is here for warps, because they are delayed visits if we set this before the actual visit we'll get sectors marked as visited long before they are actually visited - causes problems when it's quicker to walk to the warp exit than to warp there. |
134 | 134 | // We still need to mark walked sectors as visited before we go to each one otherwise we get a huge number of paths being checked twice (up then left, left then up are essentially the same but if we set up-left as visited only when we actually check it then it gets queued up twice - nasty) |
135 | 135 | if ($checkSectorID >= $lowLimit && $checkSectorID <= $highLimit) { |
136 | - $checkSector = SmrSector::getSector($gameID,$checkSectorID); |
|
137 | - if($x=='Distance') { |
|
136 | + $checkSector = SmrSector::getSector($gameID, $checkSectorID); |
|
137 | + if ($x == 'Distance') { |
|
138 | 138 | $distances[$sectorsTravelled][$checkSector->getSectorID()] = $distance; |
139 | 139 | } |
140 | - else if (($needsToHaveBeenExploredBy===null||$needsToHaveBeenExploredBy->hasVisitedSector($checkSector->getSectorID()))===true |
|
141 | - && $checkSector->hasX($x,$player)===true) { |
|
142 | - if($useFirst===true) |
|
140 | + else if (($needsToHaveBeenExploredBy === null || $needsToHaveBeenExploredBy->hasVisitedSector($checkSector->getSectorID())) === true |
|
141 | + && $checkSector->hasX($x, $player) === true) { |
|
142 | + if ($useFirst === true) |
|
143 | 143 | return $distance; |
144 | 144 | $distances[$checkSector->getSectorID()] = $distance; |
145 | 145 | } |
146 | 146 | //Warps first as a slight optimisation due to how visitedSectors is set. |
147 | - if($checkSector->hasWarp()===true) { |
|
147 | + if ($checkSector->hasWarp() === true) { |
|
148 | 148 | if (!isset($visitedSectors[$checkSector->getWarp()])) { |
149 | 149 | $cloneDistance = clone($distance); |
150 | 150 | $cloneDistance->addWarpToPath($checkSector->getWarp(), $checkSector->getSectorID()); |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | } |
164 | 164 | } |
165 | 165 | } |
166 | - if($useFirst===true) { |
|
166 | + if ($useFirst === true) { |
|
167 | 167 | $return = false; |
168 | 168 | return $return; |
169 | 169 | } |
@@ -172,10 +172,10 @@ discard block |
||
172 | 172 | |
173 | 173 | public static function &calculatePortToPortDistances(array $sectors, $distanceLimit = 10000, $lowLimit = 0, $highLimit = 100000) { |
174 | 174 | $distances = array(); |
175 | - foreach($sectors as $sec) { |
|
175 | + foreach ($sectors as $sec) { |
|
176 | 176 | if ($sec !== null) { |
177 | 177 | if ($sec->getSectorID() >= $lowLimit && $sec->getSectorID() <= $highLimit) { |
178 | - if ($sec->hasPort()===true) { |
|
178 | + if ($sec->hasPort() === true) { |
|
179 | 179 | $distances[$sec->getSectorID()] = self::findDistanceToOtherPorts($sec, $distanceLimit, $lowLimit, $highLimit); |
180 | 180 | } |
181 | 181 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | protected $typeInfo; |
37 | 37 | |
38 | 38 | protected $hasChanged = false; |
39 | - protected $hasChangedFinancial = false; // for credits, bond, maturity |
|
39 | + protected $hasChangedFinancial = false; // for credits, bond, maturity |
|
40 | 40 | protected $hasChangedStockpile = false; |
41 | 41 | protected $hasChangedWeapons = array(); |
42 | 42 | protected $hasChangedBuildings = array(); |
@@ -48,9 +48,9 @@ discard block |
||
48 | 48 | protected $delayedArmourDelta = 0; |
49 | 49 | |
50 | 50 | public static function refreshCache() { |
51 | - foreach(self::$CACHE_PLANETS as $gameID => &$gamePlanets) { |
|
52 | - foreach($gamePlanets as $sectorID => &$planet) { |
|
53 | - $planet = self::getPlanet($gameID,$sectorID,true); |
|
51 | + foreach (self::$CACHE_PLANETS as $gameID => &$gamePlanets) { |
|
52 | + foreach ($gamePlanets as $sectorID => &$planet) { |
|
53 | + $planet = self::getPlanet($gameID, $sectorID, true); |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | } |
@@ -60,22 +60,22 @@ discard block |
||
60 | 60 | } |
61 | 61 | |
62 | 62 | public static function savePlanets() { |
63 | - foreach(self::$CACHE_PLANETS as $gamePlanets) { |
|
64 | - foreach($gamePlanets as $planet) { |
|
63 | + foreach (self::$CACHE_PLANETS as $gamePlanets) { |
|
64 | + foreach ($gamePlanets as $planet) { |
|
65 | 65 | $planet->update(); |
66 | 66 | } |
67 | 67 | } |
68 | 68 | } |
69 | 69 | |
70 | - public static function &getPlanet($gameID, $sectorID, $forceUpdate=false, $db=null) { |
|
71 | - if($forceUpdate || !isset(self::$CACHE_PLANETS[$gameID][$sectorID])) { |
|
70 | + public static function &getPlanet($gameID, $sectorID, $forceUpdate = false, $db = null) { |
|
71 | + if ($forceUpdate || !isset(self::$CACHE_PLANETS[$gameID][$sectorID])) { |
|
72 | 72 | self::$CACHE_PLANETS[$gameID][$sectorID] = new SmrPlanet($gameID, $sectorID, $db); |
73 | 73 | } |
74 | 74 | return self::$CACHE_PLANETS[$gameID][$sectorID]; |
75 | 75 | } |
76 | 76 | |
77 | - public static function &createPlanet($gameID,$sectorID,$type=1) { |
|
78 | - if(!self::getPlanet($gameID,$sectorID)->exists()) { |
|
77 | + public static function &createPlanet($gameID, $sectorID, $type = 1) { |
|
78 | + if (!self::getPlanet($gameID, $sectorID)->exists()) { |
|
79 | 79 | $minTime = max(SmrGame::getGame($gameID)->getStartDate(), |
80 | 80 | SmrGame::getGame($gameID)->getStartTurnsDate()); |
81 | 81 | $inhabitableTime = $minTime + pow(mt_rand(45, 85), 3); |
@@ -85,10 +85,10 @@ discard block |
||
85 | 85 | $db->query('INSERT INTO planet (game_id, sector_id, inhabitable_time, planet_type_id) |
86 | 86 | VALUES (' . $db->escapeNumber($gameID) . ', ' . $db->escapeNumber($sectorID) . ', ' . $db->escapeNumber($inhabitableTime) . ', ' . $db->escapeNumber($type) . ')'); |
87 | 87 | } |
88 | - return self::getPlanet($gameID,$sectorID,true); |
|
88 | + return self::getPlanet($gameID, $sectorID, true); |
|
89 | 89 | } |
90 | 90 | |
91 | - public static function removePlanet($gameID,$sectorID) { |
|
91 | + public static function removePlanet($gameID, $sectorID) { |
|
92 | 92 | $db = new SmrMySqlDatabase(); |
93 | 93 | $SQL = 'game_id = ' . $db->escapeNumber($gameID) . ' AND sector_id = ' . $db->escapeNumber($sectorID); |
94 | 94 | $db->query('DELETE FROM planet WHERE ' . $SQL); |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | unset(self::$CACHE_PLANETS[$gameID][$sectorID]); |
103 | 103 | } |
104 | 104 | |
105 | - protected function __construct($gameID, $sectorID, $db=null) { |
|
105 | + protected function __construct($gameID, $sectorID, $db = null) { |
|
106 | 106 | $this->db = new SmrMySqlDatabase(); |
107 | 107 | $this->SQL = 'game_id = ' . $this->db->escapeNumber($gameID) . ' AND sector_id = ' . $this->db->escapeNumber($sectorID); |
108 | 108 | |
@@ -115,8 +115,8 @@ discard block |
||
115 | 115 | } |
116 | 116 | |
117 | 117 | if ($planetExists) { |
118 | - $this->gameID = (int) $gameID; |
|
119 | - $this->sectorID = (int) $sectorID; |
|
118 | + $this->gameID = (int)$gameID; |
|
119 | + $this->sectorID = (int)$sectorID; |
|
120 | 120 | $this->planetName = stripslashes($db->getField('planet_name')); |
121 | 121 | $this->ownerID = $db->getInt('owner_id'); |
122 | 122 | $this->password = $db->getField('password'); |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | // calc the interest for the time |
168 | 168 | $interest = $this->getBonds() * $this->getInterestRate(); |
169 | 169 | |
170 | - if($partial === true && $this->getMaturity() > TIME) { |
|
170 | + if ($partial === true && $this->getMaturity() > TIME) { |
|
171 | 171 | // Adjust interest based upon how much of the bond duration has passed. |
172 | 172 | $interest -= ($interest / $this->getBondTime()) * ($this->getMaturity() - TIME); |
173 | 173 | } |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | } |
210 | 210 | |
211 | 211 | public function &getGalaxy() { |
212 | - return SmrGalaxy::getGalaxyContaining($this->getGameID(),$this->getSectorID()); |
|
212 | + return SmrGalaxy::getGalaxyContaining($this->getGameID(), $this->getSectorID()); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | public function getOwnerID() { |
@@ -217,19 +217,19 @@ discard block |
||
217 | 217 | } |
218 | 218 | |
219 | 219 | public function hasOwner() { |
220 | - return $this->ownerID!=0; |
|
220 | + return $this->ownerID != 0; |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | public function setOwnerID($claimerID) { |
224 | - if($this->ownerID==$claimerID) { |
|
224 | + if ($this->ownerID == $claimerID) { |
|
225 | 225 | return; |
226 | 226 | } |
227 | - $this->ownerID=$claimerID; |
|
227 | + $this->ownerID = $claimerID; |
|
228 | 228 | $this->hasChanged = true; |
229 | 229 | } |
230 | 230 | |
231 | 231 | public function &getOwner() { |
232 | - return SmrPlayer::getPlayer($this->getOwnerID(),$this->getGameID()); |
|
232 | + return SmrPlayer::getPlayer($this->getOwnerID(), $this->getGameID()); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | public function getPassword() { |
@@ -237,10 +237,10 @@ discard block |
||
237 | 237 | } |
238 | 238 | |
239 | 239 | public function setPassword($password) { |
240 | - if($this->password==$password) { |
|
240 | + if ($this->password == $password) { |
|
241 | 241 | return; |
242 | 242 | } |
243 | - $this->password=$password; |
|
243 | + $this->password = $password; |
|
244 | 244 | $this->hasChanged = true; |
245 | 245 | } |
246 | 246 | |
@@ -253,10 +253,10 @@ discard block |
||
253 | 253 | } |
254 | 254 | |
255 | 255 | public function setCredits($num) { |
256 | - if($this->credits==$num) { |
|
256 | + if ($this->credits == $num) { |
|
257 | 257 | return; |
258 | 258 | } |
259 | - if($num < 0) { |
|
259 | + if ($num < 0) { |
|
260 | 260 | throw new Exception('You cannot set negative credits.'); |
261 | 261 | } |
262 | 262 | $this->credits = $num; |
@@ -264,14 +264,14 @@ discard block |
||
264 | 264 | } |
265 | 265 | |
266 | 266 | public function increaseCredits($num) { |
267 | - if($num == 0) { |
|
267 | + if ($num == 0) { |
|
268 | 268 | return; |
269 | 269 | } |
270 | 270 | $this->setCredits($this->getCredits() + $num); |
271 | 271 | } |
272 | 272 | |
273 | 273 | public function decreaseCredits($num) { |
274 | - if($num == 0) { |
|
274 | + if ($num == 0) { |
|
275 | 275 | return; |
276 | 276 | } |
277 | 277 | $this->setCredits($this->getCredits() - $num); |
@@ -282,10 +282,10 @@ discard block |
||
282 | 282 | } |
283 | 283 | |
284 | 284 | public function setMaturity($num) { |
285 | - if($this->maturity==$num) { |
|
285 | + if ($this->maturity == $num) { |
|
286 | 286 | return; |
287 | 287 | } |
288 | - if($num < 0) { |
|
288 | + if ($num < 0) { |
|
289 | 289 | throw new Exception('You cannot set negative maturity.'); |
290 | 290 | } |
291 | 291 | $this->maturity = $num; |
@@ -297,10 +297,10 @@ discard block |
||
297 | 297 | } |
298 | 298 | |
299 | 299 | public function setBonds($num) { |
300 | - if($this->bonds==$num) { |
|
300 | + if ($this->bonds == $num) { |
|
301 | 301 | return; |
302 | 302 | } |
303 | - if($num < 0) { |
|
303 | + if ($num < 0) { |
|
304 | 304 | throw new Exception('You cannot set negative bonds.'); |
305 | 305 | } |
306 | 306 | $this->bonds = $num; |
@@ -308,14 +308,14 @@ discard block |
||
308 | 308 | } |
309 | 309 | |
310 | 310 | public function increaseBonds($num) { |
311 | - if($num == 0) { |
|
311 | + if ($num == 0) { |
|
312 | 312 | return; |
313 | 313 | } |
314 | 314 | $this->setBonds($this->getBonds() + $num); |
315 | 315 | } |
316 | 316 | |
317 | 317 | public function decreaseBonds($num) { |
318 | - if($num == 0) { |
|
318 | + if ($num == 0) { |
|
319 | 319 | return; |
320 | 320 | } |
321 | 321 | $this->setBonds($this->getBonds() - $num); |
@@ -344,27 +344,27 @@ discard block |
||
344 | 344 | } |
345 | 345 | |
346 | 346 | public function getShields($delayed = false) { |
347 | - return $this->shields + ($delayed?$this->delayedShieldsDelta:0); |
|
347 | + return $this->shields + ($delayed ? $this->delayedShieldsDelta : 0); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | public function hasShields($delayed = false) { |
351 | - return $this->getShields($delayed)>0; |
|
351 | + return $this->getShields($delayed) > 0; |
|
352 | 352 | } |
353 | 353 | |
354 | 354 | public function setShields($shields) { |
355 | 355 | $shields = max(0, min($shields, $this->getMaxShields())); |
356 | - if($this->shields == $shields) { |
|
356 | + if ($this->shields == $shields) { |
|
357 | 357 | return; |
358 | 358 | } |
359 | - $this->shields=$shields; |
|
359 | + $this->shields = $shields; |
|
360 | 360 | $this->hasChanged = true; |
361 | 361 | } |
362 | 362 | |
363 | 363 | public function decreaseShields($number, $delayed = false) { |
364 | - if($number == 0) { |
|
364 | + if ($number == 0) { |
|
365 | 365 | return; |
366 | 366 | } |
367 | - if($delayed===false) { |
|
367 | + if ($delayed === false) { |
|
368 | 368 | $this->setShields($this->getShields() - $number); |
369 | 369 | } |
370 | 370 | else { |
@@ -373,10 +373,10 @@ discard block |
||
373 | 373 | } |
374 | 374 | |
375 | 375 | public function increaseShields($number, $delayed = false) { |
376 | - if($number == 0) { |
|
376 | + if ($number == 0) { |
|
377 | 377 | return; |
378 | 378 | } |
379 | - if($delayed===false) { |
|
379 | + if ($delayed === false) { |
|
380 | 380 | $this->setShields($this->getShields() + $number); |
381 | 381 | } |
382 | 382 | else { |
@@ -389,16 +389,16 @@ discard block |
||
389 | 389 | } |
390 | 390 | |
391 | 391 | public function getArmour($delayed = false) { |
392 | - return $this->armour + ($delayed?$this->delayedArmourDelta:0); |
|
392 | + return $this->armour + ($delayed ? $this->delayedArmourDelta : 0); |
|
393 | 393 | } |
394 | 394 | |
395 | 395 | public function hasArmour($delayed = false) { |
396 | - return $this->getArmour($delayed)>0; |
|
396 | + return $this->getArmour($delayed) > 0; |
|
397 | 397 | } |
398 | 398 | |
399 | 399 | public function setArmour($armour) { |
400 | 400 | $armour = max(0, min($armour, $this->getMaxArmour())); |
401 | - if($this->armour == $armour) { |
|
401 | + if ($this->armour == $armour) { |
|
402 | 402 | return; |
403 | 403 | } |
404 | 404 | $this->armour = $armour; |
@@ -406,10 +406,10 @@ discard block |
||
406 | 406 | } |
407 | 407 | |
408 | 408 | public function decreaseArmour($number, $delayed = false) { |
409 | - if($number == 0) { |
|
409 | + if ($number == 0) { |
|
410 | 410 | return; |
411 | 411 | } |
412 | - if($delayed===false) { |
|
412 | + if ($delayed === false) { |
|
413 | 413 | $this->setArmour($this->getArmour() - $number); |
414 | 414 | } |
415 | 415 | else { |
@@ -418,10 +418,10 @@ discard block |
||
418 | 418 | } |
419 | 419 | |
420 | 420 | public function increaseArmour($number, $delayed = false) { |
421 | - if($number == 0) { |
|
421 | + if ($number == 0) { |
|
422 | 422 | return; |
423 | 423 | } |
424 | - if($delayed===false) { |
|
424 | + if ($delayed === false) { |
|
425 | 425 | $this->setArmour($this->getArmour() + $number); |
426 | 426 | } |
427 | 427 | else { |
@@ -434,27 +434,27 @@ discard block |
||
434 | 434 | } |
435 | 435 | |
436 | 436 | public function getCDs($delayed = false) { |
437 | - return $this->drones + ($delayed?$this->delayedCDsDelta:0); |
|
437 | + return $this->drones + ($delayed ? $this->delayedCDsDelta : 0); |
|
438 | 438 | } |
439 | 439 | |
440 | 440 | public function hasCDs($delayed = false) { |
441 | - return $this->getCDs($delayed)>0; |
|
441 | + return $this->getCDs($delayed) > 0; |
|
442 | 442 | } |
443 | 443 | |
444 | 444 | public function setCDs($combatDrones) { |
445 | 445 | $combatDrones = max(0, min($combatDrones, $this->getMaxCDs())); |
446 | - if($this->drones == $combatDrones) { |
|
446 | + if ($this->drones == $combatDrones) { |
|
447 | 447 | return; |
448 | 448 | } |
449 | - $this->drones=$combatDrones; |
|
449 | + $this->drones = $combatDrones; |
|
450 | 450 | $this->hasChanged = true; |
451 | 451 | } |
452 | 452 | |
453 | 453 | public function decreaseCDs($number, $delayed = false) { |
454 | - if($number == 0) { |
|
454 | + if ($number == 0) { |
|
455 | 455 | return; |
456 | 456 | } |
457 | - if($delayed===false) { |
|
457 | + if ($delayed === false) { |
|
458 | 458 | $this->setCDs($this->getCDs() - $number); |
459 | 459 | } |
460 | 460 | else { |
@@ -463,10 +463,10 @@ discard block |
||
463 | 463 | } |
464 | 464 | |
465 | 465 | public function increaseCDs($number, $delayed = false) { |
466 | - if($number == 0) { |
|
466 | + if ($number == 0) { |
|
467 | 467 | return; |
468 | 468 | } |
469 | - if($delayed===false) { |
|
469 | + if ($delayed === false) { |
|
470 | 470 | $this->setCDs($this->getCDs() + $number); |
471 | 471 | } |
472 | 472 | else { |
@@ -514,13 +514,13 @@ discard block |
||
514 | 514 | if ($orderID == 0) { |
515 | 515 | throw Exception('Cannot move this weapon up!'); |
516 | 516 | } |
517 | - if (isset($this->mountedWeapons[$orderID-1])) { |
|
518 | - $previousWeapon = $this->mountedWeapons[$orderID-1]; |
|
517 | + if (isset($this->mountedWeapons[$orderID - 1])) { |
|
518 | + $previousWeapon = $this->mountedWeapons[$orderID - 1]; |
|
519 | 519 | } |
520 | 520 | if (isset($this->mountedWeapons[$orderID])) { |
521 | - $this->mountedWeapons[$orderID-1] = $this->mountedWeapons[$orderID]; |
|
521 | + $this->mountedWeapons[$orderID - 1] = $this->mountedWeapons[$orderID]; |
|
522 | 522 | } else { |
523 | - unset($this->mountedWeapons[$orderID-1]); |
|
523 | + unset($this->mountedWeapons[$orderID - 1]); |
|
524 | 524 | } |
525 | 525 | if (isset($previousWeapon)) { |
526 | 526 | $this->mountedWeapons[$orderID] = $previousWeapon; |
@@ -528,21 +528,21 @@ discard block |
||
528 | 528 | unset($this->mountedWeapons[$orderID]); |
529 | 529 | } |
530 | 530 | $this->hasChangedWeapons[$orderID] = true; |
531 | - $this->hasChangedWeapons[$orderID-1] = true; |
|
531 | + $this->hasChangedWeapons[$orderID - 1] = true; |
|
532 | 532 | } |
533 | 533 | |
534 | 534 | public function moveMountedWeaponDown($orderID) { |
535 | 535 | $this->getMountedWeapons(); // Make sure array is initialized |
536 | - if ($orderID == $this->getMaxMountedWeapons()-1) { |
|
536 | + if ($orderID == $this->getMaxMountedWeapons() - 1) { |
|
537 | 537 | throw Exception('Cannot move this weapon down!'); |
538 | 538 | } |
539 | - if (isset($this->mountedWeapons[$orderID+1])) { |
|
540 | - $nextWeapon = $this->mountedWeapons[$orderID+1]; |
|
539 | + if (isset($this->mountedWeapons[$orderID + 1])) { |
|
540 | + $nextWeapon = $this->mountedWeapons[$orderID + 1]; |
|
541 | 541 | } |
542 | 542 | if (isset($this->mountedWeapons[$orderID])) { |
543 | - $this->mountedWeapons[$orderID+1] = $this->mountedWeapons[$orderID]; |
|
543 | + $this->mountedWeapons[$orderID + 1] = $this->mountedWeapons[$orderID]; |
|
544 | 544 | } else { |
545 | - unset($this->mountedWeapons[$orderID+1]); |
|
545 | + unset($this->mountedWeapons[$orderID + 1]); |
|
546 | 546 | } |
547 | 547 | if (isset($nextWeapon)) { |
548 | 548 | $this->mountedWeapons[$orderID] = $nextWeapon; |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | unset($this->mountedWeapons[$orderID]); |
551 | 551 | } |
552 | 552 | $this->hasChangedWeapons[$orderID] = true; |
553 | - $this->hasChangedWeapons[$orderID+1] = true; |
|
553 | + $this->hasChangedWeapons[$orderID + 1] = true; |
|
554 | 554 | } |
555 | 555 | |
556 | 556 | |
@@ -559,11 +559,11 @@ discard block |
||
559 | 559 | } |
560 | 560 | |
561 | 561 | public function exists() { |
562 | - return $this->getGameID()!=null && $this->getSectorID()!==null; |
|
562 | + return $this->getGameID() != null && $this->getSectorID() !== null; |
|
563 | 563 | } |
564 | 564 | |
565 | - public function getStockpile($goodID=false) { |
|
566 | - if(!isset($this->stockpile)) { |
|
565 | + public function getStockpile($goodID = false) { |
|
566 | + if (!isset($this->stockpile)) { |
|
567 | 567 | // initialize cargo array |
568 | 568 | $this->stockpile = array(); |
569 | 569 | // get supplies from db |
@@ -572,15 +572,15 @@ discard block |
||
572 | 572 | while ($this->db->nextRecord()) |
573 | 573 | $this->stockpile[$this->db->getInt('good_id')] = $this->db->getInt('amount'); |
574 | 574 | } |
575 | - if($goodID===false) |
|
575 | + if ($goodID === false) |
|
576 | 576 | return $this->stockpile; |
577 | - if(isset($this->stockpile[$goodID])) |
|
577 | + if (isset($this->stockpile[$goodID])) |
|
578 | 578 | return $this->stockpile[$goodID]; |
579 | 579 | return 0; |
580 | 580 | } |
581 | 581 | |
582 | - public function hasStockpile($goodID=false) { |
|
583 | - if($goodID===false) { |
|
582 | + public function hasStockpile($goodID = false) { |
|
583 | + if ($goodID === false) { |
|
584 | 584 | $stockpile = $this->getStockpile($goodID); |
585 | 585 | return count($stockpile) > 0 && max($stockpile) > 0; |
586 | 586 | } |
@@ -589,31 +589,31 @@ discard block |
||
589 | 589 | } |
590 | 590 | } |
591 | 591 | |
592 | - public function setStockpile($goodID,$amount) { |
|
593 | - if($amount < 0) { |
|
592 | + public function setStockpile($goodID, $amount) { |
|
593 | + if ($amount < 0) { |
|
594 | 594 | throw new Exception('Trying to set negative stockpile.'); |
595 | 595 | } |
596 | - if($this->getStockpile($goodID) == $amount) { |
|
596 | + if ($this->getStockpile($goodID) == $amount) { |
|
597 | 597 | return; |
598 | 598 | } |
599 | 599 | $this->stockpile[$goodID] = $amount; |
600 | 600 | $this->hasChangedStockpile = true; |
601 | 601 | } |
602 | 602 | |
603 | - public function decreaseStockpile($goodID,$amount) { |
|
604 | - if($amount < 0) |
|
603 | + public function decreaseStockpile($goodID, $amount) { |
|
604 | + if ($amount < 0) |
|
605 | 605 | throw new Exception('Trying to decrease negative stockpile.'); |
606 | - $this->setStockpile($goodID,$this->getStockpile($goodID) - $amount); |
|
606 | + $this->setStockpile($goodID, $this->getStockpile($goodID) - $amount); |
|
607 | 607 | } |
608 | 608 | |
609 | - public function increaseStockpile($goodID,$amount) { |
|
610 | - if($amount < 0) |
|
609 | + public function increaseStockpile($goodID, $amount) { |
|
610 | + if ($amount < 0) |
|
611 | 611 | throw new Exception('Trying to increase negative stockpile.'); |
612 | - $this->setStockpile($goodID,$this->getStockpile($goodID) + $amount); |
|
612 | + $this->setStockpile($goodID, $this->getStockpile($goodID) + $amount); |
|
613 | 613 | } |
614 | 614 | |
615 | 615 | public function getBuildings() { |
616 | - if(!isset($this->buildings)) { |
|
616 | + if (!isset($this->buildings)) { |
|
617 | 617 | $this->buildings = array(); |
618 | 618 | |
619 | 619 | // get buildingss from db |
@@ -631,41 +631,41 @@ discard block |
||
631 | 631 | |
632 | 632 | public function getBuilding($buildingTypeID) { |
633 | 633 | $buildings = $this->getBuildings(); |
634 | - if(isset($buildings[$buildingTypeID])) { |
|
634 | + if (isset($buildings[$buildingTypeID])) { |
|
635 | 635 | return $buildings[$buildingTypeID]; |
636 | 636 | } |
637 | 637 | return 0; |
638 | 638 | } |
639 | 639 | |
640 | 640 | public function hasBuilding($buildingTypeID) { |
641 | - return $this->getBuilding($buildingTypeID)>0; |
|
641 | + return $this->getBuilding($buildingTypeID) > 0; |
|
642 | 642 | } |
643 | 643 | |
644 | - public function setBuilding($buildingTypeID,$number) { |
|
645 | - if($this->getBuilding($buildingTypeID) == $number) |
|
644 | + public function setBuilding($buildingTypeID, $number) { |
|
645 | + if ($this->getBuilding($buildingTypeID) == $number) |
|
646 | 646 | return; |
647 | 647 | |
648 | 648 | $this->buildings[$buildingTypeID] = $number; |
649 | 649 | $this->hasChangedBuildings[$buildingTypeID] = true; |
650 | 650 | } |
651 | 651 | |
652 | - public function increaseBuilding($buildingTypeID,$number) { |
|
653 | - $this->setBuilding($buildingTypeID,$this->getBuilding($buildingTypeID)+$number); |
|
652 | + public function increaseBuilding($buildingTypeID, $number) { |
|
653 | + $this->setBuilding($buildingTypeID, $this->getBuilding($buildingTypeID) + $number); |
|
654 | 654 | } |
655 | 655 | |
656 | - public function destroyBuilding($buildingTypeID,$number) { |
|
657 | - if(!$this->hasBuilding($buildingTypeID)) { |
|
656 | + public function destroyBuilding($buildingTypeID, $number) { |
|
657 | + if (!$this->hasBuilding($buildingTypeID)) { |
|
658 | 658 | throw new Exception('Trying to destroy a nonexistent building'); |
659 | 659 | } |
660 | - $this->setBuilding($buildingTypeID,$this->getBuilding($buildingTypeID)-$number); |
|
660 | + $this->setBuilding($buildingTypeID, $this->getBuilding($buildingTypeID) - $number); |
|
661 | 661 | } |
662 | 662 | |
663 | 663 | function getCurrentlyBuilding() { |
664 | - if(!isset($this->currentlyBuilding)) { |
|
664 | + if (!isset($this->currentlyBuilding)) { |
|
665 | 665 | $this->currentlyBuilding = array(); |
666 | 666 | |
667 | 667 | $this->db->query('SELECT * FROM planet_is_building WHERE ' . $this->SQL); |
668 | - while($this->db->nextRecord()) { |
|
668 | + while ($this->db->nextRecord()) { |
|
669 | 669 | $this->currentlyBuilding[$this->db->getInt('building_slot_id')] = array( |
670 | 670 | 'BuildingSlotID' => $this->db->getInt('building_slot_id'), |
671 | 671 | 'ConstructionID' => $this->db->getInt('construction_id'), |
@@ -681,9 +681,9 @@ discard block |
||
681 | 681 | unset($this->currentlyBuilding[$id]); |
682 | 682 | $expGain = $this->getConstructionExp($building['ConstructionID']); |
683 | 683 | $player = SmrPlayer::getPlayer($building['ConstructorID'], $this->getGameID()); |
684 | - $player->increaseHOF(1, array('Planet','Buildings','Built'), HOF_ALLIANCE); |
|
684 | + $player->increaseHOF(1, array('Planet', 'Buildings', 'Built'), HOF_ALLIANCE); |
|
685 | 685 | $player->increaseExperience($expGain); |
686 | - $player->increaseHOF($expGain, array('Planet','Buildings','Experience'), HOF_ALLIANCE); |
|
686 | + $player->increaseHOF($expGain, array('Planet', 'Buildings', 'Experience'), HOF_ALLIANCE); |
|
687 | 687 | $this->hasStoppedBuilding[] = $building['BuildingSlotID']; |
688 | 688 | $this->increaseBuilding($building['ConstructionID'], 1); |
689 | 689 | |
@@ -700,8 +700,8 @@ discard block |
||
700 | 700 | return $this->currentlyBuilding; |
701 | 701 | } |
702 | 702 | |
703 | - public function getMaxBuildings($buildingTypeID=false) { |
|
704 | - if($buildingTypeID===false) { |
|
703 | + public function getMaxBuildings($buildingTypeID = false) { |
|
704 | + if ($buildingTypeID === false) { |
|
705 | 705 | $structs = $this->typeInfo::STRUCTURES; |
706 | 706 | return array_combine(array_keys($structs), |
707 | 707 | array_column($structs, 'max_amount')); |
@@ -718,13 +718,13 @@ discard block |
||
718 | 718 | return; |
719 | 719 | } |
720 | 720 | $this->typeID = $num; |
721 | - $this->db->query('UPDATE planet SET planet_type_id = '.$this->db->escapeNumber($num).' WHERE '.$this->SQL); |
|
721 | + $this->db->query('UPDATE planet SET planet_type_id = ' . $this->db->escapeNumber($num) . ' WHERE ' . $this->SQL); |
|
722 | 722 | $this->typeInfo = SmrPlanetType::getTypeInfo($this->getTypeID()); |
723 | 723 | |
724 | 724 | //trim buildings first |
725 | 725 | foreach ($this->getBuildings() as $id => $amt) { |
726 | 726 | if ($this->getMaxBuildings($id) < $amt) { |
727 | - $this->destroyBuilding($id,$amt - $this->getMaxBuildings($id)); |
|
727 | + $this->destroyBuilding($id, $amt - $this->getMaxBuildings($id)); |
|
728 | 728 | } |
729 | 729 | } |
730 | 730 | |
@@ -755,7 +755,7 @@ discard block |
||
755 | 755 | return $this->typeInfo->maxLanded(); |
756 | 756 | } |
757 | 757 | |
758 | - public function getStructureTypes($structureID=false) { |
|
758 | + public function getStructureTypes($structureID = false) { |
|
759 | 759 | return $this->typeInfo->structureTypes($structureID); |
760 | 760 | } |
761 | 761 | |
@@ -781,14 +781,14 @@ discard block |
||
781 | 781 | } |
782 | 782 | |
783 | 783 | public function update() { |
784 | - if(!$this->exists()) { |
|
784 | + if (!$this->exists()) { |
|
785 | 785 | return; |
786 | 786 | } |
787 | 787 | $this->doDelayedUpdates(); |
788 | - if($this->hasChanged) { |
|
788 | + if ($this->hasChanged) { |
|
789 | 789 | $this->db->query('UPDATE planet SET |
790 | 790 | owner_id = ' . $this->db->escapeNumber($this->ownerID) . ', |
791 | - password = '.$this->db->escapeString($this->password) .', |
|
791 | + password = '.$this->db->escapeString($this->password) . ', |
|
792 | 792 | planet_name = ' . $this->db->escapeString($this->planetName) . ', |
793 | 793 | shields = ' . $this->db->escapeNumber($this->shields) . ', |
794 | 794 | armour = ' . $this->db->escapeNumber($this->armour) . ', |
@@ -809,7 +809,7 @@ discard block |
||
809 | 809 | $this->hasChangedFinancial = false; |
810 | 810 | } |
811 | 811 | |
812 | - if($this->hasChangedStockpile) { |
|
812 | + if ($this->hasChangedStockpile) { |
|
813 | 813 | // write stockpile info |
814 | 814 | foreach ($this->getStockpile() as $id => $amount) { |
815 | 815 | if ($amount != 0) { |
@@ -826,21 +826,21 @@ discard block |
||
826 | 826 | if ($this->hasChangedWeapons) { |
827 | 827 | foreach (array_keys($this->hasChangedWeapons) as $orderID) { |
828 | 828 | if (isset($this->mountedWeapons[$orderID])) { |
829 | - $this->db->query('REPLACE INTO planet_has_weapon (game_id, sector_id, order_id, weapon_type_id) VALUES ('.$this->db->escapeNumber($this->getGameID()).','.$this->db->escapeNumber($this->getSectorID()).','.$this->db->escapeNumber($orderID).','.$this->db->escapeNumber($this->mountedWeapons[$orderID]->getWeaponTypeID()).')'); |
|
829 | + $this->db->query('REPLACE INTO planet_has_weapon (game_id, sector_id, order_id, weapon_type_id) VALUES (' . $this->db->escapeNumber($this->getGameID()) . ',' . $this->db->escapeNumber($this->getSectorID()) . ',' . $this->db->escapeNumber($orderID) . ',' . $this->db->escapeNumber($this->mountedWeapons[$orderID]->getWeaponTypeID()) . ')'); |
|
830 | 830 | } else { |
831 | - $this->db->query('DELETE FROM planet_has_weapon WHERE '.$this->SQL.' AND order_id='.$this->db->escapeNumber($orderID)); |
|
831 | + $this->db->query('DELETE FROM planet_has_weapon WHERE ' . $this->SQL . ' AND order_id=' . $this->db->escapeNumber($orderID)); |
|
832 | 832 | } |
833 | 833 | } |
834 | 834 | } |
835 | 835 | |
836 | - if(count($this->hasStoppedBuilding)>0) { |
|
836 | + if (count($this->hasStoppedBuilding) > 0) { |
|
837 | 837 | $this->db->query('DELETE FROM planet_is_building WHERE ' . $this->SQL . ' |
838 | 838 | AND building_slot_id IN (' . $this->db->escapeArray($this->hasStoppedBuilding) . ') LIMIT ' . count($this->hasStoppedBuilding)); |
839 | 839 | $this->hasStoppedBuilding = array(); |
840 | 840 | } |
841 | 841 | // write building info |
842 | 842 | foreach ($this->hasChangedBuildings as $id => $hasChanged) { |
843 | - if($hasChanged===true) { |
|
843 | + if ($hasChanged === true) { |
|
844 | 844 | if ($this->hasBuilding($id)) { |
845 | 845 | $this->db->query('REPLACE INTO planet_has_building (game_id, sector_id, construction_id, amount) ' . |
846 | 846 | 'VALUES(' . $this->db->escapeNumber($this->gameID) . ', ' . $this->db->escapeNumber($this->sectorID) . ', ' . $this->db->escapeNumber($id) . ', ' . $this->db->escapeNumber($this->getBuilding($id)) . ')'); |
@@ -855,15 +855,15 @@ discard block |
||
855 | 855 | } |
856 | 856 | |
857 | 857 | function getLevel() { |
858 | - return array_sum($this->getBuildings())/3; |
|
858 | + return array_sum($this->getBuildings()) / 3; |
|
859 | 859 | } |
860 | 860 | |
861 | 861 | function getMaxLevel() { |
862 | - return array_sum($this->getMaxBuildings())/3; |
|
862 | + return array_sum($this->getMaxBuildings()) / 3; |
|
863 | 863 | } |
864 | 864 | |
865 | 865 | function accuracy() { |
866 | - if($this->hasWeapons()) { |
|
866 | + if ($this->hasWeapons()) { |
|
867 | 867 | $weapons = $this->getWeapons(); |
868 | 868 | return $weapons[0]->getModifiedPlanetAccuracy($this); |
869 | 869 | } |
@@ -889,10 +889,10 @@ discard block |
||
889 | 889 | } |
890 | 890 | |
891 | 891 | function canBuild(AbstractSmrPlayer $constructor, $constructionID) { |
892 | - if($this->hasCurrentlyBuilding()) { |
|
892 | + if ($this->hasCurrentlyBuilding()) { |
|
893 | 893 | return 'There is already a building in progress!'; |
894 | 894 | } |
895 | - if($this->getBuilding($constructionID) >= $this->getMaxBuildings($constructionID)) { |
|
895 | + if ($this->getBuilding($constructionID) >= $this->getMaxBuildings($constructionID)) { |
|
896 | 896 | return 'This planet has reached the maximum buildings of that type.'; |
897 | 897 | } |
898 | 898 | $cost = $this->getStructureTypes($constructionID)->creditCost(); |
@@ -918,7 +918,7 @@ discard block |
||
918 | 918 | private function getCompletionModifier($constructionID) { |
919 | 919 | $currentBuildings = $this->getBuilding($constructionID); |
920 | 920 | $maxBuildings = $this->getMaxBuildings($constructionID); |
921 | - return 0.01 + 2.97 * pow($currentBuildings/$maxBuildings, 2); |
|
921 | + return 0.01 + 2.97 * pow($currentBuildings / $maxBuildings, 2); |
|
922 | 922 | } |
923 | 923 | |
924 | 924 | // Amount of exp gained to build the next building of this type |
@@ -935,13 +935,13 @@ discard block |
||
935 | 935 | } |
936 | 936 | |
937 | 937 | function startBuilding(AbstractSmrPlayer $constructor, $constructionID) { |
938 | - if(($message = $this->canBuild($constructor, $constructionID)) !== true) { |
|
939 | - throw new Exception('Unable to start building: '.$message); |
|
938 | + if (($message = $this->canBuild($constructor, $constructionID)) !== true) { |
|
939 | + throw new Exception('Unable to start building: ' . $message); |
|
940 | 940 | } |
941 | 941 | $constructor->decreaseCredits($this->getStructureTypes($constructionID)->creditCost()); |
942 | 942 | // take the goods that are needed |
943 | 943 | foreach ($this->getStructureTypes($constructionID)->goods() as $goodID => $amount) { |
944 | - $this->decreaseStockpile($goodID,$amount); |
|
944 | + $this->decreaseStockpile($goodID, $amount); |
|
945 | 945 | } |
946 | 946 | foreach ($this->getStructureTypes($constructionID)->hardwareCost() as $hardwareID) { |
947 | 947 | $constructor->getShip()->setHardware($hardwareID, 0); |
@@ -964,13 +964,13 @@ discard block |
||
964 | 964 | function stopBuilding($constructionID) { |
965 | 965 | $matchingBuilding = false; |
966 | 966 | $latestFinish = 0; |
967 | - foreach($this->getCurrentlyBuilding() as $key => $building) { |
|
968 | - if($building['ConstructionID'] == $constructionID && $building['Finishes'] > $latestFinish) { |
|
967 | + foreach ($this->getCurrentlyBuilding() as $key => $building) { |
|
968 | + if ($building['ConstructionID'] == $constructionID && $building['Finishes'] > $latestFinish) { |
|
969 | 969 | $latestFinish = $building['Finishes']; |
970 | 970 | $matchingBuilding = $building; |
971 | 971 | } |
972 | 972 | } |
973 | - if($matchingBuilding) { |
|
973 | + if ($matchingBuilding) { |
|
974 | 974 | $this->hasStoppedBuilding[] = $matchingBuilding['BuildingSlotID']; |
975 | 975 | unset($this->currentlyBuilding[$matchingBuilding['BuildingSlotID']]); |
976 | 976 | return true; |
@@ -983,7 +983,7 @@ discard block |
||
983 | 983 | } |
984 | 984 | |
985 | 985 | public function setName($name) { |
986 | - if($this->planetName == $name) { |
|
986 | + if ($this->planetName == $name) { |
|
987 | 987 | return; |
988 | 988 | } |
989 | 989 | $this->planetName = $name; |
@@ -991,15 +991,15 @@ discard block |
||
991 | 991 | } |
992 | 992 | |
993 | 993 | public function getDisplayName() { |
994 | - return '<span style="color:yellow;font-variant:small-caps">' . $this->getName() . '(#'.$this->getSectorID().')</span>';; |
|
994 | + return '<span style="color:yellow;font-variant:small-caps">' . $this->getName() . '(#' . $this->getSectorID() . ')</span>'; ; |
|
995 | 995 | } |
996 | 996 | |
997 | 997 | public function isInhabitable() { |
998 | - return $this->inhabitableTime<= TIME; |
|
998 | + return $this->inhabitableTime <= TIME; |
|
999 | 999 | } |
1000 | 1000 | |
1001 | 1001 | public function isClaimed() { |
1002 | - return $this->ownerID>0; |
|
1002 | + return $this->ownerID > 0; |
|
1003 | 1003 | } |
1004 | 1004 | |
1005 | 1005 | public function removeClaimed() { |
@@ -1041,9 +1041,9 @@ discard block |
||
1041 | 1041 | } |
1042 | 1042 | |
1043 | 1043 | public function attackedBy(AbstractSmrPlayer $trigger, array $attackers) { |
1044 | - $trigger->increaseHOF(1,array('Combat','Planet','Number Of Triggers'), HOF_PUBLIC); |
|
1044 | + $trigger->increaseHOF(1, array('Combat', 'Planet', 'Number Of Triggers'), HOF_PUBLIC); |
|
1045 | 1045 | foreach ($attackers as $attacker) { |
1046 | - $attacker->increaseHOF(1,array('Combat','Planet','Number Of Attacks'), HOF_PUBLIC); |
|
1046 | + $attacker->increaseHOF(1, array('Combat', 'Planet', 'Number Of Attacks'), HOF_PUBLIC); |
|
1047 | 1047 | $this->db->query('REPLACE INTO player_attacks_planet (game_id, account_id, sector_id, time, level) VALUES ' . |
1048 | 1048 | '(' . $this->db->escapeNumber($this->getGameID()) . ', ' . $this->db->escapeNumber($attacker->getAccountID()) . ', ' . $this->db->escapeNumber($this->getSectorID()) . ', ' . $this->db->escapeNumber(TIME) . ', ' . $this->db->escapeNumber($this->getLevel()) . ')'); |
1049 | 1049 | } |
@@ -1052,9 +1052,9 @@ discard block |
||
1052 | 1052 | // Note: Attack uniqueness determined by planet owner. |
1053 | 1053 | $owner = $this->getOwner(); |
1054 | 1054 | $this->db->query('SELECT 1 FROM news WHERE type = \'BREAKING\' AND game_id = ' . $this->db->escapeNumber($trigger->getGameID()) . ' AND dead_id=' . $this->db->escapeNumber($owner->getAccountID()) . ' AND time > ' . $this->db->escapeNumber(TIME - self::TIME_ATTACK_NEWS_COOLDOWN) . ' LIMIT 1'); |
1055 | - if ($this->db->getNumRows()==0) { |
|
1055 | + if ($this->db->getNumRows() == 0) { |
|
1056 | 1056 | if (count($attackers) >= 5) { |
1057 | - $text = count($attackers) . ' members of '.$trigger->getAllianceBBLink().' have been spotted attacking ' . |
|
1057 | + $text = count($attackers) . ' members of ' . $trigger->getAllianceBBLink() . ' have been spotted attacking ' . |
|
1058 | 1058 | $this->getDisplayName() . ' in sector ' . Globals::getSectorBBLink($this->getSectorID()) . '. The planet is owned by ' . $owner->getBBLink(); |
1059 | 1059 | if ($owner->hasAlliance()) { |
1060 | 1060 | $text .= ', a member of ' . $owner->getAllianceBBLink(); |
@@ -1068,7 +1068,7 @@ discard block |
||
1068 | 1068 | |
1069 | 1069 | |
1070 | 1070 | public function &getPlayers() { |
1071 | - return SmrPlayer::getPlanetPlayers($this->getGameID(),$this->getSectorID()); |
|
1071 | + return SmrPlayer::getPlanetPlayers($this->getGameID(), $this->getSectorID()); |
|
1072 | 1072 | } |
1073 | 1073 | |
1074 | 1074 | public function countPlayers() { |
@@ -1080,7 +1080,7 @@ discard block |
||
1080 | 1080 | } |
1081 | 1081 | |
1082 | 1082 | public function &getOtherTraders(AbstractSmrPlayer $player) { |
1083 | - $players = SmrPlayer::getPlanetPlayers($this->getGameID(),$this->getSectorID()); //Do not use & because we unset something and only want that in what we return |
|
1083 | + $players = SmrPlayer::getPlanetPlayers($this->getGameID(), $this->getSectorID()); //Do not use & because we unset something and only want that in what we return |
|
1084 | 1084 | unset($players[$player->getAccountID()]); |
1085 | 1085 | return $players; |
1086 | 1086 | } |
@@ -1090,22 +1090,22 @@ discard block |
||
1090 | 1090 | } |
1091 | 1091 | |
1092 | 1092 | public function hasEnemyTraders(AbstractSmrPlayer $player) { |
1093 | - if(!$this->hasOtherTraders($player)) |
|
1093 | + if (!$this->hasOtherTraders($player)) |
|
1094 | 1094 | return false; |
1095 | 1095 | $otherPlayers = $this->getOtherTraders($player); |
1096 | - foreach($otherPlayers as $otherPlayer) { |
|
1097 | - if(!$player->traderNAPAlliance($otherPlayer)) |
|
1096 | + foreach ($otherPlayers as $otherPlayer) { |
|
1097 | + if (!$player->traderNAPAlliance($otherPlayer)) |
|
1098 | 1098 | return true; |
1099 | 1099 | } |
1100 | 1100 | return false; |
1101 | 1101 | } |
1102 | 1102 | |
1103 | 1103 | public function hasFriendlyTraders(AbstractSmrPlayer $player) { |
1104 | - if(!$this->hasOtherTraders($player)) |
|
1104 | + if (!$this->hasOtherTraders($player)) |
|
1105 | 1105 | return false; |
1106 | 1106 | $otherPlayers = $this->getOtherTraders($player); |
1107 | - foreach($otherPlayers as $otherPlayer) { |
|
1108 | - if($player->traderNAPAlliance($otherPlayer)) |
|
1107 | + foreach ($otherPlayers as $otherPlayer) { |
|
1108 | + if ($player->traderNAPAlliance($otherPlayer)) |
|
1109 | 1109 | return true; |
1110 | 1110 | } |
1111 | 1111 | return false; |
@@ -1113,14 +1113,14 @@ discard block |
||
1113 | 1113 | |
1114 | 1114 | public function &getWeapons() { |
1115 | 1115 | $weapons = $this->getMountedWeapons(); |
1116 | - for($i=0; $i<$this->getBuilding(PLANET_TURRET); ++$i) { |
|
1116 | + for ($i = 0; $i < $this->getBuilding(PLANET_TURRET); ++$i) { |
|
1117 | 1117 | $weapons[] = SmrWeapon::getWeapon(WEAPON_PLANET_TURRET); |
1118 | 1118 | } |
1119 | 1119 | return $weapons; |
1120 | 1120 | } |
1121 | 1121 | |
1122 | 1122 | public function hasWeapons() { |
1123 | - return count($this->getWeapons())>0; |
|
1123 | + return count($this->getWeapons()) > 0; |
|
1124 | 1124 | } |
1125 | 1125 | |
1126 | 1126 | public function &shootPlayer(AbstractSmrPlayer $targetPlayer) { |
@@ -1129,25 +1129,25 @@ discard block |
||
1129 | 1129 | |
1130 | 1130 | public function &shootPlayers(array $targetPlayers) { |
1131 | 1131 | $results = array('Planet' => $this, 'TotalDamage' => 0, 'TotalDamagePerTargetPlayer' => array()); |
1132 | - foreach($targetPlayers as $targetPlayer) { |
|
1132 | + foreach ($targetPlayers as $targetPlayer) { |
|
1133 | 1133 | $results['TotalDamagePerTargetPlayer'][$targetPlayer->getAccountID()] = 0; |
1134 | 1134 | } |
1135 | - if($this->isDestroyed()) { |
|
1135 | + if ($this->isDestroyed()) { |
|
1136 | 1136 | $results['DeadBeforeShot'] = true; |
1137 | 1137 | return $results; |
1138 | 1138 | } |
1139 | 1139 | $results['DeadBeforeShot'] = false; |
1140 | 1140 | $weapons = $this->getWeapons(); |
1141 | - foreach($weapons as $orderID => $weapon) { |
|
1142 | - $results['Weapons'][$orderID] =& $weapon->shootPlayerAsPlanet($this, $targetPlayers[array_rand($targetPlayers)]); |
|
1143 | - if($results['Weapons'][$orderID]['Hit']) { |
|
1141 | + foreach ($weapons as $orderID => $weapon) { |
|
1142 | + $results['Weapons'][$orderID] = & $weapon->shootPlayerAsPlanet($this, $targetPlayers[array_rand($targetPlayers)]); |
|
1143 | + if ($results['Weapons'][$orderID]['Hit']) { |
|
1144 | 1144 | $results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage']; |
1145 | 1145 | $results['TotalDamagePerTargetPlayer'][$results['Weapons'][$orderID]['TargetPlayer']->getAccountID()] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage']; |
1146 | 1146 | } |
1147 | 1147 | } |
1148 | - if($this->hasCDs()) { |
|
1149 | - $thisCDs = new SmrCombatDrones($this->getGameID(),$this->getCDs(),true); |
|
1150 | - $results['Drones'] =& $thisCDs->shootPlayerAsPlanet($this, $targetPlayers[array_rand($targetPlayers)]); |
|
1148 | + if ($this->hasCDs()) { |
|
1149 | + $thisCDs = new SmrCombatDrones($this->getGameID(), $this->getCDs(), true); |
|
1150 | + $results['Drones'] = & $thisCDs->shootPlayerAsPlanet($this, $targetPlayers[array_rand($targetPlayers)]); |
|
1151 | 1151 | $results['TotalDamage'] += $results['Drones']['ActualDamage']['TotalDamage']; |
1152 | 1152 | $results['TotalDamagePerTargetPlayer'][$results['Drones']['TargetPlayer']->getAccountID()] += $results['Drones']['ActualDamage']['TotalDamage']; |
1153 | 1153 | } |
@@ -1159,7 +1159,7 @@ discard block |
||
1159 | 1159 | // For every 70 damage there is a 15% chance of destroying a structure. |
1160 | 1160 | // Which structure is destroyed depends on the ratio of buildings and |
1161 | 1161 | // the time it takes to build them. |
1162 | - for ($i = 0; $damage > self::DAMAGE_NEEDED_FOR_DOWNGRADE_CHANCE; $damage-=self::DAMAGE_NEEDED_FOR_DOWNGRADE_CHANCE) { |
|
1162 | + for ($i = 0; $damage > self::DAMAGE_NEEDED_FOR_DOWNGRADE_CHANCE; $damage -= self::DAMAGE_NEEDED_FOR_DOWNGRADE_CHANCE) { |
|
1163 | 1163 | // Stop if the planet has no more buildlings |
1164 | 1164 | if ($this->getLevel() == 0) { |
1165 | 1165 | break; |
@@ -1173,7 +1173,7 @@ discard block |
||
1173 | 1173 | $destroyID = getWeightedRandom($chanceFactors); |
1174 | 1174 | $this->destroyBuilding($destroyID, 1); |
1175 | 1175 | $this->checkForExcessDefense(); |
1176 | - $results .= 'This team destroys <span class="red">1</span> '.$this->getStructureTypes($destroyID)->name().'.<br />'; |
|
1176 | + $results .= 'This team destroys <span class="red">1</span> ' . $this->getStructureTypes($destroyID)->name() . '.<br />'; |
|
1177 | 1177 | } |
1178 | 1178 | } |
1179 | 1179 | return $results; |
@@ -1184,20 +1184,20 @@ discard block |
||
1184 | 1184 | $shieldDamage = 0; |
1185 | 1185 | $cdDamage = 0; |
1186 | 1186 | $armourDamage = 0; |
1187 | - if(!$alreadyDead) { |
|
1188 | - if($damage['Shield'] || !$this->hasShields(true)) { |
|
1189 | - $shieldDamage = $this->doShieldDamage(min($damage['MaxDamage'],$damage['Shield']),$delayed); |
|
1187 | + if (!$alreadyDead) { |
|
1188 | + if ($damage['Shield'] || !$this->hasShields(true)) { |
|
1189 | + $shieldDamage = $this->doShieldDamage(min($damage['MaxDamage'], $damage['Shield']), $delayed); |
|
1190 | 1190 | $damage['Shield'] -= $shieldDamage; |
1191 | 1191 | $damage['MaxDamage'] -= $shieldDamage; |
1192 | 1192 | |
1193 | - if(!$this->hasShields(true) && ($shieldDamage == 0 || $damage['Rollover'])) { |
|
1193 | + if (!$this->hasShields(true) && ($shieldDamage == 0 || $damage['Rollover'])) { |
|
1194 | 1194 | if ($this->hasCDs(true)) { |
1195 | - $cdDamage = $this->doCDDamage(min($damage['MaxDamage'],$damage['Armour']),$delayed); |
|
1195 | + $cdDamage = $this->doCDDamage(min($damage['MaxDamage'], $damage['Armour']), $delayed); |
|
1196 | 1196 | $damage['Armour'] -= $cdDamage; |
1197 | 1197 | $damage['MaxDamage'] -= $cdDamage; |
1198 | 1198 | } |
1199 | 1199 | if ($this->hasArmour(true) && ($cdDamage == 0 || $damage['Rollover'])) { |
1200 | - $armourDamage = $this->doArmourDamage(min($damage['MaxDamage'],$damage['Armour']),$delayed); |
|
1200 | + $armourDamage = $this->doArmourDamage(min($damage['MaxDamage'], $damage['Armour']), $delayed); |
|
1201 | 1201 | $damage['Armour'] -= $armourDamage; |
1202 | 1202 | $damage['MaxDamage'] -= $armourDamage; |
1203 | 1203 | } |
@@ -1205,7 +1205,7 @@ discard block |
||
1205 | 1205 | |
1206 | 1206 | } |
1207 | 1207 | else { // hit drones behind shields - we should only use this reduced damage branch if we cannot hit shields. |
1208 | - $cdDamage = $this->doCDDamage(floor(min($damage['MaxDamage'],$damage['Armour'])*DRONES_BEHIND_SHIELDS_DAMAGE_PERCENT),$delayed); |
|
1208 | + $cdDamage = $this->doCDDamage(floor(min($damage['MaxDamage'], $damage['Armour']) * DRONES_BEHIND_SHIELDS_DAMAGE_PERCENT), $delayed); |
|
1209 | 1209 | } |
1210 | 1210 | } |
1211 | 1211 | |
@@ -1217,27 +1217,27 @@ discard block |
||
1217 | 1217 | 'HasShields' => $this->hasShields(true), |
1218 | 1218 | 'HasArmour' => $this->hasArmour(true), |
1219 | 1219 | 'CDs' => $cdDamage, |
1220 | - 'NumCDs' => $cdDamage/CD_ARMOUR, |
|
1220 | + 'NumCDs' => $cdDamage / CD_ARMOUR, |
|
1221 | 1221 | 'HasCDs' => $this->hasCDs(true), |
1222 | - 'TotalDamage' => $shieldDamage+$cdDamage+$armourDamage |
|
1222 | + 'TotalDamage' => $shieldDamage + $cdDamage + $armourDamage |
|
1223 | 1223 | ); |
1224 | 1224 | return $return; |
1225 | 1225 | } |
1226 | 1226 | |
1227 | 1227 | protected function doShieldDamage($damage, $delayed) { |
1228 | - $actualDamage = min($this->getShields(true),$damage); |
|
1228 | + $actualDamage = min($this->getShields(true), $damage); |
|
1229 | 1229 | $this->decreaseShields($actualDamage, $delayed); |
1230 | 1230 | return $actualDamage; |
1231 | 1231 | } |
1232 | 1232 | |
1233 | 1233 | protected function doCDDamage($damage, $delayed) { |
1234 | - $actualDamage = min($this->getCDs(true),floor($damage/CD_ARMOUR)); |
|
1234 | + $actualDamage = min($this->getCDs(true), floor($damage / CD_ARMOUR)); |
|
1235 | 1235 | $this->decreaseCDs($actualDamage, $delayed); |
1236 | - return $actualDamage*CD_ARMOUR; |
|
1236 | + return $actualDamage * CD_ARMOUR; |
|
1237 | 1237 | } |
1238 | 1238 | |
1239 | 1239 | protected function doArmourDamage($damage, $delayed) { |
1240 | - $actualDamage = min($this->getArmour(true),$damage);; |
|
1240 | + $actualDamage = min($this->getArmour(true), $damage); ; |
|
1241 | 1241 | $this->decreaseArmour($actualDamage, $delayed); |
1242 | 1242 | return $actualDamage; |
1243 | 1243 | } |
@@ -1246,9 +1246,9 @@ discard block |
||
1246 | 1246 | //get all players involved for HoF |
1247 | 1247 | $this->db->query('SELECT account_id,level FROM player_attacks_planet WHERE ' . $this->SQL . ' AND time > ' . $this->db->escapeNumber(TIME - self::TIME_TO_CREDIT_BUST)); |
1248 | 1248 | while ($this->db->nextRecord()) { |
1249 | - $currPlayer = SmrPlayer::getPlayer($this->db->getInt('account_id'),$this->getGameID()); |
|
1250 | - $currPlayer->increaseHOF($this->db->getInt('level'),array('Combat','Planet','Levels'), HOF_PUBLIC); |
|
1251 | - $currPlayer->increaseHOF(1,array('Combat','Planet','Completed'), HOF_PUBLIC); |
|
1249 | + $currPlayer = SmrPlayer::getPlayer($this->db->getInt('account_id'), $this->getGameID()); |
|
1250 | + $currPlayer->increaseHOF($this->db->getInt('level'), array('Combat', 'Planet', 'Levels'), HOF_PUBLIC); |
|
1251 | + $currPlayer->increaseHOF(1, array('Combat', 'Planet', 'Completed'), HOF_PUBLIC); |
|
1252 | 1252 | } |
1253 | 1253 | $this->db->query('DELETE FROM player_attacks_planet WHERE ' . $this->SQL); |
1254 | 1254 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | const DCS_DAMAGE_MODIFIER = .75; |
7 | 7 | protected $numberOfMines; |
8 | 8 | |
9 | - public function __construct($gameTypeID,$numberOfMines) { |
|
9 | + public function __construct($gameTypeID, $numberOfMines) { |
|
10 | 10 | $this->gameTypeID = $gameTypeID; |
11 | 11 | $this->numberOfMines = $numberOfMines; |
12 | 12 | $this->name = 'Mines'; |
@@ -28,30 +28,30 @@ discard block |
||
28 | 28 | return $modifiedAccuracy; |
29 | 29 | } |
30 | 30 | |
31 | - public function getModifiedForceAccuracyAgainstPlayer(SmrForce $forces,AbstractSmrPlayer $targetPlayer,$minesAreAttacker) { |
|
32 | - return $this->getModifiedForceAccuracyAgainstPlayerUsingRandom($forces,$targetPlayer,mt_rand(1,7) * mt_rand(1,7),$minesAreAttacker); |
|
31 | + public function getModifiedForceAccuracyAgainstPlayer(SmrForce $forces, AbstractSmrPlayer $targetPlayer, $minesAreAttacker) { |
|
32 | + return $this->getModifiedForceAccuracyAgainstPlayerUsingRandom($forces, $targetPlayer, mt_rand(1, 7) * mt_rand(1, 7), $minesAreAttacker); |
|
33 | 33 | } |
34 | 34 | |
35 | - protected function getModifiedForceAccuracyAgainstPlayerUsingRandom(SmrForce $forces,AbstractSmrPlayer $targetPlayer, $random,$minesAreAttacker) { |
|
35 | + protected function getModifiedForceAccuracyAgainstPlayerUsingRandom(SmrForce $forces, AbstractSmrPlayer $targetPlayer, $random, $minesAreAttacker) { |
|
36 | 36 | $modifiedAccuracy = $this->getModifiedAccuracy(); |
37 | 37 | $modifiedAccuracy -= $targetPlayer->getLevelID() + $random; |
38 | - if($minesAreAttacker) { |
|
39 | - $modifiedAccuracy /= pow(SmrSector::getSector($forces->getGameID(),$forces->getSectorID())->getNumberOfConnections(), 0.6); |
|
38 | + if ($minesAreAttacker) { |
|
39 | + $modifiedAccuracy /= pow(SmrSector::getSector($forces->getGameID(), $forces->getSectorID())->getNumberOfConnections(), 0.6); |
|
40 | 40 | } |
41 | 41 | |
42 | - if(self::TOTAL_ENEMY_MINES_MODIFIER > 0) { |
|
42 | + if (self::TOTAL_ENEMY_MINES_MODIFIER > 0) { |
|
43 | 43 | $enemyMines = 0; |
44 | 44 | $enemyForces = $forces->getSector()->getEnemyForces($targetPlayer); |
45 | - foreach($enemyForces as $enemyForce) { |
|
45 | + foreach ($enemyForces as $enemyForce) { |
|
46 | 46 | $enemyMines += $enemyForce->getMines(); |
47 | 47 | } |
48 | 48 | $modifiedAccuracy += $enemyMines / self::TOTAL_ENEMY_MINES_MODIFIER; |
49 | 49 | } |
50 | - return max(0,min(100,$modifiedAccuracy)); |
|
50 | + return max(0, min(100, $modifiedAccuracy)); |
|
51 | 51 | } |
52 | 52 | |
53 | - public function getMaxModifiedForceAccuracyAgainstPlayer(SmrForce $forces,AbstractSmrPlayer $targetPlayer,$minesAreAttacker) { |
|
54 | - return $this->getModifiedForceAccuracyAgainstPlayerUsingRandom($forces,$targetPlayer,49,$minesAreAttacker); |
|
53 | + public function getMaxModifiedForceAccuracyAgainstPlayer(SmrForce $forces, AbstractSmrPlayer $targetPlayer, $minesAreAttacker) { |
|
54 | + return $this->getModifiedForceAccuracyAgainstPlayerUsingRandom($forces, $targetPlayer, 49, $minesAreAttacker); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | public function &getModifiedDamage() { |
@@ -89,13 +89,13 @@ discard block |
||
89 | 89 | return $return; |
90 | 90 | } |
91 | 91 | |
92 | - public function &getModifiedForceDamageAgainstPlayer(SmrForce $forces, AbstractSmrPlayer $targetPlayer,$minesAreAttacker=false) { |
|
93 | - if(!$this->canShootTraders()) { // If we can't shoot traders then just return a damageless array and don't waste resources calculated any damage mods. |
|
92 | + public function &getModifiedForceDamageAgainstPlayer(SmrForce $forces, AbstractSmrPlayer $targetPlayer, $minesAreAttacker = false) { |
|
93 | + if (!$this->canShootTraders()) { // If we can't shoot traders then just return a damageless array and don't waste resources calculated any damage mods. |
|
94 | 94 | $return = array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover()); |
95 | 95 | return $return; |
96 | 96 | } |
97 | - $damage =& $this->getModifiedDamage(); |
|
98 | - if($targetPlayer->getShip()->isFederal()) { // do less damage to fed ships |
|
97 | + $damage = & $this->getModifiedDamage(); |
|
98 | + if ($targetPlayer->getShip()->isFederal()) { // do less damage to fed ships |
|
99 | 99 | $damage['MaxDamage'] = round($damage['MaxDamage'] * self::FED_SHIP_DAMAGE_MODIFIER); |
100 | 100 | $damage['Shield'] = round($damage['Shield'] * self::FED_SHIP_DAMAGE_MODIFIER); |
101 | 101 | $damage['Armour'] = round($damage['Armour'] * self::FED_SHIP_DAMAGE_MODIFIER); |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | $damage['Shield'] = round($damage['Shield'] * self::DCS_DAMAGE_MODIFIER); |
107 | 107 | $damage['Armour'] = round($damage['Armour'] * self::DCS_DAMAGE_MODIFIER); |
108 | 108 | } |
109 | - $damage['Launched'] = ceil($this->getNumberOfMines() * $this->getModifiedForceAccuracyAgainstPlayer($forces,$targetPlayer,$minesAreAttacker) / 100); |
|
109 | + $damage['Launched'] = ceil($this->getNumberOfMines() * $this->getModifiedForceAccuracyAgainstPlayer($forces, $targetPlayer, $minesAreAttacker) / 100); |
|
110 | 110 | $damage['MaxDamage'] = ceil($damage['Launched'] * $damage['MaxDamage']); |
111 | 111 | $damage['Shield'] = ceil($damage['Launched'] * $damage['Shield']); |
112 | 112 | $damage['Armour'] = ceil($damage['Launched'] * $damage['Armour']); |
@@ -123,20 +123,20 @@ discard block |
||
123 | 123 | return $return; |
124 | 124 | } |
125 | 125 | |
126 | - public function &shootPlayerAsForce(SmrForce $forces, AbstractSmrPlayer $targetPlayer,$minesAreAttacker=false) { |
|
126 | + public function &shootPlayerAsForce(SmrForce $forces, AbstractSmrPlayer $targetPlayer, $minesAreAttacker = false) { |
|
127 | 127 | $return = array('Weapon' => $this, 'TargetPlayer' => $targetPlayer, 'Hit' => true); |
128 | 128 | $this->doForceDamageToPlayer($return, $forces, $targetPlayer, $minesAreAttacker); |
129 | 129 | $forces->takeMines($return['ActualDamage']['Launched']); |
130 | 130 | return $return; |
131 | 131 | } |
132 | 132 | |
133 | - protected function &doForceDamageToPlayer(array &$return, SmrForce $forces, AbstractSmrPlayer $targetPlayer,$minesAreAttacker=false) { |
|
134 | - $return['WeaponDamage'] =& $this->getModifiedForceDamageAgainstPlayer($forces,$targetPlayer,$minesAreAttacker); |
|
135 | - $return['ActualDamage'] =& $targetPlayer->getShip()->doMinesDamage($return['WeaponDamage']); |
|
133 | + protected function &doForceDamageToPlayer(array &$return, SmrForce $forces, AbstractSmrPlayer $targetPlayer, $minesAreAttacker = false) { |
|
134 | + $return['WeaponDamage'] = & $this->getModifiedForceDamageAgainstPlayer($forces, $targetPlayer, $minesAreAttacker); |
|
135 | + $return['ActualDamage'] = & $targetPlayer->getShip()->doMinesDamage($return['WeaponDamage']); |
|
136 | 136 | $return['ActualDamage']['Launched'] = ceil($return['WeaponDamage']['Launched'] * $return['ActualDamage']['TotalDamage'] / $return['WeaponDamage']['MaxDamage']); |
137 | 137 | |
138 | - if($return['ActualDamage']['KillingShot']) { |
|
139 | - $return['KillResults'] =& $targetPlayer->killPlayerByForces($forces); |
|
138 | + if ($return['ActualDamage']['KillingShot']) { |
|
139 | + $return['KillResults'] = & $targetPlayer->killPlayerByForces($forces); |
|
140 | 140 | } |
141 | 141 | return $return; |
142 | 142 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | private static $reverseOrder; |
5 | 5 | |
6 | 6 | private static function cmpStrProp($a, $b) { |
7 | - return (self::$reverseOrder?-1:1)*strcasecmp($a->{self::$sortKey}, $b->{self::$sortKey}); |
|
7 | + return (self::$reverseOrder ?-1 : 1) * strcasecmp($a->{self::$sortKey}, $b->{self::$sortKey}); |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | private static function cmpNumElement($a, $b) { |
@@ -20,8 +20,8 @@ discard block |
||
20 | 20 | } |
21 | 21 | |
22 | 22 | public static function cmpNum($a, $b) { |
23 | - if($a == $b) return 0; |
|
24 | - return (self::$reverseOrder?-1:1)*($a < $b ? -1 : 1); |
|
23 | + if ($a == $b) return 0; |
|
24 | + return (self::$reverseOrder ?-1 : 1) * ($a < $b ? -1 : 1); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | public static function sortByStrProp(array &$array, $property, $reverseOrder = false) { |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | protected $maxDamage; |
13 | 13 | protected $shieldDamage; |
14 | 14 | protected $armourDamage; |
15 | - protected $empDamage=0; |
|
15 | + protected $empDamage = 0; |
|
16 | 16 | protected $accuracy; |
17 | 17 | protected $damageRollover; |
18 | 18 | protected $raidWeapon; |
@@ -85,62 +85,62 @@ discard block |
||
85 | 85 | abstract public function &getModifiedForceDamageAgainstPlayer(SmrForce $forces, AbstractSmrPlayer $targetPlayer); |
86 | 86 | |
87 | 87 | protected function &doPlayerDamageToForce(array &$return, AbstractSmrPlayer $weaponPlayer, SmrForce $forces) { |
88 | - $return['WeaponDamage'] =& $this->getModifiedDamageAgainstForces($weaponPlayer,$forces); |
|
89 | - $return['ActualDamage'] =& $forces->doWeaponDamage($return['WeaponDamage']); |
|
90 | - if($return['ActualDamage']['KillingShot']) |
|
91 | - $return['KillResults'] =& $forces->killForcesByPlayer($weaponPlayer); |
|
88 | + $return['WeaponDamage'] = & $this->getModifiedDamageAgainstForces($weaponPlayer, $forces); |
|
89 | + $return['ActualDamage'] = & $forces->doWeaponDamage($return['WeaponDamage']); |
|
90 | + if ($return['ActualDamage']['KillingShot']) |
|
91 | + $return['KillResults'] = & $forces->killForcesByPlayer($weaponPlayer); |
|
92 | 92 | return $return; |
93 | 93 | } |
94 | 94 | |
95 | 95 | protected function &doPlayerDamageToPlayer(array &$return, AbstractSmrPlayer $weaponPlayer, AbstractSmrPlayer $targetPlayer) { |
96 | - $return['WeaponDamage'] =& $this->getModifiedDamageAgainstPlayer($weaponPlayer,$targetPlayer); |
|
97 | - $return['ActualDamage'] =& $targetPlayer->getShip()->doWeaponDamage($return['WeaponDamage']); |
|
96 | + $return['WeaponDamage'] = & $this->getModifiedDamageAgainstPlayer($weaponPlayer, $targetPlayer); |
|
97 | + $return['ActualDamage'] = & $targetPlayer->getShip()->doWeaponDamage($return['WeaponDamage']); |
|
98 | 98 | |
99 | - if($return['ActualDamage']['KillingShot']) |
|
100 | - $return['KillResults'] =& $targetPlayer->killPlayerByPlayer($weaponPlayer); |
|
99 | + if ($return['ActualDamage']['KillingShot']) |
|
100 | + $return['KillResults'] = & $targetPlayer->killPlayerByPlayer($weaponPlayer); |
|
101 | 101 | return $return; |
102 | 102 | } |
103 | 103 | |
104 | 104 | protected function &doPlayerDamageToPort(array &$return, AbstractSmrPlayer $weaponPlayer, SmrPort $port) { |
105 | - $return['WeaponDamage'] =& $this->getModifiedDamageAgainstPort($weaponPlayer,$port); |
|
106 | - $return['ActualDamage'] =& $port->doWeaponDamage($return['WeaponDamage']); |
|
107 | - if($return['ActualDamage']['KillingShot']) |
|
108 | - $return['KillResults'] =& $port->killPortByPlayer($weaponPlayer); |
|
105 | + $return['WeaponDamage'] = & $this->getModifiedDamageAgainstPort($weaponPlayer, $port); |
|
106 | + $return['ActualDamage'] = & $port->doWeaponDamage($return['WeaponDamage']); |
|
107 | + if ($return['ActualDamage']['KillingShot']) |
|
108 | + $return['KillResults'] = & $port->killPortByPlayer($weaponPlayer); |
|
109 | 109 | return $return; |
110 | 110 | } |
111 | 111 | |
112 | 112 | protected function &doPlayerDamageToPlanet(array &$return, AbstractSmrPlayer $weaponPlayer, SmrPlanet $planet, $delayed) { |
113 | - $return['WeaponDamage'] =& $this->getModifiedDamageAgainstPlanet($weaponPlayer,$planet); |
|
114 | - $return['ActualDamage'] =& $planet->doWeaponDamage($return['WeaponDamage'],$delayed); |
|
115 | - if($return['ActualDamage']['KillingShot']) |
|
116 | - $return['KillResults'] =& $planet->killPlanetByPlayer($weaponPlayer); |
|
113 | + $return['WeaponDamage'] = & $this->getModifiedDamageAgainstPlanet($weaponPlayer, $planet); |
|
114 | + $return['ActualDamage'] = & $planet->doWeaponDamage($return['WeaponDamage'], $delayed); |
|
115 | + if ($return['ActualDamage']['KillingShot']) |
|
116 | + $return['KillResults'] = & $planet->killPlanetByPlayer($weaponPlayer); |
|
117 | 117 | return $return; |
118 | 118 | } |
119 | 119 | |
120 | 120 | protected function &doPortDamageToPlayer(array &$return, SmrPort $port, AbstractSmrPlayer $targetPlayer) { |
121 | - $return['WeaponDamage'] =& $this->getModifiedPortDamageAgainstPlayer($port,$targetPlayer); |
|
122 | - $return['ActualDamage'] =& $targetPlayer->getShip()->doWeaponDamage($return['WeaponDamage']); |
|
121 | + $return['WeaponDamage'] = & $this->getModifiedPortDamageAgainstPlayer($port, $targetPlayer); |
|
122 | + $return['ActualDamage'] = & $targetPlayer->getShip()->doWeaponDamage($return['WeaponDamage']); |
|
123 | 123 | |
124 | - if($return['ActualDamage']['KillingShot']) |
|
125 | - $return['KillResults'] =& $targetPlayer->killPlayerByPort($port); |
|
124 | + if ($return['ActualDamage']['KillingShot']) |
|
125 | + $return['KillResults'] = & $targetPlayer->killPlayerByPort($port); |
|
126 | 126 | return $return; |
127 | 127 | } |
128 | 128 | |
129 | 129 | protected function &doPlanetDamageToPlayer(array &$return, SmrPlanet $planet, AbstractSmrPlayer $targetPlayer) { |
130 | - $return['WeaponDamage'] =& $this->getModifiedPlanetDamageAgainstPlayer($planet,$targetPlayer); |
|
131 | - $return['ActualDamage'] =& $targetPlayer->getShip()->doWeaponDamage($return['WeaponDamage']); |
|
130 | + $return['WeaponDamage'] = & $this->getModifiedPlanetDamageAgainstPlayer($planet, $targetPlayer); |
|
131 | + $return['ActualDamage'] = & $targetPlayer->getShip()->doWeaponDamage($return['WeaponDamage']); |
|
132 | 132 | |
133 | - if($return['ActualDamage']['KillingShot']) |
|
134 | - $return['KillResults'] =& $targetPlayer->killPlayerByPlanet($planet); |
|
133 | + if ($return['ActualDamage']['KillingShot']) |
|
134 | + $return['KillResults'] = & $targetPlayer->killPlayerByPlanet($planet); |
|
135 | 135 | return $return; |
136 | 136 | } |
137 | 137 | |
138 | 138 | protected function &doForceDamageToPlayer(array &$return, SmrForce $forces, AbstractSmrPlayer $targetPlayer) { |
139 | - $return['WeaponDamage'] =& $this->getModifiedForceDamageAgainstPlayer($forces,$targetPlayer); |
|
140 | - $return['ActualDamage'] =& $targetPlayer->getShip()->doWeaponDamage($return['WeaponDamage']); |
|
139 | + $return['WeaponDamage'] = & $this->getModifiedForceDamageAgainstPlayer($forces, $targetPlayer); |
|
140 | + $return['ActualDamage'] = & $targetPlayer->getShip()->doWeaponDamage($return['WeaponDamage']); |
|
141 | 141 | |
142 | - if($return['ActualDamage']['KillingShot']) |
|
143 | - $return['KillResults'] =& $targetPlayer->killPlayerByForces($forces); |
|
142 | + if ($return['ActualDamage']['KillingShot']) |
|
143 | + $return['KillResults'] = & $targetPlayer->killPlayerByForces($forces); |
|
144 | 144 | return $return; |
145 | 145 | } |
146 | 146 |
@@ -115,13 +115,13 @@ discard block |
||
115 | 115 | ); |
116 | 116 | |
117 | 117 | function checkMissionRequirements(&$values, array &$mission, AbstractSmrPlayer &$player, array &$requirements = null) { |
118 | - if($requirements == null) { |
|
118 | + if ($requirements == null) { |
|
119 | 119 | return checkMissionRequirements($values, $mission, $player, $mission['Task']['Detail']); |
120 | 120 | } |
121 | - foreach($requirements as $reqName => $req) { |
|
122 | - if(is_string($req)) { |
|
121 | + foreach ($requirements as $reqName => $req) { |
|
122 | + if (is_string($req)) { |
|
123 | 123 | // Handle aliases |
124 | - switch($reqName) { |
|
124 | + switch ($reqName) { |
|
125 | 125 | case 'SectorID': |
126 | 126 | $reqName = 'Sector'; |
127 | 127 | $req = array( |
@@ -129,23 +129,23 @@ discard block |
||
129 | 129 | ); |
130 | 130 | break; |
131 | 131 | default: |
132 | - $req = str_replace(array('<Race>','<Sector>','<Starting Sector>','<trader>'),array($player->getRaceID(),$mission['Sector'],$mission['Starting Sector'],$player->getPlayerName()),$req); |
|
132 | + $req = str_replace(array('<Race>', '<Sector>', '<Starting Sector>', '<trader>'), array($player->getRaceID(), $mission['Sector'], $mission['Starting Sector'], $player->getPlayerName()), $req); |
|
133 | 133 | |
134 | 134 | } |
135 | 135 | } |
136 | - if(is_array($values)) { |
|
136 | + if (is_array($values)) { |
|
137 | 137 | $value = $values[$reqName]; |
138 | 138 | } |
139 | - else if(is_object($values)) { |
|
139 | + else if (is_object($values)) { |
|
140 | 140 | $value = $values->$reqName(); |
141 | 141 | } |
142 | - if(is_array($req)) { |
|
143 | - if(checkMissionRequirements($value, $mission, $player, $req) === false) { |
|
142 | + if (is_array($req)) { |
|
143 | + if (checkMissionRequirements($value, $mission, $player, $req) === false) { |
|
144 | 144 | return false; |
145 | 145 | } |
146 | 146 | } |
147 | 147 | else { |
148 | - if($value != $req) { |
|
148 | + if ($value != $req) { |
|
149 | 149 | return false; |
150 | 150 | } |
151 | 151 | } |
@@ -35,12 +35,12 @@ discard block |
||
35 | 35 | } |
36 | 36 | } |
37 | 37 | |
38 | - public static function &getGalaxySectors($gameID,$galaxyID,$forceUpdate = false) { |
|
39 | - if($forceUpdate || !isset(self::$CACHE_GALAXY_SECTORS[$gameID][$galaxyID])) { |
|
38 | + public static function &getGalaxySectors($gameID, $galaxyID, $forceUpdate = false) { |
|
39 | + if ($forceUpdate || !isset(self::$CACHE_GALAXY_SECTORS[$gameID][$galaxyID])) { |
|
40 | 40 | $db = new SmrMySqlDatabase(); |
41 | - $db->query('SELECT * FROM sector WHERE game_id = ' . $db->escapeNumber($gameID) .' AND galaxy_id=' . $db->escapeNumber($galaxyID) . ' ORDER BY sector_id ASC'); |
|
41 | + $db->query('SELECT * FROM sector WHERE game_id = ' . $db->escapeNumber($gameID) . ' AND galaxy_id=' . $db->escapeNumber($galaxyID) . ' ORDER BY sector_id ASC'); |
|
42 | 42 | $sectors = array(); |
43 | - while($db->nextRecord()) { |
|
43 | + while ($db->nextRecord()) { |
|
44 | 44 | $sectorID = $db->getInt('sector_id'); |
45 | 45 | $sectors[$sectorID] = self::getSector($gameID, $sectorID, $forceUpdate, $db); |
46 | 46 | } |
@@ -49,12 +49,12 @@ discard block |
||
49 | 49 | return self::$CACHE_GALAXY_SECTORS[$gameID][$galaxyID]; |
50 | 50 | } |
51 | 51 | |
52 | - public static function &getLocationSectors($gameID,$locationTypeID,$forceUpdate = false) { |
|
53 | - if($forceUpdate || !isset(self::$CACHE_LOCATION_SECTORS[$gameID][$locationTypeID])) { |
|
52 | + public static function &getLocationSectors($gameID, $locationTypeID, $forceUpdate = false) { |
|
53 | + if ($forceUpdate || !isset(self::$CACHE_LOCATION_SECTORS[$gameID][$locationTypeID])) { |
|
54 | 54 | $db = new SmrMySqlDatabase(); |
55 | 55 | $db->query('SELECT * FROM location JOIN sector USING (game_id, sector_id) WHERE location_type_id = ' . $db->escapeNumber($locationTypeID) . ' AND game_id=' . $db->escapeNumber($gameID) . ' ORDER BY sector_id ASC'); |
56 | 56 | $sectors = array(); |
57 | - while($db->nextRecord()) { |
|
57 | + while ($db->nextRecord()) { |
|
58 | 58 | $sectorID = $db->getInt('sector_id'); |
59 | 59 | $sectors[$sectorID] = self::getSector($gameID, $sectorID, $forceUpdate, $db); |
60 | 60 | } |
@@ -63,8 +63,8 @@ discard block |
||
63 | 63 | return self::$CACHE_LOCATION_SECTORS[$gameID][$locationTypeID]; |
64 | 64 | } |
65 | 65 | |
66 | - public static function &getSector($gameID, $sectorID, $forceUpdate=false, $db=null) { |
|
67 | - if(!isset(self::$CACHE_SECTORS[$gameID][$sectorID]) || $forceUpdate) { |
|
66 | + public static function &getSector($gameID, $sectorID, $forceUpdate = false, $db = null) { |
|
67 | + if (!isset(self::$CACHE_SECTORS[$gameID][$sectorID]) || $forceUpdate) { |
|
68 | 68 | self::$CACHE_SECTORS[$gameID][$sectorID] = new SmrSector($gameID, $sectorID, false, $db); |
69 | 69 | } |
70 | 70 | return self::$CACHE_SECTORS[$gameID][$sectorID]; |
@@ -77,22 +77,22 @@ discard block |
||
77 | 77 | } |
78 | 78 | |
79 | 79 | public static function saveSectors() { |
80 | - foreach(self::$CACHE_SECTORS as $gameSectors) { |
|
81 | - foreach($gameSectors as $sector) { |
|
80 | + foreach (self::$CACHE_SECTORS as $gameSectors) { |
|
81 | + foreach ($gameSectors as $sector) { |
|
82 | 82 | $sector->update(); |
83 | 83 | } |
84 | 84 | } |
85 | 85 | } |
86 | 86 | |
87 | - public static function &createSector($gameID,$sectorID) { |
|
88 | - if(!isset(self::$CACHE_SECTORS[$gameID][$sectorID])) { |
|
89 | - $s = new SmrSector($gameID,$sectorID,true); |
|
87 | + public static function &createSector($gameID, $sectorID) { |
|
88 | + if (!isset(self::$CACHE_SECTORS[$gameID][$sectorID])) { |
|
89 | + $s = new SmrSector($gameID, $sectorID, true); |
|
90 | 90 | self::$CACHE_SECTORS[$gameID][$sectorID] = $s; |
91 | 91 | } |
92 | 92 | return self::$CACHE_SECTORS[$gameID][$sectorID]; |
93 | 93 | } |
94 | 94 | |
95 | - protected function __construct($gameID, $sectorID, $create=false, $db=null) { |
|
95 | + protected function __construct($gameID, $sectorID, $create = false, $db = null) { |
|
96 | 96 | $this->db = new SmrMySqlDatabase(); |
97 | 97 | $this->SQL = 'game_id = ' . $this->db->escapeNumber($gameID) . ' AND sector_id = ' . $this->db->escapeNumber($sectorID); |
98 | 98 | |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | $sectorExists = $db->nextRecord(); |
106 | 106 | } |
107 | 107 | |
108 | - $this->gameID = (int) $gameID; |
|
109 | - $this->sectorID = (int) $sectorID; |
|
108 | + $this->gameID = (int)$gameID; |
|
109 | + $this->sectorID = (int)$sectorID; |
|
110 | 110 | |
111 | 111 | if ($sectorExists) { |
112 | 112 | $this->galaxyID = $db->getInt('galaxy_id'); |
@@ -127,21 +127,21 @@ discard block |
||
127 | 127 | } |
128 | 128 | $this->warp = $db->getInt('warp'); |
129 | 129 | } |
130 | - else if($create) { |
|
131 | - $this->battles = 0; |
|
130 | + else if ($create) { |
|
131 | + $this->battles = 0; |
|
132 | 132 | $this->links = array(); |
133 | 133 | $this->warp = 0; |
134 | - $this->isNew = true; |
|
134 | + $this->isNew = true; |
|
135 | 135 | return; |
136 | 136 | } |
137 | 137 | else { |
138 | - throw new SectorNotFoundException('No such sector: '.$gameID.'-'.$sectorID); |
|
138 | + throw new SectorNotFoundException('No such sector: ' . $gameID . '-' . $sectorID); |
|
139 | 139 | } |
140 | 140 | } |
141 | 141 | |
142 | 142 | function update() { |
143 | - if($this->hasChanged) { |
|
144 | - if($this->isNew===false) { |
|
143 | + if ($this->hasChanged) { |
|
144 | + if ($this->isNew === false) { |
|
145 | 145 | $this->db->query('UPDATE sector SET battles = ' . $this->db->escapeNumber($this->getBattles()) . |
146 | 146 | ', galaxy_id=' . $this->db->escapeNumber($this->getGalaxyID()) . |
147 | 147 | ', link_up=' . $this->db->escapeNumber($this->getLinkUp()) . |
@@ -163,26 +163,26 @@ discard block |
||
163 | 163 | ',' . $this->db->escapeNumber($this->getLinkRight()) . |
164 | 164 | ',' . $this->db->escapeNumber($this->getWarp()) . |
165 | 165 | ')'); |
166 | - $this->isNew=false; |
|
166 | + $this->isNew = false; |
|
167 | 167 | } |
168 | 168 | } |
169 | 169 | } |
170 | 170 | |
171 | 171 | function markVisited(AbstractSmrPlayer $player) { |
172 | - if($this->hasPort()) |
|
172 | + if ($this->hasPort()) |
|
173 | 173 | $this->getPort()->addCachePort($player->getAccountID()); |
174 | 174 | |
175 | 175 | //now delete the entry from visited |
176 | - if(!$this->isVisited($player)) |
|
176 | + if (!$this->isVisited($player)) |
|
177 | 177 | $this->db->query('DELETE FROM player_visited_sector WHERE ' . $this->SQL . ' |
178 | 178 | AND account_id = ' . $this->db->escapeNumber($player->getAccountID()) . ' LIMIT 1'); |
179 | - $this->visited[$player->getAccountID()]=true; |
|
179 | + $this->visited[$player->getAccountID()] = true; |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | function hasWeaponShop() { |
183 | 183 | $locations = $this->getLocations(); |
184 | - foreach($locations as $location) { |
|
185 | - if($location->isWeaponSold()) |
|
184 | + foreach ($locations as $location) { |
|
185 | + if ($location->isWeaponSold()) |
|
186 | 186 | return true; |
187 | 187 | } |
188 | 188 | return false; |
@@ -190,8 +190,8 @@ discard block |
||
190 | 190 | |
191 | 191 | function hasHQ() { |
192 | 192 | $locations = $this->getLocations(); |
193 | - foreach($locations as $location) { |
|
194 | - if($location->isHQ()) |
|
193 | + foreach ($locations as $location) { |
|
194 | + if ($location->isHQ()) |
|
195 | 195 | return true; |
196 | 196 | } |
197 | 197 | return false; |
@@ -199,8 +199,8 @@ discard block |
||
199 | 199 | |
200 | 200 | function hasUG() { |
201 | 201 | $locations = $this->getLocations(); |
202 | - foreach($locations as $location) { |
|
203 | - if($location->isUG()) |
|
202 | + foreach ($locations as $location) { |
|
203 | + if ($location->isUG()) |
|
204 | 204 | return true; |
205 | 205 | } |
206 | 206 | return false; |
@@ -208,8 +208,8 @@ discard block |
||
208 | 208 | |
209 | 209 | function hasShipShop() { |
210 | 210 | $locations = $this->getLocations(); |
211 | - foreach($locations as $location) { |
|
212 | - if($location->isShipSold()) |
|
211 | + foreach ($locations as $location) { |
|
212 | + if ($location->isShipSold()) |
|
213 | 213 | return true; |
214 | 214 | } |
215 | 215 | return false; |
@@ -217,8 +217,8 @@ discard block |
||
217 | 217 | |
218 | 218 | function offersFederalProtection() { |
219 | 219 | $locations = $this->getLocations(); |
220 | - foreach($locations as $location) { |
|
221 | - if($location->isFed()) |
|
220 | + foreach ($locations as $location) { |
|
221 | + if ($location->isFed()) |
|
222 | 222 | return true; |
223 | 223 | } |
224 | 224 | return false; |
@@ -227,8 +227,8 @@ discard block |
||
227 | 227 | public function getFedRaceIDs() { |
228 | 228 | $raceIDs = array(); |
229 | 229 | $locations = $this->getLocations(); |
230 | - foreach($locations as $location) { |
|
231 | - if($location->isFed()) |
|
230 | + foreach ($locations as $location) { |
|
231 | + if ($location->isFed()) |
|
232 | 232 | $raceIDs[$location->getRaceID()] = $location->getRaceID(); |
233 | 233 | } |
234 | 234 | return $raceIDs; |
@@ -236,8 +236,8 @@ discard block |
||
236 | 236 | |
237 | 237 | function hasBar() { |
238 | 238 | $locations = $this->getLocations(); |
239 | - foreach($locations as $location) { |
|
240 | - if($location->isBar()) |
|
239 | + foreach ($locations as $location) { |
|
240 | + if ($location->isBar()) |
|
241 | 241 | return true; |
242 | 242 | } |
243 | 243 | return false; |
@@ -245,8 +245,8 @@ discard block |
||
245 | 245 | |
246 | 246 | function hasHardwareShop() { |
247 | 247 | $locations = $this->getLocations(); |
248 | - foreach($locations as $location) { |
|
249 | - if($location->isHardwareSold()) |
|
248 | + foreach ($locations as $location) { |
|
249 | + if ($location->isHardwareSold()) |
|
250 | 250 | return true; |
251 | 251 | } |
252 | 252 | return false; |
@@ -254,8 +254,8 @@ discard block |
||
254 | 254 | |
255 | 255 | function hasBank() { |
256 | 256 | $locations = $this->getLocations(); |
257 | - foreach($locations as $location) { |
|
258 | - if($location->isBank()) |
|
257 | + foreach ($locations as $location) { |
|
258 | + if ($location->isBank()) |
|
259 | 259 | return true; |
260 | 260 | } |
261 | 261 | return false; |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | function enteringSector(AbstractSmrPlayer $player, $movementType) { |
265 | 265 | // send scout messages to user |
266 | 266 | $message = 'Your forces have spotted ' . $player->getBBLink() . ' '; |
267 | - switch($movementType) { |
|
267 | + switch ($movementType) { |
|
268 | 268 | case MOVEMENT_JUMP: |
269 | 269 | $message .= 'jumping into'; |
270 | 270 | break; |
@@ -278,15 +278,15 @@ discard block |
||
278 | 278 | $message .= ' sector ' . Globals::getSectorBBLink($this->getSectorID()); |
279 | 279 | |
280 | 280 | $forces = $this->getForces(); |
281 | - foreach($forces as $force) { |
|
282 | - $force->ping($message,$player); |
|
281 | + foreach ($forces as $force) { |
|
282 | + $force->ping($message, $player); |
|
283 | 283 | } |
284 | 284 | } |
285 | 285 | |
286 | 286 | function leavingSector(AbstractSmrPlayer $player, $movementType) { |
287 | 287 | // send scout messages to user |
288 | 288 | $message = 'Your forces have spotted ' . $player->getBBLink() . ' '; |
289 | - switch($movementType) { |
|
289 | + switch ($movementType) { |
|
290 | 290 | case MOVEMENT_JUMP: |
291 | 291 | $message .= 'jumping from'; |
292 | 292 | break; |
@@ -301,8 +301,8 @@ discard block |
||
301 | 301 | |
302 | 302 | // iterate over all scout drones in sector |
303 | 303 | $forces = $this->getForces(); |
304 | - foreach($forces as $force) { |
|
305 | - $force->ping($message,$player); |
|
304 | + foreach ($forces as $force) { |
|
305 | + $force->ping($message, $player); |
|
306 | 306 | } |
307 | 307 | $this->db->query('UPDATE sector_has_forces SET refresher = 0 WHERE ' . $this->SQL . ' |
308 | 308 | AND refresher = ' . $this->db->escapeNumber($player->getAccountID())); |
@@ -311,10 +311,10 @@ discard block |
||
311 | 311 | function diedHere(AbstractSmrPlayer $player) { |
312 | 312 | // iterate over all scout drones in sector |
313 | 313 | $forces = $this->getForces(); |
314 | - foreach($forces as $force) { |
|
314 | + foreach ($forces as $force) { |
|
315 | 315 | // send scout messages to user |
316 | 316 | $message = 'Your forces have spotted that ' . $player->getBBLink() . ' has been <span class="red">DESTROYED</span> in sector ' . Globals::getSectorBBLink($this->sectorID); |
317 | - $force->ping($message,$player); |
|
317 | + $force->ping($message, $player); |
|
318 | 318 | } |
319 | 319 | } |
320 | 320 | |
@@ -331,10 +331,10 @@ discard block |
||
331 | 331 | } |
332 | 332 | |
333 | 333 | public function setGalaxyID($galaxyID) { |
334 | - if($this->galaxyID==$galaxyID) |
|
334 | + if ($this->galaxyID == $galaxyID) |
|
335 | 335 | return; |
336 | - $this->galaxyID=$galaxyID; |
|
337 | - $this->hasChanged=true; |
|
336 | + $this->galaxyID = $galaxyID; |
|
337 | + $this->hasChanged = true; |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | public function getGalaxyName() { |
@@ -342,71 +342,71 @@ discard block |
||
342 | 342 | } |
343 | 343 | |
344 | 344 | public function getNumberOfLinks() { |
345 | - $num=0; |
|
346 | - if(!is_array($this->getLinks())) |
|
345 | + $num = 0; |
|
346 | + if (!is_array($this->getLinks())) |
|
347 | 347 | return $num; |
348 | - foreach($this->getLinks() as $link) |
|
349 | - if($link!==0) |
|
348 | + foreach ($this->getLinks() as $link) |
|
349 | + if ($link !== 0) |
|
350 | 350 | $num++; |
351 | 351 | return $num; |
352 | 352 | } |
353 | 353 | |
354 | 354 | public function getNumberOfConnections() { |
355 | 355 | $links = $this->getNumberOfLinks(); |
356 | - if($this->hasWarp()) |
|
356 | + if ($this->hasWarp()) |
|
357 | 357 | $links++; |
358 | 358 | return $links; |
359 | 359 | } |
360 | 360 | |
361 | 361 | public function &getGalaxy() { |
362 | - return SmrGalaxy::getGalaxy($this->getGameID(),$this->getGalaxyID()); |
|
362 | + return SmrGalaxy::getGalaxy($this->getGameID(), $this->getGalaxyID()); |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | public function getNeighbourID($dir) { |
366 | - if($this->hasLink($dir)) |
|
366 | + if ($this->hasLink($dir)) |
|
367 | 367 | return $this->getLink($dir); |
368 | 368 | $galaxy = $this->getGalaxy(); |
369 | 369 | $neighbour = $this->getSectorID(); |
370 | - switch($dir) { |
|
370 | + switch ($dir) { |
|
371 | 371 | case 'Up': |
372 | 372 | $neighbour -= $galaxy->getWidth(); |
373 | - if($neighbour<$galaxy->getStartSector()) |
|
374 | - $neighbour+=$galaxy->getSize(); |
|
373 | + if ($neighbour < $galaxy->getStartSector()) |
|
374 | + $neighbour += $galaxy->getSize(); |
|
375 | 375 | break; |
376 | 376 | case 'Down': |
377 | 377 | $neighbour += $galaxy->getWidth(); |
378 | - if($neighbour>$galaxy->getEndSector()) |
|
379 | - $neighbour-=$galaxy->getSize(); |
|
378 | + if ($neighbour > $galaxy->getEndSector()) |
|
379 | + $neighbour -= $galaxy->getSize(); |
|
380 | 380 | break; |
381 | 381 | case 'Left': |
382 | 382 | $neighbour -= 1; |
383 | - if((1+$neighbour-$galaxy->getStartSector())%$galaxy->getWidth()==0) |
|
384 | - $neighbour+=$galaxy->getWidth(); |
|
383 | + if ((1 + $neighbour - $galaxy->getStartSector()) % $galaxy->getWidth() == 0) |
|
384 | + $neighbour += $galaxy->getWidth(); |
|
385 | 385 | break; |
386 | 386 | case 'Right': |
387 | 387 | $neighbour += 1; |
388 | - if(($neighbour-$galaxy->getStartSector())%$galaxy->getWidth()==0) |
|
389 | - $neighbour-=$galaxy->getWidth(); |
|
388 | + if (($neighbour - $galaxy->getStartSector()) % $galaxy->getWidth() == 0) |
|
389 | + $neighbour -= $galaxy->getWidth(); |
|
390 | 390 | break; |
391 | 391 | default: |
392 | - throw new Exception($dir.': is not a valid direction'); |
|
392 | + throw new Exception($dir . ': is not a valid direction'); |
|
393 | 393 | } |
394 | 394 | return $neighbour; |
395 | 395 | } |
396 | 396 | |
397 | 397 | public function getSectorDirection($sectorID) { |
398 | - if($sectorID == $this->getSectorID()) |
|
398 | + if ($sectorID == $this->getSectorID()) |
|
399 | 399 | return 'Current'; |
400 | 400 | $dir = array_search($sectorID, $this->getLinks()); |
401 | - if($dir !== false) |
|
401 | + if ($dir !== false) |
|
402 | 402 | return $dir; |
403 | - if($sectorID == $this->getWarp()) |
|
403 | + if ($sectorID == $this->getWarp()) |
|
404 | 404 | return 'Warp'; |
405 | 405 | return 'None'; |
406 | 406 | } |
407 | 407 | |
408 | 408 | public function &getNeighbourSector($dir) { |
409 | - return SmrSector::getSector($this->getGameID(),$this->getNeighbourID($dir)); |
|
409 | + return SmrSector::getSector($this->getGameID(), $this->getNeighbourID($dir)); |
|
410 | 410 | } |
411 | 411 | |
412 | 412 | public function getLinks() { |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | } |
415 | 415 | |
416 | 416 | public function isLinked($sectorID) { |
417 | - return in_array($sectorID,$this->links)||$sectorID==$this->getWarp(); |
|
417 | + return in_array($sectorID, $this->links) || $sectorID == $this->getWarp(); |
|
418 | 418 | } |
419 | 419 | |
420 | 420 | public function getLink($name) { |
@@ -422,56 +422,56 @@ discard block |
||
422 | 422 | } |
423 | 423 | |
424 | 424 | public function hasLink($name) { |
425 | - return $this->getLink($name)!=0; |
|
425 | + return $this->getLink($name) != 0; |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | public function &getLinkSector($name) { |
429 | - if($this->hasLink($name)) |
|
430 | - return SmrSector::getSector($this->getGameID(),$this->getLink($name)); |
|
429 | + if ($this->hasLink($name)) |
|
430 | + return SmrSector::getSector($this->getGameID(), $this->getLink($name)); |
|
431 | 431 | return false; |
432 | 432 | } |
433 | 433 | |
434 | 434 | /** |
435 | 435 | * Cannot be used for Warps |
436 | 436 | */ |
437 | - public function setLink($name,$linkID) { |
|
438 | - if($this->getLink($name)==$linkID) |
|
437 | + public function setLink($name, $linkID) { |
|
438 | + if ($this->getLink($name) == $linkID) |
|
439 | 439 | return; |
440 | - if($linkID==0) |
|
440 | + if ($linkID == 0) |
|
441 | 441 | unset($this->links[$name]); |
442 | 442 | else |
443 | 443 | $this->links[$name] = $linkID; |
444 | - $this->hasChanged=true; |
|
444 | + $this->hasChanged = true; |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | /** |
448 | 448 | * Cannot be used for Warps |
449 | 449 | */ |
450 | - public function setLinkSector($dir,SmrSector $linkSector) { |
|
451 | - if($this->getLink($dir)==$linkSector->getSectorID()||$linkSector->equals($this)) |
|
450 | + public function setLinkSector($dir, SmrSector $linkSector) { |
|
451 | + if ($this->getLink($dir) == $linkSector->getSectorID() || $linkSector->equals($this)) |
|
452 | 452 | return; |
453 | - $this->setLink($dir,$linkSector->getSectorID()); |
|
454 | - $linkSector->setLink(self::oppositeDir($dir),$this->getSectorID()); |
|
455 | - $this->hasChanged=true; |
|
453 | + $this->setLink($dir, $linkSector->getSectorID()); |
|
454 | + $linkSector->setLink(self::oppositeDir($dir), $this->getSectorID()); |
|
455 | + $this->hasChanged = true; |
|
456 | 456 | } |
457 | 457 | /** |
458 | 458 | * Cannot be used for Warps |
459 | 459 | */ |
460 | 460 | public function enableLink($dir) { |
461 | - $this->setLinkSector($dir,$this->getNeighbourSector($dir)); |
|
461 | + $this->setLinkSector($dir, $this->getNeighbourSector($dir)); |
|
462 | 462 | } |
463 | 463 | /** |
464 | 464 | * Cannot be used for Warps |
465 | 465 | */ |
466 | 466 | public function disableLink($dir) { |
467 | - $this->setLink($dir,0); |
|
468 | - $this->getNeighbourSector($dir)->setLink(self::oppositeDir($dir),0); |
|
467 | + $this->setLink($dir, 0); |
|
468 | + $this->getNeighbourSector($dir)->setLink(self::oppositeDir($dir), 0); |
|
469 | 469 | } |
470 | 470 | /** |
471 | 471 | * Cannot be used for Warps |
472 | 472 | */ |
473 | 473 | public function toggleLink($dir) { |
474 | - if($this->hasLink($dir)) { |
|
474 | + if ($this->hasLink($dir)) { |
|
475 | 475 | $this->disableLink($dir); |
476 | 476 | } |
477 | 477 | else { |
@@ -480,7 +480,7 @@ discard block |
||
480 | 480 | } |
481 | 481 | |
482 | 482 | protected static function oppositeDir($dir) { |
483 | - switch($dir) { |
|
483 | + switch ($dir) { |
|
484 | 484 | case 'Up': return 'Down'; |
485 | 485 | case 'Down': return 'Up'; |
486 | 486 | case 'Left': return 'Right'; |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | } |
495 | 495 | |
496 | 496 | public function setLinkUp($linkID) { |
497 | - $this->setLink('Up',$linkID); |
|
497 | + $this->setLink('Up', $linkID); |
|
498 | 498 | } |
499 | 499 | |
500 | 500 | public function hasLinkUp() { |
@@ -506,7 +506,7 @@ discard block |
||
506 | 506 | } |
507 | 507 | |
508 | 508 | public function setLinkDown($linkID) { |
509 | - $this->setLink('Down',$linkID); |
|
509 | + $this->setLink('Down', $linkID); |
|
510 | 510 | } |
511 | 511 | |
512 | 512 | public function hasLinkDown() { |
@@ -522,7 +522,7 @@ discard block |
||
522 | 522 | } |
523 | 523 | |
524 | 524 | public function setLinkLeft($linkID) { |
525 | - $this->setLink('Left',$linkID); |
|
525 | + $this->setLink('Left', $linkID); |
|
526 | 526 | } |
527 | 527 | |
528 | 528 | public function getLinkRight() { |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | } |
535 | 535 | |
536 | 536 | public function setLinkRight($linkID) { |
537 | - $this->setLink('Right',$linkID); |
|
537 | + $this->setLink('Right', $linkID); |
|
538 | 538 | } |
539 | 539 | |
540 | 540 | /** |
@@ -545,11 +545,11 @@ discard block |
||
545 | 545 | } |
546 | 546 | |
547 | 547 | public function &getWarpSector() { |
548 | - return SmrSector::getSector($this->getGameID(),$this->getWarp()); |
|
548 | + return SmrSector::getSector($this->getGameID(), $this->getWarp()); |
|
549 | 549 | } |
550 | 550 | |
551 | 551 | public function hasWarp() { |
552 | - return $this->getWarp()!=0; |
|
552 | + return $this->getWarp() != 0; |
|
553 | 553 | } |
554 | 554 | |
555 | 555 | /** |
@@ -607,65 +607,65 @@ discard block |
||
607 | 607 | } |
608 | 608 | |
609 | 609 | public function &getPort() { |
610 | - return SmrPort::getPort($this->getGameID(),$this->getSectorID()); |
|
610 | + return SmrPort::getPort($this->getGameID(), $this->getSectorID()); |
|
611 | 611 | } |
612 | 612 | |
613 | 613 | public function &createPort() { |
614 | - return SmrPort::createPort($this->getGameID(),$this->getSectorID()); |
|
614 | + return SmrPort::createPort($this->getGameID(), $this->getSectorID()); |
|
615 | 615 | } |
616 | 616 | |
617 | 617 | public function removePort() { |
618 | - SmrPort::removePort($this->getGameID(),$this->getSectorID()); |
|
618 | + SmrPort::removePort($this->getGameID(), $this->getSectorID()); |
|
619 | 619 | } |
620 | 620 | |
621 | - public function hasCachedPort(AbstractSmrPlayer $player=null) { |
|
622 | - return $this->getCachedPort($player)!==false; |
|
621 | + public function hasCachedPort(AbstractSmrPlayer $player = null) { |
|
622 | + return $this->getCachedPort($player) !== false; |
|
623 | 623 | } |
624 | 624 | |
625 | - public function &getCachedPort(AbstractSmrPlayer $player=null) { |
|
626 | - if($player == null) { |
|
625 | + public function &getCachedPort(AbstractSmrPlayer $player = null) { |
|
626 | + if ($player == null) { |
|
627 | 627 | $return = false; |
628 | 628 | return $return; |
629 | 629 | } |
630 | - return SmrPort::getCachedPort($this->getGameID(),$this->getSectorID(),$player->getAccountID()); |
|
630 | + return SmrPort::getCachedPort($this->getGameID(), $this->getSectorID(), $player->getAccountID()); |
|
631 | 631 | } |
632 | 632 | |
633 | 633 | public function hasAnyLocationsWithAction() { |
634 | - $locations = SmrLocation::getSectorLocations($this->getGameID(),$this->getSectorID()); |
|
634 | + $locations = SmrLocation::getSectorLocations($this->getGameID(), $this->getSectorID()); |
|
635 | 635 | $hasAction = false; |
636 | - foreach($locations as $location) { |
|
637 | - if($location->hasAction()) |
|
636 | + foreach ($locations as $location) { |
|
637 | + if ($location->hasAction()) |
|
638 | 638 | $hasAction = true; |
639 | 639 | } |
640 | 640 | return $hasAction; |
641 | 641 | } |
642 | 642 | |
643 | - public function hasLocation($locationTypeID=false) { |
|
643 | + public function hasLocation($locationTypeID = false) { |
|
644 | 644 | $locations = $this->getLocations(); |
645 | - if(count($locations) == 0) |
|
645 | + if (count($locations) == 0) |
|
646 | 646 | return false; |
647 | - if($locationTypeID==false) |
|
647 | + if ($locationTypeID == false) |
|
648 | 648 | return true; |
649 | - foreach($locations as $location) { |
|
650 | - if($location->getTypeID()==$locationTypeID) |
|
649 | + foreach ($locations as $location) { |
|
650 | + if ($location->getTypeID() == $locationTypeID) |
|
651 | 651 | return true; |
652 | 652 | } |
653 | 653 | return false; |
654 | 654 | } |
655 | 655 | |
656 | 656 | public function &getLocations() { |
657 | - return SmrLocation::getSectorLocations($this->getGameID(),$this->getSectorID()); |
|
657 | + return SmrLocation::getSectorLocations($this->getGameID(), $this->getSectorID()); |
|
658 | 658 | } |
659 | 659 | |
660 | 660 | public function addLocation(SmrLocation $location) { |
661 | 661 | $this->db->query('INSERT INTO location (game_id,sector_id,location_type_id) |
662 | 662 | values(' . $this->db->escapeNumber($this->getGameID()) . ',' . $this->db->escapeNumber($this->getSectorID()) . ',' . $this->db->escapeNumber($location->getTypeID()) . ')'); |
663 | - SmrLocation::getSectorLocations($this->getGameID(),$this->getSectorID(),true); |
|
663 | + SmrLocation::getSectorLocations($this->getGameID(), $this->getSectorID(), true); |
|
664 | 664 | } |
665 | 665 | |
666 | 666 | public function removeAllLocations() { |
667 | 667 | $this->db->query('DELETE FROM location WHERE ' . $this->SQL); |
668 | - SmrLocation::getSectorLocations($this->getGameID(),$this->getSectorID(),true); |
|
668 | + SmrLocation::getSectorLocations($this->getGameID(), $this->getSectorID(), true); |
|
669 | 669 | } |
670 | 670 | |
671 | 671 | public function hasPlanet() { |
@@ -673,27 +673,27 @@ discard block |
||
673 | 673 | } |
674 | 674 | |
675 | 675 | public function &getPlanet() { |
676 | - return SmrPlanet::getPlanet($this->getGameID(),$this->getSectorID()); |
|
676 | + return SmrPlanet::getPlanet($this->getGameID(), $this->getSectorID()); |
|
677 | 677 | } |
678 | 678 | |
679 | - public function &createPlanet($type=1) { |
|
680 | - return SmrPlanet::createPlanet($this->getGameID(),$this->getSectorID(), $type); |
|
679 | + public function &createPlanet($type = 1) { |
|
680 | + return SmrPlanet::createPlanet($this->getGameID(), $this->getSectorID(), $type); |
|
681 | 681 | } |
682 | 682 | |
683 | 683 | public function removePlanet() { |
684 | - SmrPlanet::removePlanet($this->getGameID(),$this->getSectorID()); |
|
684 | + SmrPlanet::removePlanet($this->getGameID(), $this->getSectorID()); |
|
685 | 685 | } |
686 | 686 | |
687 | 687 | public function hasForces() { |
688 | 688 | return count($this->getForces()) > 0; |
689 | 689 | } |
690 | 690 | |
691 | - public function hasEnemyForces(AbstractSmrPlayer $player=null) { |
|
692 | - if($player == null || !$this->hasForces()) |
|
691 | + public function hasEnemyForces(AbstractSmrPlayer $player = null) { |
|
692 | + if ($player == null || !$this->hasForces()) |
|
693 | 693 | return false; |
694 | 694 | $forces = $this->getForces(); |
695 | - foreach($forces as $force) { |
|
696 | - if(!$player->forceNAPAlliance($force->getOwner())) |
|
695 | + foreach ($forces as $force) { |
|
696 | + if (!$player->forceNAPAlliance($force->getOwner())) |
|
697 | 697 | return true; |
698 | 698 | } |
699 | 699 | return false; |
@@ -701,11 +701,11 @@ discard block |
||
701 | 701 | |
702 | 702 | public function &getEnemyForces(AbstractSmrPlayer $player) { |
703 | 703 | $enemyForces = array(); |
704 | - if(!$this->hasForces()) |
|
704 | + if (!$this->hasForces()) |
|
705 | 705 | return $enemyForces; |
706 | 706 | $forces = $this->getForces(); |
707 | - foreach($forces as $force) { |
|
708 | - if(!$player->forceNAPAlliance($force->getOwner())) |
|
707 | + foreach ($forces as $force) { |
|
708 | + if (!$player->forceNAPAlliance($force->getOwner())) |
|
709 | 709 | $enemyForces[] = $force; |
710 | 710 | } |
711 | 711 | return $enemyForces; |
@@ -723,12 +723,12 @@ discard block |
||
723 | 723 | return false; |
724 | 724 | } |
725 | 725 | |
726 | - public function hasFriendlyForces(AbstractSmrPlayer $player=null) { |
|
727 | - if($player == null || !$this->hasForces()) |
|
726 | + public function hasFriendlyForces(AbstractSmrPlayer $player = null) { |
|
727 | + if ($player == null || !$this->hasForces()) |
|
728 | 728 | return false; |
729 | 729 | $forces = $this->getForces(); |
730 | - foreach($forces as $force) { |
|
731 | - if($player->forceNAPAlliance($force->getOwner())) |
|
730 | + foreach ($forces as $force) { |
|
731 | + if ($player->forceNAPAlliance($force->getOwner())) |
|
732 | 732 | return true; |
733 | 733 | } |
734 | 734 | return false; |
@@ -736,22 +736,22 @@ discard block |
||
736 | 736 | |
737 | 737 | public function &getFriendlyForces(AbstractSmrPlayer $player) { |
738 | 738 | $friendlyForces = array(); |
739 | - if(!$this->hasForces()) |
|
739 | + if (!$this->hasForces()) |
|
740 | 740 | return $friendlyForces; |
741 | 741 | $forces = $this->getForces(); |
742 | - foreach($forces as $force) { |
|
743 | - if($player->forceNAPAlliance($force->getOwner())) |
|
742 | + foreach ($forces as $force) { |
|
743 | + if ($player->forceNAPAlliance($force->getOwner())) |
|
744 | 744 | $friendlyForces[] = $force; |
745 | 745 | } |
746 | 746 | return $friendlyForces; |
747 | 747 | } |
748 | 748 | |
749 | 749 | public function &getForces() { |
750 | - return SmrForce::getSectorForces($this->getGameID(),$this->getSectorID()); |
|
750 | + return SmrForce::getSectorForces($this->getGameID(), $this->getSectorID()); |
|
751 | 751 | } |
752 | 752 | |
753 | 753 | public function &getPlayers() { |
754 | - return SmrPlayer::getSectorPlayers($this->getGameID(),$this->getSectorID()); |
|
754 | + return SmrPlayer::getSectorPlayers($this->getGameID(), $this->getSectorID()); |
|
755 | 755 | } |
756 | 756 | |
757 | 757 | public function hasPlayers() { |
@@ -759,7 +759,7 @@ discard block |
||
759 | 759 | } |
760 | 760 | |
761 | 761 | public function &getOtherTraders(AbstractSmrPlayer $player) { |
762 | - $players = SmrPlayer::getSectorPlayers($this->getGameID(),$this->getSectorID()); //Do not use & because we unset something and only want that in what we return |
|
762 | + $players = SmrPlayer::getSectorPlayers($this->getGameID(), $this->getSectorID()); //Do not use & because we unset something and only want that in what we return |
|
763 | 763 | unset($players[$player->getAccountID()]); |
764 | 764 | return $players; |
765 | 765 | } |
@@ -768,12 +768,12 @@ discard block |
||
768 | 768 | return count($this->getOtherTraders($player)) > 0; |
769 | 769 | } |
770 | 770 | |
771 | - public function hasEnemyTraders(AbstractSmrPlayer $player=null) { |
|
772 | - if($player == null || !$this->hasOtherTraders($player)) |
|
771 | + public function hasEnemyTraders(AbstractSmrPlayer $player = null) { |
|
772 | + if ($player == null || !$this->hasOtherTraders($player)) |
|
773 | 773 | return false; |
774 | 774 | $otherPlayers = $this->getOtherTraders($player); |
775 | - foreach($otherPlayers as $otherPlayer) { |
|
776 | - if(!$player->traderNAPAlliance($otherPlayer) |
|
775 | + foreach ($otherPlayers as $otherPlayer) { |
|
776 | + if (!$player->traderNAPAlliance($otherPlayer) |
|
777 | 777 | && !$otherPlayer->hasNewbieTurns() |
778 | 778 | && !$otherPlayer->hasFederalProtection()) { |
779 | 779 | return true; |
@@ -782,12 +782,12 @@ discard block |
||
782 | 782 | return false; |
783 | 783 | } |
784 | 784 | |
785 | - public function hasFriendlyTraders(AbstractSmrPlayer $player=null) { |
|
786 | - if($player == null || !$this->hasOtherTraders($player)) |
|
785 | + public function hasFriendlyTraders(AbstractSmrPlayer $player = null) { |
|
786 | + if ($player == null || !$this->hasOtherTraders($player)) |
|
787 | 787 | return false; |
788 | 788 | $otherPlayers = $this->getOtherTraders($player); |
789 | - foreach($otherPlayers as $otherPlayer) { |
|
790 | - if($player->traderNAPAlliance($otherPlayer)) |
|
789 | + foreach ($otherPlayers as $otherPlayer) { |
|
790 | + if ($player->traderNAPAlliance($otherPlayer)) |
|
791 | 791 | return true; |
792 | 792 | } |
793 | 793 | return false; |
@@ -796,7 +796,7 @@ discard block |
||
796 | 796 | /** |
797 | 797 | * Is the $player's alliance flagship in this sector? |
798 | 798 | */ |
799 | - public function hasAllianceFlagship(AbstractSmrPlayer $player=null) { |
|
799 | + public function hasAllianceFlagship(AbstractSmrPlayer $player = null) { |
|
800 | 800 | if (is_null($player) || !$player->hasAlliance() || !$player->getAlliance()->hasFlagship()) { |
801 | 801 | return false; |
802 | 802 | } |
@@ -809,12 +809,12 @@ discard block |
||
809 | 809 | return false; |
810 | 810 | } |
811 | 811 | |
812 | - public function hasProtectedTraders(AbstractSmrPlayer $player=null) { |
|
813 | - if($player == null || !$this->hasOtherTraders($player)) |
|
812 | + public function hasProtectedTraders(AbstractSmrPlayer $player = null) { |
|
813 | + if ($player == null || !$this->hasOtherTraders($player)) |
|
814 | 814 | return false; |
815 | 815 | $otherPlayers = $this->getOtherTraders($player); |
816 | - foreach($otherPlayers as $otherPlayer) { |
|
817 | - if(!$player->traderNAPAlliance($otherPlayer) |
|
816 | + foreach ($otherPlayers as $otherPlayer) { |
|
817 | + if (!$player->traderNAPAlliance($otherPlayer) |
|
818 | 818 | && ($otherPlayer->hasNewbieTurns() || $otherPlayer->hasFederalProtection())) { |
819 | 819 | return true; |
820 | 820 | } |
@@ -829,11 +829,11 @@ discard block |
||
829 | 829 | |
830 | 830 | public function &getFightingTradersAgainstPort(AbstractSmrPlayer $attackingPlayer, SmrPort $defendingPort) { |
831 | 831 | $fightingPlayers = array(); |
832 | - $alliancePlayers = SmrPlayer::getSectorPlayersByAlliances($this->getGameID(),$this->getSectorID(), array($attackingPlayer->getAllianceID())); |
|
833 | - if(count($alliancePlayers) > 0) |
|
834 | - foreach($alliancePlayers as $accountID => $player) { |
|
835 | - if($player->canFight()) { |
|
836 | - if($attackingPlayer->traderAttackPortAlliance($player)) |
|
832 | + $alliancePlayers = SmrPlayer::getSectorPlayersByAlliances($this->getGameID(), $this->getSectorID(), array($attackingPlayer->getAllianceID())); |
|
833 | + if (count($alliancePlayers) > 0) |
|
834 | + foreach ($alliancePlayers as $accountID => $player) { |
|
835 | + if ($player->canFight()) { |
|
836 | + if ($attackingPlayer->traderAttackPortAlliance($player)) |
|
837 | 837 | $fightingPlayers[$accountID] = $alliancePlayers[$accountID]; |
838 | 838 | } |
839 | 839 | } |
@@ -842,43 +842,43 @@ discard block |
||
842 | 842 | |
843 | 843 | public function &getFightingTradersAgainstPlanet(AbstractSmrPlayer $attackingPlayer, SmrPlanet $defendingPlanet) { |
844 | 844 | $fightingPlayers = array(); |
845 | - $alliancePlayers = SmrPlayer::getSectorPlayersByAlliances($this->getGameID(),$this->getSectorID(), array($attackingPlayer->getAllianceID())); |
|
846 | - if(count($alliancePlayers) > 0) { |
|
845 | + $alliancePlayers = SmrPlayer::getSectorPlayersByAlliances($this->getGameID(), $this->getSectorID(), array($attackingPlayer->getAllianceID())); |
|
846 | + if (count($alliancePlayers) > 0) { |
|
847 | 847 | $planetOwner = $defendingPlanet->getOwner(); |
848 | - foreach($alliancePlayers as $accountID => $player) { |
|
849 | - if($player->canFight()) { |
|
850 | - if($attackingPlayer->traderAttackPlanetAlliance($player) && !$planetOwner->planetNAPAlliance($player)) |
|
848 | + foreach ($alliancePlayers as $accountID => $player) { |
|
849 | + if ($player->canFight()) { |
|
850 | + if ($attackingPlayer->traderAttackPlanetAlliance($player) && !$planetOwner->planetNAPAlliance($player)) |
|
851 | 851 | $fightingPlayers[$accountID] = $alliancePlayers[$accountID]; |
852 | 852 | } |
853 | 853 | } |
854 | 854 | } |
855 | - return self::limitFightingTraders($fightingPlayers, $attackingPlayer, min($defendingPlanet->getMaxAttackers(),MAXIMUM_PLANET_FLEET_SIZE)); |
|
855 | + return self::limitFightingTraders($fightingPlayers, $attackingPlayer, min($defendingPlanet->getMaxAttackers(), MAXIMUM_PLANET_FLEET_SIZE)); |
|
856 | 856 | } |
857 | 857 | |
858 | - public function &getFightingTraders(AbstractSmrPlayer $attackingPlayer, AbstractSmrPlayer $defendingPlayer, $checkForCloak=false) { |
|
859 | - if($attackingPlayer->traderNAPAlliance($defendingPlayer)) |
|
858 | + public function &getFightingTraders(AbstractSmrPlayer $attackingPlayer, AbstractSmrPlayer $defendingPlayer, $checkForCloak = false) { |
|
859 | + if ($attackingPlayer->traderNAPAlliance($defendingPlayer)) |
|
860 | 860 | throw new Exception('These traders are NAPed.'); |
861 | 861 | $fightingPlayers = array('Attackers' => array(), 'Defenders' => array()); |
862 | - $alliancePlayers = SmrPlayer::getSectorPlayersByAlliances($this->getGameID(),$this->getSectorID(), array($attackingPlayer->getAllianceID(), $defendingPlayer->getAllianceID())); |
|
862 | + $alliancePlayers = SmrPlayer::getSectorPlayersByAlliances($this->getGameID(), $this->getSectorID(), array($attackingPlayer->getAllianceID(), $defendingPlayer->getAllianceID())); |
|
863 | 863 | $attackers = array(); |
864 | 864 | $defenders = array(); |
865 | - if(count($alliancePlayers) > 0) |
|
866 | - foreach($alliancePlayers as $accountID => $player) { |
|
867 | - if($player->canFight()) { |
|
868 | - if($attackingPlayer->traderAttackTraderAlliance($player) && !$defendingPlayer->traderDefendTraderAlliance($player) && !$defendingPlayer->traderNAPAlliance($player)) |
|
865 | + if (count($alliancePlayers) > 0) |
|
866 | + foreach ($alliancePlayers as $accountID => $player) { |
|
867 | + if ($player->canFight()) { |
|
868 | + if ($attackingPlayer->traderAttackTraderAlliance($player) && !$defendingPlayer->traderDefendTraderAlliance($player) && !$defendingPlayer->traderNAPAlliance($player)) |
|
869 | 869 | $attackers[] = $alliancePlayers[$accountID]; |
870 | - else if($defendingPlayer->traderDefendTraderAlliance($player) && !$attackingPlayer->traderAttackTraderAlliance($player) && !$attackingPlayer->traderNAPAlliance($player) && ($checkForCloak===false || $attackingPlayer->canSee($player))) |
|
870 | + else if ($defendingPlayer->traderDefendTraderAlliance($player) && !$attackingPlayer->traderAttackTraderAlliance($player) && !$attackingPlayer->traderNAPAlliance($player) && ($checkForCloak === false || $attackingPlayer->canSee($player))) |
|
871 | 871 | $defenders[] = $alliancePlayers[$accountID]; |
872 | 872 | } |
873 | 873 | } |
874 | 874 | $attackers = self::limitFightingTraders($attackers, $attackingPlayer, MAXIMUM_PVP_FLEET_SIZE); |
875 | 875 | shuffle($attackers); |
876 | - foreach($attackers as $attacker) { |
|
876 | + foreach ($attackers as $attacker) { |
|
877 | 877 | $fightingPlayers['Attackers'][$attacker->getAccountID()] = $attacker; |
878 | 878 | } |
879 | - $defenders = self::limitFightingTraders($defenders,$defendingPlayer, MAXIMUM_PVP_FLEET_SIZE); |
|
879 | + $defenders = self::limitFightingTraders($defenders, $defendingPlayer, MAXIMUM_PVP_FLEET_SIZE); |
|
880 | 880 | shuffle($defenders); |
881 | - foreach($defenders as $defender) { |
|
881 | + foreach ($defenders as $defender) { |
|
882 | 882 | $fightingPlayers['Defenders'][$defender->getAccountID()] = $defender; |
883 | 883 | } |
884 | 884 | return $fightingPlayers; |
@@ -887,12 +887,12 @@ discard block |
||
887 | 887 | public static function &limitFightingTraders(array &$fightingPlayers, AbstractSmrPlayer $keepPlayer, $maximumFleetSize) { |
888 | 888 | // Cap fleets to the required size |
889 | 889 | $fleet_size = count($fightingPlayers); |
890 | - if($fleet_size > $maximumFleetSize) { |
|
890 | + if ($fleet_size > $maximumFleetSize) { |
|
891 | 891 | // We use random key to stop the same people being capped all the time |
892 | - for($j=0;$j<$fleet_size-$maximumFleetSize;++$j) { |
|
892 | + for ($j = 0; $j < $fleet_size - $maximumFleetSize; ++$j) { |
|
893 | 893 | do { |
894 | 894 | $key = array_rand($fightingPlayers); |
895 | - } while($keepPlayer->equals($fightingPlayers[$key])); |
|
895 | + } while ($keepPlayer->equals($fightingPlayers[$key])); |
|
896 | 896 | unset($fightingPlayers[$key]); |
897 | 897 | } |
898 | 898 | } |
@@ -901,11 +901,11 @@ discard block |
||
901 | 901 | |
902 | 902 | public function &getPotentialFightingTraders(AbstractSmrPlayer $attackingPlayer) { |
903 | 903 | $fightingPlayers = array(); |
904 | - $alliancePlayers = SmrPlayer::getSectorPlayersByAlliances($this->getGameID(),$this->getSectorID(), array($attackingPlayer->getAllianceID())); |
|
905 | - if(count($alliancePlayers) > 0) |
|
906 | - foreach($alliancePlayers as $accountID => $player) { |
|
907 | - if($player->canFight()) { |
|
908 | - if($attackingPlayer->traderAttackTraderAlliance($player)) |
|
904 | + $alliancePlayers = SmrPlayer::getSectorPlayersByAlliances($this->getGameID(), $this->getSectorID(), array($attackingPlayer->getAllianceID())); |
|
905 | + if (count($alliancePlayers) > 0) |
|
906 | + foreach ($alliancePlayers as $accountID => $player) { |
|
907 | + if ($player->canFight()) { |
|
908 | + if ($attackingPlayer->traderAttackTraderAlliance($player)) |
|
909 | 909 | $fightingPlayers['Attackers'][$accountID] = $player; |
910 | 910 | } |
911 | 911 | } |
@@ -917,32 +917,32 @@ discard block |
||
917 | 917 | } |
918 | 918 | |
919 | 919 | public function setBattles($amount) { |
920 | - if($this->battles == $amount) |
|
920 | + if ($this->battles == $amount) |
|
921 | 921 | return; |
922 | 922 | $this->battles = $amount; |
923 | 923 | $this->hasChanged = true; |
924 | 924 | } |
925 | 925 | |
926 | 926 | public function decreaseBattles($amount) { |
927 | - $this->setBattles($this->battles-$amount); |
|
927 | + $this->setBattles($this->battles - $amount); |
|
928 | 928 | } |
929 | 929 | |
930 | 930 | public function increaseBattles($amount) { |
931 | - $this->setBattles($this->battles+$amount); |
|
931 | + $this->setBattles($this->battles + $amount); |
|
932 | 932 | } |
933 | 933 | |
934 | 934 | function equals(SmrSector $otherSector) { |
935 | - return $otherSector->getSectorID()==$this->getSectorID() && $otherSector->getGameID()==$this->getGameID(); |
|
935 | + return $otherSector->getSectorID() == $this->getSectorID() && $otherSector->getGameID() == $this->getGameID(); |
|
936 | 936 | } |
937 | 937 | |
938 | 938 | function isLinkedSector(SmrSector $otherSector) { |
939 | - return $otherSector->getGameID()==$this->getGameID() && $this->isLinked($otherSector->getSectorID()); |
|
939 | + return $otherSector->getGameID() == $this->getGameID() && $this->isLinked($otherSector->getSectorID()); |
|
940 | 940 | } |
941 | 941 | |
942 | - public function isVisited(AbstractSmrPlayer $player=null) { |
|
943 | - if($player===null) |
|
942 | + public function isVisited(AbstractSmrPlayer $player = null) { |
|
943 | + if ($player === null) |
|
944 | 944 | return true; |
945 | - if(!isset($this->visited[$player->getAccountID()])) { |
|
945 | + if (!isset($this->visited[$player->getAccountID()])) { |
|
946 | 946 | $this->db->query('SELECT sector_id FROM player_visited_sector WHERE ' . $this->SQL . ' AND account_id=' . $this->db->escapeNumber($player->getAccountID()) . ' LIMIT 1'); |
947 | 947 | $this->visited[$player->getAccountID()] = !$this->db->nextRecord(); |
948 | 948 | } |
@@ -958,15 +958,15 @@ discard block |
||
958 | 958 | } |
959 | 959 | |
960 | 960 | public function getGalaxyMapHREF() { |
961 | - return '?sector_id='.$this->getSectorID(); |
|
961 | + return '?sector_id=' . $this->getSectorID(); |
|
962 | 962 | } |
963 | 963 | |
964 | 964 | public function getScanSectorHREF() { |
965 | 965 | return Globals::getSectorScanHREF($this->getSectorID()); |
966 | 966 | } |
967 | 967 | |
968 | - public function hasX(/*Object*/ $x, AbstractSmrPlayer $player=null) { |
|
969 | - if($x instanceof SmrSector) { |
|
968 | + public function hasX(/*Object*/ $x, AbstractSmrPlayer $player = null) { |
|
969 | + if ($x instanceof SmrSector) { |
|
970 | 970 | return $this->equals($x); |
971 | 971 | } |
972 | 972 | if ($x == 'Port') { |
@@ -982,16 +982,16 @@ discard block |
||
982 | 982 | return $x->contains($this); |
983 | 983 | } |
984 | 984 | |
985 | - if(is_array($x) && $x['Type']=='Good') //Check if it's possible for port to have X, hacky but nice performance gains |
|
985 | + if (is_array($x) && $x['Type'] == 'Good') //Check if it's possible for port to have X, hacky but nice performance gains |
|
986 | 986 | if ($this->hasPort()) |
987 | 987 | if ($this->getPort()->hasX($x)) |
988 | 988 | return true; |
989 | 989 | |
990 | - if($x instanceof SmrWeapon || (is_array($x) && ($x['Type']=='Ship'||$x['Type']=='Hardware')) || (is_string($x) && ($x=='Bank'||$x=='Bar'||$x=='Fed'||$x=='SafeFed'||$x=='HQ'||$x=='UG'||$x=='Hardware'||$x=='Ship'||$x=='Weapon'))) //Check if it's possible for location to have X, hacky but nice performance gains |
|
990 | + if ($x instanceof SmrWeapon || (is_array($x) && ($x['Type'] == 'Ship' || $x['Type'] == 'Hardware')) || (is_string($x) && ($x == 'Bank' || $x == 'Bar' || $x == 'Fed' || $x == 'SafeFed' || $x == 'HQ' || $x == 'UG' || $x == 'Hardware' || $x == 'Ship' || $x == 'Weapon'))) //Check if it's possible for location to have X, hacky but nice performance gains |
|
991 | 991 | if ($this->hasLocation()) { |
992 | 992 | $locations = $this->getLocations(); |
993 | 993 | foreach ($locations as $l) { |
994 | - if ($l->hasX($x,$player)) |
|
994 | + if ($l->hasX($x, $player)) |
|
995 | 995 | return true; |
996 | 996 | } |
997 | 997 | } |
@@ -20,19 +20,19 @@ discard block |
||
20 | 20 | protected $ownerID; |
21 | 21 | protected $sectorID; |
22 | 22 | protected $gameID; |
23 | - protected $combatDrones=0; |
|
24 | - protected $scoutDrones=0; |
|
25 | - protected $mines=0; |
|
26 | - protected $expire=0; |
|
23 | + protected $combatDrones = 0; |
|
24 | + protected $scoutDrones = 0; |
|
25 | + protected $mines = 0; |
|
26 | + protected $expire = 0; |
|
27 | 27 | |
28 | 28 | protected $isNew; |
29 | 29 | protected $hasChanged = false; |
30 | 30 | |
31 | 31 | public static function refreshCache() { |
32 | - foreach(self::$CACHE_FORCES as $gameID => &$gameForces) { |
|
33 | - foreach($gameForces as $sectorID => &$gameSectorForces) { |
|
34 | - foreach($gameSectorForces as $ownerID => &$forces) { |
|
35 | - $forces = self::getForce($gameID,$sectorID,$ownerID,true); |
|
32 | + foreach (self::$CACHE_FORCES as $gameID => &$gameForces) { |
|
33 | + foreach ($gameForces as $sectorID => &$gameSectorForces) { |
|
34 | + foreach ($gameSectorForces as $ownerID => &$forces) { |
|
35 | + $forces = self::getForce($gameID, $sectorID, $ownerID, true); |
|
36 | 36 | } |
37 | 37 | } |
38 | 38 | } |
@@ -44,22 +44,22 @@ discard block |
||
44 | 44 | } |
45 | 45 | |
46 | 46 | public static function saveForces() { |
47 | - foreach(self::$CACHE_FORCES as $gameForces) { |
|
48 | - foreach($gameForces as $gameSectorForces) { |
|
49 | - foreach($gameSectorForces as $forces) { |
|
47 | + foreach (self::$CACHE_FORCES as $gameForces) { |
|
48 | + foreach ($gameForces as $gameSectorForces) { |
|
49 | + foreach ($gameSectorForces as $forces) { |
|
50 | 50 | $forces->update(); |
51 | 51 | } |
52 | 52 | } |
53 | 53 | } |
54 | 54 | } |
55 | 55 | |
56 | - public static function &getSectorForces($gameID,$sectorID,$forceUpdate = false) { |
|
57 | - if($forceUpdate || !isset(self::$CACHE_SECTOR_FORCES[$gameID][$sectorID])) { |
|
58 | - self::tidyUpForces(SmrGalaxy::getGalaxyContaining($gameID,$sectorID)); |
|
56 | + public static function &getSectorForces($gameID, $sectorID, $forceUpdate = false) { |
|
57 | + if ($forceUpdate || !isset(self::$CACHE_SECTOR_FORCES[$gameID][$sectorID])) { |
|
58 | + self::tidyUpForces(SmrGalaxy::getGalaxyContaining($gameID, $sectorID)); |
|
59 | 59 | $db = new SmrMySqlDatabase(); |
60 | 60 | $db->query('SELECT * FROM sector_has_forces WHERE sector_id = ' . $db->escapeNumber($sectorID) . ' AND game_id=' . $db->escapeNumber($gameID) . ' ORDER BY expire_time ASC'); |
61 | 61 | $forces = array(); |
62 | - while($db->nextRecord()) { |
|
62 | + while ($db->nextRecord()) { |
|
63 | 63 | $ownerID = $db->getInt('owner_id'); |
64 | 64 | $forces[$ownerID] = self::getForce($gameID, $sectorID, $ownerID, $forceUpdate, $db); |
65 | 65 | } |
@@ -68,9 +68,9 @@ discard block |
||
68 | 68 | return self::$CACHE_SECTOR_FORCES[$gameID][$sectorID]; |
69 | 69 | } |
70 | 70 | |
71 | - public static function &getForce($gameID, $sectorID, $ownerID, $forceUpdate=false, $db=null) { |
|
72 | - if($forceUpdate || !isset(self::$CACHE_FORCES[$gameID][$sectorID][$ownerID])) { |
|
73 | - self::tidyUpForces(SmrGalaxy::getGalaxyContaining($gameID,$sectorID)); |
|
71 | + public static function &getForce($gameID, $sectorID, $ownerID, $forceUpdate = false, $db = null) { |
|
72 | + if ($forceUpdate || !isset(self::$CACHE_FORCES[$gameID][$sectorID][$ownerID])) { |
|
73 | + self::tidyUpForces(SmrGalaxy::getGalaxyContaining($gameID, $sectorID)); |
|
74 | 74 | $p = new SmrForce($gameID, $sectorID, $ownerID, $db); |
75 | 75 | self::$CACHE_FORCES[$gameID][$sectorID][$ownerID] = $p; |
76 | 76 | } |
@@ -78,24 +78,24 @@ discard block |
||
78 | 78 | } |
79 | 79 | |
80 | 80 | public static function tidyUpForces(SmrGalaxy $galaxyToTidy) { |
81 | - if(!isset(self::$TIDIED_UP[$galaxyToTidy->getGameID()][$galaxyToTidy->getGalaxyID()])) { |
|
81 | + if (!isset(self::$TIDIED_UP[$galaxyToTidy->getGameID()][$galaxyToTidy->getGalaxyID()])) { |
|
82 | 82 | self::$TIDIED_UP[$galaxyToTidy->getGameID()][$galaxyToTidy->getGalaxyID()] = true; |
83 | 83 | $db = new SmrMySqlDatabase(); |
84 | 84 | $db->query('UPDATE sector_has_forces |
85 | 85 | SET refresher=0, |
86 | 86 | expire_time = (refresh_at + if(combat_drones+mines=0, |
87 | - LEAST('.$db->escapeNumber(self::LOWEST_MAX_EXPIRE_SCOUTS_ONLY).', scout_drones*'.$db->escapeNumber(self::TIME_PER_SCOUT_ONLY).'), |
|
88 | - LEAST('.$db->escapeNumber($galaxyToTidy->getMaxForceTime()).', (combat_drones*'.$db->escapeNumber(self::TIME_PERCENT_PER_COMBAT).'+scout_drones*'.$db->escapeNumber(self::TIME_PERCENT_PER_SCOUT).'+mines*'.$db->escapeNumber(self::TIME_PERCENT_PER_MINE).')*'.$db->escapeNumber($galaxyToTidy->getMaxForceTime()).') |
|
87 | + LEAST('.$db->escapeNumber(self::LOWEST_MAX_EXPIRE_SCOUTS_ONLY) . ', scout_drones*' . $db->escapeNumber(self::TIME_PER_SCOUT_ONLY) . '), |
|
88 | + LEAST('.$db->escapeNumber($galaxyToTidy->getMaxForceTime()) . ', (combat_drones*' . $db->escapeNumber(self::TIME_PERCENT_PER_COMBAT) . '+scout_drones*' . $db->escapeNumber(self::TIME_PERCENT_PER_SCOUT) . '+mines*' . $db->escapeNumber(self::TIME_PERCENT_PER_MINE) . ')*' . $db->escapeNumber($galaxyToTidy->getMaxForceTime()) . ') |
|
89 | 89 | )) |
90 | - WHERE game_id = '.$db->escapeNumber($galaxyToTidy->getGameID()).' AND sector_id >= '.$db->escapeNumber($galaxyToTidy->getStartSector()).' AND sector_id <= '.$db->escapeNumber($galaxyToTidy->getEndSector()).' AND refresher != 0 AND refresh_at <= '.$db->escapeNumber(TIME)); |
|
90 | + WHERE game_id = '.$db->escapeNumber($galaxyToTidy->getGameID()) . ' AND sector_id >= ' . $db->escapeNumber($galaxyToTidy->getStartSector()) . ' AND sector_id <= ' . $db->escapeNumber($galaxyToTidy->getEndSector()) . ' AND refresher != 0 AND refresh_at <= ' . $db->escapeNumber(TIME)); |
|
91 | 91 | $db->query('DELETE FROM sector_has_forces WHERE expire_time < ' . $db->escapeNumber(TIME)); |
92 | 92 | } |
93 | 93 | } |
94 | 94 | |
95 | - protected function __construct($gameID, $sectorID, $ownerID, $db=null) { |
|
95 | + protected function __construct($gameID, $sectorID, $ownerID, $db = null) { |
|
96 | 96 | $this->db = new SmrMySqlDatabase(); |
97 | - $this->SQL = 'game_id = '.$this->db->escapeNumber($gameID).' |
|
98 | - AND sector_id = '.$this->db->escapeNumber($sectorID).' |
|
97 | + $this->SQL = 'game_id = ' . $this->db->escapeNumber($gameID) . ' |
|
98 | + AND sector_id = '.$this->db->escapeNumber($sectorID) . ' |
|
99 | 99 | AND owner_id = '.$this->db->escapeNumber($ownerID); |
100 | 100 | |
101 | 101 | if (isset($db)) { |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | } |
119 | 119 | |
120 | 120 | public function exists() { |
121 | - return ($this->hasCDs()||$this->hasSDs()||$this->hasMines())&&!$this->hasExpired(); |
|
121 | + return ($this->hasCDs() || $this->hasSDs() || $this->hasMines()) && !$this->hasExpired(); |
|
122 | 122 | } |
123 | 123 | public function getTypeID() { |
124 | 124 | return $this->typeID; |
@@ -137,34 +137,34 @@ discard block |
||
137 | 137 | } |
138 | 138 | |
139 | 139 | public function getHREF() { |
140 | - if(!isset($this->HREF)) { |
|
140 | + if (!isset($this->HREF)) { |
|
141 | 141 | $this->HREF = SmrSession::getNewHREF(create_container('skeleton.php', $this->getProcessor())); |
142 | 142 | } |
143 | 143 | return $this->HREF; |
144 | 144 | } |
145 | 145 | |
146 | 146 | public function canAcceptCDs() { |
147 | - return $this->getCDs()<50; |
|
147 | + return $this->getCDs() < 50; |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | public function canAcceptSDs() { |
151 | - return $this->getSDs()<5; |
|
151 | + return $this->getSDs() < 5; |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | public function canAcceptMines() { |
155 | - return $this->getMines()<50; |
|
155 | + return $this->getMines() < 50; |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | public function hasCDs() { |
159 | - return $this->getCDs()>0; |
|
159 | + return $this->getCDs() > 0; |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | public function hasSDs() { |
163 | - return $this->getSDs()>0; |
|
163 | + return $this->getSDs() > 0; |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | public function hasMines() { |
167 | - return $this->getMines()>0; |
|
167 | + return $this->getMines() > 0; |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | public function getCDs() { |
@@ -180,52 +180,52 @@ discard block |
||
180 | 180 | } |
181 | 181 | |
182 | 182 | public function addMines($amount) { |
183 | - if($amount<0) { |
|
183 | + if ($amount < 0) { |
|
184 | 184 | throw new Exception('Cannot add negative mines.'); |
185 | 185 | } |
186 | 186 | $this->setMines($this->getMines() + $amount); |
187 | 187 | } |
188 | 188 | |
189 | 189 | public function addCDs($amount) { |
190 | - if($amount<0) { |
|
190 | + if ($amount < 0) { |
|
191 | 191 | throw new Exception('Cannot add negative CDs.'); |
192 | 192 | } |
193 | 193 | $this->setCDs($this->getCDs() + $amount); |
194 | 194 | } |
195 | 195 | |
196 | 196 | public function addSDs($amount) { |
197 | - if($amount<0) { |
|
197 | + if ($amount < 0) { |
|
198 | 198 | throw new Exception('Cannot add negative SDs.'); |
199 | 199 | } |
200 | 200 | $this->setSDs($this->getSDs() + $amount); |
201 | 201 | } |
202 | 202 | |
203 | 203 | public function takeMines($amount) { |
204 | - if($amount<0) { |
|
204 | + if ($amount < 0) { |
|
205 | 205 | throw new Exception('Cannot take negative mines.'); |
206 | 206 | } |
207 | 207 | $this->setMines($this->getMines() - $amount); |
208 | 208 | } |
209 | 209 | |
210 | 210 | public function takeCDs($amount) { |
211 | - if($amount<0) { |
|
211 | + if ($amount < 0) { |
|
212 | 212 | throw new Exception('Cannot take negative CDs.'); |
213 | 213 | } |
214 | 214 | $this->setCDs($this->getCDs() - $amount); |
215 | 215 | } |
216 | 216 | |
217 | 217 | public function takeSDs($amount) { |
218 | - if($amount<0) { |
|
218 | + if ($amount < 0) { |
|
219 | 219 | throw new Exception('Cannot take negative SDs.'); |
220 | 220 | } |
221 | 221 | $this->setSDs($this->getSDs() - $amount); |
222 | 222 | } |
223 | 223 | |
224 | 224 | public function setMines($amount) { |
225 | - if($amount<0) { |
|
225 | + if ($amount < 0) { |
|
226 | 226 | throw new Exception('Cannot set negative mines.'); |
227 | 227 | } |
228 | - if($amount==$this->getMines()) { |
|
228 | + if ($amount == $this->getMines()) { |
|
229 | 229 | return; |
230 | 230 | } |
231 | 231 | $this->hasChanged = true; |
@@ -233,10 +233,10 @@ discard block |
||
233 | 233 | } |
234 | 234 | |
235 | 235 | public function setCDs($amount) { |
236 | - if($amount<0) { |
|
236 | + if ($amount < 0) { |
|
237 | 237 | throw new Exception('Cannot set negative CDs.'); |
238 | 238 | } |
239 | - if($amount==$this->getCDs()) { |
|
239 | + if ($amount == $this->getCDs()) { |
|
240 | 240 | return; |
241 | 241 | } |
242 | 242 | $this->hasChanged = true; |
@@ -244,10 +244,10 @@ discard block |
||
244 | 244 | } |
245 | 245 | |
246 | 246 | public function setSDs($amount) { |
247 | - if($amount<0) { |
|
247 | + if ($amount < 0) { |
|
248 | 248 | throw new Exception('Cannot set negative SDs.'); |
249 | 249 | } |
250 | - if($amount==$this->getSDs()) { |
|
250 | + if ($amount == $this->getSDs()) { |
|
251 | 251 | return; |
252 | 252 | } |
253 | 253 | $this->hasChanged = true; |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | } |
256 | 256 | |
257 | 257 | public function hasExpired() { |
258 | - return $this->expire<TIME; |
|
258 | + return $this->expire < TIME; |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | public function getExpire() { |
@@ -263,38 +263,38 @@ discard block |
||
263 | 263 | } |
264 | 264 | |
265 | 265 | public function setExpire($time) { |
266 | - if($time<0) { |
|
266 | + if ($time < 0) { |
|
267 | 267 | throw new Exception('Cannot set negative expiry.'); |
268 | 268 | } |
269 | - if($time==$this->getExpire()) { |
|
269 | + if ($time == $this->getExpire()) { |
|
270 | 270 | return; |
271 | 271 | } |
272 | - if($time > TIME + $this->getMaxExpireTime()) { |
|
272 | + if ($time > TIME + $this->getMaxExpireTime()) { |
|
273 | 273 | $time = TIME + $this->getMaxExpireTime(); |
274 | 274 | } |
275 | 275 | $this->hasChanged = true; |
276 | 276 | $this->expire = $time; |
277 | - if(!$this->isNew) |
|
277 | + if (!$this->isNew) |
|
278 | 278 | $this->update(); |
279 | 279 | } |
280 | 280 | |
281 | 281 | public function updateExpire() { |
282 | 282 | // Changed (26/10/05) - scout drones count * 2 |
283 | - if($this->getCDs() == 0 && $this->getMines() == 0 && $this->getSDs() > 0) { |
|
284 | - $time = self::TIME_PER_SCOUT_ONLY*$this->getSDs(); |
|
283 | + if ($this->getCDs() == 0 && $this->getMines() == 0 && $this->getSDs() > 0) { |
|
284 | + $time = self::TIME_PER_SCOUT_ONLY * $this->getSDs(); |
|
285 | 285 | } |
286 | 286 | else { |
287 | - $time = ($this->getCDs()*self::TIME_PERCENT_PER_COMBAT + $this->getSDs()*self::TIME_PERCENT_PER_SCOUT + $this->getMines()*self::TIME_PERCENT_PER_MINE) * $this->getMaxGalaxyExpireTime(); |
|
287 | + $time = ($this->getCDs() * self::TIME_PERCENT_PER_COMBAT + $this->getSDs() * self::TIME_PERCENT_PER_SCOUT + $this->getMines() * self::TIME_PERCENT_PER_MINE) * $this->getMaxGalaxyExpireTime(); |
|
288 | 288 | } |
289 | 289 | $this->setExpire(TIME + $time); |
290 | 290 | } |
291 | 291 | |
292 | 292 | public function getMaxExpireTime() { |
293 | - if($this->hasCDs()||$this->hasMines()) { |
|
293 | + if ($this->hasCDs() || $this->hasMines()) { |
|
294 | 294 | return $this->getMaxGalaxyExpireTime(); |
295 | 295 | } |
296 | - if(!$this->hasCDs() && !$this->hasMines() && $this->hasSDs()) { |
|
297 | - return max(self::LOWEST_MAX_EXPIRE_SCOUTS_ONLY,$this->getMaxGalaxyExpireTime()); |
|
296 | + if (!$this->hasCDs() && !$this->hasMines() && $this->hasSDs()) { |
|
297 | + return max(self::LOWEST_MAX_EXPIRE_SCOUTS_ONLY, $this->getMaxGalaxyExpireTime()); |
|
298 | 298 | } |
299 | 299 | return 0; |
300 | 300 | } |
@@ -305,26 +305,26 @@ discard block |
||
305 | 305 | |
306 | 306 | public function getBumpTurnCost(AbstractSmrShip $ship) { |
307 | 307 | $mines = $this->getMines(); |
308 | - if($mines <= 1) { |
|
308 | + if ($mines <= 1) { |
|
309 | 309 | return 0; |
310 | 310 | } |
311 | - if($mines < 10) { |
|
311 | + if ($mines < 10) { |
|
312 | 312 | $turns = 1; |
313 | 313 | } |
314 | - else if($mines < 25) { |
|
314 | + else if ($mines < 25) { |
|
315 | 315 | $turns = 2; |
316 | 316 | } |
317 | 317 | else { |
318 | 318 | $turns = 3; |
319 | 319 | } |
320 | - if($ship->isFederal() || $ship->hasDCS()) { |
|
320 | + if ($ship->isFederal() || $ship->hasDCS()) { |
|
321 | 321 | $turns -= 1; |
322 | 322 | } |
323 | 323 | return $turns; |
324 | 324 | } |
325 | 325 | |
326 | 326 | public function getAttackTurnCost(AbstractSmrShip $ship) { |
327 | - if($ship->isFederal() || $ship->hasDCS()) { |
|
327 | + if ($ship->isFederal() || $ship->hasDCS()) { |
|
328 | 328 | return 2; |
329 | 329 | } |
330 | 330 | return 3; |
@@ -339,45 +339,45 @@ discard block |
||
339 | 339 | } |
340 | 340 | |
341 | 341 | public function &getSector() { |
342 | - return SmrSector::getSector($this->getGameID(),$this->getSectorID()); |
|
342 | + return SmrSector::getSector($this->getGameID(), $this->getSectorID()); |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | public function getSectorID() { |
346 | 346 | return $this->sectorID; |
347 | 347 | } |
348 | 348 | |
349 | - public function ping($pingMessage, AbstractSmrPlayer $playerPinging, $skipCheck=false) { |
|
350 | - if(!$this->hasSDs() && !$skipCheck) { |
|
349 | + public function ping($pingMessage, AbstractSmrPlayer $playerPinging, $skipCheck = false) { |
|
350 | + if (!$this->hasSDs() && !$skipCheck) { |
|
351 | 351 | return; |
352 | 352 | } |
353 | 353 | $owner = $this->getOwner(); |
354 | - if(!$playerPinging->sameAlliance($owner)) { |
|
355 | - $playerPinging->sendMessage($owner->getAccountID(), MSG_SCOUT, $pingMessage,false); |
|
354 | + if (!$playerPinging->sameAlliance($owner)) { |
|
355 | + $playerPinging->sendMessage($owner->getAccountID(), MSG_SCOUT, $pingMessage, false); |
|
356 | 356 | } |
357 | 357 | } |
358 | 358 | |
359 | 359 | function &getGalaxy() { |
360 | - return SmrGalaxy::getGalaxyContaining($this->getGameID(),$this->getSectorID()); |
|
360 | + return SmrGalaxy::getGalaxyContaining($this->getGameID(), $this->getSectorID()); |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | function &getOwner() { |
364 | - return SmrPlayer::getPlayer($this->getOwnerID(),$this->getGameID()); |
|
364 | + return SmrPlayer::getPlayer($this->getOwnerID(), $this->getGameID()); |
|
365 | 365 | } |
366 | 366 | |
367 | 367 | public function update() { |
368 | - if(!$this->isNew) { |
|
368 | + if (!$this->isNew) { |
|
369 | 369 | if (!$this->exists()) { |
370 | 370 | $this->db->query('DELETE FROM sector_has_forces WHERE ' . $this->SQL); |
371 | - $this->isNew=true; |
|
371 | + $this->isNew = true; |
|
372 | 372 | } |
373 | 373 | else if ($this->hasChanged) { |
374 | - $this->db->query('UPDATE sector_has_forces SET combat_drones = '.$this->db->escapeNumber($this->combatDrones).', scout_drones = ' . $this->db->escapeNumber($this->scoutDrones) . ', mines = ' . $this->db->escapeNumber($this->mines) . ', expire_time = ' . $this->db->escapeNumber($this->expire) . ' WHERE ' . $this->SQL); |
|
374 | + $this->db->query('UPDATE sector_has_forces SET combat_drones = ' . $this->db->escapeNumber($this->combatDrones) . ', scout_drones = ' . $this->db->escapeNumber($this->scoutDrones) . ', mines = ' . $this->db->escapeNumber($this->mines) . ', expire_time = ' . $this->db->escapeNumber($this->expire) . ' WHERE ' . $this->SQL); |
|
375 | 375 | } |
376 | 376 | } |
377 | - else if($this->exists()) { |
|
377 | + else if ($this->exists()) { |
|
378 | 378 | $this->db->query('INSERT INTO sector_has_forces (game_id, sector_id, owner_id, combat_drones, scout_drones, mines, expire_time) |
379 | - VALUES('.$this->db->escapeNumber($this->gameID).', '.$this->db->escapeNumber($this->sectorID).', '.$this->db->escapeNumber($this->ownerID).', '.$this->db->escapeNumber($this->combatDrones).', '.$this->db->escapeNumber($this->scoutDrones).', '.$this->db->escapeNumber($this->mines).', '.$this->db->escapeNumber($this->expire).')'); |
|
380 | - $this->isNew=false; |
|
379 | + VALUES('.$this->db->escapeNumber($this->gameID) . ', ' . $this->db->escapeNumber($this->sectorID) . ', ' . $this->db->escapeNumber($this->ownerID) . ', ' . $this->db->escapeNumber($this->combatDrones) . ', ' . $this->db->escapeNumber($this->scoutDrones) . ', ' . $this->db->escapeNumber($this->mines) . ', ' . $this->db->escapeNumber($this->expire) . ')'); |
|
380 | + $this->isNew = false; |
|
381 | 381 | } |
382 | 382 | // This instance is now in sync with the database |
383 | 383 | $this->hasChanged = false; |
@@ -392,20 +392,20 @@ discard block |
||
392 | 392 | |
393 | 393 | public function getExamineDropForcesHREF() { |
394 | 394 | $container = create_container('skeleton.php', 'forces_drop.php'); |
395 | - $container['owner_id'] = $this->getOwnerID(); |
|
395 | + $container['owner_id'] = $this->getOwnerID(); |
|
396 | 396 | return SmrSession::getNewHREF($container); |
397 | 397 | } |
398 | 398 | |
399 | 399 | public function getAttackForcesHREF() { |
400 | 400 | $container = create_container('forces_attack_processing.php'); |
401 | 401 | $container['action'] = 'attack'; |
402 | - $container['owner_id'] = $this->getOwnerID(); |
|
402 | + $container['owner_id'] = $this->getOwnerID(); |
|
403 | 403 | return SmrSession::getNewHREF($container); |
404 | 404 | } |
405 | 405 | |
406 | 406 | public function getRefreshHREF() { |
407 | 407 | $container = create_container('forces_refresh_processing.php'); |
408 | - $container['owner_id'] = $this->getOwnerID(); |
|
408 | + $container['owner_id'] = $this->getOwnerID(); |
|
409 | 409 | return SmrSession::getNewHREF($container); |
410 | 410 | } |
411 | 411 | |
@@ -415,74 +415,74 @@ discard block |
||
415 | 415 | |
416 | 416 | public function getDropSDHREF() { |
417 | 417 | $container = $this->getDropContainer(); |
418 | - $container['drop_scout_drones'] = 1; |
|
418 | + $container['drop_scout_drones'] = 1; |
|
419 | 419 | return SmrSession::getNewHREF($container); |
420 | 420 | } |
421 | 421 | |
422 | 422 | public function getTakeSDHREF() { |
423 | 423 | $container = $this->getDropContainer(); |
424 | - $container['take_scout_drones'] = 1; |
|
424 | + $container['take_scout_drones'] = 1; |
|
425 | 425 | return SmrSession::getNewHREF($container); |
426 | 426 | } |
427 | 427 | |
428 | 428 | public function getDropCDHREF() { |
429 | 429 | $container = $this->getDropContainer(); |
430 | - $container['drop_combat_drones'] = 1; |
|
430 | + $container['drop_combat_drones'] = 1; |
|
431 | 431 | return SmrSession::getNewHREF($container); |
432 | 432 | } |
433 | 433 | |
434 | 434 | public function getTakeCDHREF() { |
435 | 435 | $container = $this->getDropContainer(); |
436 | - $container['take_combat_drones'] = 1; |
|
436 | + $container['take_combat_drones'] = 1; |
|
437 | 437 | return SmrSession::getNewHREF($container); |
438 | 438 | } |
439 | 439 | |
440 | 440 | public function getDropMineHREF() { |
441 | 441 | $container = $this->getDropContainer(); |
442 | - $container['drop_mines'] = 1; |
|
442 | + $container['drop_mines'] = 1; |
|
443 | 443 | return SmrSession::getNewHREF($container); |
444 | 444 | } |
445 | 445 | |
446 | 446 | public function getTakeMineHREF() { |
447 | 447 | $container = $this->getDropContainer(); |
448 | - $container['take_mines'] = 1; |
|
448 | + $container['take_mines'] = 1; |
|
449 | 449 | return SmrSession::getNewHREF($container); |
450 | 450 | } |
451 | 451 | |
452 | 452 | public static function getRefreshAllHREF() { |
453 | 453 | $container = array(); |
454 | - $container['url'] = 'forces_mass_refresh.php'; |
|
454 | + $container['url'] = 'forces_mass_refresh.php'; |
|
455 | 455 | return SmrSession::getNewHREF($container); |
456 | 456 | } |
457 | 457 | |
458 | - public function &shootPlayer(AbstractSmrPlayer $targetPlayer,$minesAreAttacker) { |
|
459 | - return $this->shootPlayers(array($targetPlayer),$minesAreAttacker); |
|
458 | + public function &shootPlayer(AbstractSmrPlayer $targetPlayer, $minesAreAttacker) { |
|
459 | + return $this->shootPlayers(array($targetPlayer), $minesAreAttacker); |
|
460 | 460 | } |
461 | 461 | |
462 | - public function &shootPlayers(array $targetPlayers,$minesAreAttacker) { |
|
462 | + public function &shootPlayers(array $targetPlayers, $minesAreAttacker) { |
|
463 | 463 | $results = array('TotalDamage' => 0); |
464 | - if(!$this->exists()) { |
|
464 | + if (!$this->exists()) { |
|
465 | 465 | $results['DeadBeforeShot'] = true; |
466 | 466 | return $results; |
467 | 467 | } |
468 | 468 | $results['DeadBeforeShot'] = false; |
469 | 469 | |
470 | - if($this->hasMines()) { |
|
471 | - $thisMines = new SmrMines($this->getGameID(),$this->getMines()); |
|
472 | - $results['Results']['Mines'] =& $thisMines->shootPlayerAsForce($this, $targetPlayers[array_rand($targetPlayers)],$minesAreAttacker); |
|
470 | + if ($this->hasMines()) { |
|
471 | + $thisMines = new SmrMines($this->getGameID(), $this->getMines()); |
|
472 | + $results['Results']['Mines'] = & $thisMines->shootPlayerAsForce($this, $targetPlayers[array_rand($targetPlayers)], $minesAreAttacker); |
|
473 | 473 | $results['TotalDamage'] += $results['Results']['Mines']['ActualDamage']['TotalDamage']; |
474 | 474 | } |
475 | 475 | |
476 | - if($this->hasCDs()) { |
|
477 | - $thisCDs = new SmrCombatDrones($this->getGameID(),$this->getCDs()); |
|
478 | - $results['Results']['Drones'] =& $thisCDs->shootPlayerAsForce($this, $targetPlayers[array_rand($targetPlayers)]); |
|
476 | + if ($this->hasCDs()) { |
|
477 | + $thisCDs = new SmrCombatDrones($this->getGameID(), $this->getCDs()); |
|
478 | + $results['Results']['Drones'] = & $thisCDs->shootPlayerAsForce($this, $targetPlayers[array_rand($targetPlayers)]); |
|
479 | 479 | $results['TotalDamage'] += $results['Results']['Drones']['ActualDamage']['TotalDamage']; |
480 | 480 | } |
481 | 481 | |
482 | - if(!$minesAreAttacker) { |
|
483 | - if($this->hasSDs()) { |
|
484 | - $thisSDs = new SmrScoutDrones($this->getGameID(),$this->getSDs()); |
|
485 | - $results['Results']['Scouts'] =& $thisSDs->shootPlayerAsForce($this, $targetPlayers[array_rand($targetPlayers)]); |
|
482 | + if (!$minesAreAttacker) { |
|
483 | + if ($this->hasSDs()) { |
|
484 | + $thisSDs = new SmrScoutDrones($this->getGameID(), $this->getSDs()); |
|
485 | + $results['Results']['Scouts'] = & $thisSDs->shootPlayerAsForce($this, $targetPlayers[array_rand($targetPlayers)]); |
|
486 | 486 | $results['TotalDamage'] += $results['Results']['Scouts']['ActualDamage']['TotalDamage']; |
487 | 487 | } |
488 | 488 | } |
@@ -496,16 +496,16 @@ discard block |
||
496 | 496 | $minesDamage = 0; |
497 | 497 | $cdDamage = 0; |
498 | 498 | $sdDamage = 0; |
499 | - if(!$alreadyDead) { |
|
500 | - $minesDamage = $this->doMinesDamage(min($damage['MaxDamage'],$damage['Armour'])); |
|
499 | + if (!$alreadyDead) { |
|
500 | + $minesDamage = $this->doMinesDamage(min($damage['MaxDamage'], $damage['Armour'])); |
|
501 | 501 | $damage['Armour'] -= $minesDamage; |
502 | 502 | $damage['MaxDamage'] -= $minesDamage; |
503 | - if(!$this->hasMines() && ($minesDamage == 0 || $damage['Rollover'])) { |
|
504 | - $cdDamage = $this->doCDDamage(min($damage['MaxDamage'],$damage['Armour'])); |
|
503 | + if (!$this->hasMines() && ($minesDamage == 0 || $damage['Rollover'])) { |
|
504 | + $cdDamage = $this->doCDDamage(min($damage['MaxDamage'], $damage['Armour'])); |
|
505 | 505 | $damage['Armour'] -= $cdDamage; |
506 | 506 | $damage['MaxDamage'] -= $cdDamage; |
507 | - if(!$this->hasCDs() && ($cdDamage == 0 || $damage['Rollover'])) { |
|
508 | - $sdDamage = $this->doSDDamage(min($damage['MaxDamage'],$damage['Armour'])); |
|
507 | + if (!$this->hasCDs() && ($cdDamage == 0 || $damage['Rollover'])) { |
|
508 | + $sdDamage = $this->doSDDamage(min($damage['MaxDamage'], $damage['Armour'])); |
|
509 | 509 | } |
510 | 510 | } |
511 | 511 | } |
@@ -513,35 +513,35 @@ discard block |
||
513 | 513 | 'KillingShot' => !$alreadyDead && !$this->exists(), |
514 | 514 | 'TargetAlreadyDead' => $alreadyDead, |
515 | 515 | 'Mines' => $minesDamage, |
516 | - 'NumMines' => $minesDamage/MINE_ARMOUR, |
|
516 | + 'NumMines' => $minesDamage / MINE_ARMOUR, |
|
517 | 517 | 'HasMines' => $this->hasMines(), |
518 | 518 | 'CDs' => $cdDamage, |
519 | - 'NumCDs' => $cdDamage/CD_ARMOUR, |
|
519 | + 'NumCDs' => $cdDamage / CD_ARMOUR, |
|
520 | 520 | 'HasCDs' => $this->hasCDs(), |
521 | 521 | 'SDs' => $sdDamage, |
522 | - 'NumSDs' => $sdDamage/SD_ARMOUR, |
|
522 | + 'NumSDs' => $sdDamage / SD_ARMOUR, |
|
523 | 523 | 'HasSDs' => $this->hasSDs(), |
524 | - 'TotalDamage' => $minesDamage+$cdDamage+$sdDamage |
|
524 | + 'TotalDamage' => $minesDamage + $cdDamage + $sdDamage |
|
525 | 525 | ); |
526 | 526 | return $return; |
527 | 527 | } |
528 | 528 | |
529 | 529 | protected function doMinesDamage($damage) { |
530 | - $actualDamage = min($this->getMines(),floor($damage/MINE_ARMOUR)); |
|
530 | + $actualDamage = min($this->getMines(), floor($damage / MINE_ARMOUR)); |
|
531 | 531 | $this->takeMines($actualDamage); |
532 | - return $actualDamage*MINE_ARMOUR; |
|
532 | + return $actualDamage * MINE_ARMOUR; |
|
533 | 533 | } |
534 | 534 | |
535 | 535 | protected function doCDDamage($damage) { |
536 | - $actualDamage = min($this->getCDs(),floor($damage/CD_ARMOUR)); |
|
536 | + $actualDamage = min($this->getCDs(), floor($damage / CD_ARMOUR)); |
|
537 | 537 | $this->takeCDs($actualDamage); |
538 | - return $actualDamage*CD_ARMOUR; |
|
538 | + return $actualDamage * CD_ARMOUR; |
|
539 | 539 | } |
540 | 540 | |
541 | 541 | protected function doSDDamage($damage) { |
542 | - $actualDamage = min($this->getSDs(),floor($damage/SD_ARMOUR)); |
|
542 | + $actualDamage = min($this->getSDs(), floor($damage / SD_ARMOUR)); |
|
543 | 543 | $this->takeSDs($actualDamage); |
544 | - return $actualDamage*SD_ARMOUR; |
|
544 | + return $actualDamage * SD_ARMOUR; |
|
545 | 545 | } |
546 | 546 | |
547 | 547 | public function &killForcesByPlayer(AbstractSmrPlayer $killer) { |