Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Passed
Branch master (0a752f)
by Dan
03:57
created
engine/Default/smr_file_create.php 1 patch
Braces   +20 added lines, -14 removed lines patch added patch discarded remove patch
@@ -4,15 +4,17 @@  discard block
 block discarded – undo
4 4
 // code is read-only. This will help reduce sector lag and possible abuse.
5 5
 release_lock();
6 6
 
7
-if (isset($var['AdminCreateGameID']) && $var['AdminCreateGameID'] !== false)
7
+if (isset($var['AdminCreateGameID']) && $var['AdminCreateGameID'] !== false) {
8 8
 	$gameID = $var['AdminCreateGameID'];
9
-else
9
+} else {
10 10
 	$gameID = $player->getGameID();
11
+}
11 12
 
12
-if (isset($var['AdminCreateGameID']) && $var['AdminCreateGameID'] !== false)
13
+if (isset($var['AdminCreateGameID']) && $var['AdminCreateGameID'] !== false) {
13 14
 	$adminCreate = true;
14
-else
15
+} else {
15 16
 	$adminCreate = false;
17
+}
16 18
 
17 19
 // NOTE: If the format of this file is changed in an incompatible way,
18 20
 // make sure to update the SMR_FILE_VERSION!
@@ -103,8 +105,9 @@  discard block
 block discarded – undo
103 105
 	if ($location->isFed()) {
104 106
 		$locSells .= 'Fed=,';
105 107
 	}
106
-	if ($locSells != '')
107
-		$file .= substr($locSells, 0, -1);
108
+	if ($locSells != '') {
109
+			$file .= substr($locSells, 0, -1);
110
+	}
108 111
 	$file .= EOL;
109 112
 }
110 113
 
@@ -125,19 +128,22 @@  discard block
 block discarded – undo
125 128
 	foreach ($galaxy->getSectors() as $sector) {
126 129
 		$file .= '[Sector=' . $sector->getSectorID() . ']' . EOL;
127 130
 		
128
-		if (!$sector->isVisited($player) && $adminCreate === false)
129
-			continue;
131
+		if (!$sector->isVisited($player) && $adminCreate === false) {
132
+					continue;
133
+		}
130 134
 		
131 135
 		foreach ($sector->getLinks() as $linkName => $link) {
132 136
 			$file .= $linkName . '=' . $link . EOL;
133 137
 		}
134
-		if ($sector->hasWarp())
135
-			$file .= 'Warp=' . $sector->getWarp() . EOL;
138
+		if ($sector->hasWarp()) {
139
+					$file .= 'Warp=' . $sector->getWarp() . EOL;
140
+		}
136 141
 		if (($adminCreate !== false && $sector->hasPort()) || is_object($player) && $sector->hasCachedPort($player)) {
137
-			if ($adminCreate !== false)
138
-				$port = $sector->getPort();
139
-			else
140
-				$port = $sector->getCachedPort($player);
142
+			if ($adminCreate !== false) {
143
+							$port = $sector->getPort();
144
+			} else {
145
+							$port = $sector->getCachedPort($player);
146
+			}
141 147
 			$file .= 'Port Level=' . $port->getLevel() . EOL;
142 148
 			$file .= 'Port Race=' . $port->getRaceID() . EOL;
143 149
 			if (!empty($port->getSoldGoodIDs())) {
Please login to merge, or discard this patch.
htdocs/config.inc 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@
 block discarded – undo
69 69
 	if (!empty(BUG_REPORT_TO_ADDRESSES)) {
70 70
 		$mail = setupMailer();
71 71
 		$mail->Subject = (defined('PAGE_PREFIX') ? PAGE_PREFIX : '??? ') .
72
-		                 'Automatic Bug Report';
72
+						 'Automatic Bug Report';
73 73
 		$mail->setFrom('[email protected]');
74 74
 		$mail->Body = $message;
75 75
 		foreach (BUG_REPORT_TO_ADDRESSES as $toAddress) {
Please login to merge, or discard this patch.
tools/npc/npc.php 2 patches
Braces   +55 added lines, -67 removed lines patch added patch discarded remove patch
@@ -95,12 +95,10 @@  discard block
 block discarded – undo
95 95
 
96 96
 	try {
97 97
 		changeNPCLogin();
98
-	}
99
-	catch (ForwardException $e) {}
98
+	} catch (ForwardException $e) {}
100 99
 
101 100
 	NPCStuff();
102
-}
103
-catch (Throwable $e) {
101
+} catch (Throwable $e) {
104 102
 	logException($e);
105 103
 	// Try to shut down cleanly
106 104
 	exitNPC();
@@ -159,8 +157,7 @@  discard block
 block discarded – undo
159 157
 			$fedContainer = null;
160 158
 			if ($var['url'] == 'shop_ship_processing.php' && ($fedContainer = plotToFed($player, true)) !== true) { //We just bought a ship, we should head back to our trade gal/uno - we use HQ for now as it's both in our gal and a UNO, plus it's safe which is always a bonus
161 159
 				processContainer($fedContainer);
162
-			}
163
-			else if ($player->getShip()->isUnderAttack() === true
160
+			} else if ($player->getShip()->isUnderAttack() === true
164 161
 				&&($player->hasPlottedCourse() === false || $player->getPlottedCourse()->getEndSector()->offersFederalProtection() === false)
165 162
 				&&($fedContainer == null ? $fedContainer = plotToFed($player, true) : $fedContainer) !== true) { //We're under attack and need to plot course to fed.
166 163
 				// Get the lock, remove under attack and update.
@@ -173,20 +170,16 @@  discard block
 block discarded – undo
173 170
 				debug('Under Attack');
174 171
 				$underAttack = true;
175 172
 				processContainer($fedContainer);
176
-			}
177
-			else if ($player->hasPlottedCourse() === true && $player->getPlottedCourse()->getEndSector()->offersFederalProtection()) { //We have a route to fed to follow, figure it's probably a damned sensible thing to follow.
173
+			} else if ($player->hasPlottedCourse() === true && $player->getPlottedCourse()->getEndSector()->offersFederalProtection()) { //We have a route to fed to follow, figure it's probably a damned sensible thing to follow.
178 174
 				debug('Follow Course: ' . $player->getPlottedCourse()->getNextOnPath());
179 175
 				processContainer(moveToSector($player, $player->getPlottedCourse()->getNextOnPath()));
180
-			}
181
-			else if (($container = canWeUNO($player, true)) !== false) { //We have money and are at a uno, let's uno!
176
+			} else if (($container = canWeUNO($player, true)) !== false) { //We have money and are at a uno, let's uno!
182 177
 				debug('We\'re UNOing');
183 178
 				processContainer($container);
184
-			}
185
-			else if ($player->hasPlottedCourse() === true) { //We have a route to follow, figure it's probably a sensible thing to follow.
179
+			} else if ($player->hasPlottedCourse() === true) { //We have a route to follow, figure it's probably a sensible thing to follow.
186 180
 				debug('Follow Course: ' . $player->getPlottedCourse()->getNextOnPath());
187 181
 				processContainer(moveToSector($player, $player->getPlottedCourse()->getNextOnPath()));
188
-			}
189
-			else if ($player->getTurns() < NPC_LOW_TURNS || ($player->getTurns() < $player->getMaxTurns() / 2 && $player->getNewbieTurns() < NPC_LOW_NEWBIE_TURNS) || $underAttack) { //We're low on turns or have been under attack and need to plot course to fed
182
+			} else if ($player->getTurns() < NPC_LOW_TURNS || ($player->getTurns() < $player->getMaxTurns() / 2 && $player->getNewbieTurns() < NPC_LOW_NEWBIE_TURNS) || $underAttack) { //We're low on turns or have been under attack and need to plot course to fed
190 183
 				if ($player->getTurns() < NPC_LOW_TURNS) {
191 184
 					debug('Low Turns:' . $player->getTurns());
192 185
 				}
@@ -203,16 +196,13 @@  discard block
 block discarded – undo
203 196
 				}
204 197
 				$ship = $player->getShip();
205 198
 				processContainer(plotToFed($player, !$ship->hasMaxShields() || !$ship->hasMaxArmour() || !$ship->hasMaxCargoHolds()));
206
-			}
207
-			else if (($container = checkForShipUpgrade($player)) !== false) { //We have money and are at a uno, let's uno!
199
+			} else if (($container = checkForShipUpgrade($player)) !== false) { //We have money and are at a uno, let's uno!
208 200
 				debug('We\'re reshipping!');
209 201
 				processContainer($container);
210
-			}
211
-			else if (($container = canWeUNO($player, false)) !== false) { //We need to UNO and have enough money to do it properly so let's do it sooner rather than later.
202
+			} else if (($container = canWeUNO($player, false)) !== false) { //We need to UNO and have enough money to do it properly so let's do it sooner rather than later.
212 203
 				debug('We need to UNO, so off we go!');
213 204
 				processContainer($container);
214
-			}
215
-			else if ($TRADE_ROUTE instanceof Route) {
205
+			} else if ($TRADE_ROUTE instanceof Route) {
216 206
 				debug('Trade Route');
217 207
 				$forwardRoute =& $TRADE_ROUTE->getForwardRoute();
218 208
 				$returnRoute =& $TRADE_ROUTE->getReturnRoute();
@@ -220,8 +210,7 @@  discard block
 block discarded – undo
220 210
 					if ($forwardRoute->getBuySectorId() == $player->getSectorID()) {
221 211
 						$buyRoute =& $forwardRoute;
222 212
 						$sellRoute =& $returnRoute;
223
-					}
224
-					else if ($returnRoute->getBuySectorId() == $player->getSectorID()) {
213
+					} else if ($returnRoute->getBuySectorId() == $player->getSectorID()) {
225 214
 						$buyRoute =& $returnRoute;
226 215
 						$sellRoute =& $forwardRoute;
227 216
 					}
@@ -238,30 +227,25 @@  discard block
 block discarded – undo
238 227
 								//Sell goods
239 228
 								debug('Sell Goods');
240 229
 								processContainer(tradeGoods($goodID, $player, $port));
241
-							}
242
-							else {
230
+							} else {
243 231
 								//Move to next route or fed.
244 232
 								if (($TRADE_ROUTE =& changeRoute($TRADE_ROUTES)) === false) {
245 233
 									debug('Changing Route Failed');
246 234
 									processContainer(plotToFed($player));
247
-								}
248
-								else {
235
+								} else {
249 236
 									debug('Route Changed');
250 237
 									continue;
251 238
 								}
252 239
 							}
253
-						}
254
-						else if ($ship->hasCargo($buyRoute->getGoodID()) === true) { //We've bought goods, plot to sell
240
+						} else if ($ship->hasCargo($buyRoute->getGoodID()) === true) { //We've bought goods, plot to sell
255 241
 							debug('Plot To Sell: ' . $buyRoute->getSellSectorId());
256 242
 							processContainer(plotToSector($player, $buyRoute->getSellSectorId()));
257
-						}
258
-						else {
243
+						} else {
259 244
 							//Dump goods
260 245
 							debug('Dump Goods');
261 246
 							processContainer(dumpCargo($player));
262 247
 						}
263
-					}
264
-					else { //Buy goods
248
+					} else { //Buy goods
265 249
 						$goodID = $buyRoute->getGoodID();
266 250
 
267 251
 						$port = $player->getSector()->getPort();
@@ -270,26 +254,22 @@  discard block
 block discarded – undo
270 254
 						if ($tradeable === true && $port->getGoodAmount($goodID) >= $ship->getEmptyHolds()) { //Buy goods
271 255
 							debug('Buy Goods');
272 256
 							processContainer(tradeGoods($goodID, $player, $port));
273
-						}
274
-						else {
257
+						} else {
275 258
 							//Move to next route or fed.
276 259
 							if (($TRADE_ROUTE =& changeRoute($TRADE_ROUTES)) === false) {
277 260
 								debug('Changing Route Failed');
278 261
 								processContainer(plotToFed($player));
279
-							}
280
-							else {
262
+							} else {
281 263
 								debug('Route Changed');
282 264
 								continue;
283 265
 							}
284 266
 						}
285 267
 					}
286
-				}
287
-				else {
268
+				} else {
288 269
 					debug('Plot To Buy: ' . $forwardRoute->getBuySectorId());
289 270
 					processContainer(plotToSector($player, $forwardRoute->getBuySectorId()));
290 271
 				}
291
-			}
292
-			else { //Something weird is going on.. Let's fed and wait.
272
+			} else { //Something weird is going on.. Let's fed and wait.
293 273
 				debug('No actual action? Wtf?');
294 274
 				processContainer(plotToFed($player));
295 275
 			}
@@ -301,8 +281,7 @@  discard block
 block discarded – undo
301 281
 				processContainer(moveToSector($player,$moveTo));
302 282
 			}
303 283
 			*/
304
-		}
305
-		catch (ForwardException $e) {
284
+		} catch (ForwardException $e) {
306 285
 			global $lock;
307 286
 			if ($lock) { //only save if we have the lock.
308 287
 				SmrSector::saveSectors();
@@ -310,8 +289,9 @@  discard block
 block discarded – undo
310 289
 				SmrPlayer::savePlayers();
311 290
 				SmrForce::saveForces();
312 291
 				SmrPort::savePorts();
313
-				if (class_exists('WeightedRandom', false))
314
-					WeightedRandom::saveWeightedRandoms();
292
+				if (class_exists('WeightedRandom', false)) {
293
+									WeightedRandom::saveWeightedRandoms();
294
+				}
315 295
 				release_lock();
316 296
 			}
317 297
 			//Clean up the caches as the data may get changed by other players
@@ -429,11 +409,13 @@  discard block
 block discarded – undo
429 409
 }
430 410
 
431 411
 function canWeUNO(AbstractSmrPlayer $player, $oppurtunisticOnly) {
432
-	if ($player->getCredits() < MINUMUM_RESERVE_CREDITS)
433
-		return false;
412
+	if ($player->getCredits() < MINUMUM_RESERVE_CREDITS) {
413
+			return false;
414
+	}
434 415
 	$ship = $player->getShip();
435
-	if ($ship->hasMaxShields() && $ship->hasMaxArmour() && $ship->hasMaxCargoHolds())
436
-		return false;
416
+	if ($ship->hasMaxShields() && $ship->hasMaxArmour() && $ship->hasMaxCargoHolds()) {
417
+			return false;
418
+	}
437 419
 	$sector = $player->getSector();
438 420
 
439 421
 	// We buy armour in preference to shields as it's cheaper.
@@ -447,8 +429,7 @@  discard block
 block discarded – undo
447 429
 			$hardwareSold = $location->getHardwareSold();
448 430
 			if ($player->getNewbieTurns() > MIN_NEWBIE_TURNS_TO_BUY_CARGO && !$ship->hasMaxCargoHolds() && isset($hardwareSold[HARDWARE_CARGO]) && ($amount = floor(($player->getCredits() - MINUMUM_RESERVE_CREDITS) / Globals::getHardwareCost(HARDWARE_CARGO))) > 0) { // Buy cargo holds first if we have plenty of newbie turns left.
449 431
 				$hardwareID = HARDWARE_CARGO;
450
-			}
451
-			else {
432
+			} else {
452 433
 				foreach ($hardwareArray as $hardwareArrayID) {
453 434
 					if (!$ship->hasMaxHardware($hardwareArrayID) && isset($hardwareSold[$hardwareArrayID]) && ($amount = floor(($player->getCredits() - MINUMUM_RESERVE_CREDITS) / Globals::getHardwareCost($hardwareArrayID))) > 0) {
454 435
 						$hardwareID = $hardwareArrayID;
@@ -462,11 +443,14 @@  discard block
 block discarded – undo
462 443
 		}
463 444
 	}
464 445
 
465
-	if ($oppurtunisticOnly === true)
466
-		return false;
446
+	if ($oppurtunisticOnly === true) {
447
+			return false;
448
+	}
467 449
 
468
-	if ($player->getCredits() - $ship->getCostToUNO() < MINUMUM_RESERVE_CREDITS)
469
-		return false; //Only do non-oppurtunistic UNO if we have the money to do it properly!
450
+	if ($player->getCredits() - $ship->getCostToUNO() < MINUMUM_RESERVE_CREDITS) {
451
+			return false;
452
+	}
453
+	//Only do non-oppurtunistic UNO if we have the money to do it properly!
470 454
 
471 455
 	foreach ($hardwareArray as $hardwareArrayID) {
472 456
 		if (!$ship->hasMaxHardware($hardwareArrayID)) {
@@ -556,8 +540,10 @@  discard block
 block discarded – undo
556 540
 
557 541
 function checkForShipUpgrade(AbstractSmrPlayer $player) {
558 542
 	foreach (SHIP_UPGRADE_PATH[$player->getRaceID()] as $upgradeShipID) {
559
-		if ($player->getShipTypeID() == $upgradeShipID) //We can't upgrade, only downgrade.
543
+		if ($player->getShipTypeID() == $upgradeShipID) {
544
+			//We can't upgrade, only downgrade.
560 545
 			return false;
546
+		}
561 547
 		$cost = $player->getShip()->getCostToUpgrade($upgradeShipID);
562 548
 		if ($cost <= 0 || $player->getCredits() - $cost > MINUMUM_RESERVE_CREDITS) {
563 549
 			return doShipUpgrade($player, $upgradeShipID);
@@ -579,8 +565,9 @@  discard block
 block discarded – undo
579 565
 
580 566
 function &changeRoute(array &$tradeRoutes) {
581 567
 	$false = false;
582
-	if (count($tradeRoutes) == 0)
583
-		return $false;
568
+	if (count($tradeRoutes) == 0) {
569
+			return $false;
570
+	}
584 571
 	$routeKey = array_rand($tradeRoutes);
585 572
 	$tradeRoute =& $tradeRoutes[$routeKey];
586 573
 	unset($tradeRoutes[$routeKey]);
@@ -594,10 +581,11 @@  discard block
 block discarded – undo
594 581
 
595 582
 	$tradeGoods = array(GOOD_NOTHING => false);
596 583
 	foreach (Globals::getGoods() as $goodID => $good) {
597
-		if ($player->meetsAlignmentRestriction($good['AlignRestriction']))
598
-			$tradeGoods[$goodID] = true;
599
-		else
600
-			$tradeGoods[$goodID] = false;
584
+		if ($player->meetsAlignmentRestriction($good['AlignRestriction'])) {
585
+					$tradeGoods[$goodID] = true;
586
+		} else {
587
+					$tradeGoods[$goodID] = false;
588
+		}
601 589
 	}
602 590
 	$tradeRaces = array();
603 591
 	foreach (Globals::getRaces() as $raceID => $race) {
@@ -624,8 +612,7 @@  discard block
 block discarded – undo
624 612
 		$routes = unserialize(gzuncompress($db->getField('routes')));
625 613
 		debug('Using Cached Routes: #' . count($routes));
626 614
 		return $routes;
627
-	}
628
-	else {
615
+	} else {
629 616
 		debug('Generating Routes');
630 617
 		$allSectors = array();
631 618
 		foreach (SmrGalaxy::getGameGalaxies($player->getGameID()) as $galaxy) {
@@ -635,10 +622,11 @@  discard block
 block discarded – undo
635 622
 		$distances =& Plotter::calculatePortToPortDistances($allSectors, $maxDistance, $startSectorID, $endSectorID);
636 623
 
637 624
 
638
-		if ($maxNumberOfPorts == 1)
639
-			$allRoutes = RouteGenerator::generateOneWayRoutes($allSectors, $distances, $tradeGoods, $tradeRaces, $routesForPort);
640
-		else
641
-			$allRoutes = RouteGenerator::generateMultiPortRoutes($maxNumberOfPorts, $allSectors, $tradeGoods, $tradeRaces, $distances, $routesForPort, $numberOfRoutes);
625
+		if ($maxNumberOfPorts == 1) {
626
+					$allRoutes = RouteGenerator::generateOneWayRoutes($allSectors, $distances, $tradeGoods, $tradeRaces, $routesForPort);
627
+		} else {
628
+					$allRoutes = RouteGenerator::generateMultiPortRoutes($maxNumberOfPorts, $allSectors, $tradeGoods, $tradeRaces, $distances, $routesForPort, $numberOfRoutes);
629
+		}
642 630
 
643 631
 		unset($distances);
644 632
 
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 
115 115
 		$actions++;
116 116
 		try {
117
-			$TRADE_ROUTE =& $GLOBALS['TRADE_ROUTE'];
117
+			$TRADE_ROUTE = & $GLOBALS['TRADE_ROUTE'];
118 118
 			debug('Action #' . $actions);
119 119
 
120 120
 			//We have to reload player on each loop
@@ -133,14 +133,14 @@  discard block
 block discarded – undo
133 133
 			}
134 134
 
135 135
 			if (!isset($TRADE_ROUTE)) { //We only want to change trade route if there isn't already one set.
136
-				$TRADE_ROUTES =& findRoutes($player);
137
-				$TRADE_ROUTE =& changeRoute($TRADE_ROUTES);
136
+				$TRADE_ROUTES = & findRoutes($player);
137
+				$TRADE_ROUTE = & changeRoute($TRADE_ROUTES);
138 138
 			}
139 139
 
140 140
 			if ($player->isDead()) {
141 141
 				debug('Some evil person killed us, let\'s move on now.');
142 142
 				$previousContainer = null; //We died, we don't care what we were doing beforehand.
143
-				$TRADE_ROUTE =& changeRoute($TRADE_ROUTES); //Change route
143
+				$TRADE_ROUTE = & changeRoute($TRADE_ROUTES); //Change route
144 144
 				processContainer(create_container('death_processing.php'));
145 145
 			}
146 146
 			if ($player->getNewbieTurns() <= NEWBIE_TURNS_WARNING_LIMIT && $player->getNewbieWarning()) {
@@ -205,16 +205,16 @@  discard block
 block discarded – undo
205 205
 			}
206 206
 			else if ($TRADE_ROUTE instanceof Route) {
207 207
 				debug('Trade Route');
208
-				$forwardRoute =& $TRADE_ROUTE->getForwardRoute();
209
-				$returnRoute =& $TRADE_ROUTE->getReturnRoute();
208
+				$forwardRoute = & $TRADE_ROUTE->getForwardRoute();
209
+				$returnRoute = & $TRADE_ROUTE->getReturnRoute();
210 210
 				if ($forwardRoute->getBuySectorId() == $player->getSectorID() || $returnRoute->getBuySectorId() == $player->getSectorID()) {
211 211
 					if ($forwardRoute->getBuySectorId() == $player->getSectorID()) {
212
-						$buyRoute =& $forwardRoute;
213
-						$sellRoute =& $returnRoute;
212
+						$buyRoute = & $forwardRoute;
213
+						$sellRoute = & $returnRoute;
214 214
 					}
215 215
 					else if ($returnRoute->getBuySectorId() == $player->getSectorID()) {
216
-						$buyRoute =& $returnRoute;
217
-						$sellRoute =& $forwardRoute;
216
+						$buyRoute = & $returnRoute;
217
+						$sellRoute = & $forwardRoute;
218 218
 					}
219 219
 
220 220
 					$ship = $player->getShip();
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 							}
233 233
 							else {
234 234
 								//Move to next route or fed.
235
-								if (($TRADE_ROUTE =& changeRoute($TRADE_ROUTES)) === false) {
235
+								if (($TRADE_ROUTE = & changeRoute($TRADE_ROUTES)) === false) {
236 236
 									debug('Changing Route Failed');
237 237
 									processContainer(plotToFed($player));
238 238
 								}
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 						}
265 265
 						else {
266 266
 							//Move to next route or fed.
267
-							if (($TRADE_ROUTE =& changeRoute($TRADE_ROUTES)) === false) {
267
+							if (($TRADE_ROUTE = & changeRoute($TRADE_ROUTES)) === false) {
268 268
 								debug('Changing Route Failed');
269 269
 								processContainer(plotToFed($player));
270 270
 							}
@@ -591,9 +591,9 @@  discard block
 block discarded – undo
591 591
 	if (count($tradeRoutes) == 0)
592 592
 		return $false;
593 593
 	$routeKey = array_rand($tradeRoutes);
594
-	$tradeRoute =& $tradeRoutes[$routeKey];
594
+	$tradeRoute = & $tradeRoutes[$routeKey];
595 595
 	unset($tradeRoutes[$routeKey]);
596
-	$GLOBALS['TRADE_ROUTE'] =& $tradeRoute;
596
+	$GLOBALS['TRADE_ROUTE'] = & $tradeRoute;
597 597
 	debug('Switched route', $tradeRoute);
598 598
 	return $tradeRoute;
599 599
 }
@@ -641,7 +641,7 @@  discard block
 block discarded – undo
641 641
 			$allSectors += $galaxy->getSectors(); //Merge arrays
642 642
 		}
643 643
 
644
-		$distances =& Plotter::calculatePortToPortDistances($allSectors, $maxDistance, $startSectorID, $endSectorID);
644
+		$distances = & Plotter::calculatePortToPortDistances($allSectors, $maxDistance, $startSectorID, $endSectorID);
645 645
 
646 646
 
647 647
 		if ($maxNumberOfPorts == 1)
@@ -651,7 +651,7 @@  discard block
 block discarded – undo
651 651
 
652 652
 		unset($distances);
653 653
 
654
-		$allRoutes =& $allRoutes[RouteGenerator::EXP_ROUTE];
654
+		$allRoutes = & $allRoutes[RouteGenerator::EXP_ROUTE];
655 655
 		$routesMerged = array();
656 656
 		foreach ($allRoutes as $multi => &$routesByMulti) {
657 657
 			$routesMerged += $routesByMulti; //Merge arrays
Please login to merge, or discard this patch.
admin/Default/1.6/universe_create_save_processing.php 1 patch
Braces   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -19,21 +19,19 @@  discard block
 block discarded – undo
19 19
 	}
20 20
 	SmrSector::saveSectors();
21 21
 	$var['message'] = '<span class="green">Success</span> : Succesfully created galaxies.';
22
-}
23
-else if ($submit == 'Redo Connections') {
22
+} else if ($submit == 'Redo Connections') {
24 23
 	$galaxy = SmrGalaxy::getGalaxy($var['game_id'], $var['gal_on']);
25
-	if (!$galaxy->setConnectivity($_REQUEST['connect']))
26
-		$var['message'] = '<span class="red">Error</span> : Regenerating connections failed.';
27
-	else
28
-		$var['message'] = '<span class="green">Success</span> : Regenerated connectivity with ' . $_REQUEST['connect'] . '% target.';
24
+	if (!$galaxy->setConnectivity($_REQUEST['connect'])) {
25
+			$var['message'] = '<span class="red">Error</span> : Regenerating connections failed.';
26
+	} else {
27
+			$var['message'] = '<span class="green">Success</span> : Regenerated connectivity with ' . $_REQUEST['connect'] . '% target.';
28
+	}
29 29
 	SmrSector::saveSectors();
30
-}
31
-elseif ($submit == 'Toggle Link') {
30
+} elseif ($submit == 'Toggle Link') {
32 31
 	$linkSector = SmrSector::getSector($var['game_id'], $var['sector_id']);
33 32
 	$linkSector->toggleLink($var['dir']);
34 33
 	SmrSector::saveSectors();
35
-}
36
-elseif ($submit == 'Create Locations') {
34
+} elseif ($submit == 'Create Locations') {
37 35
 	$galSectors = SmrSector::getGalaxySectors($var['game_id'], $var['gal_on']);
38 36
 	foreach ($galSectors as $galSector) {
39 37
 		$galSector->removeAllLocations();
@@ -53,8 +51,7 @@  discard block
 block discarded – undo
53 51
 		}
54 52
 	}
55 53
 	$var['message'] = '<span class="green">Success</span> : Succesfully added locations.';
56
-}
57
-elseif ($submit == 'Create Warps') {
54
+} elseif ($submit == 'Create Warps') {
58 55
 	//get all warp info from all gals, some need to be removed, some need to be added
59 56
 	$galaxy = SmrGalaxy::getGalaxy($var['game_id'], $var['gal_on']);
60 57
 	$galSectors = $galaxy->getSectors();
@@ -94,8 +91,7 @@  discard block
 block discarded – undo
94 91
 	}
95 92
 	SmrSector::saveSectors();
96 93
 	$var['message'] = '<span class="green">Success</span> : Succesfully added warps.';
97
-}
98
-elseif ($submit == 'Create Planets') {
94
+} elseif ($submit == 'Create Planets') {
99 95
 	$galaxy = SmrGalaxy::getGalaxy($var['game_id'], $var['gal_on']);
100 96
 	$galSectors = $galaxy->getSectors();
101 97
 	foreach ($galSectors as $galSector) {
@@ -108,13 +104,15 @@  discard block
 block discarded – undo
108 104
 		$numberOfPlanets = $_POST['type' . $planetTypeID];
109 105
 		for ($i = 1; $i <= $numberOfPlanets; $i++) {
110 106
 			$galSector = $galSectors[array_rand($galSectors)];
111
-			while ($galSector->hasPlanet()) $galSector = $galSectors[array_rand($galSectors)]; //1 per sector
107
+			while ($galSector->hasPlanet()) {
108
+				$galSector = $galSectors[array_rand($galSectors)];
109
+			}
110
+			//1 per sector
112 111
 			$galSector->createPlanet($planetTypeID);
113 112
 		}
114 113
 	}
115 114
 	$var['message'] = '<span class="green">Success</span> : Succesfully added planets.';
116
-}
117
-elseif ($submit == 'Create Ports') {
115
+} elseif ($submit == 'Create Ports') {
118 116
 	$numLevelPorts = [];
119 117
 	for ($i = 1; $i <= SmrPort::MAX_LEVEL; $i++) {
120 118
 		$numLevelPorts[$i] = $_REQUEST['port' . $i] ?? 0;
@@ -169,27 +167,23 @@  discard block
 block discarded – undo
169 167
 		}
170 168
 		SmrPort::savePorts();
171 169
 		$var['message'] = '<span class="green">Success</span> : Succesfully added ports.';
172
-	}
173
-	else {
170
+	} else {
174 171
 		$var['message'] = '<span class="red">Error: Your port race distribution must equal 100!</span>';
175 172
 	}
176
-}
177
-elseif ($submit == 'Edit Sector') {
173
+} elseif ($submit == 'Edit Sector') {
178 174
 	$editSector = SmrSector::getSector($var['game_id'], $var['sector_id']);
179 175
 
180 176
 	//update planet
181 177
 	if ($_POST['plan_type'] != '0') {
182 178
 		if (!$editSector->hasPlanet()) {
183 179
 			$editSector->createPlanet($_POST['plan_type']);
184
-		}
185
-		else {
180
+		} else {
186 181
 			$type = $editSector->getPlanet()->getTypeID();
187 182
 			if ($_POST['plan_type'] != $type) {
188 183
 				$editSector->getPlanet()->setTypeID($_POST['plan_type']);
189 184
 			}
190 185
 		}
191
-	}
192
-	else {
186
+	} else {
193 187
 		$editSector->removePlanet();
194 188
 	}
195 189
 
@@ -228,10 +222,11 @@  discard block
 block discarded – undo
228 222
 	for ($x = 0; $x < UNI_GEN_LOCATION_SLOTS; $x++) {
229 223
 		if ($_POST['loc_type' . $x] != 0) {
230 224
 			$locationToAdd = SmrLocation::getLocation($_POST['loc_type' . $x]);
231
-			if ($editSector->hasLocation($locationToAdd->getTypeID()))
232
-				$locationsToKeep[] = $locationToAdd;
233
-			else
234
-				$locationsToAdd[] = $locationToAdd;
225
+			if ($editSector->hasLocation($locationToAdd->getTypeID())) {
226
+							$locationsToKeep[] = $locationToAdd;
227
+			} else {
228
+							$locationsToAdd[] = $locationToAdd;
229
+			}
235 230
 		}
236 231
 	}
237 232
 	$editSector->removeAllLocations();
@@ -265,8 +260,7 @@  discard block
 block discarded – undo
265 260
 function checkSectorAllowedForLoc(SmrSector $sector, SmrLocation $location) {
266 261
 	if (!$location->isHQ()) {
267 262
 		return (count($sector->getLocations()) < 4 && !$sector->offersFederalProtection());
268
-	}
269
-	else {
263
+	} else {
270 264
 		//HQs are here
271 265
 		//find a sector where there are no locations yet
272 266
 		return !$sector->hasLocation();
@@ -274,8 +268,9 @@  discard block
 block discarded – undo
274 268
 }
275 269
 
276 270
 function addLocationToSector(SmrLocation $location, SmrSector $sector) {
277
-	if ($sector->hasLocation($location->getTypeID()))
278
-		return false;
271
+	if ($sector->hasLocation($location->getTypeID())) {
272
+			return false;
273
+	}
279 274
 
280 275
 	$sector->addLocation($location); //insert the location
281 276
 	if ($location->isHQ()) {
@@ -283,13 +278,16 @@  discard block
 block discarded – undo
283 278
 		//Racial/Fed
284 279
 		foreach ($location->getLinkedLocations() as $linkedLocation) {
285 280
 			$sector->addLocation($linkedLocation);
286
-			if ($linkedLocation->isFed())
287
-				$fedBeacon = $linkedLocation;
281
+			if ($linkedLocation->isFed()) {
282
+							$fedBeacon = $linkedLocation;
283
+			}
288 284
 		}
289 285
 			
290 286
 		//add Beacons to all surrounding areas (up to 2 sectors out)
291
-		if (!$sector->offersFederalProtection())
292
-			$sector->addLocation($fedBeacon); //add beacon to this sector
287
+		if (!$sector->offersFederalProtection()) {
288
+					$sector->addLocation($fedBeacon);
289
+		}
290
+		//add beacon to this sector
293 291
 		$visitedSectors = array();
294 292
 		$links = array('Up', 'Right', 'Down', 'Left');
295 293
 		$fedSectors = array($sector);
@@ -299,8 +297,10 @@  discard block
 block discarded – undo
299 297
 				foreach ($links as $link) {
300 298
 					if ($fedSector->hasLink($link) && !isset($visitedSectors[$fedSector->getLink($link)])) {
301 299
 						$linkSector = $sector->getLinkSector($link);
302
-						if (!$linkSector->offersFederalProtection())
303
-							$linkSector->addLocation($fedBeacon); //add beacon to this sector
300
+						if (!$linkSector->offersFederalProtection()) {
301
+													$linkSector->addLocation($fedBeacon);
302
+						}
303
+						//add beacon to this sector
304 304
 						$tempFedSectors[] = $linkSector;
305 305
 						$visitedSectors[$fedSector->getLink($link)] = true;
306 306
 					}
Please login to merge, or discard this patch.
engine/Default/shop_goods_processing.php 1 patch
Braces   +36 added lines, -23 removed lines patch added patch discarded remove patch
@@ -5,59 +5,73 @@  discard block
 block discarded – undo
5 5
 $amount = get_amount();
6 6
 $bargain_price = get_bargain_price();
7 7
 
8
-if (!is_numeric($amount) || !is_numeric($bargain_price))
8
+if (!is_numeric($amount) || !is_numeric($bargain_price)) {
9 9
 	create_error('Numbers only please!');
10
+}
10 11
 // get good name, id, ...
11 12
 $good_id = $var['good_id'];
12 13
 $good_name = Globals::getGoodName($good_id);
13 14
 
14 15
 // do we have enough turns?
15
-if ($player->getTurns() == 0)
16
+if ($player->getTurns() == 0) {
16 17
 	create_error('You don\'t have enough turns to trade.');
18
+}
17 19
 
18 20
 // get rid of those bugs when we die...there is no port at the home sector
19
-if (!$sector->hasPort())
21
+if (!$sector->hasPort()) {
20 22
 	create_error('I can\'t see a port in this sector. Can you?');
23
+}
21 24
 $port = $sector->getPort();
22 25
 
23 26
 // check if the player has the right relations to trade at the current port
24
-if ($player->getRelation($port->getRaceID()) < RELATIONS_WAR)
27
+if ($player->getRelation($port->getRaceID()) < RELATIONS_WAR) {
25 28
 	create_error('This port refuses to trade with you because you are at <span class="big bold red">WAR!</span>');
29
+}
26 30
 
27 31
 // does the port actually buy or sell this good?
28 32
 $transaction = $port->getGoodTransaction($good_id);
29
-if (empty($transaction))
33
+if (empty($transaction)) {
30 34
 	create_error('I don\'t trade in that good.');
35
+}
31 36
 
32 37
 $portGood = $port->getGood($good_id);
33 38
 // check if there are enough left at port
34
-if ($port->getGoodAmount($good_id) < $amount)
39
+if ($port->getGoodAmount($good_id) < $amount) {
35 40
 	create_error('I\'m short of ' . $good_name . '. So I\'m not going to sell you ' . $amount . ' pcs.');
41
+}
36 42
 
37 43
 // does we have what we are going to sell?
38
-if ($transaction == 'Sell' && $amount > $ship->getCargo($good_id))
44
+if ($transaction == 'Sell' && $amount > $ship->getCargo($good_id)) {
39 45
 	create_error('Scanning your ships indicates you don\'t have ' . $amount . ' pcs. of ' . $good_name . '!');
46
+}
40 47
 
41 48
 // check if we have enough room for the thing we are going to buy
42
-if ($transaction == 'Buy' && $amount > $ship->getEmptyHolds())
49
+if ($transaction == 'Buy' && $amount > $ship->getEmptyHolds()) {
43 50
 	create_error('Scanning your ships indicates you don\'t have enough free cargo bays!');
51
+}
44 52
 
45 53
 // check if the guy has enough money
46
-if ($transaction == 'Buy' && $player->getCredits() < $bargain_price)
54
+if ($transaction == 'Buy' && $player->getCredits() < $bargain_price) {
47 55
 	create_error('You don\'t have enough credits!');
56
+}
48 57
 
49 58
 // get relations for us (global + personal)
50 59
 $relations = $player->getRelation($port->getRaceID());
51 60
 
52
-if (!isset($var['ideal_price'])) SmrSession::updateVar('ideal_price', $port->getIdealPrice($good_id, $transaction, $amount, $relations));
61
+if (!isset($var['ideal_price'])) {
62
+	SmrSession::updateVar('ideal_price', $port->getIdealPrice($good_id, $transaction, $amount, $relations));
63
+}
53 64
 $ideal_price = $var['ideal_price'];
54 65
 
55
-if (!isset($var['offered_price'])) SmrSession::updateVar('offered_price', $port->getOfferPrice($ideal_price, $relations, $transaction));
66
+if (!isset($var['offered_price'])) {
67
+	SmrSession::updateVar('offered_price', $port->getOfferPrice($ideal_price, $relations, $transaction));
68
+}
56 69
 $offered_price = $var['offered_price'];
57 70
 
58 71
 // nothing should happen here but just to avoid / by 0
59
-if ($ideal_price == 0 || $offered_price == 0)
72
+if ($ideal_price == 0 || $offered_price == 0) {
60 73
 	create_error('Port calculation error...buy more goods.');
74
+}
61 75
 
62 76
 if ($_REQUEST['action'] == 'Steal') {
63 77
 	if (!$ship->isUnderground()) {
@@ -109,8 +123,7 @@  discard block
 block discarded – undo
109 123
 		$player->increaseHOF($bargain_price, array('Trade', 'Money', 'Buying'), HOF_PUBLIC);
110 124
 		$port->buyGoods($portGood, $amount, $ideal_price, $bargain_price, $gained_exp);
111 125
 		$player->increaseRelationsByTrade($amount, $port->getRaceID());
112
-	}
113
-	elseif ($transaction == 'Sell') {
126
+	} elseif ($transaction == 'Sell') {
114 127
 		$msg_transaction = 'sold';
115 128
 		$ship->decreaseCargo($good_id, $amount);
116 129
 		$player->increaseCredits($bargain_price);
@@ -120,8 +133,7 @@  discard block
 block discarded – undo
120 133
 		$player->increaseHOF($bargain_price, array('Trade', 'Money', 'Selling'), HOF_PUBLIC);
121 134
 		$port->sellGoods($portGood, $amount, $ideal_price, $bargain_price, $gained_exp);
122 135
 		$player->increaseRelationsByTrade($amount, $port->getRaceID());
123
-	}
124
-	elseif ($transaction == 'Steal') {
136
+	} elseif ($transaction == 'Steal') {
125 137
 		$msg_transaction = 'stolen';
126 138
 		$ship->increaseCargo($good_id, $amount);
127 139
 		$player->increaseHOF($amount, array('Trade', 'Goods', 'Stolen'), HOF_ALLIANCE);
@@ -151,13 +163,13 @@  discard block
 block discarded – undo
151 163
 
152 164
 	$container['trade_msg'] = $tradeMessage;
153 165
 
154
-	if ($ship->getEmptyHolds() == 0)
155
-		$container['body'] = 'current_sector.php';
156
-	else
157
-		$container['body'] = 'shop_goods.php';
166
+	if ($ship->getEmptyHolds() == 0) {
167
+			$container['body'] = 'current_sector.php';
168
+	} else {
169
+			$container['body'] = 'shop_goods.php';
170
+	}
158 171
 
159
-}
160
-else {
172
+} else {
161 173
 	// does the trader try to outsmart us?
162 174
 	$container = create_container('skeleton.php', 'shop_goods_trade.php');
163 175
 	transfer('ideal_price');
@@ -172,8 +184,9 @@  discard block
 block discarded – undo
172 184
 }
173 185
 
174 186
 // only take turns if they bargained
175
-if (!isset($container['number_of_bargains']) || $container['number_of_bargains'] != 1)
187
+if (!isset($container['number_of_bargains']) || $container['number_of_bargains'] != 1) {
176 188
 	$player->takeTurns(TURNS_PER_TRADE, TURNS_PER_TRADE);
189
+}
177 190
 
178 191
 // go to next page
179 192
 forward($container);
Please login to merge, or discard this patch.
lib/Default/PlayingCard.class.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -44,8 +44,8 @@
 block discarded – undo
44 44
 	 */
45 45
 	public function getValue() {
46 46
 		if ($this->rankID == self::RANK_JACK ||
47
-		    $this->rankID == self::RANK_QUEEN ||
48
-		    $this->rankID == self::RANK_KING) {
47
+			$this->rankID == self::RANK_QUEEN ||
48
+			$this->rankID == self::RANK_KING) {
49 49
 			return 10;
50 50
 		} elseif ($this->isAce()) {
51 51
 			return 11;
Please login to merge, or discard this patch.
lib/Default/AbstractSmrPlayer.class.php 3 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -242,9 +242,9 @@
 block discarded – undo
242 242
 	 */
243 243
 	public function canFight() {
244 244
 		return !($this->hasNewbieTurns() ||
245
-		         $this->isDead() ||
246
-		         $this->isLandedOnPlanet() ||
247
-		         $this->hasFederalProtection());
245
+				 $this->isDead() ||
246
+				 $this->isLandedOnPlanet() ||
247
+				 $this->hasFederalProtection());
248 248
 	}
249 249
 
250 250
 	public function setDead($bool) {
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -896,8 +896,8 @@  discard block
 block discarded – undo
896 896
 		}
897 897
 		self::$HOFVis[$hofType] = $visibility;
898 898
 
899
-		$hof =& $this->HOF;
900
-		$hofChanged =& $this->hasHOFChanged;
899
+		$hof = & $this->HOF;
900
+		$hofChanged = & $this->hasHOFChanged;
901 901
 		$new = false;
902 902
 		foreach ($typeList as $type) {
903 903
 			if (!isset($hofChanged[$type]))
@@ -906,8 +906,8 @@  discard block
 block discarded – undo
906 906
 				$hof[$type] = array();
907 907
 				$new = true;
908 908
 			}
909
-			$hof =& $hof[$type];
910
-			$hofChanged =& $hofChanged[$type];
909
+			$hof = & $hof[$type];
910
+			$hofChanged = & $hofChanged[$type];
911 911
 		}
912 912
 		if ($hofChanged == null) {
913 913
 			$hofChanged = self::HOF_CHANGED;
@@ -1059,7 +1059,7 @@  discard block
 block discarded – undo
1059 1059
 	}
1060 1060
 
1061 1061
 	private function setupMissionStep($missionID) {
1062
-		$mission =& $this->missions[$missionID];
1062
+		$mission = & $this->missions[$missionID];
1063 1063
 		if ($mission['On Step'] >= count(MISSIONS[$missionID]['Steps'])) {
1064 1064
 			// Nothing to do if this mission is already completed
1065 1065
 			return;
@@ -1103,7 +1103,7 @@  discard block
 block discarded – undo
1103 1103
 			'Starting Sector' => $this->getSectorID()
1104 1104
 		);
1105 1105
 
1106
-		$this->missions[$missionID] =& $mission;
1106
+		$this->missions[$missionID] = & $mission;
1107 1107
 		$this->setupMissionStep($missionID);
1108 1108
 		$this->rebuildMission($missionID);
1109 1109
 
@@ -1162,7 +1162,7 @@  discard block
 block discarded – undo
1162 1162
 
1163 1163
 	public function claimMissionReward($missionID) {
1164 1164
 		$this->getMissions();
1165
-		$mission =& $this->missions[$missionID];
1165
+		$mission = & $this->missions[$missionID];
1166 1166
 		if ($mission === false) {
1167 1167
 			throw new Exception('Unknown mission: ' . $missionID);
1168 1168
 		}
Please login to merge, or discard this patch.
Braces   +220 added lines, -151 removed lines patch added patch discarded remove patch
@@ -77,8 +77,9 @@  discard block
 block discarded – undo
77 77
 		return $this->getNewbieTurns() > 0;
78 78
 	}
79 79
 	public function setNewbieTurns($newbieTurns) {
80
-		if ($this->newbieTurns == $newbieTurns)
81
-			return;
80
+		if ($this->newbieTurns == $newbieTurns) {
81
+					return;
82
+		}
82 83
 		$this->newbieTurns = $newbieTurns;
83 84
 		$this->hasChanged = true;
84 85
 	}
@@ -88,8 +89,9 @@  discard block
 block discarded – undo
88 89
 	}
89 90
 
90 91
 	public function setShipTypeID($shipID) {
91
-		if ($this->shipID == $shipID)
92
-			return;
92
+		if ($this->shipID == $shipID) {
93
+					return;
94
+		}
93 95
 		$this->shipID = $shipID;
94 96
 		$this->hasChanged = true;
95 97
 	}
@@ -199,8 +201,9 @@  discard block
 block discarded – undo
199 201
 		}
200 202
 
201 203
 		$ship = $this->getShip();
202
-		if ($ship->hasIllegalGoods())
203
-			return false;
204
+		if ($ship->hasIllegalGoods()) {
205
+					return false;
206
+		}
204 207
 
205 208
 		if ($ship->getAttackRating() <= $this->getSafeAttackRating()) {
206 209
 			foreach ($sector->getFedRaceIDs() as $fedRaceID) {
@@ -241,8 +244,9 @@  discard block
 block discarded – undo
241 244
 	}
242 245
 
243 246
 	public function setDead($bool) {
244
-		if ($this->dead == $bool)
245
-			return;
247
+		if ($this->dead == $bool) {
248
+					return;
249
+		}
246 250
 		$this->dead = $bool;
247 251
 		$this->hasChanged = true;
248 252
 	}
@@ -252,14 +256,16 @@  discard block
 block discarded – undo
252 256
 	}
253 257
 
254 258
 	public function increaseKills($kills) {
255
-		if ($kills < 0)
256
-			throw new Exception('Trying to increase negative kills.');
259
+		if ($kills < 0) {
260
+					throw new Exception('Trying to increase negative kills.');
261
+		}
257 262
 		$this->setKills($this->kills + $kills);
258 263
 	}
259 264
 
260 265
 	public function setKills($kills) {
261
-		if ($this->kills == $kills)
262
-			return;
266
+		if ($this->kills == $kills) {
267
+					return;
268
+		}
263 269
 		$this->kills = $kills;
264 270
 		$this->hasChanged = true;
265 271
 	}
@@ -269,14 +275,16 @@  discard block
 block discarded – undo
269 275
 	}
270 276
 
271 277
 	public function increaseDeaths($deaths) {
272
-		if ($deaths < 0)
273
-			throw new Exception('Trying to increase negative deaths.');
278
+		if ($deaths < 0) {
279
+					throw new Exception('Trying to increase negative deaths.');
280
+		}
274 281
 		$this->setDeaths($this->getDeaths() + $deaths);
275 282
 	}
276 283
 
277 284
 	public function setDeaths($deaths) {
278
-		if ($this->deaths == $deaths)
279
-			return;
285
+		if ($this->deaths == $deaths) {
286
+					return;
287
+		}
280 288
 		$this->deaths = $deaths;
281 289
 		$this->hasChanged = true;
282 290
 	}
@@ -298,24 +306,29 @@  discard block
 block discarded – undo
298 306
 	}
299 307
 
300 308
 	public function increaseAlignment($align) {
301
-		if ($align < 0)
302
-			throw new Exception('Trying to increase negative align.');
303
-		if ($align == 0)
304
-			return;
309
+		if ($align < 0) {
310
+					throw new Exception('Trying to increase negative align.');
311
+		}
312
+		if ($align == 0) {
313
+					return;
314
+		}
305 315
 		$align += $this->alignment;
306 316
 		$this->setAlignment($align);
307 317
 	}
308 318
 	public function decreaseAlignment($align) {
309
-		if ($align < 0)
310
-			throw new Exception('Trying to decrease negative align.');
311
-		if ($align == 0)
312
-			return;
319
+		if ($align < 0) {
320
+					throw new Exception('Trying to decrease negative align.');
321
+		}
322
+		if ($align == 0) {
323
+					return;
324
+		}
313 325
 		$align = $this->alignment - $align;
314 326
 		$this->setAlignment($align);
315 327
 	}
316 328
 	public function setAlignment($align) {
317
-		if ($this->alignment == $align)
318
-			return;
329
+		if ($this->alignment == $align) {
330
+					return;
331
+		}
319 332
 		$this->alignment = $align;
320 333
 		$this->hasChanged = true;
321 334
 	}
@@ -329,8 +342,9 @@  discard block
 block discarded – undo
329 342
 	}
330 343
 
331 344
 	public function getNextLevelPercentAcquired() {
332
-		if ($this->getNextLevelExperience() == $this->getThisLevelExperience())
333
-			return 100;
345
+		if ($this->getNextLevelExperience() == $this->getThisLevelExperience()) {
346
+					return 100;
347
+		}
334 348
 		return max(0, min(100, round(($this->getExperience() - $this->getThisLevelExperience()) / ($this->getNextLevelExperience() - $this->getThisLevelExperience()) * 100)));
335 349
 	}
336 350
 
@@ -340,8 +354,10 @@  discard block
 block discarded – undo
340 354
 
341 355
 	public function getNextLevelExperience() {
342 356
 		$LEVELS_REQUIREMENTS = Globals::getLevelRequirements();
343
-		if (!isset($LEVELS_REQUIREMENTS[$this->getLevelID() + 1]))
344
-			return $this->getThisLevelExperience(); //Return current level experience if on last level.
357
+		if (!isset($LEVELS_REQUIREMENTS[$this->getLevelID() + 1])) {
358
+					return $this->getThisLevelExperience();
359
+		}
360
+		//Return current level experience if on last level.
345 361
 		return $LEVELS_REQUIREMENTS[$this->getLevelID() + 1]['Requirement'];
346 362
 	}
347 363
 
@@ -351,12 +367,15 @@  discard block
 block discarded – undo
351 367
 	}
352 368
 
353 369
 	public function setExperience($experience) {
354
-		if ($this->experience == $experience)
355
-			return;
356
-		if ($experience < MIN_EXPERIENCE)
357
-			$experience = MIN_EXPERIENCE;
358
-		if ($experience > MAX_EXPERIENCE)
359
-			$experience = MAX_EXPERIENCE;
370
+		if ($this->experience == $experience) {
371
+					return;
372
+		}
373
+		if ($experience < MIN_EXPERIENCE) {
374
+					$experience = MIN_EXPERIENCE;
375
+		}
376
+		if ($experience > MAX_EXPERIENCE) {
377
+					$experience = MAX_EXPERIENCE;
378
+		}
360 379
 		$this->experience = $experience;
361 380
 		$this->hasChanged = true;
362 381
 
@@ -366,46 +385,57 @@  discard block
 block discarded – undo
366 385
 	}
367 386
 
368 387
 	public function increaseCredits($credits) {
369
-		if ($credits < 0)
370
-			throw new Exception('Trying to increase negative credits.');
371
-		if ($credits == 0)
372
-			return;
388
+		if ($credits < 0) {
389
+					throw new Exception('Trying to increase negative credits.');
390
+		}
391
+		if ($credits == 0) {
392
+					return;
393
+		}
373 394
 		$credits += $this->credits;
374 395
 		$this->setCredits($credits);
375 396
 	}
376 397
 	public function decreaseCredits($credits) {
377
-		if ($credits < 0)
378
-			throw new Exception('Trying to decrease negative credits.');
379
-		if ($credits == 0)
380
-			return;
398
+		if ($credits < 0) {
399
+					throw new Exception('Trying to decrease negative credits.');
400
+		}
401
+		if ($credits == 0) {
402
+					return;
403
+		}
381 404
 		$credits = $this->credits - $credits;
382 405
 		$this->setCredits($credits);
383 406
 	}
384 407
 	public function setCredits($credits) {
385
-		if ($this->credits == $credits)
386
-			return;
387
-		if ($credits < 0)
388
-			throw new Exception('Trying to set negative credits.');
389
-		if ($credits > MAX_MONEY)
390
-			$credits = MAX_MONEY;
408
+		if ($this->credits == $credits) {
409
+					return;
410
+		}
411
+		if ($credits < 0) {
412
+					throw new Exception('Trying to set negative credits.');
413
+		}
414
+		if ($credits > MAX_MONEY) {
415
+					$credits = MAX_MONEY;
416
+		}
391 417
 		$this->credits = $credits;
392 418
 		$this->hasChanged = true;
393 419
 	}
394 420
 
395 421
 	public function increaseExperience($experience) {
396
-		if ($experience < 0)
397
-			throw new Exception('Trying to increase negative experience.');
398
-		if ($experience == 0)
399
-			return;
422
+		if ($experience < 0) {
423
+					throw new Exception('Trying to increase negative experience.');
424
+		}
425
+		if ($experience == 0) {
426
+					return;
427
+		}
400 428
 		$newExperience = $this->experience + $experience;
401 429
 		$this->setExperience($newExperience);
402 430
 		$this->increaseHOF($experience, array('Experience', 'Total', 'Gain'), HOF_PUBLIC);
403 431
 	}
404 432
 	public function decreaseExperience($experience) {
405
-		if ($experience < 0)
406
-			throw new Exception('Trying to decrease negative experience.');
407
-		if ($experience == 0)
408
-			return;
433
+		if ($experience < 0) {
434
+					throw new Exception('Trying to decrease negative experience.');
435
+		}
436
+		if ($experience == 0) {
437
+					return;
438
+		}
409 439
 		$newExperience = $this->experience - $experience;
410 440
 		$this->setExperience($newExperience);
411 441
 		$this->decreaseHOF($experience, array('Experience', 'Total', 'Loss'), HOF_PUBLIC);
@@ -416,8 +446,9 @@  discard block
 block discarded – undo
416 446
 	}
417 447
 
418 448
 	public function setLandedOnPlanet($bool) {
419
-		if ($this->landedOnPlanet == $bool)
420
-			return;
449
+		if ($this->landedOnPlanet == $bool) {
450
+					return;
451
+		}
421 452
 		$this->landedOnPlanet = $bool;
422 453
 		$this->hasChanged = true;
423 454
 	}
@@ -431,7 +462,9 @@  discard block
 block discarded – undo
431 462
 		if ($this->level === null) {
432 463
 			$LEVELS_REQUIREMENTS = Globals::getLevelRequirements();
433 464
 			foreach ($LEVELS_REQUIREMENTS as $level_id => $require) {
434
-				if ($this->getExperience() >= $require['Requirement']) continue;
465
+				if ($this->getExperience() >= $require['Requirement']) {
466
+					continue;
467
+				}
435 468
 				$this->level = $level_id - 1;
436 469
 				return $this->level;
437 470
 			}
@@ -509,8 +542,9 @@  discard block
 block discarded – undo
509 542
 	}
510 543
 
511 544
 	public function setRaceID($raceID) {
512
-		if ($this->raceID == $raceID)
513
-			return;
545
+		if ($this->raceID == $raceID) {
546
+					return;
547
+		}
514 548
 		$this->raceID = $raceID;
515 549
 		$this->hasChanged = true;
516 550
 	}
@@ -532,8 +566,9 @@  discard block
 block discarded – undo
532 566
 	}
533 567
 
534 568
 	protected function setAllianceID($ID) {
535
-		if ($this->allianceID == $ID)
536
-			return;
569
+		if ($this->allianceID == $ID) {
570
+					return;
571
+		}
537 572
 		$this->allianceID = $ID;
538 573
 		if ($this->allianceID != 0) {
539 574
 			$status = $this->hasNewbieStatus() ? 'NEWBIE' : 'VETERAN';
@@ -550,8 +585,7 @@  discard block
 block discarded – undo
550 585
 	public function getAllianceName($linked = false, $includeAllianceID = false) {
551 586
 		if ($this->hasAlliance()) {
552 587
 			return $this->getAlliance()->getAllianceName($linked, $includeAllianceID);
553
-		}
554
-		else {
588
+		} else {
555 589
 			return 'No Alliance';
556 590
 		}
557 591
 	}
@@ -579,8 +613,9 @@  discard block
 block discarded – undo
579 613
 	}
580 614
 
581 615
 	public function setCombatDronesKamikazeOnMines($bool) {
582
-		if ($this->combatDronesKamikazeOnMines == $bool)
583
-			return;
616
+		if ($this->combatDronesKamikazeOnMines == $bool) {
617
+					return;
618
+		}
584 619
 		$this->combatDronesKamikazeOnMines = $bool;
585 620
 		$this->hasChanged = true;
586 621
 	}
@@ -597,15 +632,17 @@  discard block
 block discarded – undo
597 632
 			$gadgetID = $GADGETS[$gadgetID]['ID'];
598 633
 		}
599 634
 		$gadgets = $this->getGadgets();
600
-		if (isset($gadgets[$gadgetID]))
601
-			return $gadgets[$gadgetID];
635
+		if (isset($gadgets[$gadgetID])) {
636
+					return $gadgets[$gadgetID];
637
+		}
602 638
 		return false;
603 639
 	}
604 640
 
605 641
 	public function isGadgetEquipped($gadgetID) {
606 642
 		$gadget = $this->getGadget($gadgetID);
607
-		if ($gadget === false)
608
-			return false;
643
+		if ($gadget === false) {
644
+					return false;
645
+		}
609 646
 		return $gadget['Equipped'] > 0 && $gadget['Equipped'] < TIME && ($gadget['Expires'] == 0 || $gadget['Expires'] > TIME) && $gadget['Cooldown'] <= TIME;
610 647
 	}
611 648
 
@@ -677,21 +714,24 @@  discard block
 block discarded – undo
677 714
 	}
678 715
 
679 716
 	public function setMilitaryPayment($amount) {
680
-		if ($this->militaryPayment == $amount)
681
-			return;
717
+		if ($this->militaryPayment == $amount) {
718
+					return;
719
+		}
682 720
 		$this->militaryPayment = $amount;
683 721
 		$this->hasChanged = true;
684 722
 	}
685 723
 
686 724
 	public function increaseMilitaryPayment($amount) {
687
-		if ($amount < 0)
688
-			throw new Exception('Trying to increase negative military payment.');
725
+		if ($amount < 0) {
726
+					throw new Exception('Trying to increase negative military payment.');
727
+		}
689 728
 		$this->setMilitaryPayment($this->getMilitaryPayment() + $amount);
690 729
 	}
691 730
 
692 731
 	public function decreaseMilitaryPayment($amount) {
693
-		if ($amount < 0)
694
-			throw new Exception('Trying to decrease negative military payment.');
732
+		if ($amount < 0) {
733
+					throw new Exception('Trying to decrease negative military payment.');
734
+		}
695 735
 		$this->setMilitaryPayment($this->getMilitaryPayment() - $amount);
696 736
 	}
697 737
 
@@ -734,10 +774,11 @@  discard block
 block discarded – undo
734 774
 
735 775
 	protected function getNextBountyID() : int {
736 776
 		$keys = array_keys($this->getBounties());
737
-		if (count($keys) > 0)
738
-			return max($keys) + 1;
739
-		else
740
-			return 0;
777
+		if (count($keys) > 0) {
778
+					return max($keys) + 1;
779
+		} else {
780
+					return 0;
781
+		}
741 782
 	}
742 783
 
743 784
 	protected function setBounty(array $bounty) : void {
@@ -752,22 +793,25 @@  discard block
 block discarded – undo
752 793
 	}
753 794
 
754 795
 	public function increaseBountyAmount(int $bountyID, int $amount) : void {
755
-		if ($amount < 0)
756
-			throw new Exception('Trying to increase negative bounty.');
796
+		if ($amount < 0) {
797
+					throw new Exception('Trying to increase negative bounty.');
798
+		}
757 799
 		$this->setBountyAmount($this->getBountyAmount($bountyID) + $amount);
758 800
 	}
759 801
 
760 802
 	public function decreaseBountyAmount(int $bountyID, int $amount) : void {
761
-		if ($amount < 0)
762
-			throw new Exception('Trying to decrease negative bounty.');
803
+		if ($amount < 0) {
804
+					throw new Exception('Trying to decrease negative bounty.');
805
+		}
763 806
 		$this->setBountyAmount($this->getBountyAmount($bountyID) + $amount);
764 807
 	}
765 808
 
766 809
 	public function getCurrentBounty(string $type) : array {
767 810
 		$bounties = $this->getBounties();
768 811
 		foreach ($bounties as $bounty) {
769
-			if ($bounty['Claimer'] == 0 && $bounty['Type'] == $type)
770
-				return $bounty;
812
+			if ($bounty['Claimer'] == 0 && $bounty['Type'] == $type) {
813
+							return $bounty;
814
+			}
771 815
 		}
772 816
 		return $this->createBounty($type);
773 817
 	}
@@ -775,8 +819,9 @@  discard block
 block discarded – undo
775 819
 	public function hasCurrentBounty(string $type) : bool {
776 820
 		$bounties = $this->getBounties();
777 821
 		foreach ($bounties as $bounty) {
778
-			if ($bounty['Claimer'] == 0 && $bounty['Type'] == $type)
779
-				return true;
822
+			if ($bounty['Claimer'] == 0 && $bounty['Type'] == $type) {
823
+							return true;
824
+			}
780 825
 		}
781 826
 		return false;
782 827
 	}
@@ -788,21 +833,24 @@  discard block
 block discarded – undo
788 833
 
789 834
 	protected function setCurrentBountyAmount(string $type, int $amount) : void {
790 835
 		$bounty = $this->getCurrentBounty($type);
791
-		if ($bounty['Amount'] == $amount)
792
-			return;
836
+		if ($bounty['Amount'] == $amount) {
837
+					return;
838
+		}
793 839
 		$bounty['Amount'] = $amount;
794 840
 		$this->setBounty($bounty);
795 841
 	}
796 842
 
797 843
 	public function increaseCurrentBountyAmount(string $type, int $amount) : void {
798
-		if ($amount < 0)
799
-			throw new Exception('Trying to increase negative current bounty.');
844
+		if ($amount < 0) {
845
+					throw new Exception('Trying to increase negative current bounty.');
846
+		}
800 847
 		$this->setCurrentBountyAmount($type, $this->getCurrentBountyAmount($type) + $amount);
801 848
 	}
802 849
 
803 850
 	public function decreaseCurrentBountyAmount(string $type, int $amount) : void {
804
-		if ($amount < 0)
805
-			throw new Exception('Trying to decrease negative current bounty.');
851
+		if ($amount < 0) {
852
+					throw new Exception('Trying to decrease negative current bounty.');
853
+		}
806 854
 		$this->setCurrentBountyAmount($type, $this->getCurrentBountyAmount($type) - $amount);
807 855
 	}
808 856
 
@@ -813,21 +861,24 @@  discard block
 block discarded – undo
813 861
 
814 862
 	protected function setCurrentBountySmrCredits(string $type, int $credits) : void {
815 863
 		$bounty = $this->getCurrentBounty($type);
816
-		if ($bounty['SmrCredits'] == $credits)
817
-			return;
864
+		if ($bounty['SmrCredits'] == $credits) {
865
+					return;
866
+		}
818 867
 		$bounty['SmrCredits'] = $credits;
819 868
 		$this->setBounty($bounty);
820 869
 	}
821 870
 
822 871
 	public function increaseCurrentBountySmrCredits(string $type, int $credits) : void {
823
-		if ($credits < 0)
824
-			throw new Exception('Trying to increase negative current bounty.');
872
+		if ($credits < 0) {
873
+					throw new Exception('Trying to increase negative current bounty.');
874
+		}
825 875
 		$this->setCurrentBountySmrCredits($type, $this->getCurrentBountySmrCredits($type) + $credits);
826 876
 	}
827 877
 
828 878
 	public function decreaseCurrentBountySmrCredits(string $type, int $credits) : void {
829
-		if ($credits < 0)
830
-			throw new Exception('Trying to decrease negative current bounty.');
879
+		if ($credits < 0) {
880
+					throw new Exception('Trying to decrease negative current bounty.');
881
+		}
831 882
 		$this->setCurrentBountySmrCredits($type, $this->getCurrentBountySmrCredits($type) - $credits);
832 883
 	}
833 884
 
@@ -848,51 +899,59 @@  discard block
 block discarded – undo
848 899
 
849 900
 	public function getHOF(array $typeList = null) {
850 901
 		$this->getHOFData();
851
-		if ($typeList == null)
852
-			return $this->HOF;
902
+		if ($typeList == null) {
903
+					return $this->HOF;
904
+		}
853 905
 		$hof = $this->HOF;
854 906
 		foreach ($typeList as $type) {
855
-			if (!isset($hof[$type]))
856
-				return 0;
907
+			if (!isset($hof[$type])) {
908
+							return 0;
909
+			}
857 910
 			$hof = $hof[$type];
858 911
 		}
859 912
 		return $hof;
860 913
 	}
861 914
 
862 915
 	public function increaseHOF($amount, array $typeList, $visibility) {
863
-		if ($amount < 0)
864
-			throw new Exception('Trying to increase negative HOF: ' . implode(':', $typeList));
865
-		if ($amount == 0)
866
-			return;
916
+		if ($amount < 0) {
917
+					throw new Exception('Trying to increase negative HOF: ' . implode(':', $typeList));
918
+		}
919
+		if ($amount == 0) {
920
+					return;
921
+		}
867 922
 		$this->setHOF($this->getHOF($typeList) + $amount, $typeList, $visibility);
868 923
 	}
869 924
 
870 925
 	public function decreaseHOF($amount, array $typeList, $visibility) {
871
-		if ($amount < 0)
872
-			throw new Exception('Trying to decrease negative HOF: ' . implode(':', $typeList));
873
-		if ($amount == 0)
874
-			return;
926
+		if ($amount < 0) {
927
+					throw new Exception('Trying to decrease negative HOF: ' . implode(':', $typeList));
928
+		}
929
+		if ($amount == 0) {
930
+					return;
931
+		}
875 932
 		$this->setHOF($this->getHOF($typeList) - $amount, $typeList, $visibility);
876 933
 	}
877 934
 
878 935
 	public function setHOF($amount, array $typeList, $visibility) {
879
-		if (is_array($this->getHOF($typeList)))
880
-			throw new Exception('Trying to overwrite a HOF type: ' . implode(':', $typeList));
936
+		if (is_array($this->getHOF($typeList))) {
937
+					throw new Exception('Trying to overwrite a HOF type: ' . implode(':', $typeList));
938
+		}
881 939
 		if ($this->isNPC()) {
882 940
 			// Don't store HOF for NPCs.
883 941
 			return;
884 942
 		}
885
-		if ($this->getHOF($typeList) == $amount)
886
-			return;
887
-		if ($amount < 0)
888
-			$amount = 0;
943
+		if ($this->getHOF($typeList) == $amount) {
944
+					return;
945
+		}
946
+		if ($amount < 0) {
947
+					$amount = 0;
948
+		}
889 949
 		$this->getHOF();
890 950
 
891 951
 		$hofType = implode(':', $typeList);
892 952
 		if (!isset(self::$HOFVis[$hofType])) {
893 953
 			self::$hasHOFVisChanged[$hofType] = self::HOF_NEW;
894
-		}
895
-		else if (self::$HOFVis[$hofType] != $visibility) {
954
+		} else if (self::$HOFVis[$hofType] != $visibility) {
896 955
 			self::$hasHOFVisChanged[$hofType] = self::HOF_CHANGED;
897 956
 		}
898 957
 		self::$HOFVis[$hofType] = $visibility;
@@ -901,8 +960,9 @@  discard block
 block discarded – undo
901 960
 		$hofChanged =& $this->hasHOFChanged;
902 961
 		$new = false;
903 962
 		foreach ($typeList as $type) {
904
-			if (!isset($hofChanged[$type]))
905
-				$hofChanged[$type] = array();
963
+			if (!isset($hofChanged[$type])) {
964
+							$hofChanged[$type] = array();
965
+			}
906 966
 			if (!isset($hof[$type])) {
907 967
 				$hof[$type] = array();
908 968
 				$new = true;
@@ -912,8 +972,9 @@  discard block
 block discarded – undo
912 972
 		}
913 973
 		if ($hofChanged == null) {
914 974
 			$hofChanged = self::HOF_CHANGED;
915
-			if ($new)
916
-				$hofChanged = self::HOF_NEW;
975
+			if ($new) {
976
+							$hofChanged = self::HOF_NEW;
977
+			}
917 978
 		}
918 979
 		$hof = $amount;
919 980
 	}
@@ -978,8 +1039,9 @@  discard block
 block discarded – undo
978 1039
 	}
979 1040
 
980 1041
 	public function setLastActive($lastActive) {
981
-		if ($this->lastActive == $lastActive)
982
-			return;
1042
+		if ($this->lastActive == $lastActive) {
1043
+					return;
1044
+		}
983 1045
 		$this->lastActive = $lastActive;
984 1046
 		$this->hasChanged = true;
985 1047
 	}
@@ -989,8 +1051,9 @@  discard block
 block discarded – undo
989 1051
 	}
990 1052
 
991 1053
 	public function setLastCPLAction($time) {
992
-		if ($this->lastCPLAction == $time)
993
-			return;
1054
+		if ($this->lastCPLAction == $time) {
1055
+					return;
1056
+		}
994 1057
 		$this->lastCPLAction = $time;
995 1058
 		$this->hasChanged = true;
996 1059
 	}
@@ -1031,8 +1094,9 @@  discard block
 block discarded – undo
1031 1094
 
1032 1095
 	protected function getMission($missionID) {
1033 1096
 		$missions = $this->getMissions();
1034
-		if (isset($missions[$missionID]))
1035
-			return $missions[$missionID];
1097
+		if (isset($missions[$missionID])) {
1098
+					return $missions[$missionID];
1099
+		}
1036 1100
 		return false;
1037 1101
 	}
1038 1102
 
@@ -1091,8 +1155,9 @@  discard block
 block discarded – undo
1091 1155
 	public function addMission($missionID, $step = 0) {
1092 1156
 		$this->getMissions();
1093 1157
 
1094
-		if (isset($this->missions[$missionID]))
1095
-			return;
1158
+		if (isset($this->missions[$missionID])) {
1159
+					return;
1160
+		}
1096 1161
 		$sector = 0;
1097 1162
 
1098 1163
 		$mission = array(
@@ -1121,8 +1186,7 @@  discard block
 block discarded – undo
1121 1186
 		if ($mission['On Step'] >= count(MISSIONS[$missionID]['Steps'])) {
1122 1187
 			// If we have completed this mission just use false to indicate no current task.
1123 1188
 			$currentStep = false;
1124
-		}
1125
-		else {
1189
+		} else {
1126 1190
 			$currentStep = MISSIONS[$missionID]['Steps'][$mission['On Step']];
1127 1191
 			$currentStep['Text'] = str_replace(array('<Race>', '<Sector>', '<Starting Sector>', '<trader>'), array($this->getRaceID(), $mission['Sector'], $mission['Starting Sector'], $this->playerName), $currentStep['Text']);
1128 1192
 			if (isset($currentStep['Task'])) {
@@ -1130,8 +1194,7 @@  discard block
 block discarded – undo
1130 1194
 			}
1131 1195
 			if (isset($currentStep['Level'])) {
1132 1196
 				$currentStep['Level'] = str_replace('<Player Level>', $this->getLevelID(), $currentStep['Level']);
1133
-			}
1134
-			else {
1197
+			} else {
1135 1198
 				$currentStep['Level'] = 0;
1136 1199
 			}
1137 1200
 		}
@@ -1259,12 +1322,15 @@  discard block
 block discarded – undo
1259 1322
 	}
1260 1323
 
1261 1324
 	public function canSee(AbstractSmrPlayer $otherPlayer) {
1262
-		if (!$otherPlayer->getShip()->isCloaked())
1263
-			return true;
1264
-		if ($this->sameAlliance($otherPlayer))
1265
-			return true;
1266
-		if ($this->getExperience() >= $otherPlayer->getExperience())
1267
-			return true;
1325
+		if (!$otherPlayer->getShip()->isCloaked()) {
1326
+					return true;
1327
+		}
1328
+		if ($this->sameAlliance($otherPlayer)) {
1329
+					return true;
1330
+		}
1331
+		if ($this->getExperience() >= $otherPlayer->getExperience()) {
1332
+					return true;
1333
+		}
1268 1334
 		return false;
1269 1335
 	}
1270 1336
 
@@ -1317,10 +1383,12 @@  discard block
 block discarded – undo
1317 1383
 	}
1318 1384
 
1319 1385
 	public function meetsAlignmentRestriction($restriction) {
1320
-		if ($restriction < 0)
1321
-			return $this->getAlignment() <= $restriction;
1322
-		if ($restriction > 0)
1323
-			return $this->getAlignment() >= $restriction;
1386
+		if ($restriction < 0) {
1387
+					return $this->getAlignment() <= $restriction;
1388
+		}
1389
+		if ($restriction > 0) {
1390
+					return $this->getAlignment() >= $restriction;
1391
+		}
1324 1392
 		return true;
1325 1393
 	}
1326 1394
 
@@ -1343,8 +1411,9 @@  discard block
 block discarded – undo
1343 1411
 		if (!isset($this->visitedSectors)) {
1344 1412
 			$this->visitedSectors = array();
1345 1413
 			$this->db->query('SELECT sector_id FROM player_visited_sector WHERE ' . $this->SQL);
1346
-			while ($this->db->nextRecord())
1347
-				$this->visitedSectors[$this->db->getField('sector_id')] = false;
1414
+			while ($this->db->nextRecord()) {
1415
+							$this->visitedSectors[$this->db->getField('sector_id')] = false;
1416
+			}
1348 1417
 		}
1349 1418
 		return !isset($this->visitedSectors[$sectorID]);
1350 1419
 	}
Please login to merge, or discard this patch.
lib/Default/ChessPiece.class.php 2 patches
Spacing   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -52,10 +52,10 @@  discard block
 block discarded – undo
52 52
 	}
53 53
 	
54 54
 	public function isAttacking(array &$board, array &$hasMoved, $king, $x = -1, $y = -1) {
55
-		$moves =& $this->getPossibleMoves($board, $hasMoved, null, true);
56
-		foreach($moves as &$move) {
57
-			$p =& $board[$move[1]][$move[0]];
58
-			if(($move[0] == $x && $move[1] == $y) || ($king === true && $p != null && $p->pieceID == self::KING && $this->colour != $p->colour)) {
55
+		$moves = & $this->getPossibleMoves($board, $hasMoved, null, true);
56
+		foreach ($moves as &$move) {
57
+			$p = & $board[$move[1]][$move[0]];
58
+			if (($move[0] == $x && $move[1] == $y) || ($king === true && $p != null && $p->pieceID == self::KING && $this->colour != $p->colour)) {
59 59
 				return true;
60 60
 			}
61 61
 		}
@@ -64,130 +64,130 @@  discard block
 block discarded – undo
64 64
 
65 65
 	public function &getPossibleMoves(array &$board, array &$hasMoved, $forAccountID = null, $attackingCheck = false) {
66 66
 		$moves = array();
67
-		if($forAccountID == null || $this->accountID == $forAccountID) {
68
-			if($this->pieceID==self::PAWN) {
69
-				$dirY = $this->colour==ChessGame::PLAYER_BLACK ? 1 : -1;
70
-				$moveY = $this->y+$dirY;
67
+		if ($forAccountID == null || $this->accountID == $forAccountID) {
68
+			if ($this->pieceID == self::PAWN) {
69
+				$dirY = $this->colour == ChessGame::PLAYER_BLACK ? 1 : -1;
70
+				$moveY = $this->y + $dirY;
71 71
 				//Pawn forward movement is not attacking - so don't check it if doing an attacking check.
72
-				if(!$attackingCheck) {
73
-					if(ChessGame::isValidCoord($this->x, $moveY, $board) && $board[$moveY][$this->x] == null && $this->isSafeMove($board, $hasMoved, $this->x, $moveY)) {
74
-						$moves[] = array($this->x,$moveY);
72
+				if (!$attackingCheck) {
73
+					if (ChessGame::isValidCoord($this->x, $moveY, $board) && $board[$moveY][$this->x] == null && $this->isSafeMove($board, $hasMoved, $this->x, $moveY)) {
74
+						$moves[] = array($this->x, $moveY);
75 75
 					}
76 76
 					$doubleMoveY = $moveY + $dirY;
77
-					if($this->y-$dirY == 0 || $this->y-$dirY*2 == count($board)) { //Double move first move
78
-						if($board[$moveY][$this->x] == null && $board[$doubleMoveY][$this->x] == null && $this->isSafeMove($board, $hasMoved, $this->x, $doubleMoveY)) {
79
-							$moves[] = array($this->x,$doubleMoveY);
77
+					if ($this->y - $dirY == 0 || $this->y - $dirY * 2 == count($board)) { //Double move first move
78
+						if ($board[$moveY][$this->x] == null && $board[$doubleMoveY][$this->x] == null && $this->isSafeMove($board, $hasMoved, $this->x, $doubleMoveY)) {
79
+							$moves[] = array($this->x, $doubleMoveY);
80 80
 						}
81 81
 					}
82 82
 				}
83
-				for($i=-1;$i<2;$i+=2) {
84
-					$moveX = $this->x+$i;
85
-					if(ChessGame::isValidCoord($moveX, $moveY, $board)) {
86
-						if($attackingCheck || 
83
+				for ($i = -1; $i < 2; $i += 2) {
84
+					$moveX = $this->x + $i;
85
+					if (ChessGame::isValidCoord($moveX, $moveY, $board)) {
86
+						if ($attackingCheck || 
87 87
 							((($hasMoved[ChessPiece::PAWN][0] == $moveX && $hasMoved[ChessPiece::PAWN][1] == $this->y) || 
88
-							($board[$moveY][$moveX] != null && $board[$moveY][$moveX]->colour!=$this->colour))
88
+							($board[$moveY][$moveX] != null && $board[$moveY][$moveX]->colour != $this->colour))
89 89
 							&& $this->isSafeMove($board, $hasMoved, $moveX, $moveY))) {
90
-							$moves[] = array($moveX,$moveY);
90
+							$moves[] = array($moveX, $moveY);
91 91
 						}
92 92
 					}
93 93
 				}
94 94
 			}
95
-			else if($this->pieceID==self::KING) {
96
-				for($i = -1; $i < 2; $i++) {
97
-					for($j = -1; $j < 2; $j++) {
98
-						if($i!=0 || $j!=0) {
99
-							$this->addMove($this->x+$i, $this->y+$j, $board, $moves, $hasMoved, $attackingCheck);
95
+			else if ($this->pieceID == self::KING) {
96
+				for ($i = -1; $i < 2; $i++) {
97
+					for ($j = -1; $j < 2; $j++) {
98
+						if ($i != 0 || $j != 0) {
99
+							$this->addMove($this->x + $i, $this->y + $j, $board, $moves, $hasMoved, $attackingCheck);
100 100
 						}
101 101
 					}
102 102
 				}
103 103
 				//Castling is not attacking - so don't check it if doing an attacking check.
104
-				if(!$attackingCheck && !$hasMoved[$this->colour][ChessPiece::KING] && !ChessGame::isPlayerChecked($board, $hasMoved, $this->colour)) {
105
-					if(!$hasMoved[$this->colour][ChessPiece::ROOK]['Queen'] && 
106
-							ChessGame::isValidCoord($this->x-1, $this->y, $board) && $board[$this->y][$this->x-1] == null &&
107
-							ChessGame::isValidCoord($this->x-3, $this->y, $board) && $board[$this->y][$this->x-3] == null &&
108
-							$this->isSafeMove($board, $hasMoved, $this->x-1, $this->y)) {
109
-						$this->addMove($this->x-2, $this->y, $board, $moves, $hasMoved, $attackingCheck);
104
+				if (!$attackingCheck && !$hasMoved[$this->colour][ChessPiece::KING] && !ChessGame::isPlayerChecked($board, $hasMoved, $this->colour)) {
105
+					if (!$hasMoved[$this->colour][ChessPiece::ROOK]['Queen'] && 
106
+							ChessGame::isValidCoord($this->x - 1, $this->y, $board) && $board[$this->y][$this->x - 1] == null &&
107
+							ChessGame::isValidCoord($this->x - 3, $this->y, $board) && $board[$this->y][$this->x - 3] == null &&
108
+							$this->isSafeMove($board, $hasMoved, $this->x - 1, $this->y)) {
109
+						$this->addMove($this->x - 2, $this->y, $board, $moves, $hasMoved, $attackingCheck);
110 110
 					}
111
-					if(!$hasMoved[$this->colour][ChessPiece::ROOK]['King'] &&
112
-							ChessGame::isValidCoord($this->x+1, $this->y, $board) && $board[$this->y][$this->x+1] == null &&
113
-							$this->isSafeMove($board, $hasMoved, $this->x+1, $this->y)) {
114
-						$this->addMove($this->x+2, $this->y, $board, $moves, $hasMoved, $attackingCheck);
111
+					if (!$hasMoved[$this->colour][ChessPiece::ROOK]['King'] &&
112
+							ChessGame::isValidCoord($this->x + 1, $this->y, $board) && $board[$this->y][$this->x + 1] == null &&
113
+							$this->isSafeMove($board, $hasMoved, $this->x + 1, $this->y)) {
114
+						$this->addMove($this->x + 2, $this->y, $board, $moves, $hasMoved, $attackingCheck);
115 115
 					}
116 116
 				}
117 117
 			}
118
-			else if($this->pieceID==self::QUEEN) {
118
+			else if ($this->pieceID == self::QUEEN) {
119 119
 				$moveX = $this->x;
120 120
 				$moveY = $this->y;
121
-				while($this->addMove(--$moveX, $moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Left
121
+				while ($this->addMove(--$moveX, $moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Left
122 122
 				$moveX = $this->x;
123 123
 				$moveY = $this->y;
124
-				while($this->addMove(++$moveX, $moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Right
124
+				while ($this->addMove(++$moveX, $moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Right
125 125
 				$moveX = $this->x;
126 126
 				$moveY = $this->y;
127
-				while($this->addMove($moveX, ++$moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Up
127
+				while ($this->addMove($moveX, ++$moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Up
128 128
 				$moveX = $this->x;
129 129
 				$moveY = $this->y;
130
-				while($this->addMove($moveX, --$moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Down
130
+				while ($this->addMove($moveX, --$moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Down
131 131
 				$moveX = $this->x;
132 132
 				$moveY = $this->y;
133
-				while($this->addMove(--$moveX, --$moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Up-Left
133
+				while ($this->addMove(--$moveX, --$moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Up-Left
134 134
 				$moveX = $this->x;
135 135
 				$moveY = $this->y;
136
-				while($this->addMove(++$moveX, --$moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Up-Right
136
+				while ($this->addMove(++$moveX, --$moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Up-Right
137 137
 				$moveX = $this->x;
138 138
 				$moveY = $this->y;
139
-				while($this->addMove(--$moveX, ++$moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Down-Left
139
+				while ($this->addMove(--$moveX, ++$moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Down-Left
140 140
 				$moveX = $this->x;
141 141
 				$moveY = $this->y;
142
-				while($this->addMove(++$moveX, ++$moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Up-Left
142
+				while ($this->addMove(++$moveX, ++$moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Up-Left
143 143
 			}
144
-			else if($this->pieceID==self::ROOK) {
144
+			else if ($this->pieceID == self::ROOK) {
145 145
 				$moveX = $this->x;
146 146
 				$moveY = $this->y;
147
-				while($this->addMove(--$moveX, $moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Left
147
+				while ($this->addMove(--$moveX, $moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Left
148 148
 				$moveX = $this->x;
149 149
 				$moveY = $this->y;
150
-				while($this->addMove(++$moveX, $moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Right
150
+				while ($this->addMove(++$moveX, $moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Right
151 151
 				$moveX = $this->x;
152 152
 				$moveY = $this->y;
153
-				while($this->addMove($moveX, ++$moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Up
153
+				while ($this->addMove($moveX, ++$moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Up
154 154
 				$moveX = $this->x;
155 155
 				$moveY = $this->y;
156
-				while($this->addMove($moveX, --$moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Down
156
+				while ($this->addMove($moveX, --$moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Down
157 157
 			}
158
-			else if($this->pieceID==self::BISHOP) {
158
+			else if ($this->pieceID == self::BISHOP) {
159 159
 				$moveX = $this->x;
160 160
 				$moveY = $this->y;
161
-				while($this->addMove(--$moveX, --$moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Up-Left
161
+				while ($this->addMove(--$moveX, --$moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Up-Left
162 162
 				$moveX = $this->x;
163 163
 				$moveY = $this->y;
164
-				while($this->addMove(++$moveX, --$moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Up-Right
164
+				while ($this->addMove(++$moveX, --$moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Up-Right
165 165
 				$moveX = $this->x;
166 166
 				$moveY = $this->y;
167
-				while($this->addMove(--$moveX, ++$moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Down-Left
167
+				while ($this->addMove(--$moveX, ++$moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Down-Left
168 168
 				$moveX = $this->x;
169 169
 				$moveY = $this->y;
170
-				while($this->addMove(++$moveX, ++$moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Up-Left
170
+				while ($this->addMove(++$moveX, ++$moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Up-Left
171 171
 			}
172
-			else if($this->pieceID==self::KNIGHT) {
173
-				$moveX = $this->x-1;
174
-				$moveY = $this->y-2;
175
-				$this->addMove($moveX, $moveY, $board, $moves, $hasMoved, $attackingCheck);//2up-left
172
+			else if ($this->pieceID == self::KNIGHT) {
173
+				$moveX = $this->x - 1;
174
+				$moveY = $this->y - 2;
175
+				$this->addMove($moveX, $moveY, $board, $moves, $hasMoved, $attackingCheck); //2up-left
176 176
 				$moveX += 2;
177
-				$this->addMove($moveX, $moveY, $board, $moves, $hasMoved, $attackingCheck);//2up-right
178
-				$moveY = $this->y+2;
179
-				$this->addMove($moveX, $moveY, $board, $moves, $hasMoved, $attackingCheck);//2down-right
177
+				$this->addMove($moveX, $moveY, $board, $moves, $hasMoved, $attackingCheck); //2up-right
178
+				$moveY = $this->y + 2;
179
+				$this->addMove($moveX, $moveY, $board, $moves, $hasMoved, $attackingCheck); //2down-right
180 180
 				$moveX -= 2;
181
-				$this->addMove($moveX, $moveY, $board, $moves, $hasMoved, $attackingCheck);//2down-left
182
-				$moveX = $this->x-2;
183
-				$moveY = $this->y-1;
184
-				$this->addMove($moveX, $moveY, $board, $moves, $hasMoved, $attackingCheck);//2left-up
181
+				$this->addMove($moveX, $moveY, $board, $moves, $hasMoved, $attackingCheck); //2down-left
182
+				$moveX = $this->x - 2;
183
+				$moveY = $this->y - 1;
184
+				$this->addMove($moveX, $moveY, $board, $moves, $hasMoved, $attackingCheck); //2left-up
185 185
 				$moveY += 2;
186
-				$this->addMove($moveX, $moveY, $board, $moves, $hasMoved, $attackingCheck);//2left-down
187
-				$moveX = $this->x+2;
188
-				$this->addMove($moveX, $moveY, $board, $moves, $hasMoved, $attackingCheck);//2right-down
186
+				$this->addMove($moveX, $moveY, $board, $moves, $hasMoved, $attackingCheck); //2left-down
187
+				$moveX = $this->x + 2;
188
+				$this->addMove($moveX, $moveY, $board, $moves, $hasMoved, $attackingCheck); //2right-down
189 189
 				$moveY -= 2;
190
-				$this->addMove($moveX, $moveY, $board, $moves, $hasMoved, $attackingCheck);//2right-up
190
+				$this->addMove($moveX, $moveY, $board, $moves, $hasMoved, $attackingCheck); //2right-up
191 191
 			}
192 192
 		}
193 193
 		
@@ -195,11 +195,11 @@  discard block
 block discarded – undo
195 195
 	}
196 196
 	
197 197
 	private function addMove($toX, $toY, array &$board, array &$moves, array &$hasMoved = null, $attackingCheck = true) {
198
-		if(ChessGame::isValidCoord($toX, $toY, $board)) {
199
-			if(($board[$toY][$toX] == null || $board[$toY][$toX]->colour!=$this->colour)) {
198
+		if (ChessGame::isValidCoord($toX, $toY, $board)) {
199
+			if (($board[$toY][$toX] == null || $board[$toY][$toX]->colour != $this->colour)) {
200 200
 				//We can only actually move to this position if it is safe to do so, however we can pass through it looking for a safe move so we still want to return true.
201
-				if(($attackingCheck == true || $this->isSafeMove($board, $hasMoved, $toX, $toY))) {
202
-					$moves[] = array($toX,$toY);
201
+				if (($attackingCheck == true || $this->isSafeMove($board, $hasMoved, $toX, $toY))) {
202
+					$moves[] = array($toX, $toY);
203 203
 				}
204 204
 				return true;
205 205
 			}
@@ -208,30 +208,30 @@  discard block
 block discarded – undo
208 208
 	}
209 209
 	
210 210
 	public function promote($pawnPromotionPieceID, array &$board) {
211
-		if($pawnPromotionPieceID==null) {
211
+		if ($pawnPromotionPieceID == null) {
212 212
 			throw new Exception('Promotion piece cannot be null on a promote.');
213 213
 		}
214 214
 		$takenNos = array();
215
-		foreach($board as $row) {
216
-			foreach($row as $piece) {
217
-				if($piece != null && $piece->pieceID == $pawnPromotionPieceID && $piece->colour == $this->colour) {
215
+		foreach ($board as $row) {
216
+			foreach ($row as $piece) {
217
+				if ($piece != null && $piece->pieceID == $pawnPromotionPieceID && $piece->colour == $this->colour) {
218 218
 					$takenNos[$piece->pieceNo] = true;
219 219
 				}
220 220
 			}
221 221
 		}
222
-		$i=0;
223
-		while(isset($takenNos[$i])) {
222
+		$i = 0;
223
+		while (isset($takenNos[$i])) {
224 224
 			$i++;
225 225
 		}
226 226
 		return array('PieceID' => $pawnPromotionPieceID, 'PieceNo' => $i);
227 227
 	}
228 228
 
229 229
 	public function getPieceLetter() {
230
-		return self::getLetterForPiece($this->pieceID,$this->colour);
230
+		return self::getLetterForPiece($this->pieceID, $this->colour);
231 231
 	}
232 232
 
233 233
 	public function getPieceSymbol() {
234
-		return self::getSymbolForPiece($this->pieceID,$this->colour);
234
+		return self::getSymbolForPiece($this->pieceID, $this->colour);
235 235
 	}
236 236
 
237 237
 	public static function getSymbolForPiece($pieceID, $colour) {
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 	}
240 240
 
241 241
 	public static function getLetterForPiece($pieceID, $colour) {
242
-		switch($pieceID) {
242
+		switch ($pieceID) {
243 243
 			case self::KING:
244 244
 				$letter = 'k';
245 245
 			break;
@@ -260,14 +260,14 @@  discard block
 block discarded – undo
260 260
 				$letter = 'p';
261 261
 			break;
262 262
 		}
263
-		if($colour == ChessGame::PLAYER_WHITE) {
263
+		if ($colour == ChessGame::PLAYER_WHITE) {
264 264
 			$letter = strtoupper($letter);
265 265
 		}
266 266
 		return $letter;
267 267
 	}
268 268
 
269 269
 	public static function getPieceForLetter($letter) {
270
-		switch($letter) {
270
+		switch ($letter) {
271 271
 			case 'k':
272 272
 			case 'K':
273 273
 				return self::KING;
Please login to merge, or discard this patch.
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -91,8 +91,7 @@  discard block
 block discarded – undo
91 91
 						}
92 92
 					}
93 93
 				}
94
-			}
95
-			else if($this->pieceID==self::KING) {
94
+			} else if($this->pieceID==self::KING) {
96 95
 				for($i = -1; $i < 2; $i++) {
97 96
 					for($j = -1; $j < 2; $j++) {
98 97
 						if($i!=0 || $j!=0) {
@@ -114,8 +113,7 @@  discard block
 block discarded – undo
114 113
 						$this->addMove($this->x+2, $this->y, $board, $moves, $hasMoved, $attackingCheck);
115 114
 					}
116 115
 				}
117
-			}
118
-			else if($this->pieceID==self::QUEEN) {
116
+			} else if($this->pieceID==self::QUEEN) {
119 117
 				$moveX = $this->x;
120 118
 				$moveY = $this->y;
121 119
 				while($this->addMove(--$moveX, $moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Left
@@ -140,8 +138,7 @@  discard block
 block discarded – undo
140 138
 				$moveX = $this->x;
141 139
 				$moveY = $this->y;
142 140
 				while($this->addMove(++$moveX, ++$moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Up-Left
143
-			}
144
-			else if($this->pieceID==self::ROOK) {
141
+			} else if($this->pieceID==self::ROOK) {
145 142
 				$moveX = $this->x;
146 143
 				$moveY = $this->y;
147 144
 				while($this->addMove(--$moveX, $moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Left
@@ -154,8 +151,7 @@  discard block
 block discarded – undo
154 151
 				$moveX = $this->x;
155 152
 				$moveY = $this->y;
156 153
 				while($this->addMove($moveX, --$moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Down
157
-			}
158
-			else if($this->pieceID==self::BISHOP) {
154
+			} else if($this->pieceID==self::BISHOP) {
159 155
 				$moveX = $this->x;
160 156
 				$moveY = $this->y;
161 157
 				while($this->addMove(--$moveX, --$moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Up-Left
@@ -168,8 +164,7 @@  discard block
 block discarded – undo
168 164
 				$moveX = $this->x;
169 165
 				$moveY = $this->y;
170 166
 				while($this->addMove(++$moveX, ++$moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Up-Left
171
-			}
172
-			else if($this->pieceID==self::KNIGHT) {
167
+			} else if($this->pieceID==self::KNIGHT) {
173 168
 				$moveX = $this->x-1;
174 169
 				$moveY = $this->y-2;
175 170
 				$this->addMove($moveX, $moveY, $board, $moves, $hasMoved, $attackingCheck);//2up-left
Please login to merge, or discard this patch.
lib/Default/SmrWeapon.class.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -193,21 +193,21 @@  discard block
 block discarded – undo
193 193
 	public function &getModifiedDamageAgainstForces(AbstractSmrPlayer $weaponPlayer, SmrForce $forces) {
194 194
 		if (!$this->canShootForces()) // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods.
195 195
 			return array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover());
196
-		$damage =& $this->getModifiedDamage($weaponPlayer);
196
+		$damage = & $this->getModifiedDamage($weaponPlayer);
197 197
 		return $damage;
198 198
 	}
199 199
 	
200 200
 	public function &getModifiedDamageAgainstPort(AbstractSmrPlayer $weaponPlayer, SmrPort $port) {
201 201
 		if (!$this->canShootPorts()) // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods.
202 202
 			return array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover());
203
-		$damage =& $this->getModifiedDamage($weaponPlayer);
203
+		$damage = & $this->getModifiedDamage($weaponPlayer);
204 204
 		return $damage;
205 205
 	}
206 206
 	
207 207
 	public function &getModifiedDamageAgainstPlanet(AbstractSmrPlayer $weaponPlayer, SmrPlanet $planet) {
208 208
 		if (!$this->canShootPlanets()) // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods.
209 209
 			return array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover());
210
-		$damage =& $this->getModifiedDamage($weaponPlayer);
210
+		$damage = & $this->getModifiedDamage($weaponPlayer);
211 211
 		
212 212
 		$planetMod = self::PLANET_DAMAGE_MOD;
213 213
 		$damage['MaxDamage'] = ceil($damage['MaxDamage'] * $planetMod);
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 			$return = array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover());
228 228
 			return $return;
229 229
 		}
230
-		$damage =& $this->getModifiedDamage($weaponPlayer);
230
+		$damage = & $this->getModifiedDamage($weaponPlayer);
231 231
 		return $damage;
232 232
 	}
233 233
 	
Please login to merge, or discard this patch.
Braces   +26 added lines, -15 removed lines patch added patch discarded remove patch
@@ -12,17 +12,19 @@  discard block
 block discarded – undo
12 12
 
13 13
 	
14 14
 	protected static function initialiseDatabase() {
15
-		if (self::$db == null)
16
-			self::$db = new SmrMySqlDatabase();
15
+		if (self::$db == null) {
16
+					self::$db = new SmrMySqlDatabase();
17
+		}
17 18
 	}
18 19
 
19 20
 	public static function &getWeapon($weaponTypeID, $forceUpdate = false, $db = null) {
20 21
 		if ($forceUpdate || !isset(self::$CACHE_WEAPONS[$weaponTypeID])) {
21 22
 			$w = new SmrWeapon($weaponTypeID, $db);
22
-			if ($w->exists())
23
-				self::$CACHE_WEAPONS[$weaponTypeID] = $w;
24
-			else
25
-				self::$CACHE_WEAPONS[$weaponTypeID] = false;
23
+			if ($w->exists()) {
24
+							self::$CACHE_WEAPONS[$weaponTypeID] = $w;
25
+			} else {
26
+							self::$CACHE_WEAPONS[$weaponTypeID] = false;
27
+			}
26 28
 		}
27 29
 		return self::$CACHE_WEAPONS[$weaponTypeID];
28 30
 	}
@@ -115,8 +117,9 @@  discard block
 block discarded – undo
115 117
 	public function getModifiedAccuracy(AbstractSmrPlayer $weaponPlayer) {
116 118
 		$modifiedAccuracy = $this->getBaseAccuracy();
117 119
 		$modifiedAccuracy += $this->getBaseAccuracy() * self::getPlayerLevelAccuracyMod($weaponPlayer);
118
-		if ($weaponPlayer->isGadgetEquipped('Increased Accuracy'))
119
-			$modifiedAccuracy += $this->getBaseAccuracy() * INCREASED_ACC_GADGET_FACTOR / 100;
120
+		if ($weaponPlayer->isGadgetEquipped('Increased Accuracy')) {
121
+					$modifiedAccuracy += $this->getBaseAccuracy() * INCREASED_ACC_GADGET_FACTOR / 100;
122
+		}
120 123
 		return $modifiedAccuracy;
121 124
 	}
122 125
 	
@@ -140,14 +143,16 @@  discard block
 block discarded – undo
140 143
 	public function getModifiedAccuracyAgainstPlayer(AbstractSmrPlayer $weaponPlayer, AbstractSmrPlayer $targetPlayer) {
141 144
 		$modifiedAccuracy = $this->getModifiedAccuracy($weaponPlayer);
142 145
 		$modifiedAccuracy -= $this->getBaseAccuracy() * self::getPlayerLevelAccuracyMod($targetPlayer) / 2;
143
-		if ($targetPlayer->isGadgetEquipped('Increased Maneuverability'))
144
-			$modifiedAccuracy -= $this->getBaseAccuracy() * INCREASED_MAN_GADGET_FACTOR / 100;
146
+		if ($targetPlayer->isGadgetEquipped('Increased Maneuverability')) {
147
+					$modifiedAccuracy -= $this->getBaseAccuracy() * INCREASED_MAN_GADGET_FACTOR / 100;
148
+		}
145 149
 		
146 150
 		$weaponShip = $weaponPlayer->getShip();
147 151
 		$targetShip = $targetPlayer->getShip();
148 152
 		$mrDiff = $targetShip->getMR() - $weaponShip->getMR();
149
-		if ($mrDiff > 0)
150
-			$modifiedAccuracy -= $this->getBaseAccuracy() * ($mrDiff / MR_FACTOR) / 100;
153
+		if ($mrDiff > 0) {
154
+					$modifiedAccuracy -= $this->getBaseAccuracy() * ($mrDiff / MR_FACTOR) / 100;
155
+		}
151 156
 	
152 157
 		return $modifiedAccuracy;
153 158
 	}
@@ -191,22 +196,28 @@  discard block
 block discarded – undo
191 196
 	}
192 197
 	
193 198
 	public function &getModifiedDamageAgainstForces(AbstractSmrPlayer $weaponPlayer, SmrForce $forces) {
194
-		if (!$this->canShootForces()) // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods.
199
+		if (!$this->canShootForces()) {
200
+			// If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods.
195 201
 			return array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover());
202
+		}
196 203
 		$damage =& $this->getModifiedDamage($weaponPlayer);
197 204
 		return $damage;
198 205
 	}
199 206
 	
200 207
 	public function &getModifiedDamageAgainstPort(AbstractSmrPlayer $weaponPlayer, SmrPort $port) {
201
-		if (!$this->canShootPorts()) // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods.
208
+		if (!$this->canShootPorts()) {
209
+			// If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods.
202 210
 			return array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover());
211
+		}
203 212
 		$damage =& $this->getModifiedDamage($weaponPlayer);
204 213
 		return $damage;
205 214
 	}
206 215
 	
207 216
 	public function &getModifiedDamageAgainstPlanet(AbstractSmrPlayer $weaponPlayer, SmrPlanet $planet) {
208
-		if (!$this->canShootPlanets()) // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods.
217
+		if (!$this->canShootPlanets()) {
218
+			// If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods.
209 219
 			return array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover());
220
+		}
210 221
 		$damage =& $this->getModifiedDamage($weaponPlayer);
211 222
 		
212 223
 		$planetMod = self::PLANET_DAMAGE_MOD;
Please login to merge, or discard this patch.