We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -19,12 +19,12 @@ discard block |
||
19 | 19 | protected $hasChanged = false; |
20 | 20 | protected $isNew = false; |
21 | 21 | |
22 | - public static function &getGameGalaxies($gameID,$forceUpdate = false) { |
|
23 | - if($forceUpdate || !isset(self::$CACHE_GAME_GALAXIES[$gameID])) { |
|
22 | + public static function &getGameGalaxies($gameID, $forceUpdate = false) { |
|
23 | + if ($forceUpdate || !isset(self::$CACHE_GAME_GALAXIES[$gameID])) { |
|
24 | 24 | $db = new SmrMySqlDatabase(); |
25 | - $db->query('SELECT * FROM game_galaxy WHERE game_id = ' . $db->escapeNumber($gameID) .' ORDER BY galaxy_id ASC'); |
|
25 | + $db->query('SELECT * FROM game_galaxy WHERE game_id = ' . $db->escapeNumber($gameID) . ' ORDER BY galaxy_id ASC'); |
|
26 | 26 | $galaxies = array(); |
27 | - while($db->nextRecord()) { |
|
27 | + while ($db->nextRecord()) { |
|
28 | 28 | $galaxyID = $db->getField('galaxy_id'); |
29 | 29 | $galaxies[$galaxyID] = self::getGalaxy($gameID, $galaxyID, $forceUpdate, $db); |
30 | 30 | } |
@@ -33,8 +33,8 @@ discard block |
||
33 | 33 | return self::$CACHE_GAME_GALAXIES[$gameID]; |
34 | 34 | } |
35 | 35 | |
36 | - public static function &getGalaxy($gameID, $galaxyID, $forceUpdate=false, $db=null) { |
|
37 | - if($forceUpdate || !isset(self::$CACHE_GALAXIES[$gameID][$galaxyID])) { |
|
36 | + public static function &getGalaxy($gameID, $galaxyID, $forceUpdate = false, $db = null) { |
|
37 | + if ($forceUpdate || !isset(self::$CACHE_GALAXIES[$gameID][$galaxyID])) { |
|
38 | 38 | $g = new SmrGalaxy($gameID, $galaxyID, false, $db); |
39 | 39 | self::$CACHE_GALAXIES[$gameID][$galaxyID] = $g; |
40 | 40 | } |
@@ -42,22 +42,22 @@ discard block |
||
42 | 42 | } |
43 | 43 | |
44 | 44 | public static function saveGalaxies() { |
45 | - foreach(self::$CACHE_GALAXIES as $gameGalaxies) { |
|
46 | - foreach($gameGalaxies as $galaxy) { |
|
45 | + foreach (self::$CACHE_GALAXIES as $gameGalaxies) { |
|
46 | + foreach ($gameGalaxies as $galaxy) { |
|
47 | 47 | $galaxy->save(); |
48 | 48 | } |
49 | 49 | } |
50 | 50 | } |
51 | 51 | |
52 | - public static function &createGalaxy($gameID,$galaxyID) { |
|
53 | - if(!isset(self::$CACHE_GALAXIES[$gameID][$galaxyID])) { |
|
54 | - $g = new SmrGalaxy($gameID,$galaxyID,true); |
|
52 | + public static function &createGalaxy($gameID, $galaxyID) { |
|
53 | + if (!isset(self::$CACHE_GALAXIES[$gameID][$galaxyID])) { |
|
54 | + $g = new SmrGalaxy($gameID, $galaxyID, true); |
|
55 | 55 | self::$CACHE_GALAXIES[$gameID][$galaxyID] = $g; |
56 | 56 | } |
57 | 57 | return self::$CACHE_GALAXIES[$gameID][$galaxyID]; |
58 | 58 | } |
59 | 59 | |
60 | - protected function __construct($gameID, $galaxyID, $create=false, $db=null) { |
|
60 | + protected function __construct($gameID, $galaxyID, $create = false, $db = null) { |
|
61 | 61 | $this->db = new SmrMySqlDatabase(); |
62 | 62 | $this->SQL = 'game_id = ' . $this->db->escapeNumber($gameID) . ' |
63 | 63 | AND galaxy_id = ' . $this->db->escapeNumber($galaxyID); |
@@ -70,8 +70,8 @@ discard block |
||
70 | 70 | $this->isNew = !$db->nextRecord(); |
71 | 71 | } |
72 | 72 | |
73 | - $this->gameID = (int) $gameID; |
|
74 | - $this->galaxyID = (int) $galaxyID; |
|
73 | + $this->gameID = (int)$gameID; |
|
74 | + $this->galaxyID = (int)$galaxyID; |
|
75 | 75 | if (!$this->isNew) { |
76 | 76 | $this->name = $db->getField('galaxy_name'); |
77 | 77 | $this->width = $db->getInt('width'); |
@@ -79,13 +79,13 @@ discard block |
||
79 | 79 | $this->galaxyType = $db->getField('galaxy_type'); |
80 | 80 | $this->maxForceTime = $db->getInt('max_force_time'); |
81 | 81 | } elseif ($create === false) { |
82 | - throw new Exception('No such galaxy: '.$gameID.'-'.$galaxyID); |
|
82 | + throw new Exception('No such galaxy: ' . $gameID . '-' . $galaxyID); |
|
83 | 83 | } |
84 | 84 | } |
85 | 85 | |
86 | 86 | public function save() { |
87 | - if($this->hasChanged) { |
|
88 | - if($this->isNew==false) { |
|
87 | + if ($this->hasChanged) { |
|
88 | + if ($this->isNew == false) { |
|
89 | 89 | $this->db->query('UPDATE game_galaxy SET galaxy_name = ' . $this->db->escapeString($this->getName()) . |
90 | 90 | ', width = ' . $this->db->escapeNumber($this->getWidth()) . |
91 | 91 | ', height = ' . $this->db->escapeNumber($this->getHeight()) . |
@@ -125,8 +125,8 @@ discard block |
||
125 | 125 | } |
126 | 126 | |
127 | 127 | public function setName($name) { |
128 | - $name = htmlentities($name,ENT_COMPAT,'utf-8'); |
|
129 | - if($this->name == $name) { |
|
128 | + $name = htmlentities($name, ENT_COMPAT, 'utf-8'); |
|
129 | + if ($this->name == $name) { |
|
130 | 130 | return; |
131 | 131 | } |
132 | 132 | $this->name = $name; |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | } |
139 | 139 | |
140 | 140 | public function setWidth($width) { |
141 | - if($this->width == $width) { |
|
141 | + if ($this->width == $width) { |
|
142 | 142 | return; |
143 | 143 | } |
144 | 144 | $this->width = $width; |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | } |
151 | 151 | |
152 | 152 | public function setHeight($height) { |
153 | - if($this->height == $height) { |
|
153 | + if ($this->height == $height) { |
|
154 | 154 | return; |
155 | 155 | } |
156 | 156 | $this->height = $height; |
@@ -158,11 +158,11 @@ discard block |
||
158 | 158 | } |
159 | 159 | |
160 | 160 | public function getStartSector() { |
161 | - if($this->startSector === false) { |
|
161 | + if ($this->startSector === false) { |
|
162 | 162 | $this->startSector = 1; |
163 | 163 | if ($this->getGalaxyID() != 1) { |
164 | 164 | $galaxies = SmrGalaxy::getGameGalaxies($this->getGameID()); |
165 | - for ($i=1;$i < $this->getGalaxyID();$i++) { |
|
165 | + for ($i = 1; $i < $this->getGalaxyID(); $i++) { |
|
166 | 166 | $this->startSector += $galaxies[$i]->getSize(); |
167 | 167 | } |
168 | 168 | } |
@@ -187,28 +187,28 @@ discard block |
||
187 | 187 | * If $centerSectorID is specified, it will be in the center of the array. |
188 | 188 | * If $dist is also specified, only include sectors $dist away from center. |
189 | 189 | */ |
190 | - public function getMapSectors($centerSectorID=false, $dist=false) { |
|
190 | + public function getMapSectors($centerSectorID = false, $dist = false) { |
|
191 | 191 | if ($centerSectorID === false) { |
192 | 192 | $topLeft = SmrSector::getSector($this->getGameID(), $this->getStartSector()); |
193 | 193 | } else { |
194 | 194 | $topLeft = SmrSector::getSector($this->getGameID(), $centerSectorID); |
195 | 195 | // go left then up |
196 | - for ($i=0; (!$dist || $i<$dist) && $i<floor($this->getWidth()/2); $i++) { |
|
196 | + for ($i = 0; (!$dist || $i < $dist) && $i < floor($this->getWidth() / 2); $i++) { |
|
197 | 197 | $topLeft = $topLeft->getNeighbourSector('Left'); |
198 | 198 | } |
199 | - for ($i=0; (!$dist || $i<$dist) && $i<floor($this->getHeight()/2); $i++) { |
|
199 | + for ($i = 0; (!$dist || $i < $dist) && $i < floor($this->getHeight() / 2); $i++) { |
|
200 | 200 | $topLeft = $topLeft->getNeighbourSector('Up'); |
201 | 201 | } |
202 | 202 | } |
203 | 203 | |
204 | 204 | $mapSectors = array(); |
205 | - for ($i=0; (!$dist || $i<2*$dist+1) && $i<$this->getHeight(); $i++) { |
|
205 | + for ($i = 0; (!$dist || $i < 2 * $dist + 1) && $i < $this->getHeight(); $i++) { |
|
206 | 206 | $mapSectors[$i] = array(); |
207 | 207 | // get left most sector for this row |
208 | 208 | $rowLeft = $i == 0 ? $topLeft : $rowLeft->getNeighbourSector('Down'); |
209 | 209 | |
210 | 210 | // iterate through the columns |
211 | - for ($j=0; (!$dist || $j<2*$dist+1) && $j<$this->getWidth(); $j++) { |
|
211 | + for ($j = 0; (!$dist || $j < 2 * $dist + 1) && $j < $this->getWidth(); $j++) { |
|
212 | 212 | $nextSec = $j == 0 ? $rowLeft : $nextSec->getNeighbourSector('Right'); |
213 | 213 | $mapSectors[$i][$j] = $nextSec; |
214 | 214 | } |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | } |
222 | 222 | |
223 | 223 | public function setGalaxyType($galaxyType) { |
224 | - if($this->galaxyType == $galaxyType) { |
|
224 | + if ($this->galaxyType == $galaxyType) { |
|
225 | 225 | return; |
226 | 226 | } |
227 | 227 | $this->galaxyType = $galaxyType; |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | } |
234 | 234 | |
235 | 235 | public function setMaxForceTime($maxForceTime) { |
236 | - if($this->maxForceTime == $maxForceTime) { |
|
236 | + if ($this->maxForceTime == $maxForceTime) { |
|
237 | 237 | return; |
238 | 238 | } |
239 | 239 | $this->maxForceTime = $maxForceTime; |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | */ |
258 | 258 | public function setConnectivity($connectivity) { |
259 | 259 | // Only set down/right, otherwise we double-hit every link |
260 | - $linkDirs = array('Down','Right'); |
|
260 | + $linkDirs = array('Down', 'Right'); |
|
261 | 261 | |
262 | 262 | $problem = true; |
263 | 263 | $problemTimes = 0; |
@@ -265,8 +265,8 @@ discard block |
||
265 | 265 | $problem = false; |
266 | 266 | |
267 | 267 | foreach ($this->getSectors() as $galSector) { |
268 | - foreach($linkDirs as $linkDir) { |
|
269 | - if (mt_rand(1,100) <= $connectivity) { |
|
268 | + foreach ($linkDirs as $linkDir) { |
|
269 | + if (mt_rand(1, 100) <= $connectivity) { |
|
270 | 270 | $galSector->enableLink($linkDir); |
271 | 271 | } else { |
272 | 272 | $galSector->disableLink($linkDir); |
@@ -305,8 +305,8 @@ discard block |
||
305 | 305 | } |
306 | 306 | |
307 | 307 | public function contains($sectorID) { |
308 | - if($sectorID instanceof SmrSector) { |
|
309 | - return $sectorID->getGalaxyID()==$this->getGalaxyID(); |
|
308 | + if ($sectorID instanceof SmrSector) { |
|
309 | + return $sectorID->getGalaxyID() == $this->getGalaxyID(); |
|
310 | 310 | } |
311 | 311 | return $sectorID >= $this->getStartSector() && $sectorID <= $this->getEndSector(); |
312 | 312 | } |
@@ -32,10 +32,10 @@ discard block |
||
32 | 32 | JOIN chess_game ON account_id = black_id OR account_id = white_id |
33 | 33 | WHERE end_time > ' . TIME . ' OR end_time IS NULL;'); |
34 | 34 | $games = array(); |
35 | - while($db->nextRecord()) { |
|
36 | - $game =& self::getChessGame($db->getInt('chess_game_id'), $forceUpdate); |
|
37 | - if($game->getCurrentTurnAccount()->isNPC()) { |
|
38 | - $games[] =& $game; |
|
35 | + while ($db->nextRecord()) { |
|
36 | + $game = & self::getChessGame($db->getInt('chess_game_id'), $forceUpdate); |
|
37 | + if ($game->getCurrentTurnAccount()->isNPC()) { |
|
38 | + $games[] = & $game; |
|
39 | 39 | } |
40 | 40 | } |
41 | 41 | return $games; |
@@ -45,8 +45,8 @@ discard block |
||
45 | 45 | $db = new SmrMySqlDatabase(); |
46 | 46 | $db->query('SELECT chess_game_id FROM chess_game WHERE (black_id = ' . $db->escapeNumber($accountID) . ' OR white_id = ' . $db->escapeNumber($accountID) . ') AND (end_time > ' . TIME . ' OR end_time IS NULL);'); |
47 | 47 | $games = array(); |
48 | - while($db->nextRecord()) { |
|
49 | - $games[] =& self::getChessGame($db->getInt('chess_game_id')); |
|
48 | + while ($db->nextRecord()) { |
|
49 | + $games[] = & self::getChessGame($db->getInt('chess_game_id')); |
|
50 | 50 | } |
51 | 51 | return $games; |
52 | 52 | } |
@@ -55,14 +55,14 @@ discard block |
||
55 | 55 | $db = new SmrMySqlDatabase(); |
56 | 56 | $db->query('SELECT chess_game_id FROM chess_game WHERE black_id = ' . $db->escapeNumber($accountID) . ' OR white_id = ' . $db->escapeNumber($accountID) . ';'); |
57 | 57 | $games = array(); |
58 | - while($db->nextRecord()) { |
|
59 | - $games[] =& self::getChessGame($db->getInt('chess_game_id')); |
|
58 | + while ($db->nextRecord()) { |
|
59 | + $games[] = & self::getChessGame($db->getInt('chess_game_id')); |
|
60 | 60 | } |
61 | 61 | return $games; |
62 | 62 | } |
63 | 63 | |
64 | - public static function &getChessGame($chessGameID,$forceUpdate = false) { |
|
65 | - if($forceUpdate || !isset(self::$CACHE_CHESS_GAMES[$chessGameID])) { |
|
64 | + public static function &getChessGame($chessGameID, $forceUpdate = false) { |
|
65 | + if ($forceUpdate || !isset(self::$CACHE_CHESS_GAMES[$chessGameID])) { |
|
66 | 66 | self::$CACHE_CHESS_GAMES[$chessGameID] = new ChessGame($chessGameID); |
67 | 67 | } |
68 | 68 | return self::$CACHE_CHESS_GAMES[$chessGameID]; |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | $this->db->query('SELECT * |
74 | 74 | FROM chess_game |
75 | 75 | WHERE chess_game_id=' . $this->db->escapeNumber($chessGameID) . ' LIMIT 1;'); |
76 | - if($this->db->nextRecord()) { |
|
76 | + if ($this->db->nextRecord()) { |
|
77 | 77 | $this->chessGameID = $chessGameID; |
78 | 78 | $this->startDate = $this->db->getInt('start_time'); |
79 | 79 | $this->endDate = $this->db->getInt('end_time'); |
@@ -92,9 +92,9 @@ discard block |
||
92 | 92 | } |
93 | 93 | |
94 | 94 | public static function isPlayerChecked(array &$board, array &$hasMoved, $colour) { |
95 | - foreach($board as &$row) { |
|
96 | - foreach($row as &$p) { |
|
97 | - if($p != null && $p->colour != $colour && $p->isAttacking($board, $hasMoved, true)) { |
|
95 | + foreach ($board as &$row) { |
|
96 | + foreach ($row as &$p) { |
|
97 | + if ($p != null && $p->colour != $colour && $p->isAttacking($board, $hasMoved, true)) { |
|
98 | 98 | return true; |
99 | 99 | } |
100 | 100 | } |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | 'King' => false |
119 | 119 | ) |
120 | 120 | ), |
121 | - ChessPiece::PAWN => array(-1,-1) |
|
121 | + ChessPiece::PAWN => array(-1, -1) |
|
122 | 122 | ); |
123 | 123 | } |
124 | 124 | |
@@ -141,17 +141,17 @@ discard block |
||
141 | 141 | $this->resetHasMoved(); |
142 | 142 | |
143 | 143 | try { |
144 | - while($db->nextRecord()) { |
|
145 | - if($debugInfo === true) { |
|
144 | + while ($db->nextRecord()) { |
|
145 | + if ($debugInfo === true) { |
|
146 | 146 | echo 'x=', $db->getInt('start_x'), ', y=', $db->getInt('start_y'), ', endX=', $db->getInt('end_x'), ', endY=', $db->getInt('end_y'), ', forAccountID=', $db->getInt('move_id') % 2 == 1 ? $this->getWhiteID() : $this->getBlackID(), EOL; |
147 | 147 | } |
148 | - if(0 != $this->tryMove($db->getInt('start_x'), $db->getInt('start_y'), $db->getInt('end_x'), $db->getInt('end_y'), $db->getInt('move_id') % 2 == 1 ? $this->getWhiteID() : $this->getBlackID())) { |
|
148 | + if (0 != $this->tryMove($db->getInt('start_x'), $db->getInt('start_y'), $db->getInt('end_x'), $db->getInt('end_y'), $db->getInt('move_id') % 2 == 1 ? $this->getWhiteID() : $this->getBlackID())) { |
|
149 | 149 | break; |
150 | 150 | } |
151 | 151 | } |
152 | 152 | } |
153 | - catch(Exception $e) { |
|
154 | - if($debugInfo === true) { |
|
153 | + catch (Exception $e) { |
|
154 | + if ($debugInfo === true) { |
|
155 | 155 | echo $e->getMessage() . EOL . $e->getTraceAsString() . EOL; |
156 | 156 | } |
157 | 157 | // We probably tried an invalid move - move on. |
@@ -159,14 +159,14 @@ discard block |
||
159 | 159 | } |
160 | 160 | |
161 | 161 | public function getBoard() { |
162 | - if($this->board == null) { |
|
162 | + if ($this->board == null) { |
|
163 | 163 | $this->db->query('SELECT * FROM chess_game_pieces WHERE chess_game_id=' . $this->db->escapeNumber($this->chessGameID) . ';'); |
164 | 164 | $pieces = array(); |
165 | - while($this->db->nextRecord()) { |
|
165 | + while ($this->db->nextRecord()) { |
|
166 | 166 | $accountID = $this->db->getInt('account_id'); |
167 | 167 | $pieces[] = new ChessPiece($this->chessGameID, $accountID, $this->getColourForAccountID($accountID), $this->db->getInt('piece_id'), $this->db->getInt('x'), $this->db->getInt('y'), $this->db->getInt('piece_no')); |
168 | 168 | } |
169 | - $this->board =& $this->parsePieces($pieces); |
|
169 | + $this->board = & $this->parsePieces($pieces); |
|
170 | 170 | } |
171 | 171 | return $this->board; |
172 | 172 | } |
@@ -177,11 +177,11 @@ discard block |
||
177 | 177 | } |
178 | 178 | |
179 | 179 | public function getMoves() { |
180 | - if($this->moves == null) { |
|
180 | + if ($this->moves == null) { |
|
181 | 181 | $this->db->query('SELECT * FROM chess_game_moves WHERE chess_game_id = ' . $this->db->escapeNumber($this->chessGameID) . ' ORDER BY move_id;'); |
182 | 182 | $this->moves = array(); |
183 | 183 | $mate = false; |
184 | - while($this->db->nextRecord()) { |
|
184 | + while ($this->db->nextRecord()) { |
|
185 | 185 | $pieceTakenID = $this->db->getField('piece_taken') == null ? null : $this->db->getInt('piece_taken'); |
186 | 186 | $this->moves[] = $this->createMove($this->db->getInt('piece_id'), $this->db->getInt('start_x'), $this->db->getInt('start_y'), $this->db->getInt('end_x'), $this->db->getInt('end_y'), $pieceTakenID, $this->db->getField('checked'), $this->db->getInt('move_id') % 2 == 1 ? self::PLAYER_WHITE : self::PLAYER_BLACK, $this->db->getField('castling'), $this->db->getBoolean('en_passant'), $this->db->getInt('promote_piece_id')); |
187 | 187 | $mate = $this->db->getField('checked') == 'MATE'; |
@@ -196,11 +196,11 @@ discard block |
||
196 | 196 | ) |
197 | 197 | ); |
198 | 198 | } |
199 | - if(!$mate && $this->hasEnded()) { |
|
200 | - if($this->getWinner() != 0) { |
|
199 | + if (!$mate && $this->hasEnded()) { |
|
200 | + if ($this->getWinner() != 0) { |
|
201 | 201 | $this->moves[] = ($this->getWinner() == $this->getWhiteID() ? 'Black' : 'White') . ' Resigned.'; |
202 | 202 | } |
203 | - else if(count($this->moves) < 2) { |
|
203 | + else if (count($this->moves) < 2) { |
|
204 | 204 | $this->moves[] = 'Game Cancelled.'; |
205 | 205 | } |
206 | 206 | else { |
@@ -213,30 +213,30 @@ discard block |
||
213 | 213 | |
214 | 214 | public function getFENString() { |
215 | 215 | $fen = ''; |
216 | - $board =& $this->getBoard(); |
|
216 | + $board = & $this->getBoard(); |
|
217 | 217 | $blanks = 0; |
218 | - for($y=0; $y < 8; $y++) { |
|
219 | - if($y > 0) { |
|
218 | + for ($y = 0; $y < 8; $y++) { |
|
219 | + if ($y > 0) { |
|
220 | 220 | $fen .= '/'; |
221 | 221 | } |
222 | - for($x=0; $x < 8; $x++) { |
|
223 | - if($board[$y][$x] == null) { |
|
222 | + for ($x = 0; $x < 8; $x++) { |
|
223 | + if ($board[$y][$x] == null) { |
|
224 | 224 | $blanks++; |
225 | 225 | } |
226 | 226 | else { |
227 | - if($blanks > 0) { |
|
227 | + if ($blanks > 0) { |
|
228 | 228 | $fen .= $blanks; |
229 | 229 | $blanks = 0; |
230 | 230 | } |
231 | 231 | $fen .= $board[$y][$x]->getPieceLetter(); |
232 | 232 | } |
233 | 233 | } |
234 | - if($blanks > 0) { |
|
234 | + if ($blanks > 0) { |
|
235 | 235 | $fen .= $blanks; |
236 | 236 | $blanks = 0; |
237 | 237 | } |
238 | 238 | } |
239 | - switch($this->getCurrentTurnColour()) { |
|
239 | + switch ($this->getCurrentTurnColour()) { |
|
240 | 240 | case self::PLAYER_WHITE: |
241 | 241 | $fen .= ' w '; |
242 | 242 | break; |
@@ -247,30 +247,30 @@ discard block |
||
247 | 247 | |
248 | 248 | // Castling |
249 | 249 | $castling = ''; |
250 | - if($this->hasMoved[self::PLAYER_WHITE][ChessPiece::KING] !== true) { |
|
251 | - if($this->hasMoved[self::PLAYER_WHITE][ChessPiece::ROOK]['King'] !== true) { |
|
250 | + if ($this->hasMoved[self::PLAYER_WHITE][ChessPiece::KING] !== true) { |
|
251 | + if ($this->hasMoved[self::PLAYER_WHITE][ChessPiece::ROOK]['King'] !== true) { |
|
252 | 252 | $castling .= 'K'; |
253 | 253 | } |
254 | - if($this->hasMoved[self::PLAYER_WHITE][ChessPiece::ROOK]['Queen'] !== true) { |
|
254 | + if ($this->hasMoved[self::PLAYER_WHITE][ChessPiece::ROOK]['Queen'] !== true) { |
|
255 | 255 | $castling .= 'Q'; |
256 | 256 | } |
257 | 257 | } |
258 | - if($this->hasMoved[self::PLAYER_BLACK][ChessPiece::KING] !== true) { |
|
259 | - if($this->hasMoved[self::PLAYER_BLACK][ChessPiece::ROOK]['King'] !== true) { |
|
258 | + if ($this->hasMoved[self::PLAYER_BLACK][ChessPiece::KING] !== true) { |
|
259 | + if ($this->hasMoved[self::PLAYER_BLACK][ChessPiece::ROOK]['King'] !== true) { |
|
260 | 260 | $castling .= 'k'; |
261 | 261 | } |
262 | - if($this->hasMoved[self::PLAYER_BLACK][ChessPiece::ROOK]['Queen'] !== true) { |
|
262 | + if ($this->hasMoved[self::PLAYER_BLACK][ChessPiece::ROOK]['Queen'] !== true) { |
|
263 | 263 | $castling .= 'q'; |
264 | 264 | } |
265 | 265 | } |
266 | - if($castling == '') { |
|
266 | + if ($castling == '') { |
|
267 | 267 | $castling = '-'; |
268 | 268 | } |
269 | 269 | $fen .= $castling . ' '; |
270 | 270 | |
271 | - if($this->hasMoved[ChessPiece::PAWN][0] != -1) { |
|
271 | + if ($this->hasMoved[ChessPiece::PAWN][0] != -1) { |
|
272 | 272 | $fen .= chr(ord('a') + $this->hasMoved[ChessPiece::PAWN][0]); |
273 | - switch($this->hasMoved[ChessPiece::PAWN][1]) { |
|
273 | + switch ($this->hasMoved[ChessPiece::PAWN][1]) { |
|
274 | 274 | case 3: |
275 | 275 | $fen .= '6'; |
276 | 276 | break; |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | else { |
283 | 283 | $fen .= '-'; |
284 | 284 | } |
285 | - $fen .= ' 0 ' . floor(count($this->moves)/2); |
|
285 | + $fen .= ' 0 ' . floor(count($this->moves) / 2); |
|
286 | 286 | |
287 | 287 | return $fen; |
288 | 288 | } |
@@ -312,17 +312,17 @@ discard block |
||
312 | 312 | public static function &parsePieces(array &$pieces) { |
313 | 313 | $board = array(); |
314 | 314 | $row = array(); |
315 | - for($i=0;$i<8;$i++) { |
|
315 | + for ($i = 0; $i < 8; $i++) { |
|
316 | 316 | $row[] = null; |
317 | 317 | } |
318 | - for($i=0;$i<8;$i++) { |
|
318 | + for ($i = 0; $i < 8; $i++) { |
|
319 | 319 | $board[] = $row; |
320 | 320 | } |
321 | - foreach($pieces as &$piece) { |
|
322 | - if($board[$piece->getY()][$piece->getX()] != null) { |
|
321 | + foreach ($pieces as &$piece) { |
|
322 | + if ($board[$piece->getY()][$piece->getX()] != null) { |
|
323 | 323 | throw new Exception('Two pieces found in the same tile.'); |
324 | 324 | } |
325 | - $board[$piece->getY()][$piece->getX()] =& $piece; |
|
325 | + $board[$piece->getY()][$piece->getX()] = & $piece; |
|
326 | 326 | } |
327 | 327 | return $board; |
328 | 328 | } |
@@ -330,8 +330,7 @@ discard block |
||
330 | 330 | public static function getStandardGame($gameID, AbstractSmrPlayer &$whitePlayer, AbstractSmrPlayer &$blackPlayer) { |
331 | 331 | $white = $whitePlayer->getAccountID(); |
332 | 332 | $black = $blackPlayer->getAccountID(); |
333 | - return array |
|
334 | - ( |
|
333 | + return array( |
|
335 | 334 | new ChessPiece($gameID, $black, self::PLAYER_BLACK, ChessPiece::ROOK, 0, 0), |
336 | 335 | new ChessPiece($gameID, $black, self::PLAYER_BLACK, ChessPiece::KNIGHT, 1, 0), |
337 | 336 | new ChessPiece($gameID, $black, self::PLAYER_BLACK, ChessPiece::BISHOP, 2, 0), |
@@ -371,7 +370,7 @@ discard block |
||
371 | 370 | } |
372 | 371 | |
373 | 372 | public static function insertNewGame($startDate, $endDate, AbstractSmrPlayer &$whitePlayer, AbstractSmrPlayer &$blackPlayer) { |
374 | - if($startDate == null) { |
|
373 | + if ($startDate == null) { |
|
375 | 374 | throw new Exception('Start date cannot be null.'); |
376 | 375 | } |
377 | 376 | |
@@ -389,7 +388,7 @@ discard block |
||
389 | 388 | private static function insertPieces($chessGameID, AbstractSmrPlayer &$whitePlayer, AbstractSmrPlayer &$blackPlayer) { |
390 | 389 | $db = new SmrMySqlDatabase(); |
391 | 390 | $pieces = self::getStandardGame($chessGameID, $whitePlayer, $blackPlayer); |
392 | - foreach($pieces as $p) { |
|
391 | + foreach ($pieces as $p) { |
|
393 | 392 | $db->query('INSERT INTO chess_game_pieces' . |
394 | 393 | '(chess_game_id,account_id,piece_id,x,y)' . |
395 | 394 | 'values' . |
@@ -399,61 +398,61 @@ discard block |
||
399 | 398 | |
400 | 399 | public function createMove($pieceID, $startX, $startY, $endX, $endY, $pieceTaken, $checking, $playerColour, $castling, $enPassant, $promotionPieceID) { |
401 | 400 | $otherPlayerColour = self::getOtherColour($playerColour); |
402 | - if($pieceID == ChessPiece::KING) { |
|
401 | + if ($pieceID == ChessPiece::KING) { |
|
403 | 402 | $this->hasMoved[$playerColour][ChessPiece::KING] = true; |
404 | 403 | } |
405 | 404 | // Check if the piece moving is a rook and mark it as moved to stop castling. |
406 | - if($pieceID == ChessPiece::ROOK && ($startX == 0 || $startX == 7) && ($startY == ($playerColour == self::PLAYER_WHITE ? 7 : 0))) { |
|
407 | - $this->hasMoved[$playerColour][ChessPiece::ROOK][$startX==0?'Queen':'King'] = true; |
|
405 | + if ($pieceID == ChessPiece::ROOK && ($startX == 0 || $startX == 7) && ($startY == ($playerColour == self::PLAYER_WHITE ? 7 : 0))) { |
|
406 | + $this->hasMoved[$playerColour][ChessPiece::ROOK][$startX == 0 ? 'Queen' : 'King'] = true; |
|
408 | 407 | } |
409 | 408 | // Check if we've taken a rook and marked them as moved, if they've already moved this does nothing, but if they were taken before moving this stops an issue with trying to castle with a non-existent castle. |
410 | - if($pieceTaken == ChessPiece::ROOK && ($endX == 0 || $endX == 7) && $endY == ($otherPlayerColour == self::PLAYER_WHITE ? 7 : 0)) { |
|
411 | - $this->hasMoved[$otherPlayerColour][ChessPiece::ROOK][$endX==0?'Queen':'King'] = true; |
|
409 | + if ($pieceTaken == ChessPiece::ROOK && ($endX == 0 || $endX == 7) && $endY == ($otherPlayerColour == self::PLAYER_WHITE ? 7 : 0)) { |
|
410 | + $this->hasMoved[$otherPlayerColour][ChessPiece::ROOK][$endX == 0 ? 'Queen' : 'King'] = true; |
|
412 | 411 | } |
413 | - if($pieceID == ChessPiece::PAWN && ($startY == 1 || $startY == 6) && ($endY == 3 || $endY == 4)) { |
|
412 | + if ($pieceID == ChessPiece::PAWN && ($startY == 1 || $startY == 6) && ($endY == 3 || $endY == 4)) { |
|
414 | 413 | $this->hasMoved[ChessPiece::PAWN] = array($endX, $endY); |
415 | 414 | } |
416 | 415 | else { |
417 | - $this->hasMoved[ChessPiece::PAWN] = array(-1,-1); |
|
416 | + $this->hasMoved[ChessPiece::PAWN] = array(-1, -1); |
|
418 | 417 | } |
419 | 418 | return ($castling == 'Queen' ? '0-0-0' : ($castling == 'King' ? '0-0' : '')) |
420 | 419 | . ChessPiece::getSymbolForPiece($pieceID, $playerColour) |
421 | - . chr(ord('a')+$startX) |
|
422 | - . (8-$startY) |
|
420 | + . chr(ord('a') + $startX) |
|
421 | + . (8 - $startY) |
|
423 | 422 | . ' ' |
424 | 423 | . ($pieceTaken == null ? '' : ChessPiece::getSymbolForPiece($pieceTaken, $otherPlayerColour)) |
425 | - . chr(ord('a')+$endX) |
|
426 | - . (8-$endY) |
|
424 | + . chr(ord('a') + $endX) |
|
425 | + . (8 - $endY) |
|
427 | 426 | . ($promotionPieceID == null ? '' : ChessPiece::getSymbolForPiece($promotionPieceID, $playerColour)) |
428 | 427 | . ' ' |
429 | - . ($checking == null ? '' : ($checking == 'CHECK' ? '+' : '++') ) |
|
428 | + . ($checking == null ? '' : ($checking == 'CHECK' ? '+' : '++')) |
|
430 | 429 | . ($enPassant ? ' e.p.' : ''); |
431 | 430 | } |
432 | 431 | |
433 | 432 | public function isCheckmated($colour) { |
434 | - $board =& $this->board; |
|
435 | - $hasMoved =& $this->getHasMoved(); |
|
433 | + $board = & $this->board; |
|
434 | + $hasMoved = & $this->getHasMoved(); |
|
436 | 435 | $king = null; |
437 | - foreach($board as $row) { |
|
438 | - foreach($row as $piece) { |
|
439 | - if($piece != null && $piece->pieceID == ChessPiece::KING && $piece->colour == $colour) { |
|
436 | + foreach ($board as $row) { |
|
437 | + foreach ($row as $piece) { |
|
438 | + if ($piece != null && $piece->pieceID == ChessPiece::KING && $piece->colour == $colour) { |
|
440 | 439 | $king = $piece; |
441 | 440 | break; |
442 | 441 | } |
443 | 442 | } |
444 | 443 | } |
445 | - if($king == null) { |
|
444 | + if ($king == null) { |
|
446 | 445 | throw new Exception('Could not find the king: game id = ' . $this->chessGameID); |
447 | 446 | } |
448 | - if(!self::isPlayerChecked($board, $hasMoved, $colour)) { |
|
447 | + if (!self::isPlayerChecked($board, $hasMoved, $colour)) { |
|
449 | 448 | return false; |
450 | 449 | } |
451 | - foreach($board as $row) { |
|
452 | - foreach($row as $piece) { |
|
453 | - if($piece != null && $piece->colour == $colour) { |
|
450 | + foreach ($board as $row) { |
|
451 | + foreach ($row as $piece) { |
|
452 | + if ($piece != null && $piece->colour == $colour) { |
|
454 | 453 | $moves = $piece->getPossibleMoves($board, $hasMoved); |
455 | 454 | //There are moves we can make, we are clearly not checkmated. |
456 | - if(count($moves) > 0) { |
|
455 | + if (count($moves) > 0) { |
|
457 | 456 | return false; |
458 | 457 | } |
459 | 458 | } |
@@ -464,15 +463,15 @@ discard block |
||
464 | 463 | |
465 | 464 | public static function isCastling($x, $toX) { |
466 | 465 | $movement = $toX - $x; |
467 | - if(abs($movement) == 2) { |
|
466 | + if (abs($movement) == 2) { |
|
468 | 467 | //To the left. |
469 | - if($movement == -2) { |
|
468 | + if ($movement == -2) { |
|
470 | 469 | return array('Type' => 'Queen', |
471 | 470 | 'X' => 0, |
472 | 471 | 'ToX' => 3 |
473 | 472 | ); |
474 | 473 | } //To the right |
475 | - else if($movement == 2) { |
|
474 | + else if ($movement == 2) { |
|
476 | 475 | return array('Type' => 'King', |
477 | 476 | 'X' => 7, |
478 | 477 | 'ToX' => 5 |
@@ -483,36 +482,36 @@ discard block |
||
483 | 482 | } |
484 | 483 | |
485 | 484 | public static function movePiece(array &$board, array &$hasMoved, $x, $y, $toX, $toY, $pawnPromotionPiece = ChessPiece::QUEEN) { |
486 | - if(!self::isValidCoord($x, $y, $board)) { |
|
485 | + if (!self::isValidCoord($x, $y, $board)) { |
|
487 | 486 | throw new Exception('Invalid from coordinates, x=' . $x . ', y=' . $y); |
488 | 487 | } |
489 | - if(!self::isValidCoord($toX, $toY, $board)) { |
|
488 | + if (!self::isValidCoord($toX, $toY, $board)) { |
|
490 | 489 | throw new Exception('Invalid to coordinates, x=' . $toX . ', y=' . $toY); |
491 | 490 | } |
492 | 491 | $pieceTaken = $board[$toY][$toX]; |
493 | 492 | $board[$toY][$toX] = $board[$y][$x]; |
494 | - $p =& $board[$toY][$toX]; |
|
493 | + $p = & $board[$toY][$toX]; |
|
495 | 494 | $board[$y][$x] = null; |
496 | - if($p == null) { |
|
495 | + if ($p == null) { |
|
497 | 496 | throw new Exception('Trying to move non-existent piece: ' . var_export($board, true)); |
498 | 497 | } |
499 | 498 | $p->setX($toX); |
500 | 499 | $p->setY($toY); |
501 | 500 | |
502 | 501 | $oldPawnMovement = $hasMoved[ChessPiece::PAWN]; |
503 | - $nextPawnMovement = array(-1,-1); |
|
502 | + $nextPawnMovement = array(-1, -1); |
|
504 | 503 | $castling = false; |
505 | 504 | $enPassant = false; |
506 | 505 | $rookMoved = false; |
507 | 506 | $rookTaken = false; |
508 | 507 | $pawnPromotion = false; |
509 | - if($p->pieceID == ChessPiece::KING) { |
|
508 | + if ($p->pieceID == ChessPiece::KING) { |
|
510 | 509 | //Castling? |
511 | 510 | $castling = self::isCastling($x, $toX); |
512 | - if($castling !== false) { |
|
511 | + if ($castling !== false) { |
|
513 | 512 | $hasMoved[$p->colour][ChessPiece::KING] = true; |
514 | 513 | $hasMoved[$p->colour][ChessPiece::ROOK][$castling['Type']] = true; |
515 | - if($board[$y][$castling['X']] == null) { |
|
514 | + if ($board[$y][$castling['X']] == null) { |
|
516 | 515 | throw new Exception('Cannot castle with non-existent castle.'); |
517 | 516 | } |
518 | 517 | $board[$toY][$castling['ToX']] = $board[$y][$castling['X']]; |
@@ -520,37 +519,37 @@ discard block |
||
520 | 519 | $board[$y][$castling['X']] = null; |
521 | 520 | } |
522 | 521 | } |
523 | - else if($p->pieceID == ChessPiece::PAWN) { |
|
524 | - if($toY == 0 || $toY == 7) { |
|
522 | + else if ($p->pieceID == ChessPiece::PAWN) { |
|
523 | + if ($toY == 0 || $toY == 7) { |
|
525 | 524 | $pawnPromotion = $p->promote($pawnPromotionPiece, $board); |
526 | 525 | } |
527 | 526 | //Double move to track? |
528 | - else if(($y == 1 || $y == 6) && ($toY == 3 || $toY == 4)) { |
|
527 | + else if (($y == 1 || $y == 6) && ($toY == 3 || $toY == 4)) { |
|
529 | 528 | $nextPawnMovement = array($toX, $toY); |
530 | 529 | } |
531 | 530 | //En passant? |
532 | - else if($hasMoved[ChessPiece::PAWN][0] == $toX && |
|
531 | + else if ($hasMoved[ChessPiece::PAWN][0] == $toX && |
|
533 | 532 | ($hasMoved[ChessPiece::PAWN][1] == 3 && $toY == 2 || $hasMoved[ChessPiece::PAWN][1] == 4 && $toY == 5)) { |
534 | 533 | $enPassant = true; |
535 | 534 | $pieceTaken = $board[$hasMoved[ChessPiece::PAWN][1]][$hasMoved[ChessPiece::PAWN][0]]; |
536 | - if($board[$hasMoved[ChessPiece::PAWN][1]][$hasMoved[ChessPiece::PAWN][0]] == null) { |
|
535 | + if ($board[$hasMoved[ChessPiece::PAWN][1]][$hasMoved[ChessPiece::PAWN][0]] == null) { |
|
537 | 536 | throw new Exception('Cannot en passant a non-existent pawn.'); |
538 | 537 | } |
539 | 538 | $board[$hasMoved[ChessPiece::PAWN][1]][$hasMoved[ChessPiece::PAWN][0]] = null; |
540 | 539 | } |
541 | 540 | } |
542 | - else if($p->pieceID == ChessPiece::ROOK && ($x == 0 || $x == 7) && $y == ($p->colour == self::PLAYER_WHITE ? 7 : 0)) { |
|
541 | + else if ($p->pieceID == ChessPiece::ROOK && ($x == 0 || $x == 7) && $y == ($p->colour == self::PLAYER_WHITE ? 7 : 0)) { |
|
543 | 542 | //Rook moved? |
544 | - if($hasMoved[$p->colour][ChessPiece::ROOK][$x==0?'Queen':'King'] === false) { |
|
543 | + if ($hasMoved[$p->colour][ChessPiece::ROOK][$x == 0 ? 'Queen' : 'King'] === false) { |
|
545 | 544 | // We set rook moved in here as it's used for move info. |
546 | - $rookMoved = $x==0?'Queen':'King'; |
|
545 | + $rookMoved = $x == 0 ? 'Queen' : 'King'; |
|
547 | 546 | $hasMoved[$p->colour][ChessPiece::ROOK][$rookMoved] = true; |
548 | 547 | } |
549 | 548 | } |
550 | 549 | // Check if we've taken a rook and marked them as moved, if they've already moved this does nothing, but if they were taken before moving this stops an issue with trying to castle with a non-existent castle. |
551 | - if($pieceTaken != null && $pieceTaken->pieceID == ChessPiece::ROOK && ($toX == 0 || $toX == 7) && $toY == ($pieceTaken->colour == self::PLAYER_WHITE ? 7 : 0)) { |
|
552 | - if($hasMoved[$pieceTaken->colour][ChessPiece::ROOK][$toX==0?'Queen':'King'] === false) { |
|
553 | - $rookTaken = $toX==0?'Queen':'King'; |
|
550 | + if ($pieceTaken != null && $pieceTaken->pieceID == ChessPiece::ROOK && ($toX == 0 || $toX == 7) && $toY == ($pieceTaken->colour == self::PLAYER_WHITE ? 7 : 0)) { |
|
551 | + if ($hasMoved[$pieceTaken->colour][ChessPiece::ROOK][$toX == 0 ? 'Queen' : 'King'] === false) { |
|
552 | + $rookTaken = $toX == 0 ? 'Queen' : 'King'; |
|
554 | 553 | $hasMoved[$pieceTaken->colour][ChessPiece::ROOK][$rookTaken] = true; |
555 | 554 | } |
556 | 555 | } |
@@ -567,18 +566,18 @@ discard block |
||
567 | 566 | } |
568 | 567 | |
569 | 568 | public static function undoMovePiece(array &$board, array &$hasMoved, $x, $y, $toX, $toY, $moveInfo) { |
570 | - if(!self::isValidCoord($x, $y, $board)) { |
|
569 | + if (!self::isValidCoord($x, $y, $board)) { |
|
571 | 570 | throw new Exception('Invalid from coordinates, x=' . $x . ', y=' . $y); |
572 | 571 | } |
573 | - if(!self::isValidCoord($toX, $toY, $board)) { |
|
572 | + if (!self::isValidCoord($toX, $toY, $board)) { |
|
574 | 573 | throw new Exception('Invalid to coordinates, x=' . $toX . ', y=' . $toY); |
575 | 574 | } |
576 | - if($board[$y][$x] != null) { |
|
575 | + if ($board[$y][$x] != null) { |
|
577 | 576 | throw new Exception('Undoing move onto another piece? x=' . $x . ', y=' . $y); |
578 | 577 | } |
579 | 578 | $board[$y][$x] = $board[$toY][$toX]; |
580 | - $p =& $board[$y][$x]; |
|
581 | - if($p == null) { |
|
579 | + $p = & $board[$y][$x]; |
|
580 | + if ($p == null) { |
|
582 | 581 | throw new Exception('Trying to undo move of a non-existent piece: ' . var_export($board, true)); |
583 | 582 | } |
584 | 583 | $board[$toY][$toX] = $moveInfo['PieceTaken']; |
@@ -587,12 +586,12 @@ discard block |
||
587 | 586 | |
588 | 587 | $hasMoved[ChessPiece::PAWN] = $moveInfo['OldPawnMovement']; |
589 | 588 | //Castling |
590 | - if($p->pieceID == ChessPiece::KING) { |
|
589 | + if ($p->pieceID == ChessPiece::KING) { |
|
591 | 590 | $castling = self::isCastling($x, $toX); |
592 | - if($castling !== false) { |
|
591 | + if ($castling !== false) { |
|
593 | 592 | $hasMoved[$p->colour][ChessPiece::KING] = false; |
594 | 593 | $hasMoved[$p->colour][ChessPiece::ROOK][$castling['Type']] = false; |
595 | - if($board[$toY][$castling['ToX']] == null) { |
|
594 | + if ($board[$toY][$castling['ToX']] == null) { |
|
596 | 595 | throw new Exception('Cannot undo castle with non-existent castle.'); |
597 | 596 | } |
598 | 597 | $board[$y][$castling['X']] = $board[$toY][$castling['ToX']]; |
@@ -600,25 +599,25 @@ discard block |
||
600 | 599 | $board[$toY][$castling['ToX']] = null; |
601 | 600 | } |
602 | 601 | } |
603 | - else if($moveInfo['EnPassant'] === true) { |
|
602 | + else if ($moveInfo['EnPassant'] === true) { |
|
604 | 603 | $board[$toY][$toX] = null; |
605 | 604 | $board[$hasMoved[ChessPiece::PAWN][1]][$hasMoved[ChessPiece::PAWN][0]] = $moveInfo['PieceTaken']; |
606 | 605 | } |
607 | - else if($moveInfo['RookMoved'] !== false) { |
|
606 | + else if ($moveInfo['RookMoved'] !== false) { |
|
608 | 607 | $hasMoved[$p->colour][ChessPiece::ROOK][$moveInfo['RookMoved']] = false; |
609 | 608 | } |
610 | - if($moveInfo['RookTaken'] !== false) { |
|
609 | + if ($moveInfo['RookTaken'] !== false) { |
|
611 | 610 | $hasMoved[$moveInfo['PieceTaken']->colour][ChessPiece::ROOK][$moveInfo['RookTaken']] = false; |
612 | 611 | } |
613 | 612 | } |
614 | 613 | |
615 | 614 | public function tryAlgebraicMove($move) { |
616 | - if(strlen($move) != 4 && strlen($move) != 5) { |
|
615 | + if (strlen($move) != 4 && strlen($move) != 5) { |
|
617 | 616 | throw new Exception('Move of length "' . strlen($move) . '" is not valid, full move: ' . $move); |
618 | 617 | } |
619 | 618 | $aVal = ord('a'); |
620 | 619 | $hVal = ord('h'); |
621 | - if(ord($move[0]) < $aVal || ord($move[2]) < $aVal |
|
620 | + if (ord($move[0]) < $aVal || ord($move[2]) < $aVal |
|
622 | 621 | || ord($move[0]) > $hVal || ord($move[2]) > $hVal |
623 | 622 | || $move[1] < 1 || $move[3] < 1 |
624 | 623 | || $move[1] > 8 || $move[3] > 8) { |
@@ -629,73 +628,73 @@ discard block |
||
629 | 628 | $toX = ord($move[2]) - $aVal; |
630 | 629 | $toY = 8 - $move[3]; |
631 | 630 | $pawnPromotionPiece = null; |
632 | - if(isset($move[4])) { |
|
631 | + if (isset($move[4])) { |
|
633 | 632 | $pawnPromotionPiece = ChessPiece::getPieceForLetter($move[4]); |
634 | 633 | } |
635 | 634 | return $this->tryMove($x, $y, $toX, $toY, $this->getCurrentTurnAccountID(), $pawnPromotionPiece); |
636 | 635 | } |
637 | 636 | |
638 | 637 | public function tryMove($x, $y, $toX, $toY, $forAccountID, $pawnPromotionPiece) { |
639 | - if($this->hasEnded()) { |
|
638 | + if ($this->hasEnded()) { |
|
640 | 639 | return 5; |
641 | 640 | } |
642 | - if($this->getCurrentTurnAccountID() != $forAccountID) { |
|
641 | + if ($this->getCurrentTurnAccountID() != $forAccountID) { |
|
643 | 642 | return 4; |
644 | 643 | } |
645 | - $lastTurnPlayer =& $this->getCurrentTurnPlayer(); |
|
644 | + $lastTurnPlayer = & $this->getCurrentTurnPlayer(); |
|
646 | 645 | $this->getBoard(); |
647 | 646 | $p = $this->board[$y][$x]; |
648 | - if($p == null || $p->colour != $this->getColourForAccountID($forAccountID)) { |
|
647 | + if ($p == null || $p->colour != $this->getColourForAccountID($forAccountID)) { |
|
649 | 648 | return 2; |
650 | 649 | } |
651 | 650 | |
652 | 651 | $moves = $p->getPossibleMoves($this->board, $this->getHasMoved(), $forAccountID); |
653 | - foreach($moves as $move) { |
|
654 | - if($move[0]==$toX && $move[1]==$toY) { |
|
652 | + foreach ($moves as $move) { |
|
653 | + if ($move[0] == $toX && $move[1] == $toY) { |
|
655 | 654 | $chessType = $this->isNPCGame() ? 'Chess (NPC)' : 'Chess'; |
656 | - $currentPlayer =& $this->getCurrentTurnPlayer(); |
|
655 | + $currentPlayer = & $this->getCurrentTurnPlayer(); |
|
657 | 656 | |
658 | 657 | $moveInfo = ChessGame::movePiece($this->board, $this->getHasMoved(), $x, $y, $toX, $toY, $pawnPromotionPiece); |
659 | 658 | |
660 | 659 | //We have taken the move, we should refresh $p |
661 | - $p =& $this->board[$toY][$toX]; |
|
660 | + $p = & $this->board[$toY][$toX]; |
|
662 | 661 | |
663 | 662 | $pieceTakenID = null; |
664 | - if($moveInfo['PieceTaken'] != null) { |
|
663 | + if ($moveInfo['PieceTaken'] != null) { |
|
665 | 664 | $pieceTakenID = $moveInfo['PieceTaken']->pieceID; |
666 | - if($moveInfo['PieceTaken']->pieceID == ChessPiece::KING) { |
|
665 | + if ($moveInfo['PieceTaken']->pieceID == ChessPiece::KING) { |
|
667 | 666 | throw new Exception('King was taken.'); |
668 | 667 | } |
669 | 668 | } |
670 | 669 | |
671 | 670 | $pieceID = $p->pieceID; |
672 | 671 | $pieceNo = $p->pieceNo; |
673 | - if($moveInfo['PawnPromotion'] !== false) { |
|
672 | + if ($moveInfo['PawnPromotion'] !== false) { |
|
674 | 673 | $p->pieceID = $moveInfo['PawnPromotion']['PieceID']; |
675 | 674 | $p->pieceNo = $moveInfo['PawnPromotion']['PieceNo']; |
676 | 675 | } |
677 | 676 | |
678 | 677 | $checking = null; |
679 | - if($p->isAttacking($this->board, $this->getHasMoved(), true)) { |
|
678 | + if ($p->isAttacking($this->board, $this->getHasMoved(), true)) { |
|
680 | 679 | $checking = 'CHECK'; |
681 | 680 | } |
682 | - if($this->isCheckmated(self::getOtherColour($p->colour))) { |
|
681 | + if ($this->isCheckmated(self::getOtherColour($p->colour))) { |
|
683 | 682 | $checking = 'MATE'; |
684 | 683 | } |
685 | - if($this->moves!=null) { |
|
684 | + if ($this->moves != null) { |
|
686 | 685 | $this->moves[] = $this->createMove($pieceID, $x, $y, $toX, $toY, $pieceTakenID, $checking, $this->getCurrentTurnColour(), $moveInfo['Castling']['Type'], $moveInfo['EnPassant'], $moveInfo['PawnPromotion'] === false ? null : $moveInfo['PawnPromotion']['PieceID']); |
687 | 686 | } |
688 | - if(self::isPlayerChecked($this->board, $this->getHasMoved(), $p->colour)) { |
|
687 | + if (self::isPlayerChecked($this->board, $this->getHasMoved(), $p->colour)) { |
|
689 | 688 | return 3; |
690 | 689 | } |
691 | 690 | |
692 | - $otherPlayer =& $this->getCurrentTurnPlayer(); |
|
693 | - if($moveInfo['PawnPromotion'] !== false) { |
|
691 | + $otherPlayer = & $this->getCurrentTurnPlayer(); |
|
692 | + if ($moveInfo['PawnPromotion'] !== false) { |
|
694 | 693 | $piecePromotedSymbol = $p->getPieceSymbol(); |
695 | - $currentPlayer->increaseHOF(1, array($chessType,'Moves','Own Pawns Promoted','Total'), HOF_PUBLIC); |
|
696 | - $otherPlayer->increaseHOF(1, array($chessType,'Moves','Opponent Pawns Promoted','Total'), HOF_PUBLIC); |
|
697 | - $currentPlayer->increaseHOF(1, array($chessType,'Moves','Own Pawns Promoted',$piecePromotedSymbol), HOF_PUBLIC); |
|
698 | - $otherPlayer->increaseHOF(1, array($chessType,'Moves','Opponent Pawns Promoted',$piecePromotedSymbol), HOF_PUBLIC); |
|
694 | + $currentPlayer->increaseHOF(1, array($chessType, 'Moves', 'Own Pawns Promoted', 'Total'), HOF_PUBLIC); |
|
695 | + $otherPlayer->increaseHOF(1, array($chessType, 'Moves', 'Opponent Pawns Promoted', 'Total'), HOF_PUBLIC); |
|
696 | + $currentPlayer->increaseHOF(1, array($chessType, 'Moves', 'Own Pawns Promoted', $piecePromotedSymbol), HOF_PUBLIC); |
|
697 | + $otherPlayer->increaseHOF(1, array($chessType, 'Moves', 'Opponent Pawns Promoted', $piecePromotedSymbol), HOF_PUBLIC); |
|
699 | 698 | } |
700 | 699 | $this->db->query('INSERT INTO chess_game_moves |
701 | 700 | (chess_game_id,piece_id,start_x,start_y,end_x,end_y,checked,piece_taken,castling,en_passant,promote_piece_id) |
@@ -703,37 +702,37 @@ discard block |
||
703 | 702 | (' . $this->db->escapeNumber($p->gameID) . ',' . $this->db->escapeNumber($pieceID) . ',' . $this->db->escapeNumber($x) . ',' . $this->db->escapeNumber($y) . ',' . $this->db->escapeNumber($toX) . ',' . $this->db->escapeNumber($toY) . ',' . $this->db->escapeString($checking, true, true) . ',' . ($moveInfo['PieceTaken'] == null ? 'NULL' : $this->db->escapeNumber($moveInfo['PieceTaken']->pieceID)) . ',' . $this->db->escapeString($moveInfo['Castling']['Type'], true, true) . ',' . $this->db->escapeBoolean($moveInfo['EnPassant']) . ',' . ($moveInfo['PawnPromotion'] == false ? 'NULL' : $this->db->escapeNumber($moveInfo['PawnPromotion']['PieceID'])) . ');'); |
704 | 703 | |
705 | 704 | |
706 | - $currentPlayer->increaseHOF(1, array($chessType,'Moves','Total Taken'), HOF_PUBLIC); |
|
707 | - if($moveInfo['PieceTaken'] != null) { |
|
705 | + $currentPlayer->increaseHOF(1, array($chessType, 'Moves', 'Total Taken'), HOF_PUBLIC); |
|
706 | + if ($moveInfo['PieceTaken'] != null) { |
|
708 | 707 | $this->db->query('DELETE FROM chess_game_pieces |
709 | 708 | WHERE chess_game_id=' . $this->db->escapeNumber($this->chessGameID) . ' AND account_id=' . $this->db->escapeNumber($moveInfo['PieceTaken']->accountID) . ' AND piece_id=' . $this->db->escapeNumber($moveInfo['PieceTaken']->pieceID) . ' AND piece_no=' . $this->db->escapeNumber($moveInfo['PieceTaken']->pieceNo) . ';'); |
710 | 709 | |
711 | 710 | $pieceTakenSymbol = $moveInfo['PieceTaken']->getPieceSymbol(); |
712 | - $currentPlayer->increaseHOF(1, array($chessType,'Moves','Opponent Pieces Taken','Total'), HOF_PUBLIC); |
|
713 | - $otherPlayer->increaseHOF(1, array($chessType,'Moves','Own Pieces Taken','Total'), HOF_PUBLIC); |
|
714 | - $currentPlayer->increaseHOF(1, array($chessType,'Moves','Opponent Pieces Taken',$pieceTakenSymbol), HOF_PUBLIC); |
|
715 | - $otherPlayer->increaseHOF(1, array($chessType,'Moves','Own Pieces Taken',$pieceTakenSymbol), HOF_PUBLIC); |
|
711 | + $currentPlayer->increaseHOF(1, array($chessType, 'Moves', 'Opponent Pieces Taken', 'Total'), HOF_PUBLIC); |
|
712 | + $otherPlayer->increaseHOF(1, array($chessType, 'Moves', 'Own Pieces Taken', 'Total'), HOF_PUBLIC); |
|
713 | + $currentPlayer->increaseHOF(1, array($chessType, 'Moves', 'Opponent Pieces Taken', $pieceTakenSymbol), HOF_PUBLIC); |
|
714 | + $otherPlayer->increaseHOF(1, array($chessType, 'Moves', 'Own Pieces Taken', $pieceTakenSymbol), HOF_PUBLIC); |
|
716 | 715 | } |
717 | 716 | $this->db->query('UPDATE chess_game_pieces |
718 | 717 | SET x=' . $this->db->escapeNumber($toX) . ', y=' . $this->db->escapeNumber($toY) . |
719 | 718 | ($moveInfo['PawnPromotion'] !== false ? ', piece_id=' . $this->db->escapeNumber($moveInfo['PawnPromotion']['PieceID']) . ', piece_no=' . $this->db->escapeNumber($moveInfo['PawnPromotion']['PieceNo']) : '') . ' |
720 | 719 | WHERE chess_game_id=' . $this->db->escapeNumber($this->chessGameID) . ' AND account_id=' . $this->db->escapeNumber($p->accountID) . ' AND piece_id=' . $this->db->escapeNumber($pieceID) . ' AND piece_no=' . $this->db->escapeNumber($pieceNo) . ';'); |
721 | - if($moveInfo['Castling'] !== false) { |
|
720 | + if ($moveInfo['Castling'] !== false) { |
|
722 | 721 | $this->db->query('UPDATE chess_game_pieces |
723 | 722 | SET x=' . $this->db->escapeNumber($moveInfo['Castling']['ToX']) . ' |
724 | 723 | WHERE chess_game_id=' . $this->db->escapeNumber($this->chessGameID) . ' AND account_id=' . $this->db->escapeNumber($p->accountID) . ' AND x = ' . $this->db->escapeNumber($moveInfo['Castling']['X']) . ' AND y = ' . $this->db->escapeNumber($y) . ';'); |
725 | 724 | } |
726 | 725 | $return = 0; |
727 | - if($checking == 'MATE') { |
|
726 | + if ($checking == 'MATE') { |
|
728 | 727 | $this->setWinner($forAccountID); |
729 | 728 | $return = 1; |
730 | 729 | SmrPlayer::sendMessageFromCasino($lastTurnPlayer->getGameID(), $this->getCurrentTurnAccountID(), 'You have just lost [chess=' . $this->getChessGameID() . '] against [player=' . $lastTurnPlayer->getPlayerID() . '].'); |
731 | 730 | } |
732 | 731 | else { |
733 | 732 | SmrPlayer::sendMessageFromCasino($lastTurnPlayer->getGameID(), $this->getCurrentTurnAccountID(), 'It is now your turn in [chess=' . $this->getChessGameID() . '] against [player=' . $lastTurnPlayer->getPlayerID() . '].'); |
734 | - if($checking == 'CHECK') { |
|
735 | - $currentPlayer->increaseHOF(1, array($chessType,'Moves','Check Given'), HOF_PUBLIC); |
|
736 | - $otherPlayer->increaseHOF(1, array($chessType,'Moves','Check Received'), HOF_PUBLIC); |
|
733 | + if ($checking == 'CHECK') { |
|
734 | + $currentPlayer->increaseHOF(1, array($chessType, 'Moves', 'Check Given'), HOF_PUBLIC); |
|
735 | + $otherPlayer->increaseHOF(1, array($chessType, 'Moves', 'Check Received'), HOF_PUBLIC); |
|
737 | 736 | } |
738 | 737 | } |
739 | 738 | $currentPlayer->saveHOF(); |
@@ -760,7 +759,7 @@ discard block |
||
760 | 759 | try { |
761 | 760 | return SmrPlayer::getPlayer($this->whiteID, $this->getGameID()); |
762 | 761 | } |
763 | - catch(Exception $e) { |
|
762 | + catch (Exception $e) { |
|
764 | 763 | $null = null; |
765 | 764 | return $null; |
766 | 765 | } |
@@ -774,7 +773,7 @@ discard block |
||
774 | 773 | try { |
775 | 774 | return SmrPlayer::getPlayer($this->blackID, $this->getGameID()); |
776 | 775 | } |
777 | - catch(Exception $e) { |
|
776 | + catch (Exception $e) { |
|
778 | 777 | $null = null; |
779 | 778 | return $null; |
780 | 779 | } |
@@ -785,10 +784,10 @@ discard block |
||
785 | 784 | } |
786 | 785 | |
787 | 786 | public function getColourID($colour) { |
788 | - if($colour == self::PLAYER_WHITE) { |
|
787 | + if ($colour == self::PLAYER_WHITE) { |
|
789 | 788 | return $this->getWhiteID(); |
790 | 789 | } |
791 | - if($colour == self::PLAYER_BLACK) { |
|
790 | + if ($colour == self::PLAYER_BLACK) { |
|
792 | 791 | return $this->getBlackID(); |
793 | 792 | } |
794 | 793 | } |
@@ -797,17 +796,17 @@ discard block |
||
797 | 796 | try { |
798 | 797 | return SmrPlayer::getPlayer($this->getColourID($colour), $this->getGameID()); |
799 | 798 | } |
800 | - catch(Exception $e) { |
|
799 | + catch (Exception $e) { |
|
801 | 800 | $null = null; |
802 | 801 | return $null; |
803 | 802 | } |
804 | 803 | } |
805 | 804 | |
806 | 805 | public function getColourForAccountID($accountID) { |
807 | - if($accountID == $this->getWhiteID()) { |
|
806 | + if ($accountID == $this->getWhiteID()) { |
|
808 | 807 | return self::PLAYER_WHITE; |
809 | 808 | } |
810 | - if($accountID == $this->getBlackID()) { |
|
809 | + if ($accountID == $this->getBlackID()) { |
|
811 | 810 | return self::PLAYER_BLACK; |
812 | 811 | } |
813 | 812 | return false; |
@@ -834,8 +833,8 @@ discard block |
||
834 | 833 | $winningPlayer = $this->getColourPlayer($winnerColour); |
835 | 834 | $losingPlayer = $this->getColourPlayer(self::getOtherColour($winnerColour)); |
836 | 835 | $chessType = $this->isNPCGame() ? 'Chess (NPC)' : 'Chess'; |
837 | - $winningPlayer->increaseHOF(1, array($chessType,'Games','Won'), HOF_PUBLIC); |
|
838 | - $losingPlayer->increaseHOF(1, array($chessType,'Games','Lost'), HOF_PUBLIC); |
|
836 | + $winningPlayer->increaseHOF(1, array($chessType, 'Games', 'Won'), HOF_PUBLIC); |
|
837 | + $losingPlayer->increaseHOF(1, array($chessType, 'Games', 'Lost'), HOF_PUBLIC); |
|
839 | 838 | return array('Winner' => $winningPlayer, 'Loser' => $losingPlayer); |
840 | 839 | } |
841 | 840 | |
@@ -855,7 +854,7 @@ discard block |
||
855 | 854 | try { |
856 | 855 | return SmrPlayer::getPlayer($this->getCurrentTurnAccountID(), $this->getGameID()); |
857 | 856 | } |
858 | - catch(Exception $e) { |
|
857 | + catch (Exception $e) { |
|
859 | 858 | $null = null; |
860 | 859 | return $null; |
861 | 860 | } |
@@ -882,21 +881,21 @@ discard block |
||
882 | 881 | } |
883 | 882 | |
884 | 883 | public static function getOtherColour($colour) { |
885 | - if($colour == self::PLAYER_WHITE) { |
|
884 | + if ($colour == self::PLAYER_WHITE) { |
|
886 | 885 | return self::PLAYER_BLACK; |
887 | 886 | } |
888 | - if($colour == self::PLAYER_BLACK) { |
|
887 | + if ($colour == self::PLAYER_BLACK) { |
|
889 | 888 | return self::PLAYER_WHITE; |
890 | 889 | } |
891 | 890 | return false; |
892 | 891 | } |
893 | 892 | |
894 | 893 | public function resign($accountID) { |
895 | - if($this->hasEnded() || !$this->getColourForAccountID($accountID)) { |
|
894 | + if ($this->hasEnded() || !$this->getColourForAccountID($accountID)) { |
|
896 | 895 | return false; |
897 | 896 | } |
898 | 897 | // If only 1 person has moved then just end the game. |
899 | - if(count($this->getMoves()) < 2) { |
|
898 | + if (count($this->getMoves()) < 2) { |
|
900 | 899 | $this->endDate = TIME; |
901 | 900 | $this->db->query('UPDATE chess_game |
902 | 901 | SET end_time=' . $this->db->escapeNumber(TIME) . ' |
@@ -908,17 +907,17 @@ discard block |
||
908 | 907 | $winnerAccountID = $this->getColourID(self::getOtherColour($loserColour)); |
909 | 908 | $results = $this->setWinner($winnerAccountID); |
910 | 909 | $chessType = $this->isNPCGame() ? 'Chess (NPC)' : 'Chess'; |
911 | - $results['Loser']->increaseHOF(1, array($chessType,'Games','Resigned'), HOF_PUBLIC); |
|
910 | + $results['Loser']->increaseHOF(1, array($chessType, 'Games', 'Resigned'), HOF_PUBLIC); |
|
912 | 911 | SmrPlayer::sendMessageFromCasino($results['Winner']->getGameID(), $results['Winner']->getPlayerID(), '[player=' . $results['Loser']->getPlayerID() . '] just resigned against you in [chess=' . $this->getChessGameID() . '].'); |
913 | 912 | return 0; |
914 | 913 | } |
915 | 914 | } |
916 | 915 | |
917 | 916 | public function getPlayGameHREF() { |
918 | - return SmrSession::getNewHREF(create_container('skeleton.php','chess_play.php',array('ChessGameID' => $this->chessGameID))); |
|
917 | + return SmrSession::getNewHREF(create_container('skeleton.php', 'chess_play.php', array('ChessGameID' => $this->chessGameID))); |
|
919 | 918 | } |
920 | 919 | |
921 | 920 | public function getResignHREF() { |
922 | - return SmrSession::getNewHREF(create_container('skeleton.php','chess_resign_processing.php',array('ChessGameID' => $this->chessGameID))); |
|
921 | + return SmrSession::getNewHREF(create_container('skeleton.php', 'chess_resign_processing.php', array('ChessGameID' => $this->chessGameID))); |
|
923 | 922 | } |
924 | 923 | } |
@@ -4,12 +4,12 @@ discard block |
||
4 | 4 | const MAX_CDS_RAND = 54; |
5 | 5 | protected $numberOfCDs; |
6 | 6 | |
7 | - public function __construct($gameTypeID,$numberOfCDs,$portPlanetDrones = false) { |
|
7 | + public function __construct($gameTypeID, $numberOfCDs, $portPlanetDrones = false) { |
|
8 | 8 | $this->gameTypeID = $gameTypeID; |
9 | 9 | $this->numberOfCDs = $numberOfCDs; |
10 | 10 | $this->name = 'Combat Drones'; |
11 | 11 | $this->raceID = 0; |
12 | - if($portPlanetDrones===false) { |
|
12 | + if ($portPlanetDrones === false) { |
|
13 | 13 | $this->maxDamage = 2; |
14 | 14 | $this->shieldDamage = 2; |
15 | 15 | $this->armourDamage = 2; |
@@ -33,91 +33,91 @@ discard block |
||
33 | 33 | return $modifiedAccuracy; |
34 | 34 | } |
35 | 35 | |
36 | - protected function getModifiedAccuracyAgainstForcesUsingRandom(AbstractSmrPlayer $weaponPlayer,SmrForce $forces, $random) { |
|
36 | + protected function getModifiedAccuracyAgainstForcesUsingRandom(AbstractSmrPlayer $weaponPlayer, SmrForce $forces, $random) { |
|
37 | 37 | $modifiedAccuracy = $this->getModifiedAccuracy(); |
38 | 38 | $modifiedAccuracy += $random; |
39 | 39 | |
40 | - return max(0,min(100,$modifiedAccuracy)); |
|
40 | + return max(0, min(100, $modifiedAccuracy)); |
|
41 | 41 | } |
42 | 42 | public function getMaxModifiedAccuracyAgainstForces(AbstractSmrPlayer $weaponPlayer, SmrForce $forces) { |
43 | - return $this->getModifiedAccuracyAgainstForcesUsingRandom($weaponPlayer,$forces,self::MAX_CDS_RAND); |
|
43 | + return $this->getModifiedAccuracyAgainstForcesUsingRandom($weaponPlayer, $forces, self::MAX_CDS_RAND); |
|
44 | 44 | } |
45 | 45 | public function getModifiedAccuracyAgainstForces(AbstractSmrPlayer $weaponPlayer, SmrForce $forces) { |
46 | - return $this->getModifiedAccuracyAgainstForcesUsingRandom($weaponPlayer,$forces,mt_rand(3,self::MAX_CDS_RAND)); |
|
46 | + return $this->getModifiedAccuracyAgainstForcesUsingRandom($weaponPlayer, $forces, mt_rand(3, self::MAX_CDS_RAND)); |
|
47 | 47 | } |
48 | 48 | |
49 | - protected function getModifiedAccuracyAgainstPortUsingRandom(AbstractSmrPlayer $weaponPlayer,SmrPort $port, $random) { |
|
49 | + protected function getModifiedAccuracyAgainstPortUsingRandom(AbstractSmrPlayer $weaponPlayer, SmrPort $port, $random) { |
|
50 | 50 | $modifiedAccuracy = $this->getModifiedAccuracy(); |
51 | 51 | $modifiedAccuracy += $random; |
52 | 52 | |
53 | - return max(0,min(100,$modifiedAccuracy)); |
|
53 | + return max(0, min(100, $modifiedAccuracy)); |
|
54 | 54 | } |
55 | 55 | public function getMaxModifiedAccuracyAgainstPort(AbstractSmrPlayer $weaponPlayer, SmrPort $port) { |
56 | - return $this->getModifiedAccuracyAgainstPortUsingRandom($weaponPlayer,$port,self::MAX_CDS_RAND); |
|
56 | + return $this->getModifiedAccuracyAgainstPortUsingRandom($weaponPlayer, $port, self::MAX_CDS_RAND); |
|
57 | 57 | } |
58 | 58 | public function getModifiedAccuracyAgainstPort(AbstractSmrPlayer $weaponPlayer, SmrPort $port) { |
59 | - return $this->getModifiedAccuracyAgainstPortUsingRandom($weaponPlayer,$port,mt_rand(3,self::MAX_CDS_RAND)); |
|
59 | + return $this->getModifiedAccuracyAgainstPortUsingRandom($weaponPlayer, $port, mt_rand(3, self::MAX_CDS_RAND)); |
|
60 | 60 | } |
61 | 61 | |
62 | - protected function getModifiedAccuracyAgainstPlanetUsingRandom(AbstractSmrPlayer $weaponPlayer,SmrPlanet $planet, $random) { |
|
62 | + protected function getModifiedAccuracyAgainstPlanetUsingRandom(AbstractSmrPlayer $weaponPlayer, SmrPlanet $planet, $random) { |
|
63 | 63 | $modifiedAccuracy = $this->getModifiedAccuracy(); |
64 | 64 | $modifiedAccuracy += $random; |
65 | 65 | |
66 | - return max(0,min(100,$modifiedAccuracy)); |
|
66 | + return max(0, min(100, $modifiedAccuracy)); |
|
67 | 67 | } |
68 | 68 | public function getMaxModifiedAccuracyAgainstPlanet(AbstractSmrPlayer $weaponPlayer, SmrPlanet $planet) { |
69 | - return $this->getModifiedAccuracyAgainstPlanetUsingRandom($weaponPlayer,$planet,self::MAX_CDS_RAND); |
|
69 | + return $this->getModifiedAccuracyAgainstPlanetUsingRandom($weaponPlayer, $planet, self::MAX_CDS_RAND); |
|
70 | 70 | } |
71 | 71 | public function getModifiedAccuracyAgainstPlanet(AbstractSmrPlayer $weaponPlayer, SmrPlanet $planet) { |
72 | - return $this->getModifiedAccuracyAgainstPlanetUsingRandom($weaponPlayer,$planet,mt_rand(3,self::MAX_CDS_RAND)); |
|
72 | + return $this->getModifiedAccuracyAgainstPlanetUsingRandom($weaponPlayer, $planet, mt_rand(3, self::MAX_CDS_RAND)); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | |
76 | 76 | public function getModifiedAccuracyAgainstPlayer(AbstractSmrPlayer $weaponPlayer, AbstractSmrPlayer $targetPlayer) { |
77 | - return $this->getModifiedAccuracyAgainstPlayerUsingRandom($weaponPlayer,$targetPlayer,mt_rand(3,self::MAX_CDS_RAND)); |
|
77 | + return $this->getModifiedAccuracyAgainstPlayerUsingRandom($weaponPlayer, $targetPlayer, mt_rand(3, self::MAX_CDS_RAND)); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | protected function getModifiedAccuracyAgainstPlayerUsingRandom(AbstractSmrPlayer $weaponPlayer, AbstractSmrPlayer $targetPlayer, $random) { |
81 | 81 | $modifiedAccuracy = $this->getModifiedAccuracy(); |
82 | - $modifiedAccuracy += ($random + mt_rand($weaponPlayer->getLevelID() / 2,$weaponPlayer->getLevelID()) - ($targetPlayer->getLevelID() - $weaponPlayer->getLevelID())/3)/1.5; |
|
82 | + $modifiedAccuracy += ($random + mt_rand($weaponPlayer->getLevelID() / 2, $weaponPlayer->getLevelID()) - ($targetPlayer->getLevelID() - $weaponPlayer->getLevelID()) / 3) / 1.5; |
|
83 | 83 | |
84 | 84 | $weaponShip = $weaponPlayer->getShip(); |
85 | 85 | $targetShip = $targetPlayer->getShip(); |
86 | 86 | $mrDiff = $targetShip->getMR() - $weaponShip->getMR(); |
87 | - if($mrDiff > 0) |
|
88 | - $modifiedAccuracy -= $this->getBaseAccuracy() * ($mrDiff/MR_FACTOR)/100; |
|
87 | + if ($mrDiff > 0) |
|
88 | + $modifiedAccuracy -= $this->getBaseAccuracy() * ($mrDiff / MR_FACTOR) / 100; |
|
89 | 89 | |
90 | - return max(0,min(100,$modifiedAccuracy)); |
|
90 | + return max(0, min(100, $modifiedAccuracy)); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | public function getMaxModifiedAccuracyAgainstPlayer(AbstractSmrPlayer $weaponPlayer, AbstractSmrPlayer $targetPlayer) { |
94 | - return $this->getModifiedAccuracyAgainstPlayerUsingRandom($weaponPlayer,$targetPlayer,self::MAX_CDS_RAND); |
|
94 | + return $this->getModifiedAccuracyAgainstPlayerUsingRandom($weaponPlayer, $targetPlayer, self::MAX_CDS_RAND); |
|
95 | 95 | } |
96 | 96 | |
97 | - public function getModifiedForceAccuracyAgainstPlayer(SmrForce $forces,AbstractSmrPlayer $targetPlayer) { |
|
98 | - return $this->getModifiedForceAccuracyAgainstPlayerUsingRandom($forces,$targetPlayer,mt_rand(3,self::MAX_CDS_RAND)); |
|
97 | + public function getModifiedForceAccuracyAgainstPlayer(SmrForce $forces, AbstractSmrPlayer $targetPlayer) { |
|
98 | + return $this->getModifiedForceAccuracyAgainstPlayerUsingRandom($forces, $targetPlayer, mt_rand(3, self::MAX_CDS_RAND)); |
|
99 | 99 | } |
100 | 100 | |
101 | - protected function getModifiedForceAccuracyAgainstPlayerUsingRandom(SmrForce $forces,AbstractSmrPlayer $targetPlayer, $random) { |
|
101 | + protected function getModifiedForceAccuracyAgainstPlayerUsingRandom(SmrForce $forces, AbstractSmrPlayer $targetPlayer, $random) { |
|
102 | 102 | $modifiedAccuracy = $this->getModifiedAccuracy(); |
103 | 103 | $modifiedAccuracy += $random; |
104 | 104 | |
105 | - return max(0,min(100,$modifiedAccuracy)); |
|
105 | + return max(0, min(100, $modifiedAccuracy)); |
|
106 | 106 | } |
107 | 107 | |
108 | - protected function getModifiedPortAccuracyAgainstPlayer(SmrPort $port,AbstractSmrPlayer $targetPlayer) { |
|
108 | + protected function getModifiedPortAccuracyAgainstPlayer(SmrPort $port, AbstractSmrPlayer $targetPlayer) { |
|
109 | 109 | return 100; |
110 | 110 | } |
111 | 111 | |
112 | - protected function getModifiedPlanetAccuracyAgainstPlayer(SmrPlanet $planet,AbstractSmrPlayer $targetPlayer) { |
|
112 | + protected function getModifiedPlanetAccuracyAgainstPlayer(SmrPlanet $planet, AbstractSmrPlayer $targetPlayer) { |
|
113 | 113 | return 100; |
114 | 114 | } |
115 | 115 | |
116 | - public function getMaxModifiedForceAccuracyAgainstPlayer(SmrForce $forces,AbstractSmrPlayer $targetPlayer) { |
|
117 | - return $this->getModifiedForceAccuracyAgainstPlayerUsingRandom($forces,$targetPlayer,self::MAX_CDS_RAND); |
|
116 | + public function getMaxModifiedForceAccuracyAgainstPlayer(SmrForce $forces, AbstractSmrPlayer $targetPlayer) { |
|
117 | + return $this->getModifiedForceAccuracyAgainstPlayerUsingRandom($forces, $targetPlayer, self::MAX_CDS_RAND); |
|
118 | 118 | } |
119 | 119 | |
120 | - public function getMaxModifiedPortAccuracyAgainstPlayer(SmrPort $forces,AbstractSmrPlayer $targetPlayer) { |
|
120 | + public function getMaxModifiedPortAccuracyAgainstPlayer(SmrPort $forces, AbstractSmrPlayer $targetPlayer) { |
|
121 | 121 | return 100; |
122 | 122 | } |
123 | 123 | |
@@ -127,13 +127,13 @@ discard block |
||
127 | 127 | } |
128 | 128 | |
129 | 129 | public function &getModifiedDamageAgainstForces(AbstractSmrPlayer $weaponPlayer, SmrForce $forces) { |
130 | - if(!$this->canShootForces()) // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods. |
|
130 | + if (!$this->canShootForces()) // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods. |
|
131 | 131 | return array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover()); |
132 | - $damage =& $this->getModifiedDamage(); |
|
133 | - $damage['Launched'] = ceil($this->getNumberOfCDs() * $this->getModifiedAccuracyAgainstForces($weaponPlayer,$forces) / 100); |
|
132 | + $damage = & $this->getModifiedDamage(); |
|
133 | + $damage['Launched'] = ceil($this->getNumberOfCDs() * $this->getModifiedAccuracyAgainstForces($weaponPlayer, $forces) / 100); |
|
134 | 134 | $damage['Kamikaze'] = 0; |
135 | - if($weaponPlayer->isCombatDronesKamikazeOnMines()) { // If kamikaze then damage is same as MINE_ARMOUR |
|
136 | - $damage['Kamikaze'] = min($damage['Launched'],$forces->getMines()); |
|
135 | + if ($weaponPlayer->isCombatDronesKamikazeOnMines()) { // If kamikaze then damage is same as MINE_ARMOUR |
|
136 | + $damage['Kamikaze'] = min($damage['Launched'], $forces->getMines()); |
|
137 | 137 | $damage['Launched'] -= $damage['Kamikaze']; |
138 | 138 | } |
139 | 139 | $damage['MaxDamage'] = ceil($damage['Launched'] * $damage['MaxDamage']); |
@@ -149,10 +149,10 @@ discard block |
||
149 | 149 | } |
150 | 150 | |
151 | 151 | public function &getModifiedDamageAgainstPort(AbstractSmrPlayer $weaponPlayer, SmrPort $port) { |
152 | - if(!$this->canShootPorts()) // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods. |
|
152 | + if (!$this->canShootPorts()) // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods. |
|
153 | 153 | return array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover()); |
154 | - $damage =& $this->getModifiedDamage(); |
|
155 | - $damage['Launched'] = ceil($this->getNumberOfCDs() * $this->getModifiedAccuracyAgainstPort($weaponPlayer,$port) / 100); |
|
154 | + $damage = & $this->getModifiedDamage(); |
|
155 | + $damage['Launched'] = ceil($this->getNumberOfCDs() * $this->getModifiedAccuracyAgainstPort($weaponPlayer, $port) / 100); |
|
156 | 156 | $damage['MaxDamage'] = ceil($damage['Launched'] * $damage['MaxDamage']); |
157 | 157 | $damage['Shield'] = ceil($damage['Launched'] * $damage['Shield']); |
158 | 158 | $damage['Armour'] = ceil($damage['Launched'] * $damage['Armour']); |
@@ -161,10 +161,10 @@ discard block |
||
161 | 161 | } |
162 | 162 | |
163 | 163 | public function &getModifiedDamageAgainstPlanet(AbstractSmrPlayer $weaponPlayer, SmrPlanet $planet) { |
164 | - if(!$this->canShootPlanets()) // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods. |
|
164 | + if (!$this->canShootPlanets()) // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods. |
|
165 | 165 | return array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover()); |
166 | - $damage =& $this->getModifiedDamage(); |
|
167 | - $damage['Launched'] = ceil($this->getNumberOfCDs() * $this->getModifiedAccuracyAgainstPlanet($weaponPlayer,$planet) / 100); |
|
166 | + $damage = & $this->getModifiedDamage(); |
|
167 | + $damage['Launched'] = ceil($this->getNumberOfCDs() * $this->getModifiedAccuracyAgainstPlanet($weaponPlayer, $planet) / 100); |
|
168 | 168 | $planetMod = self::PLANET_DAMAGE_MOD; |
169 | 169 | $damage['MaxDamage'] = ceil($damage['Launched'] * $damage['MaxDamage'] * $planetMod); |
170 | 170 | $damage['Shield'] = ceil($damage['Launched'] * $damage['Shield'] * $planetMod); |
@@ -174,17 +174,17 @@ discard block |
||
174 | 174 | } |
175 | 175 | |
176 | 176 | public function &getModifiedDamageAgainstPlayer(AbstractSmrPlayer $weaponPlayer, AbstractSmrPlayer $targetPlayer) { |
177 | - if(!$this->canShootTraders()) { // If we can't shoot traders then just return a damageless array and don't waste resources calculated any damage mods. |
|
177 | + if (!$this->canShootTraders()) { // If we can't shoot traders then just return a damageless array and don't waste resources calculated any damage mods. |
|
178 | 178 | $return = array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover()); |
179 | 179 | return $return; |
180 | 180 | } |
181 | - $damage =& $this->getModifiedDamage(); |
|
182 | - if($targetPlayer->getShip()->hasDCS()) { |
|
181 | + $damage = & $this->getModifiedDamage(); |
|
182 | + if ($targetPlayer->getShip()->hasDCS()) { |
|
183 | 183 | $damage['MaxDamage'] *= DCS_PLAYER_DAMAGE_DECIMAL_PERCENT; |
184 | 184 | $damage['Shield'] *= DCS_PLAYER_DAMAGE_DECIMAL_PERCENT; |
185 | 185 | $damage['Armour'] *= DCS_PLAYER_DAMAGE_DECIMAL_PERCENT; |
186 | 186 | } |
187 | - $damage['Launched'] = ceil($this->getNumberOfCDs() * $this->getModifiedAccuracyAgainstPlayer($weaponPlayer,$targetPlayer) / 100); |
|
187 | + $damage['Launched'] = ceil($this->getNumberOfCDs() * $this->getModifiedAccuracyAgainstPlayer($weaponPlayer, $targetPlayer) / 100); |
|
188 | 188 | $damage['MaxDamage'] = ceil($damage['Launched'] * $damage['MaxDamage']); |
189 | 189 | $damage['Shield'] = ceil($damage['Launched'] * $damage['Shield']); |
190 | 190 | $damage['Armour'] = ceil($damage['Launched'] * $damage['Armour']); |
@@ -192,19 +192,19 @@ discard block |
||
192 | 192 | } |
193 | 193 | |
194 | 194 | public function &getModifiedForceDamageAgainstPlayer(SmrForce $forces, AbstractSmrPlayer $targetPlayer) { |
195 | - if(!$this->canShootTraders()) { // If we can't shoot traders then just return a damageless array and don't waste resources calculated any damage mods. |
|
195 | + if (!$this->canShootTraders()) { // If we can't shoot traders then just return a damageless array and don't waste resources calculated any damage mods. |
|
196 | 196 | $return = array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover()); |
197 | 197 | return $return; |
198 | 198 | } |
199 | - $damage =& $this->getModifiedDamage(); |
|
199 | + $damage = & $this->getModifiedDamage(); |
|
200 | 200 | |
201 | - if($targetPlayer->getShip()->hasDCS()) { |
|
201 | + if ($targetPlayer->getShip()->hasDCS()) { |
|
202 | 202 | $damage['MaxDamage'] *= DCS_FORCE_DAMAGE_DECIMAL_PERCENT; |
203 | 203 | $damage['Shield'] *= DCS_FORCE_DAMAGE_DECIMAL_PERCENT; |
204 | 204 | $damage['Armour'] *= DCS_FORCE_DAMAGE_DECIMAL_PERCENT; |
205 | 205 | } |
206 | 206 | |
207 | - $damage['Launched'] = ceil($this->getNumberOfCDs() * $this->getModifiedForceAccuracyAgainstPlayer($forces,$targetPlayer) / 100); |
|
207 | + $damage['Launched'] = ceil($this->getNumberOfCDs() * $this->getModifiedForceAccuracyAgainstPlayer($forces, $targetPlayer) / 100); |
|
208 | 208 | $damage['MaxDamage'] = ceil($damage['Launched'] * $damage['MaxDamage']); |
209 | 209 | $damage['Shield'] = ceil($damage['Launched'] * $damage['Shield']); |
210 | 210 | $damage['Armour'] = ceil($damage['Launched'] * $damage['Armour']); |
@@ -212,18 +212,18 @@ discard block |
||
212 | 212 | } |
213 | 213 | |
214 | 214 | public function &getModifiedPortDamageAgainstPlayer(SmrPort $port, AbstractSmrPlayer $targetPlayer) { |
215 | - if(!$this->canShootTraders()) { // If we can't shoot traders then just return a damageless array and don't waste resources calculated any damage mods. |
|
215 | + if (!$this->canShootTraders()) { // If we can't shoot traders then just return a damageless array and don't waste resources calculated any damage mods. |
|
216 | 216 | $return = array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover()); |
217 | 217 | return $return; |
218 | 218 | } |
219 | - $damage =& $this->getModifiedDamage(); |
|
219 | + $damage = & $this->getModifiedDamage(); |
|
220 | 220 | |
221 | - if($targetPlayer->getShip()->hasDCS()) { |
|
221 | + if ($targetPlayer->getShip()->hasDCS()) { |
|
222 | 222 | $damage['MaxDamage'] *= DCS_PORT_DAMAGE_DECIMAL_PERCENT; |
223 | 223 | $damage['Shield'] *= DCS_PORT_DAMAGE_DECIMAL_PERCENT; |
224 | 224 | $damage['Armour'] *= DCS_PORT_DAMAGE_DECIMAL_PERCENT; |
225 | 225 | } |
226 | - $damage['Launched'] = ceil($this->getNumberOfCDs() * $this->getModifiedPortAccuracyAgainstPlayer($port,$targetPlayer) / 100); |
|
226 | + $damage['Launched'] = ceil($this->getNumberOfCDs() * $this->getModifiedPortAccuracyAgainstPlayer($port, $targetPlayer) / 100); |
|
227 | 227 | $damage['MaxDamage'] = ceil($damage['Launched'] * $damage['MaxDamage']); |
228 | 228 | $damage['Shield'] = ceil($damage['Launched'] * $damage['Shield']); |
229 | 229 | $damage['Armour'] = ceil($damage['Launched'] * $damage['Armour']); |
@@ -231,18 +231,18 @@ discard block |
||
231 | 231 | } |
232 | 232 | |
233 | 233 | public function &getModifiedPlanetDamageAgainstPlayer(SmrPlanet $planet, AbstractSmrPlayer $targetPlayer) { |
234 | - if(!$this->canShootTraders()) { // If we can't shoot traders then just return a damageless array and don't waste resources calculated any damage mods. |
|
234 | + if (!$this->canShootTraders()) { // If we can't shoot traders then just return a damageless array and don't waste resources calculated any damage mods. |
|
235 | 235 | $return = array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover()); |
236 | 236 | return $return; |
237 | 237 | } |
238 | - $damage =& $this->getModifiedDamage(); |
|
238 | + $damage = & $this->getModifiedDamage(); |
|
239 | 239 | |
240 | - if($targetPlayer->getShip()->hasDCS()) { |
|
240 | + if ($targetPlayer->getShip()->hasDCS()) { |
|
241 | 241 | $damage['MaxDamage'] *= DCS_PLANET_DAMAGE_DECIMAL_PERCENT; |
242 | 242 | $damage['Shield'] *= DCS_PLANET_DAMAGE_DECIMAL_PERCENT; |
243 | 243 | $damage['Armour'] *= DCS_PLANET_DAMAGE_DECIMAL_PERCENT; |
244 | 244 | } |
245 | - $damage['Launched'] = ceil($this->getNumberOfCDs() * $this->getModifiedPlanetAccuracyAgainstPlayer($planet,$targetPlayer) / 100); |
|
245 | + $damage['Launched'] = ceil($this->getNumberOfCDs() * $this->getModifiedPlanetAccuracyAgainstPlayer($planet, $targetPlayer) / 100); |
|
246 | 246 | $damage['MaxDamage'] = ceil($damage['Launched'] * $damage['MaxDamage']); |
247 | 247 | $damage['Shield'] = ceil($damage['Launched'] * $damage['Shield']); |
248 | 248 | $damage['Armour'] = ceil($damage['Launched'] * $damage['Armour']); |
@@ -251,8 +251,8 @@ discard block |
||
251 | 251 | |
252 | 252 | public function &shootForces(AbstractSmrPlayer $weaponPlayer, SmrForce $forces) { |
253 | 253 | $return = array('Weapon' => $this, 'TargetForces' => $forces, 'Hit' => true); |
254 | - $this->doPlayerDamageToForce($return,$weaponPlayer, $forces); |
|
255 | - if($return['WeaponDamage']['Kamikaze'] > 0) { |
|
254 | + $this->doPlayerDamageToForce($return, $weaponPlayer, $forces); |
|
255 | + if ($return['WeaponDamage']['Kamikaze'] > 0) { |
|
256 | 256 | $weaponPlayer->getShip()->decreaseCDs($return['WeaponDamage']['Kamikaze']); |
257 | 257 | } |
258 | 258 | return $return; |
@@ -260,12 +260,12 @@ discard block |
||
260 | 260 | |
261 | 261 | public function &shootPort(AbstractSmrPlayer $weaponPlayer, SmrPort $port) { |
262 | 262 | $return = array('Weapon' => $this, 'TargetPort' => $port, 'Hit' => true); |
263 | - return $this->doPlayerDamageToPort($return,$weaponPlayer, $port); |
|
263 | + return $this->doPlayerDamageToPort($return, $weaponPlayer, $port); |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | public function &shootPlanet(AbstractSmrPlayer $weaponPlayer, SmrPlanet $planet, $delayed) { |
267 | 267 | $return = array('Weapon' => $this, 'TargetPlanet' => $planet, 'Hit' => true); |
268 | - return $this->doPlayerDamageToPlanet($return,$weaponPlayer, $planet, $delayed); |
|
268 | + return $this->doPlayerDamageToPlanet($return, $weaponPlayer, $planet, $delayed); |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | public function &shootPlayer(AbstractSmrPlayer $weaponPlayer, AbstractSmrPlayer $targetPlayer) { |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | 'img_default' => 'twg.png', |
19 | 19 | 'img_star' => 'twg_vote.png', |
20 | 20 | 'url_base' => 'http://topwebgames.com/in.aspx?ID=136&alwaysreward=1', |
21 | - 'url_func' => function ($baseUrl, $accountId, $gameId, $linkId) { |
|
21 | + 'url_func' => function($baseUrl, $accountId, $gameId, $linkId) { |
|
22 | 22 | $query = array('account' => $accountId, 'game' => $gameId, 'link' => $linkId); |
23 | 23 | return $baseUrl . '&' . http_build_query($query); |
24 | 24 | }, |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | 'img_default' => 'dog.png', |
28 | 28 | 'img_star' => 'dog_vote.png', |
29 | 29 | 'url_base' => 'http://www.directoryofgames.com/main.php?view=topgames&action=vote&v_tgame=2315', |
30 | - 'url_func' => function ($baseUrl, $accountId, $gameId, $linkId) { |
|
30 | + 'url_func' => function($baseUrl, $accountId, $gameId, $linkId) { |
|
31 | 31 | return "$baseUrl&votedef=$accountId,$gameId,$linkId"; |
32 | 32 | }, |
33 | 33 | ), |
@@ -10,14 +10,14 @@ discard block |
||
10 | 10 | } |
11 | 11 | |
12 | 12 | function htmliseMessage($message) { |
13 | - $message = htmlentities($message,ENT_COMPAT,'utf-8'); |
|
14 | - $message = str_replace('<br />','<br />',$message); |
|
13 | + $message = htmlentities($message, ENT_COMPAT, 'utf-8'); |
|
14 | + $message = str_replace('<br />', '<br />', $message); |
|
15 | 15 | return $message; |
16 | 16 | } |
17 | 17 | |
18 | 18 | function parseBoolean($check) { |
19 | 19 | // Only negative strings are not implicitly converted to the correct bool |
20 | - if(is_string($check) && (strcasecmp($check,'NO') == 0 || strcasecmp($check,'FALSE')==0)) |
|
20 | + if (is_string($check) && (strcasecmp($check, 'NO') == 0 || strcasecmp($check, 'FALSE') == 0)) |
|
21 | 21 | return false; |
22 | 22 | return (bool)$check; |
23 | 23 | } |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | function smrBBCode($bbParser, $action, $tagName, $default, $tagParams, $tagContent) { |
26 | 26 | global $overrideGameID, $disableBBLinks, $player, $account, $var; |
27 | 27 | try { |
28 | - switch($tagName) { |
|
28 | + switch ($tagName) { |
|
29 | 29 | case 'combatlog': |
30 | 30 | $logID = (is_numeric($default)) ? $default : $tagParams['id']; |
31 | 31 | if ($action == \Nbbc\BBCode::BBCODE_CHECK) { |
@@ -37,14 +37,14 @@ discard block |
||
37 | 37 | break; |
38 | 38 | case 'player': |
39 | 39 | $playerID = $default; |
40 | - if(!is_numeric($playerID)) |
|
40 | + if (!is_numeric($playerID)) |
|
41 | 41 | $playerID = $tagParams['id']; |
42 | 42 | $bbPlayer = SmrPlayer::getPlayerByPlayerID($playerID, $overrideGameID); |
43 | 43 | if ($action == \Nbbc\BBCode::BBCODE_CHECK) { |
44 | 44 | return true; |
45 | 45 | } |
46 | 46 | $showAlliance = isset($tagParams['showalliance']) ? parseBoolean($tagParams['showalliance']) : false; |
47 | - if($disableBBLinks===false && $overrideGameID==SmrSession::getGameID()) { |
|
47 | + if ($disableBBLinks === false && $overrideGameID == SmrSession::getGameID()) { |
|
48 | 48 | return $bbPlayer->getLinkedDisplayName($showAlliance); |
49 | 49 | } |
50 | 50 | return $bbPlayer->getDisplayName($showAlliance); |
@@ -52,14 +52,14 @@ discard block |
||
52 | 52 | case 'alliance': |
53 | 53 | $db = new SmrMySqlDatabase(); |
54 | 54 | $allianceID = $default; |
55 | - if(!is_numeric($allianceID)) |
|
55 | + if (!is_numeric($allianceID)) |
|
56 | 56 | $allianceID = $tagParams['id']; |
57 | 57 | $alliance = SmrAlliance::getAlliance($allianceID, $overrideGameID); |
58 | 58 | if ($action == \Nbbc\BBCode::BBCODE_CHECK) { |
59 | 59 | return true; |
60 | 60 | } |
61 | 61 | |
62 | - if($disableBBLinks===false && $overrideGameID==SmrSession::getGameID()) { |
|
62 | + if ($disableBBLinks === false && $overrideGameID == SmrSession::getGameID()) { |
|
63 | 63 | $container = create_container('skeleton.php'); |
64 | 64 | $container['alliance_id'] = $alliance->getAllianceID(); |
65 | 65 | if (is_object($player) && $alliance->getAllianceID() == $player->getAllianceID()) |
@@ -73,12 +73,12 @@ discard block |
||
73 | 73 | case 'race': |
74 | 74 | $raceNameID = $default; |
75 | 75 | foreach (Globals::getRaces() as $raceID => $raceInfo) { |
76 | - if((is_numeric($raceNameID) && $raceNameID == $raceID) |
|
76 | + if ((is_numeric($raceNameID) && $raceNameID == $raceID) |
|
77 | 77 | || $raceNameID == $raceInfo['Race Name']) { |
78 | 78 | if ($action == \Nbbc\BBCode::BBCODE_CHECK) { |
79 | 79 | return true; |
80 | 80 | } |
81 | - $linked = $disableBBLinks===false && $overrideGameID==SmrSession::getGameID(); |
|
81 | + $linked = $disableBBLinks === false && $overrideGameID == SmrSession::getGameID(); |
|
82 | 82 | return AbstractSmrPlayer::getColouredRaceNameOrDefault($raceID, $player, $linked); |
83 | 83 | } |
84 | 84 | } |
@@ -89,14 +89,14 @@ discard block |
||
89 | 89 | return true; |
90 | 90 | } |
91 | 91 | if ($timeString != '' && ($time = strtotime($timeString)) !== false) { |
92 | - if(is_object($account)) |
|
92 | + if (is_object($account)) |
|
93 | 93 | $time += $account->getOffset() * 3600; |
94 | 94 | return date(DATE_FULL_SHORT, $time); |
95 | 95 | } |
96 | 96 | break; |
97 | 97 | case 'chess': |
98 | 98 | $chessGameID = $default; |
99 | - $chessGame =& ChessGame::getChessGame($chessGameID); |
|
99 | + $chessGame = & ChessGame::getChessGame($chessGameID); |
|
100 | 100 | if ($action == \Nbbc\BBCode::BBCODE_CHECK) { |
101 | 101 | return true; |
102 | 102 | } |
@@ -114,10 +114,10 @@ discard block |
||
114 | 114 | |
115 | 115 | // The use of $var here is for a corner case where an admin can check reported messages whilst being in-game. |
116 | 116 | // Ugly but working, probably want a better mechanism to check if more BBCode tags get added |
117 | - if(is_numeric($sectorID) |
|
117 | + if (is_numeric($sectorID) |
|
118 | 118 | && SmrSession::hasGame() |
119 | 119 | && SmrSector::sectorExists($overrideGameID, $sectorID) |
120 | - && $disableBBLinks===false && $overrideGameID==SmrSession::getGameID()) { |
|
120 | + && $disableBBLinks === false && $overrideGameID == SmrSession::getGameID()) { |
|
121 | 121 | return '<a href="' . Globals::getPlotCourseHREF($player->getSectorID(), $sectorID) . '">' . $sectorTag . '</a>'; |
122 | 122 | } |
123 | 123 | |
@@ -151,9 +151,9 @@ discard block |
||
151 | 151 | return str_replace(',', '', html_entity_decode($text)); |
152 | 152 | } |
153 | 153 | |
154 | -function bbifyMessage($message, $noLinks=false) { |
|
154 | +function bbifyMessage($message, $noLinks = false) { |
|
155 | 155 | static $bbParser; |
156 | - if(!isset($bbParser)) { |
|
156 | + if (!isset($bbParser)) { |
|
157 | 157 | $bbParser = new \Nbbc\BBCode(); |
158 | 158 | $bbParser->SetEnableSmileys(false); |
159 | 159 | $bbParser->RemoveRule('wiki'); |
@@ -169,23 +169,23 @@ discard block |
||
169 | 169 | 'end_tag' => \Nbbc\BBCode::BBCODE_PROHIBIT, |
170 | 170 | 'content' => \Nbbc\BBCode::BBCODE_PROHIBIT, |
171 | 171 | ); |
172 | - $bbParser->AddRule('combatlog',$smrRule); |
|
173 | - $bbParser->AddRule('player',$smrRule); |
|
174 | - $bbParser->AddRule('alliance',$smrRule); |
|
175 | - $bbParser->AddRule('race',$smrRule); |
|
176 | - $bbParser->AddRule('servertimetouser',$smrRule); |
|
177 | - $bbParser->AddRule('chess',$smrRule); |
|
178 | - $bbParser->AddRule('sector',$smrRule); |
|
179 | - $bbParser->addRule('join_alliance',$smrRule); |
|
172 | + $bbParser->AddRule('combatlog', $smrRule); |
|
173 | + $bbParser->AddRule('player', $smrRule); |
|
174 | + $bbParser->AddRule('alliance', $smrRule); |
|
175 | + $bbParser->AddRule('race', $smrRule); |
|
176 | + $bbParser->AddRule('servertimetouser', $smrRule); |
|
177 | + $bbParser->AddRule('chess', $smrRule); |
|
178 | + $bbParser->AddRule('sector', $smrRule); |
|
179 | + $bbParser->addRule('join_alliance', $smrRule); |
|
180 | 180 | } |
181 | 181 | global $disableBBLinks; |
182 | - if($noLinks===true) |
|
182 | + if ($noLinks === true) |
|
183 | 183 | $disableBBLinks = true; |
184 | 184 | else |
185 | 185 | $disableBBLinks = false; |
186 | - if(strpos($message, '[')!==false) { //We have BBCode so let's do a full parse. |
|
186 | + if (strpos($message, '[') !== false) { //We have BBCode so let's do a full parse. |
|
187 | 187 | $message = $bbParser->parse($message); |
188 | - $message = str_replace('<br />','<br />',$message); |
|
188 | + $message = str_replace('<br />', '<br />', $message); |
|
189 | 189 | } |
190 | 190 | else { //Otherwise just convert newlines |
191 | 191 | $message = nl2br($message, true); |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | global $template; |
198 | 198 | $return = '<span class="noWrap">' . implode('</span> | <span class="noWrap">', $menu) . '</span>'; |
199 | 199 | $template->unassign('MenuItems'); |
200 | - $template->assign('MenuBar',$return); |
|
200 | + $template->assign('MenuBar', $return); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | function create_table() { |
@@ -209,29 +209,29 @@ discard block |
||
209 | 209 | } |
210 | 210 | |
211 | 211 | function create_form_name($container, $name) { |
212 | - return create_form_parameter($container, 'name="'.$name.'"'); |
|
212 | + return create_form_parameter($container, 'name="' . $name . '"'); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | function create_form_parameter($container, $param) { |
216 | - return '<form '.$param.' method="POST" action="'.SmrSession::getNewHREF($container).'">'; |
|
216 | + return '<form ' . $param . ' method="POST" action="' . SmrSession::getNewHREF($container) . '">'; |
|
217 | 217 | } |
218 | 218 | |
219 | -function create_button($container,$text) { |
|
220 | - return '<div class="buttonA"><a class="buttonA" href="' . SmrSession::getNewHREF($container). '">' . $text . '</a></div>'; |
|
219 | +function create_button($container, $text) { |
|
220 | + return '<div class="buttonA"><a class="buttonA" href="' . SmrSession::getNewHREF($container) . '">' . $text . '</a></div>'; |
|
221 | 221 | } |
222 | 222 | |
223 | -function create_form($container,$actions) { |
|
223 | +function create_form($container, $actions) { |
|
224 | 224 | static $form_id = 0; |
225 | 225 | $form = array(); |
226 | 226 | $form['form'] = '<form class="standard" id="FORM' . $form_id . '" method="POST" action="' . SmrSession::getNewHREF($container) . '">'; |
227 | 227 | |
228 | - if(!is_array($actions)) { |
|
229 | - $form['submit'] = '<input class="submit" type="submit" name="action" value="' . htmlspecialchars($actions) . '">'; |
|
228 | + if (!is_array($actions)) { |
|
229 | + $form['submit'] = '<input class="submit" type="submit" name="action" value="' . htmlspecialchars($actions) . '">'; |
|
230 | 230 | } |
231 | 231 | else { |
232 | 232 | $form['submit'] = array(); |
233 | - foreach($actions as $action) { |
|
234 | - $form['submit'][$action[0]] = '<input class="submit" type="submit" name="action" value="' . htmlspecialchars($action[1]) . '">'; |
|
233 | + foreach ($actions as $action) { |
|
234 | + $form['submit'][$action[0]] = '<input class="submit" type="submit" name="action" value="' . htmlspecialchars($action[1]) . '">'; |
|
235 | 235 | } |
236 | 236 | } |
237 | 237 | |
@@ -241,11 +241,11 @@ discard block |
||
241 | 241 | } |
242 | 242 | |
243 | 243 | function create_submit($value) { |
244 | - return ('<input type="submit" name="action" value="'.htmlspecialchars($value).'" id="InputFields" />'); |
|
244 | + return ('<input type="submit" name="action" value="' . htmlspecialchars($value) . '" id="InputFields" />'); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | function create_error($message) { |
248 | - $container = create_container('skeleton.php','error.php'); |
|
248 | + $container = create_container('skeleton.php', 'error.php'); |
|
249 | 249 | $container['message'] = $message; |
250 | 250 | if (USING_AJAX) { |
251 | 251 | // To avoid the page just not refreshing when an error is encountered |
@@ -262,18 +262,18 @@ discard block |
||
262 | 262 | } |
263 | 263 | |
264 | 264 | function resetContainer($new_container) { |
265 | - global $sn,$container,$var; |
|
265 | + global $sn, $container, $var; |
|
266 | 266 | |
267 | 267 | // this sn identifies our container later |
268 | 268 | |
269 | - SmrSession::resetLink($new_container,$sn); |
|
269 | + SmrSession::resetLink($new_container, $sn); |
|
270 | 270 | |
271 | 271 | $var = $new_container; |
272 | 272 | $container = $new_container; |
273 | 273 | } |
274 | 274 | |
275 | 275 | function forward($new_container) { |
276 | - if(defined('OVERRIDE_FORWARD')&&OVERRIDE_FORWARD===true) |
|
276 | + if (defined('OVERRIDE_FORWARD') && OVERRIDE_FORWARD === true) |
|
277 | 277 | return overrideForward($new_container); |
278 | 278 | resetContainer($new_container); |
279 | 279 | do_voodoo(); |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | global $var, $container; |
291 | 291 | |
292 | 292 | // transfer this value to next container |
293 | - if(isset($var[$what])) |
|
293 | + if (isset($var[$what])) |
|
294 | 294 | $container[$what] = $var[$what]; |
295 | 295 | |
296 | 296 | } |
@@ -299,42 +299,42 @@ discard block |
||
299 | 299 | $container = $extra; |
300 | 300 | $container['url'] = $file; |
301 | 301 | $container['body'] = $body; |
302 | - if($remainingPageLoads) { |
|
302 | + if ($remainingPageLoads) { |
|
303 | 303 | $container['RemainingPageLoads'] = $remainingPageLoads; |
304 | 304 | } |
305 | 305 | return $container; |
306 | 306 | } |
307 | 307 | |
308 | -function create_link($container, $text, $class=null) { |
|
309 | - return '<a'.($class==null?'':' class="'.$class.'"').' href="' . (is_array($container)?SmrSession::getNewHREF($container):$container) . '">' . $text . '</a>'; |
|
308 | +function create_link($container, $text, $class = null) { |
|
309 | + return '<a' . ($class == null ? '' : ' class="' . $class . '"') . ' href="' . (is_array($container) ?SmrSession::getNewHREF($container) : $container) . '">' . $text . '</a>'; |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | function create_submit_link($container, $text) { |
313 | 313 | return '<a href="' . SmrSession::getNewHREF($container) . '" class="submitStyle">' . $text . '</a>'; |
314 | 314 | } |
315 | 315 | |
316 | -function get_colored_text_range($value, $maxValue, $text = null, $minValue = 0, $type='Game', $return_type = 'Normal') { |
|
317 | - if($text == null) { |
|
316 | +function get_colored_text_range($value, $maxValue, $text = null, $minValue = 0, $type = 'Game', $return_type = 'Normal') { |
|
317 | + if ($text == null) { |
|
318 | 318 | $text = number_format($value); |
319 | 319 | } |
320 | - if($maxValue-$minValue==0) { |
|
320 | + if ($maxValue - $minValue == 0) { |
|
321 | 321 | return $text; |
322 | 322 | } |
323 | 323 | else { |
324 | - $normalisedValue = round(510*max(0,min($maxValue,$value)-$minValue)/($maxValue-$minValue))-255; |
|
324 | + $normalisedValue = round(510 * max(0, min($maxValue, $value) - $minValue) / ($maxValue - $minValue)) - 255; |
|
325 | 325 | } |
326 | 326 | if ($type == 'Game') { |
327 | - if($normalisedValue < 0) { |
|
328 | - $r_component='ff'; |
|
329 | - $g_component = dechex(255+$normalisedValue); |
|
330 | - if(strlen($g_component) == 1) { |
|
327 | + if ($normalisedValue < 0) { |
|
328 | + $r_component = 'ff'; |
|
329 | + $g_component = dechex(255 + $normalisedValue); |
|
330 | + if (strlen($g_component) == 1) { |
|
331 | 331 | $g_component = '0' . $g_component; |
332 | 332 | } |
333 | 333 | } |
334 | - else if($normalisedValue > 0) { |
|
335 | - $g_component='ff'; |
|
336 | - $r_component = dechex(255-$normalisedValue); |
|
337 | - if(strlen($r_component) == 1) { |
|
334 | + else if ($normalisedValue > 0) { |
|
335 | + $g_component = 'ff'; |
|
336 | + $r_component = dechex(255 - $normalisedValue); |
|
337 | + if (strlen($r_component) == 1) { |
|
338 | 338 | $r_component = '0' . $r_component; |
339 | 339 | } |
340 | 340 | } |
@@ -356,25 +356,25 @@ discard block |
||
356 | 356 | } |
357 | 357 | } |
358 | 358 | |
359 | -function get_colored_text($value, $text = null, $type='Game', $return_type = 'Normal') { |
|
359 | +function get_colored_text($value, $text = null, $type = 'Game', $return_type = 'Normal') { |
|
360 | 360 | return get_colored_text_range($value, 300, $text, -300, $type, $return_type); |
361 | 361 | } |
362 | 362 | |
363 | 363 | function word_filter($string) { |
364 | 364 | static $words; |
365 | 365 | |
366 | - if(!is_array($words)) { |
|
366 | + if (!is_array($words)) { |
|
367 | 367 | $db = new SmrMySqlDatabase(); |
368 | 368 | $db->query('SELECT word_value, word_replacement FROM word_filter'); |
369 | 369 | $words = array(); |
370 | - while($db->nextRecord()) { |
|
370 | + while ($db->nextRecord()) { |
|
371 | 371 | $row = $db->getRow(); |
372 | - $words[] = array('word_value' => '/'.str_replace('/','\/',$row['word_value']).'/i','word_replacement'=> $row['word_replacement']); |
|
372 | + $words[] = array('word_value' => '/' . str_replace('/', '\/', $row['word_value']) . '/i', 'word_replacement'=> $row['word_replacement']); |
|
373 | 373 | } |
374 | 374 | } |
375 | 375 | |
376 | 376 | foreach ($words as $word) { |
377 | - $string = preg_replace($word['word_value'],$word['word_replacement'],$string); |
|
377 | + $string = preg_replace($word['word_value'], $word['word_replacement'], $string); |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | return $string; |
@@ -382,10 +382,10 @@ discard block |
||
382 | 382 | |
383 | 383 | // choose correct pluralization based on amount |
384 | 384 | function pluralise($word, $count = 0) { |
385 | - if($count == 1) { |
|
385 | + if ($count == 1) { |
|
386 | 386 | return $word; |
387 | 387 | } |
388 | - if(strtolower($word) == 'is') { |
|
388 | + if (strtolower($word) == 'is') { |
|
389 | 389 | return 'are'; |
390 | 390 | } |
391 | 391 | return $word . 's'; |
@@ -406,10 +406,10 @@ discard block |
||
406 | 406 | // This function is a hack around the old style http forward mechanism |
407 | 407 | function do_voodoo() { |
408 | 408 | global $lock, $var, $template, $account; |
409 | - if(!defined('AJAX_CONTAINER')) { |
|
409 | + if (!defined('AJAX_CONTAINER')) { |
|
410 | 410 | define('AJAX_CONTAINER', isset($var['AJAX']) && $var['AJAX'] === true); |
411 | 411 | } |
412 | - if(!AJAX_CONTAINER && USING_AJAX && SmrSession::$SN != SmrSession::$lastSN) |
|
412 | + if (!AJAX_CONTAINER && USING_AJAX && SmrSession::$SN != SmrSession::$lastSN) |
|
413 | 413 | exit; |
414 | 414 | // ob_clean(); |
415 | 415 | |
@@ -417,22 +417,22 @@ discard block |
||
417 | 417 | $$key = &$GLOBALS[$key]; |
418 | 418 | } |
419 | 419 | // create account object |
420 | - $account =& SmrAccount::getAccount(SmrSession::$account_id); |
|
421 | - $GLOBALS['account'] =& $account; |
|
420 | + $account = & SmrAccount::getAccount(SmrSession::$account_id); |
|
421 | + $GLOBALS['account'] = & $account; |
|
422 | 422 | |
423 | - if(!defined('DATE_DATE_SHORT')) define('DATE_DATE_SHORT',$account->getShortDateFormat()); |
|
424 | - if(!defined('DATE_TIME_SHORT')) define('DATE_TIME_SHORT',$account->getShortTimeFormat()); |
|
425 | - if(!defined('DATE_FULL_SHORT')) define('DATE_FULL_SHORT',DATE_DATE_SHORT.' '.DATE_TIME_SHORT); |
|
426 | - if(!defined('DATE_FULL_SHORT_SPLIT')) define('DATE_FULL_SHORT_SPLIT',DATE_DATE_SHORT.'\<b\r /\>'.DATE_TIME_SHORT); |
|
423 | + if (!defined('DATE_DATE_SHORT')) define('DATE_DATE_SHORT', $account->getShortDateFormat()); |
|
424 | + if (!defined('DATE_TIME_SHORT')) define('DATE_TIME_SHORT', $account->getShortTimeFormat()); |
|
425 | + if (!defined('DATE_FULL_SHORT')) define('DATE_FULL_SHORT', DATE_DATE_SHORT . ' ' . DATE_TIME_SHORT); |
|
426 | + if (!defined('DATE_FULL_SHORT_SPLIT')) define('DATE_FULL_SHORT_SPLIT', DATE_DATE_SHORT . '\<b\r /\>' . DATE_TIME_SHORT); |
|
427 | 427 | |
428 | 428 | |
429 | 429 | $db = new SmrMySqlDatabase(); |
430 | - $GLOBALS['db'] =& $db; |
|
430 | + $GLOBALS['db'] = & $db; |
|
431 | 431 | |
432 | - if($var['url'] == 'game_play_preprocessing.php') { // Would rather not have these here but if we go through the initialisation based on game id when leaving a classic game it breaks. |
|
432 | + if ($var['url'] == 'game_play_preprocessing.php') { // Would rather not have these here but if we go through the initialisation based on game id when leaving a classic game it breaks. |
|
433 | 433 | SmrSession::clearLinks(); |
434 | 434 | if (SmrSession::hasGame()) { |
435 | - $account->log(LOG_TYPE_GAME_ENTERING, 'Player left game '.SmrSession::getGameID()); |
|
435 | + $account->log(LOG_TYPE_GAME_ENTERING, 'Player left game ' . SmrSession::getGameID()); |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | // reset game id |
@@ -453,11 +453,11 @@ discard block |
||
453 | 453 | $sector_id = $db->getInt('sector_id'); |
454 | 454 | |
455 | 455 | global $locksFailed; |
456 | - if(!USING_AJAX //AJAX should never do anything that requires a lock. |
|
456 | + if (!USING_AJAX //AJAX should never do anything that requires a lock. |
|
457 | 457 | // && !isset($var['url']) && ($var['body'] == 'current_sector.php' || $var['body'] == 'map_local.php') //Neither should CS or LM and they gets loaded a lot so should reduce lag issues with big groups. |
458 | 458 | ) { |
459 | - if(!$lock && !isset($locksFailed[$sector_id])) { |
|
460 | - if(!acquire_lock($sector_id)) { |
|
459 | + if (!$lock && !isset($locksFailed[$sector_id])) { |
|
460 | + if (!acquire_lock($sector_id)) { |
|
461 | 461 | create_error('Failed to acquire sector lock'); |
462 | 462 | } |
463 | 463 | //Refetch var info in case it changed between grabbing lock. |
@@ -472,18 +472,18 @@ discard block |
||
472 | 472 | } |
473 | 473 | |
474 | 474 | // Now that they've acquire a lock we can move on |
475 | - $player =& SmrPlayer::getPlayer(SmrSession::$account_id, SmrSession::getGameID()); |
|
476 | - $GLOBALS['player'] =& $player; |
|
475 | + $player = & SmrPlayer::getPlayer(SmrSession::$account_id, SmrSession::getGameID()); |
|
476 | + $GLOBALS['player'] = & $player; |
|
477 | 477 | |
478 | - if($player->isDead() && $var['url'] != 'death_processing.php' && !isset($var['override_death'])) { |
|
478 | + if ($player->isDead() && $var['url'] != 'death_processing.php' && !isset($var['override_death'])) { |
|
479 | 479 | forward(create_container('death_processing.php')); |
480 | 480 | } |
481 | 481 | |
482 | - $ship =& $player->getShip(); |
|
483 | - $GLOBALS['ship'] =& $ship; |
|
482 | + $ship = & $player->getShip(); |
|
483 | + $GLOBALS['ship'] = & $ship; |
|
484 | 484 | |
485 | - $sector =& $player->getSector(); |
|
486 | - $GLOBALS['sector'] =& $sector; |
|
485 | + $sector = & $player->getSector(); |
|
486 | + $GLOBALS['sector'] = & $sector; |
|
487 | 487 | |
488 | 488 | // update turns on that player |
489 | 489 | $player->updateTurns(); |
@@ -494,34 +494,34 @@ discard block |
||
494 | 494 | forward(create_container('newbie_warning_processing.php')); |
495 | 495 | } |
496 | 496 | |
497 | - if($var['url'] != 'skeleton.php') { |
|
497 | + if ($var['url'] != 'skeleton.php') { |
|
498 | 498 | require(get_file_loc($var['url'])); |
499 | 499 | } |
500 | - if($var['body']) { |
|
500 | + if ($var['body']) { |
|
501 | 501 | $PHP_OUTPUT = ''; |
502 | - if ($var['body']=='error.php') { // infinite includes for error pages |
|
502 | + if ($var['body'] == 'error.php') { // infinite includes for error pages |
|
503 | 503 | require(get_file_loc($var['body'])); |
504 | 504 | } |
505 | 505 | else { |
506 | 506 | require_once(get_file_loc($var['body'])); |
507 | 507 | } |
508 | 508 | |
509 | - if($PHP_OUTPUT!='') |
|
510 | - $template->assign('PHP_OUTPUT',$PHP_OUTPUT); |
|
509 | + if ($PHP_OUTPUT != '') |
|
510 | + $template->assign('PHP_OUTPUT', $PHP_OUTPUT); |
|
511 | 511 | } |
512 | 512 | |
513 | 513 | if (SmrSession::hasGame()) { |
514 | 514 | $template->assign('UnderAttack', $ship->removeUnderAttack()); |
515 | 515 | } |
516 | 516 | |
517 | - if($lock) { //Only save if we have the lock. |
|
517 | + if ($lock) { //Only save if we have the lock. |
|
518 | 518 | SmrSector::saveSectors(); |
519 | 519 | SmrShip::saveShips(); |
520 | 520 | SmrPlayer::savePlayers(); |
521 | 521 | SmrForce::saveForces(); |
522 | 522 | SmrPort::savePorts(); |
523 | 523 | SmrPlanet::savePlanets(); |
524 | - if(class_exists('WeightedRandom', false)) { |
|
524 | + if (class_exists('WeightedRandom', false)) { |
|
525 | 525 | WeightedRandom::saveWeightedRandoms(); |
526 | 526 | } |
527 | 527 | //Update session here to make sure current page $var is up to date before releasing lock. |
@@ -531,17 +531,17 @@ discard block |
||
531 | 531 | |
532 | 532 | //Nothing below this point should require the lock. |
533 | 533 | |
534 | - $template->assign('TemplateBody',$var['body']); |
|
534 | + $template->assign('TemplateBody', $var['body']); |
|
535 | 535 | if (SmrSession::hasGame()) { |
536 | - $template->assign('ThisSector',$sector); |
|
537 | - $template->assign('ThisPlayer',$player); |
|
538 | - $template->assign('ThisShip',$ship); |
|
536 | + $template->assign('ThisSector', $sector); |
|
537 | + $template->assign('ThisPlayer', $player); |
|
538 | + $template->assign('ThisShip', $ship); |
|
539 | 539 | } |
540 | - $template->assign('ThisAccount',$account); |
|
541 | - if($account->getCssLink()!=null) { |
|
542 | - $template->assign('ExtraCSSLink',$account->getCssLink()); |
|
540 | + $template->assign('ThisAccount', $account); |
|
541 | + if ($account->getCssLink() != null) { |
|
542 | + $template->assign('ExtraCSSLink', $account->getCssLink()); |
|
543 | 543 | } |
544 | - doSkeletonAssigns($template,$player,$ship,$sector,$db,$account); |
|
544 | + doSkeletonAssigns($template, $player, $ship, $sector, $db, $account); |
|
545 | 545 | |
546 | 546 | // Set ajax refresh time |
547 | 547 | $ajaxRefresh = $var['AllowAjax'] ?? true; // hack for bar_gambling_processing.php |
@@ -571,26 +571,26 @@ discard block |
||
571 | 571 | function acquire_lock($sector) { |
572 | 572 | global $db, $lock, $locksFailed; |
573 | 573 | |
574 | - if($lock) |
|
574 | + if ($lock) |
|
575 | 575 | return true; |
576 | 576 | |
577 | 577 | // Insert ourselves into the queue. |
578 | 578 | $db->query('INSERT INTO locks_queue (game_id,account_id,sector_id,timestamp) VALUES(' . $db->escapeNumber(SmrSession::getGameID()) . ',' . $db->escapeNumber(SmrSession::$account_id) . ',' . $db->escapeNumber($sector) . ',' . $db->escapeNumber(TIME) . ')'); |
579 | 579 | $lock = $db->getInsertID(); |
580 | 580 | |
581 | - for($i=0;$i<250;++$i) { |
|
582 | - if(time() - TIME >= LOCK_DURATION - LOCK_BUFFER) { |
|
581 | + for ($i = 0; $i < 250; ++$i) { |
|
582 | + if (time() - TIME >= LOCK_DURATION - LOCK_BUFFER) { |
|
583 | 583 | break; |
584 | 584 | } |
585 | 585 | // If there is someone else before us in the queue we sleep for a while |
586 | 586 | $db->query('SELECT COUNT(*) FROM locks_queue WHERE lock_id<' . $db->escapeNumber($lock) . ' AND sector_id=' . $db->escapeNumber($sector) . ' AND game_id=' . $db->escapeNumber(SmrSession::getGameID()) . ' AND timestamp > ' . $db->escapeNumber(TIME - LOCK_DURATION)); |
587 | 587 | $locksInQueue = -1; |
588 | - if($db->nextRecord() && ($locksInQueue = $db->getInt('COUNT(*)')) > 0) { |
|
588 | + if ($db->nextRecord() && ($locksInQueue = $db->getInt('COUNT(*)')) > 0) { |
|
589 | 589 | //usleep(100000 + mt_rand(0,50000)); |
590 | 590 | |
591 | 591 | // We can only have one lock in the queue, anything more means someone is screwing around |
592 | 592 | $db->query('SELECT COUNT(*) FROM locks_queue WHERE account_id=' . $db->escapeNumber(SmrSession::$account_id) . ' AND sector_id=' . $db->escapeNumber($sector) . ' AND timestamp > ' . $db->escapeNumber(TIME - LOCK_DURATION)); |
593 | - if($db->nextRecord() && $db->getInt('COUNT(*)') > 1) { |
|
593 | + if ($db->nextRecord() && $db->getInt('COUNT(*)') > 1) { |
|
594 | 594 | release_lock(); |
595 | 595 | $locksFailed[$sector] = true; |
596 | 596 | create_error('Multiple actions cannot be performed at the same time!'); |
@@ -611,7 +611,7 @@ discard block |
||
611 | 611 | |
612 | 612 | function release_lock() { |
613 | 613 | global $db, $lock; |
614 | - if($lock) { |
|
614 | + if ($lock) { |
|
615 | 615 | $db->query('DELETE from locks_queue WHERE lock_id=' . $db->escapeNumber($lock) . ' OR timestamp<' . $db->escapeNumber(TIME - LOCK_DURATION)); |
616 | 616 | } |
617 | 617 | |
@@ -620,15 +620,15 @@ discard block |
||
620 | 620 | |
621 | 621 | function doTickerAssigns($template, $player, $db) { |
622 | 622 | //any ticker news? |
623 | - if($player->hasTickers()) { |
|
623 | + if ($player->hasTickers()) { |
|
624 | 624 | $ticker = array(); |
625 | 625 | $max = TIME - 60; |
626 | - if($player->hasTicker('NEWS')) { |
|
626 | + if ($player->hasTicker('NEWS')) { |
|
627 | 627 | $text = ''; |
628 | 628 | //get recent news (5 mins) |
629 | 629 | |
630 | - $db->query('SELECT time,news_message FROM news WHERE game_id = ' . $db->escapeNumber($player->getGameID()) . ' AND time >= '.$max.' ORDER BY time DESC LIMIT 4'); |
|
631 | - while($db->nextRecord()) { |
|
630 | + $db->query('SELECT time,news_message FROM news WHERE game_id = ' . $db->escapeNumber($player->getGameID()) . ' AND time >= ' . $max . ' ORDER BY time DESC LIMIT 4'); |
|
631 | + while ($db->nextRecord()) { |
|
632 | 632 | $ticker[] = array('Time' => date(DATE_FULL_SHORT, $db->getField('time')), |
633 | 633 | 'Message'=>$db->getField('news_message')); |
634 | 634 | } |
@@ -639,15 +639,15 @@ discard block |
||
639 | 639 | AND game_id=' . $db->escapeNumber($player->getGameID()) . ' |
640 | 640 | AND message_type_id=' . $db->escapeNumber(MSG_SCOUT) . ' |
641 | 641 | AND send_time>=' . $db->escapeNumber($max) . ' |
642 | - AND sender_id NOT IN (SELECT account_id FROM player_has_ticker WHERE type='.$db->escapeString('BLOCK').' AND expires > ' . $db->escapeNumber(TIME) . ' AND game_id = ' . $db->escapeNumber($player->getGameID()) . ') AND receiver_delete = \'FALSE\' |
|
642 | + AND sender_id NOT IN (SELECT account_id FROM player_has_ticker WHERE type='.$db->escapeString('BLOCK') . ' AND expires > ' . $db->escapeNumber(TIME) . ' AND game_id = ' . $db->escapeNumber($player->getGameID()) . ') AND receiver_delete = \'FALSE\' |
|
643 | 643 | ORDER BY send_time DESC |
644 | 644 | LIMIT 4'); |
645 | - while($db->nextRecord()) { |
|
645 | + while ($db->nextRecord()) { |
|
646 | 646 | $ticker[] = array('Time' => date(DATE_FULL_SHORT, $db->getField('send_time')), |
647 | 647 | 'Message'=>$db->getField('message_text')); |
648 | 648 | } |
649 | 649 | } |
650 | - $template->assign('Ticker',$ticker); |
|
650 | + $template->assign('Ticker', $ticker); |
|
651 | 651 | } |
652 | 652 | } |
653 | 653 | |
@@ -656,7 +656,7 @@ discard block |
||
656 | 656 | $template->assign('CSSColourLink', $account->getCssColourUrl()); |
657 | 657 | |
658 | 658 | $template->assign('FontSize', $account->getFontSize() - 20); |
659 | - $template->assign('timeDisplay',date(DATE_FULL_SHORT_SPLIT,TIME)); |
|
659 | + $template->assign('timeDisplay', date(DATE_FULL_SHORT_SPLIT, TIME)); |
|
660 | 660 | |
661 | 661 | $container = create_container('skeleton.php'); |
662 | 662 | |
@@ -665,172 +665,172 @@ discard block |
||
665 | 665 | $template->assign('GameName', Globals::getGameName(SmrSession::getGameID())); |
666 | 666 | $template->assign('GameID', SmrSession::getGameID()); |
667 | 667 | |
668 | - $template->assign('PlotCourseLink',Globals::getPlotCourseHREF()); |
|
668 | + $template->assign('PlotCourseLink', Globals::getPlotCourseHREF()); |
|
669 | 669 | |
670 | - $template->assign('TraderLink',Globals::getTraderStatusHREF()); |
|
670 | + $template->assign('TraderLink', Globals::getTraderStatusHREF()); |
|
671 | 671 | |
672 | - $template->assign('PoliticsLink',Globals::getPoliticsHREF()); |
|
672 | + $template->assign('PoliticsLink', Globals::getPoliticsHREF()); |
|
673 | 673 | |
674 | 674 | $container['body'] = 'combat_log_list.php'; |
675 | - $template->assign('CombatLogsLink',SmrSession::getNewHREF($container)); |
|
675 | + $template->assign('CombatLogsLink', SmrSession::getNewHREF($container)); |
|
676 | 676 | |
677 | - $template->assign('PlanetLink',Globals::getPlanetListHREF($player->getAllianceID())); |
|
677 | + $template->assign('PlanetLink', Globals::getPlanetListHREF($player->getAllianceID())); |
|
678 | 678 | |
679 | 679 | $container['body'] = 'forces_list.php'; |
680 | - $template->assign('ForcesLink',SmrSession::getNewHREF($container)); |
|
680 | + $template->assign('ForcesLink', SmrSession::getNewHREF($container)); |
|
681 | 681 | |
682 | 682 | $container['body'] = 'message_view.php'; |
683 | - $template->assign('MessagesLink',SmrSession::getNewHREF($container)); |
|
683 | + $template->assign('MessagesLink', SmrSession::getNewHREF($container)); |
|
684 | 684 | |
685 | 685 | $container['body'] = 'news_read_current.php'; |
686 | - $template->assign('ReadNewsLink',SmrSession::getNewHREF($container)); |
|
686 | + $template->assign('ReadNewsLink', SmrSession::getNewHREF($container)); |
|
687 | 687 | |
688 | 688 | $container['body'] = 'galactic_post_current.php'; |
689 | - $template->assign('GalacticPostLink',SmrSession::getNewHREF($container)); |
|
689 | + $template->assign('GalacticPostLink', SmrSession::getNewHREF($container)); |
|
690 | 690 | |
691 | 691 | $container['body'] = 'trader_search.php'; |
692 | - $template->assign('SearchForTraderLink',SmrSession::getNewHREF($container)); |
|
692 | + $template->assign('SearchForTraderLink', SmrSession::getNewHREF($container)); |
|
693 | 693 | |
694 | 694 | $container['body'] = 'rankings_player_experience.php'; |
695 | - $template->assign('RankingsLink',SmrSession::getNewHREF($container)); |
|
695 | + $template->assign('RankingsLink', SmrSession::getNewHREF($container)); |
|
696 | 696 | |
697 | 697 | $container['body'] = 'hall_of_fame_new.php'; |
698 | 698 | $container['game_id'] = $player->getGameID(); |
699 | - $template->assign('CurrentHallOfFameLink',SmrSession::getNewHREF($container)); |
|
699 | + $template->assign('CurrentHallOfFameLink', SmrSession::getNewHREF($container)); |
|
700 | 700 | } |
701 | 701 | |
702 | 702 | if (SmrSession::$account_id > 0) { |
703 | 703 | $container = create_container('skeleton.php', 'hall_of_fame_new.php'); |
704 | - $template->assign('HallOfFameLink',SmrSession::getNewHREF($container)); |
|
704 | + $template->assign('HallOfFameLink', SmrSession::getNewHREF($container)); |
|
705 | 705 | |
706 | - $template->assign('AccountID',SmrSession::$account_id); |
|
707 | - $template->assign('PlayGameLink',SmrSession::getNewHREF(create_container('game_play_preprocessing.php'))); |
|
706 | + $template->assign('AccountID', SmrSession::$account_id); |
|
707 | + $template->assign('PlayGameLink', SmrSession::getNewHREF(create_container('game_play_preprocessing.php'))); |
|
708 | 708 | |
709 | - $template->assign('LogoutLink',SmrSession::getNewHREF(create_container('logoff.php'))); |
|
709 | + $template->assign('LogoutLink', SmrSession::getNewHREF(create_container('logoff.php'))); |
|
710 | 710 | } |
711 | 711 | |
712 | 712 | $container = create_container('skeleton.php', 'preferences.php'); |
713 | - $template->assign('PreferencesLink',SmrSession::getNewHREF($container)); |
|
713 | + $template->assign('PreferencesLink', SmrSession::getNewHREF($container)); |
|
714 | 714 | |
715 | 715 | $container['body'] = 'admin_tools.php'; |
716 | - $template->assign('AdminToolsLink',SmrSession::getNewHREF($container)); |
|
716 | + $template->assign('AdminToolsLink', SmrSession::getNewHREF($container)); |
|
717 | 717 | |
718 | 718 | $container['body'] = 'album_edit.php'; |
719 | - $template->assign('EditPhotoLink',SmrSession::getNewHREF($container)); |
|
719 | + $template->assign('EditPhotoLink', SmrSession::getNewHREF($container)); |
|
720 | 720 | |
721 | 721 | $container['body'] = 'bug_report.php'; |
722 | - $template->assign('ReportABugLink',SmrSession::getNewHREF($container)); |
|
722 | + $template->assign('ReportABugLink', SmrSession::getNewHREF($container)); |
|
723 | 723 | |
724 | 724 | $container['body'] = 'contact.php'; |
725 | - $template->assign('ContactFormLink',SmrSession::getNewHREF($container)); |
|
725 | + $template->assign('ContactFormLink', SmrSession::getNewHREF($container)); |
|
726 | 726 | |
727 | 727 | if (SmrSession::hasGame()) { |
728 | 728 | $container['body'] = 'chat_rules.php'; |
729 | - $template->assign('IRCLink',SmrSession::getNewHREF($container)); |
|
729 | + $template->assign('IRCLink', SmrSession::getNewHREF($container)); |
|
730 | 730 | } |
731 | 731 | |
732 | 732 | $container['body'] = 'donation.php'; |
733 | - $template->assign('DonateLink',SmrSession::getNewHREF($container)); |
|
733 | + $template->assign('DonateLink', SmrSession::getNewHREF($container)); |
|
734 | 734 | |
735 | 735 | |
736 | 736 | |
737 | 737 | if (SmrSession::hasGame()) { |
738 | 738 | $db->query('SELECT message_type_id,COUNT(*) FROM player_has_unread_messages WHERE account_id=' . $db->escapeNumber($player->getAccountID()) . ' AND game_id=' . $db->escapeNumber($player->getGameID()) . ' GROUP BY message_type_id'); |
739 | 739 | |
740 | - if($db->getNumRows()) { |
|
740 | + if ($db->getNumRows()) { |
|
741 | 741 | $messages = array(); |
742 | - while($db->nextRecord()) { |
|
742 | + while ($db->nextRecord()) { |
|
743 | 743 | $messages[$db->getInt('message_type_id')] = $db->getInt('COUNT(*)'); |
744 | 744 | } |
745 | 745 | |
746 | - $container = create_container('skeleton.php','message_view.php'); |
|
746 | + $container = create_container('skeleton.php', 'message_view.php'); |
|
747 | 747 | |
748 | - if(isset($messages[MSG_GLOBAL])) { |
|
748 | + if (isset($messages[MSG_GLOBAL])) { |
|
749 | 749 | $container['folder_id'] = MSG_GLOBAL; |
750 | - $template->assign('MessageGlobalLink',SmrSession::getNewHREF($container)); |
|
751 | - $template->assign('MessageGlobalNum',$messages[MSG_GLOBAL]); |
|
750 | + $template->assign('MessageGlobalLink', SmrSession::getNewHREF($container)); |
|
751 | + $template->assign('MessageGlobalNum', $messages[MSG_GLOBAL]); |
|
752 | 752 | } |
753 | 753 | |
754 | - if(isset($messages[MSG_PLAYER])) { |
|
754 | + if (isset($messages[MSG_PLAYER])) { |
|
755 | 755 | $container['folder_id'] = MSG_PLAYER; |
756 | - $template->assign('MessagePersonalLink',SmrSession::getNewHREF($container)); |
|
757 | - $template->assign('MessagePersonalNum',$messages[MSG_PLAYER]); |
|
756 | + $template->assign('MessagePersonalLink', SmrSession::getNewHREF($container)); |
|
757 | + $template->assign('MessagePersonalNum', $messages[MSG_PLAYER]); |
|
758 | 758 | } |
759 | 759 | |
760 | - if(isset($messages[MSG_SCOUT])) { |
|
760 | + if (isset($messages[MSG_SCOUT])) { |
|
761 | 761 | $container['folder_id'] = MSG_SCOUT; |
762 | - $template->assign('MessageScoutLink',SmrSession::getNewHREF($container)); |
|
763 | - $template->assign('MessageScoutNum',$messages[MSG_SCOUT]); |
|
762 | + $template->assign('MessageScoutLink', SmrSession::getNewHREF($container)); |
|
763 | + $template->assign('MessageScoutNum', $messages[MSG_SCOUT]); |
|
764 | 764 | } |
765 | 765 | |
766 | - if(isset($messages[MSG_POLITICAL])) { |
|
766 | + if (isset($messages[MSG_POLITICAL])) { |
|
767 | 767 | $container['folder_id'] = MSG_POLITICAL; |
768 | - $template->assign('MessagePoliticalLink',SmrSession::getNewHREF($container)); |
|
769 | - $template->assign('MessagePoliticalNum',$messages[MSG_POLITICAL]); |
|
768 | + $template->assign('MessagePoliticalLink', SmrSession::getNewHREF($container)); |
|
769 | + $template->assign('MessagePoliticalNum', $messages[MSG_POLITICAL]); |
|
770 | 770 | } |
771 | 771 | |
772 | - if(isset($messages[MSG_ALLIANCE])) { |
|
772 | + if (isset($messages[MSG_ALLIANCE])) { |
|
773 | 773 | $container['folder_id'] = MSG_ALLIANCE; |
774 | - $template->assign('MessageAllianceLink',SmrSession::getNewHREF($container)); |
|
775 | - $template->assign('MessageAllianceNum',$messages[MSG_ALLIANCE]); |
|
774 | + $template->assign('MessageAllianceLink', SmrSession::getNewHREF($container)); |
|
775 | + $template->assign('MessageAllianceNum', $messages[MSG_ALLIANCE]); |
|
776 | 776 | } |
777 | 777 | |
778 | - if(isset($messages[MSG_ADMIN])) { |
|
778 | + if (isset($messages[MSG_ADMIN])) { |
|
779 | 779 | $container['folder_id'] = MSG_ADMIN; |
780 | - $template->assign('MessageAdminLink',SmrSession::getNewHREF($container)); |
|
781 | - $template->assign('MessageAdminNum',$messages[MSG_ADMIN]); |
|
780 | + $template->assign('MessageAdminLink', SmrSession::getNewHREF($container)); |
|
781 | + $template->assign('MessageAdminNum', $messages[MSG_ADMIN]); |
|
782 | 782 | } |
783 | 783 | |
784 | - if(isset($messages[MSG_CASINO])) { |
|
784 | + if (isset($messages[MSG_CASINO])) { |
|
785 | 785 | $container['folder_id'] = MSG_CASINO; |
786 | - $template->assign('MessageCasinoLink',SmrSession::getNewHREF($container)); |
|
787 | - $template->assign('MessageCasinoNum',$messages[MSG_CASINO]); |
|
786 | + $template->assign('MessageCasinoLink', SmrSession::getNewHREF($container)); |
|
787 | + $template->assign('MessageCasinoNum', $messages[MSG_CASINO]); |
|
788 | 788 | } |
789 | 789 | |
790 | - if(isset($messages[MSG_PLANET])) { |
|
790 | + if (isset($messages[MSG_PLANET])) { |
|
791 | 791 | $container = create_container('planet_msg_processing.php'); |
792 | - $template->assign('MessagePlanetLink',SmrSession::getNewHREF($container)); |
|
793 | - $template->assign('MessagePlanetNum',$messages[MSG_PLANET]); |
|
792 | + $template->assign('MessagePlanetLink', SmrSession::getNewHREF($container)); |
|
793 | + $template->assign('MessagePlanetNum', $messages[MSG_PLANET]); |
|
794 | 794 | } |
795 | 795 | } |
796 | 796 | |
797 | 797 | $container = create_container('skeleton.php', 'trader_search_result.php'); |
798 | - $container['player_id'] = $player->getPlayerID(); |
|
799 | - $template->assign('PlayerNameLink',SmrSession::getNewHREF($container)); |
|
798 | + $container['player_id'] = $player->getPlayerID(); |
|
799 | + $template->assign('PlayerNameLink', SmrSession::getNewHREF($container)); |
|
800 | 800 | |
801 | - if (is_array(Globals::getHiddenPlayers())&&in_array($player->getAccountID(), Globals::getHiddenPlayers())) $template->assign('PlayerInvisible',true); |
|
801 | + if (is_array(Globals::getHiddenPlayers()) && in_array($player->getAccountID(), Globals::getHiddenPlayers())) $template->assign('PlayerInvisible', true); |
|
802 | 802 | |
803 | 803 | // ******* Hardware ******* |
804 | 804 | $container = create_container('skeleton.php', 'configure_hardware.php'); |
805 | 805 | |
806 | - $template->assign('HardwareLink',SmrSession::getNewHREF($container)); |
|
806 | + $template->assign('HardwareLink', SmrSession::getNewHREF($container)); |
|
807 | 807 | |
808 | 808 | // ******* Forces ******* |
809 | - $template->assign('ForceDropLink',SmrSession::getNewHREF(create_container('skeleton.php', 'forces_drop.php'))); |
|
809 | + $template->assign('ForceDropLink', SmrSession::getNewHREF(create_container('skeleton.php', 'forces_drop.php'))); |
|
810 | 810 | |
811 | 811 | if ($ship->hasMines()) { |
812 | 812 | $container = create_container('forces_drop_processing.php'); |
813 | 813 | $container['owner_id'] = $player->getAccountID(); |
814 | 814 | $container['drop_mines'] = 1; |
815 | - $template->assign('DropMineLink',SmrSession::getNewHREF($container)); |
|
815 | + $template->assign('DropMineLink', SmrSession::getNewHREF($container)); |
|
816 | 816 | } |
817 | 817 | if ($ship->hasCDs()) { |
818 | 818 | $container = create_container('forces_drop_processing.php'); |
819 | 819 | $container['owner_id'] = $player->getAccountID(); |
820 | 820 | $container['drop_combat_drones'] = 1; |
821 | - $template->assign('DropCDLink',SmrSession::getNewHREF($container)); |
|
821 | + $template->assign('DropCDLink', SmrSession::getNewHREF($container)); |
|
822 | 822 | } |
823 | 823 | |
824 | 824 | if ($ship->hasSDs()) { |
825 | 825 | $container = create_container('forces_drop_processing.php'); |
826 | 826 | $container['owner_id'] = $player->getAccountID(); |
827 | 827 | $container['drop_scout_drones'] = 1; |
828 | - $template->assign('DropSDLink',SmrSession::getNewHREF($container)); |
|
828 | + $template->assign('DropSDLink', SmrSession::getNewHREF($container)); |
|
829 | 829 | } |
830 | 830 | |
831 | - $template->assign('CargoJettisonLink',SmrSession::getNewHREF(create_container('skeleton.php', 'cargo_dump.php'))); |
|
831 | + $template->assign('CargoJettisonLink', SmrSession::getNewHREF(create_container('skeleton.php', 'cargo_dump.php'))); |
|
832 | 832 | |
833 | - $template->assign('WeaponReorderLink',SmrSession::getNewHREF(create_container('skeleton.php', 'weapon_reorder.php'))); |
|
833 | + $template->assign('WeaponReorderLink', SmrSession::getNewHREF(create_container('skeleton.php', 'weapon_reorder.php'))); |
|
834 | 834 | |
835 | 835 | } |
836 | 836 | |
@@ -860,34 +860,34 @@ discard block |
||
860 | 860 | $version = create_link($container, 'v' . $db->getField('major_version') . '.' . $db->getField('minor_version') . '.' . $db->getField('patch_level')); |
861 | 861 | } |
862 | 862 | |
863 | - $template->assign('Version',$version); |
|
864 | - $template->assign('CurrentYear',date('Y',TIME)); |
|
863 | + $template->assign('Version', $version); |
|
864 | + $template->assign('CurrentYear', date('Y', TIME)); |
|
865 | 865 | } |
866 | 866 | |
867 | -function format_time($seconds, $short=false) { |
|
868 | - $minutes=0; |
|
869 | - $hours=0; |
|
870 | - $days=0; |
|
871 | - $weeks=0; |
|
867 | +function format_time($seconds, $short = false) { |
|
868 | + $minutes = 0; |
|
869 | + $hours = 0; |
|
870 | + $days = 0; |
|
871 | + $weeks = 0; |
|
872 | 872 | $string = ''; |
873 | 873 | if ($seconds == 0) { |
874 | 874 | $string = '0 seconds'; |
875 | 875 | if ($short) $string = '0s'; |
876 | 876 | } |
877 | 877 | if ($seconds >= 60) { |
878 | - $minutes = floor($seconds/60); |
|
878 | + $minutes = floor($seconds / 60); |
|
879 | 879 | $seconds = $seconds % 60; |
880 | 880 | } |
881 | 881 | if ($minutes >= 60) { |
882 | - $hours = floor($minutes/60); |
|
882 | + $hours = floor($minutes / 60); |
|
883 | 883 | $minutes = $minutes % 60; |
884 | 884 | } |
885 | 885 | if ($hours >= 24) { |
886 | - $days = floor($hours/24); |
|
886 | + $days = floor($hours / 24); |
|
887 | 887 | $hours = $hours % 24; |
888 | 888 | } |
889 | 889 | if ($days >= 7) { |
890 | - $weeks = floor($days/7); |
|
890 | + $weeks = floor($days / 7); |
|
891 | 891 | $days = $days % 7; |
892 | 892 | } |
893 | 893 | if ($weeks > 0) { |
@@ -949,19 +949,19 @@ discard block |
||
949 | 949 | return $string; |
950 | 950 | } |
951 | 951 | |
952 | -function number_colour_format($number,$justSign = false) { |
|
952 | +function number_colour_format($number, $justSign = false) { |
|
953 | 953 | $formatted = '<span'; |
954 | - if($number > 0) |
|
954 | + if ($number > 0) |
|
955 | 955 | $formatted .= ' class="green">+'; |
956 | - else if($number < 0) |
|
956 | + else if ($number < 0) |
|
957 | 957 | $formatted .= ' class="red">-'; |
958 | 958 | else |
959 | 959 | $formatted .= '>'; |
960 | - if($justSign===false) { |
|
960 | + if ($justSign === false) { |
|
961 | 961 | $decimalPlaces = 0; |
962 | - if(($pos = strpos($number,'.'))!==false) |
|
963 | - $decimalPlaces = strlen(substr($number,$pos+1)); |
|
964 | - $formatted .= number_format(abs($number),$decimalPlaces); |
|
962 | + if (($pos = strpos($number, '.')) !== false) |
|
963 | + $decimalPlaces = strlen(substr($number, $pos + 1)); |
|
964 | + $formatted .= number_format(abs($number), $decimalPlaces); |
|
965 | 965 | } |
966 | 966 | $formatted .= '</span>'; |
967 | 967 | return $formatted; |
@@ -982,7 +982,7 @@ discard block |
||
982 | 982 | // Normalize the weights so that their sum is much larger than 1. |
983 | 983 | $maxWeight = max($choices); |
984 | 984 | foreach ($choices as $key => &$weight) { |
985 | - $weight = round($weight * 1000/$maxWeight); |
|
985 | + $weight = round($weight * 1000 / $maxWeight); |
|
986 | 986 | } unset($weight); |
987 | 987 | |
988 | 988 | // Generate a random number that is lower than the sum of the weights. |
@@ -1006,5 +1006,5 @@ discard block |
||
1006 | 1006 | if ($length % 2 != 0) { |
1007 | 1007 | throw new Exception('Length must be a multiple of 2!'); |
1008 | 1008 | } |
1009 | - return bin2hex(random_bytes($length/2)); |
|
1009 | + return bin2hex(random_bytes($length / 2)); |
|
1010 | 1010 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | if ($player->getAllianceID() == $currentAlliance->getAllianceID()) { |
15 | 15 | $class = ' class="bold"'; |
16 | 16 | } |
17 | - else if($currentAlliance->hasDisbanded()) { |
|
17 | + else if ($currentAlliance->hasDisbanded()) { |
|
18 | 18 | $class = ' class="red"'; |
19 | 19 | } |
20 | 20 | |
@@ -35,15 +35,15 @@ discard block |
||
35 | 35 | $rank++; |
36 | 36 | $currentPlayer = SmrPlayer::getPlayer($db->getInt('account_id'), $player->getGameID(), false, $db); |
37 | 37 | |
38 | - $class=''; |
|
38 | + $class = ''; |
|
39 | 39 | if ($player->equals($currentPlayer)) { |
40 | 40 | $class .= 'bold'; |
41 | 41 | } |
42 | - if($currentPlayer->hasNewbieStatus()) { |
|
43 | - $class.= ' newbie'; |
|
42 | + if ($currentPlayer->hasNewbieStatus()) { |
|
43 | + $class .= ' newbie'; |
|
44 | 44 | } |
45 | - if($class!='') { |
|
46 | - $class = ' class="'.trim($class).'"'; |
|
45 | + if ($class != '') { |
|
46 | + $class = ' class="' . trim($class) . '"'; |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | $rankings[$rank] = array( |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | $minRank = min($_REQUEST['min_rank'], $_REQUEST['max_rank']); |
63 | 63 | $maxRank = max($_REQUEST['min_rank'], $_REQUEST['max_rank']); |
64 | 64 | } |
65 | - elseif(isset($var['MinRank']) && isset($var['MaxRank'])) { |
|
65 | + elseif (isset($var['MinRank']) && isset($var['MaxRank'])) { |
|
66 | 66 | $minRank = $var['MinRank']; |
67 | 67 | $maxRank = $var['MaxRank']; |
68 | 68 | } |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | |
79 | 79 | $maxRank = min($maxRank, $totalRanks); |
80 | 80 | |
81 | - SmrSession::updateVar('MinRank',$minRank); |
|
82 | - SmrSession::updateVar('MaxRank',$maxRank); |
|
81 | + SmrSession::updateVar('MinRank', $minRank); |
|
82 | + SmrSession::updateVar('MaxRank', $maxRank); |
|
83 | 83 | $template->assign('MinRank', $minRank); |
84 | 84 | $template->assign('MaxRank', $maxRank); |
85 | 85 | $template->assign('TotalRanks', $totalRanks); |
@@ -1,26 +1,26 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -function getHofRank($view,$viewType,$accountID,$gameID,&$db) { |
|
4 | - global $account,$player; |
|
5 | - $gameIDSql = ' AND game_id '.(isset($gameID) ? '= ' . $db->escapeNumber($gameID) : 'IN (SELECT game_id FROM game WHERE ignore_stats = '.$db->escapeBoolean(false).')'); |
|
3 | +function getHofRank($view, $viewType, $accountID, $gameID, &$db) { |
|
4 | + global $account, $player; |
|
5 | + $gameIDSql = ' AND game_id ' . (isset($gameID) ? '= ' . $db->escapeNumber($gameID) : 'IN (SELECT game_id FROM game WHERE ignore_stats = ' . $db->escapeBoolean(false) . ')'); |
|
6 | 6 | |
7 | 7 | $vis = HOF_PUBLIC; |
8 | - $rank = array('Amount'=>0,'Rank'=>0); |
|
9 | - if($view == DONATION_NAME) { |
|
10 | - $db->query('SELECT SUM(amount) as amount FROM account_donated WHERE account_id='.$db->escapeNumber($accountID).' GROUP BY account_id LIMIT 1'); |
|
8 | + $rank = array('Amount'=>0, 'Rank'=>0); |
|
9 | + if ($view == DONATION_NAME) { |
|
10 | + $db->query('SELECT SUM(amount) as amount FROM account_donated WHERE account_id=' . $db->escapeNumber($accountID) . ' GROUP BY account_id LIMIT 1'); |
|
11 | 11 | } |
12 | - else if($view == USER_SCORE_NAME) { |
|
12 | + else if ($view == USER_SCORE_NAME) { |
|
13 | 13 | $statements = SmrAccount::getUserScoreCaseStatement($db); |
14 | - $query = 'SELECT '.$statements['CASE'].' amount FROM (SELECT type, SUM(amount) amount FROM player_hof WHERE type IN ('.$statements['IN'].') AND account_id='.$db->escapeNumber($accountID).$gameIDSql.' GROUP BY account_id,type) x ORDER BY amount DESC'; |
|
14 | + $query = 'SELECT ' . $statements['CASE'] . ' amount FROM (SELECT type, SUM(amount) amount FROM player_hof WHERE type IN (' . $statements['IN'] . ') AND account_id=' . $db->escapeNumber($accountID) . $gameIDSql . ' GROUP BY account_id,type) x ORDER BY amount DESC'; |
|
15 | 15 | $db->query($query); |
16 | 16 | } |
17 | 17 | else { |
18 | - $db->query('SELECT visibility FROM hof_visibility WHERE type='.$db->escapeArray($viewType,false,true,':',false).' LIMIT 1'); |
|
19 | - if(!$db->nextRecord()) { |
|
18 | + $db->query('SELECT visibility FROM hof_visibility WHERE type=' . $db->escapeArray($viewType, false, true, ':', false) . ' LIMIT 1'); |
|
19 | + if (!$db->nextRecord()) { |
|
20 | 20 | return $rank; |
21 | 21 | } |
22 | 22 | $vis = $db->getField('visibility'); |
23 | - $db->query('SELECT SUM(amount) amount FROM player_hof WHERE type='.$db->escapeArray($viewType,false,true,':',false) .' AND account_id='.$db->escapeNumber($accountID).$gameIDSql.' GROUP BY account_id LIMIT 1'); |
|
23 | + $db->query('SELECT SUM(amount) amount FROM player_hof WHERE type=' . $db->escapeArray($viewType, false, true, ':', false) . ' AND account_id=' . $db->escapeNumber($accountID) . $gameIDSql . ' GROUP BY account_id LIMIT 1'); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | // What we will show for the amount: |
@@ -31,15 +31,15 @@ discard block |
||
31 | 31 | // - Current player: real total amount |
32 | 32 | // - Other Player: total amount from completed games |
33 | 33 | $realAmount = 0; |
34 | - if($db->nextRecord()) { |
|
35 | - if($db->getField('amount')!=null) { |
|
34 | + if ($db->nextRecord()) { |
|
35 | + if ($db->getField('amount') != null) { |
|
36 | 36 | $realAmount = $db->getField('amount'); |
37 | 37 | } |
38 | 38 | } |
39 | - if($vis==HOF_PUBLIC || $account->getAccountID()==$accountID) { |
|
39 | + if ($vis == HOF_PUBLIC || $account->getAccountID() == $accountID) { |
|
40 | 40 | $rank['Amount'] = $realAmount; |
41 | 41 | } |
42 | - else if($vis==HOF_ALLIANCE&&$account->getAccountID()!=$accountID) { |
|
42 | + else if ($vis == HOF_ALLIANCE && $account->getAccountID() != $accountID) { |
|
43 | 43 | if (isset($gameID)) { |
44 | 44 | $hofPlayer = SmrPlayer::getPlayer($accountID, $gameID); |
45 | 45 | // Only show the real amount if player is in your alliance. |
@@ -50,38 +50,38 @@ discard block |
||
50 | 50 | } |
51 | 51 | } else { |
52 | 52 | $rank['Amount'] = 0; //default |
53 | - $db->query('SELECT SUM(amount) amount FROM player_hof WHERE type='.$db->escapeArray($viewType,false,true,':',false) .' AND account_id='.$accountID.' AND game_id IN (SELECT game_id FROM game WHERE end_date < '.TIME.' AND ignore_stats = '.$db->escapeBoolean(false).') GROUP BY account_id LIMIT 1'); |
|
54 | - if($db->nextRecord()) { |
|
55 | - if($db->getField('amount')!=null) { |
|
53 | + $db->query('SELECT SUM(amount) amount FROM player_hof WHERE type=' . $db->escapeArray($viewType, false, true, ':', false) . ' AND account_id=' . $accountID . ' AND game_id IN (SELECT game_id FROM game WHERE end_date < ' . TIME . ' AND ignore_stats = ' . $db->escapeBoolean(false) . ') GROUP BY account_id LIMIT 1'); |
|
54 | + if ($db->nextRecord()) { |
|
55 | + if ($db->getField('amount') != null) { |
|
56 | 56 | $rank['Amount'] = $db->getField('amount'); |
57 | 57 | } |
58 | 58 | } |
59 | 59 | } |
60 | 60 | } |
61 | 61 | |
62 | - if($view == DONATION_NAME) { |
|
62 | + if ($view == DONATION_NAME) { |
|
63 | 63 | $db->query('SELECT COUNT(account_id) rank FROM (SELECT account_id FROM account_donated GROUP BY account_id HAVING SUM(amount)>' . $db->escapeNumber($rank['Amount']) . ') x'); |
64 | 64 | } |
65 | - else if($view == USER_SCORE_NAME) { |
|
66 | - $query = 'SELECT COUNT(account_id) rank FROM (SELECT account_id FROM player_hof WHERE type IN ('.$statements['IN'].')'.$gameIDSql.' GROUP BY account_id HAVING '.$statements['CASE'].'>' . $db->escapeNumber($rank['Amount']) . ') x'; |
|
65 | + else if ($view == USER_SCORE_NAME) { |
|
66 | + $query = 'SELECT COUNT(account_id) rank FROM (SELECT account_id FROM player_hof WHERE type IN (' . $statements['IN'] . ')' . $gameIDSql . ' GROUP BY account_id HAVING ' . $statements['CASE'] . '>' . $db->escapeNumber($rank['Amount']) . ') x'; |
|
67 | 67 | $db->query($query); |
68 | 68 | } |
69 | 69 | else { |
70 | - $db->query('SELECT COUNT(account_id) rank FROM (SELECT account_id FROM player_hof WHERE type='.$db->escapeArray($viewType,false,true,':',false).$gameIDSql.' GROUP BY account_id HAVING SUM(amount)>'.$db->escapeNumber($realAmount).') x'); |
|
70 | + $db->query('SELECT COUNT(account_id) rank FROM (SELECT account_id FROM player_hof WHERE type=' . $db->escapeArray($viewType, false, true, ':', false) . $gameIDSql . ' GROUP BY account_id HAVING SUM(amount)>' . $db->escapeNumber($realAmount) . ') x'); |
|
71 | 71 | } |
72 | - if($db->nextRecord()) { |
|
72 | + if ($db->nextRecord()) { |
|
73 | 73 | $rank['Rank'] = $db->getInt('rank') + 1; |
74 | 74 | } |
75 | 75 | return $rank; |
76 | 76 | } |
77 | 77 | |
78 | -function displayHOFRow($rank,$accountID,$amount) { |
|
79 | - global $account,$player,$var; |
|
80 | - if(isset($var['game_id']) && Globals::isValidGame($var['game_id'])) { |
|
78 | +function displayHOFRow($rank, $accountID, $amount) { |
|
79 | + global $account, $player, $var; |
|
80 | + if (isset($var['game_id']) && Globals::isValidGame($var['game_id'])) { |
|
81 | 81 | try { |
82 | - $hofPlayer = SmrPlayer::getPlayer($accountID,$var['game_id']); |
|
82 | + $hofPlayer = SmrPlayer::getPlayer($accountID, $var['game_id']); |
|
83 | 83 | } |
84 | - catch(PlayerNotFoundException $e) { |
|
84 | + catch (PlayerNotFoundException $e) { |
|
85 | 85 | $hofAccount = SmrAccount::getAccount($accountID); |
86 | 86 | } |
87 | 87 | } |
@@ -92,10 +92,10 @@ discard block |
||
92 | 92 | if ($accountID == $account->getAccountID()) { |
93 | 93 | $bold = ' class="bold"'; |
94 | 94 | } |
95 | - $return=('<tr>'); |
|
96 | - $return.=('<td align="center"'.$bold.'>' . $rank . '</td>'); |
|
95 | + $return = ('<tr>'); |
|
96 | + $return .= ('<td align="center"' . $bold . '>' . $rank . '</td>'); |
|
97 | 97 | |
98 | - $container = create_container('skeleton.php','hall_of_fame_player_detail.php'); |
|
98 | + $container = create_container('skeleton.php', 'hall_of_fame_player_detail.php'); |
|
99 | 99 | $container['account_id'] = $accountID; |
100 | 100 | |
101 | 101 | if (isset($var['game_id'])) { |
@@ -105,29 +105,29 @@ discard block |
||
105 | 105 | else { |
106 | 106 | $container['sending_page'] = 'personal_hof'; |
107 | 107 | } |
108 | - if(isset($hofPlayer) && is_object($hofPlayer)) { |
|
109 | - $return.=('<td align="center"'.$bold.'>'.create_link($container, $hofPlayer->getPlayerName()) .'</td>'); |
|
108 | + if (isset($hofPlayer) && is_object($hofPlayer)) { |
|
109 | + $return .= ('<td align="center"' . $bold . '>' . create_link($container, $hofPlayer->getPlayerName()) . '</td>'); |
|
110 | 110 | } |
111 | - else if(isset($hofAccount) && is_object($hofAccount)) { |
|
112 | - $return.=('<td align="center"'.$bold.'>'.create_link($container, $hofAccount->getHofName()) .'</td>'); |
|
111 | + else if (isset($hofAccount) && is_object($hofAccount)) { |
|
112 | + $return .= ('<td align="center"' . $bold . '>' . create_link($container, $hofAccount->getHofName()) . '</td>'); |
|
113 | 113 | } |
114 | 114 | else { |
115 | - $return.=('<td align="center"'.$bold.'>Unknown</td>'); |
|
115 | + $return .= ('<td align="center"' . $bold . '>Unknown</td>'); |
|
116 | 116 | } |
117 | - $return.=('<td align="center"'.$bold.'>' . $amount . '</td>'); |
|
118 | - $return.=('</tr>'); |
|
117 | + $return .= ('<td align="center"' . $bold . '>' . $amount . '</td>'); |
|
118 | + $return .= ('</tr>'); |
|
119 | 119 | return $return; |
120 | 120 | } |
121 | 121 | |
122 | -function buildBreadcrumb(&$var,&$hofTypes,$hofName) { |
|
122 | +function buildBreadcrumb(&$var, &$hofTypes, $hofName) { |
|
123 | 123 | $container = $var; |
124 | 124 | unset($container['type']); |
125 | 125 | unset($container['view']); |
126 | - $viewing= '<span class="bold">Currently viewing: </span>'.create_link($container,$hofName); |
|
126 | + $viewing = '<span class="bold">Currently viewing: </span>' . create_link($container, $hofName); |
|
127 | 127 | $typeList = array(); |
128 | - if(isset($var['type'])) { |
|
129 | - foreach($var['type'] as $type) { |
|
130 | - if(!is_array($hofTypes[$type])) { |
|
128 | + if (isset($var['type'])) { |
|
129 | + foreach ($var['type'] as $type) { |
|
130 | + if (!is_array($hofTypes[$type])) { |
|
131 | 131 | $var['type'] = $typeList; |
132 | 132 | $var['view'] = $type; |
133 | 133 | break; |
@@ -139,25 +139,25 @@ discard block |
||
139 | 139 | $container = $var; |
140 | 140 | $container['type'] = $typeList; |
141 | 141 | unset($container['view']); |
142 | - $viewing.= create_link($container,$type); |
|
142 | + $viewing .= create_link($container, $type); |
|
143 | 143 | |
144 | 144 | $hofTypes = $hofTypes[$type]; |
145 | 145 | } |
146 | 146 | } |
147 | - if(isset($var['view'])) { |
|
147 | + if (isset($var['view'])) { |
|
148 | 148 | $viewing .= ' -> '; |
149 | - if(is_array($hofTypes[$var['view']])) { |
|
149 | + if (is_array($hofTypes[$var['view']])) { |
|
150 | 150 | $typeList[] = $var['view']; |
151 | 151 | $var['type'] = $typeList; |
152 | 152 | } |
153 | 153 | $container = $var; |
154 | - $viewing .= create_link($container,$var['view']); |
|
154 | + $viewing .= create_link($container, $var['view']); |
|
155 | 155 | |
156 | - if(is_array($hofTypes[$var['view']])) { |
|
156 | + if (is_array($hofTypes[$var['view']])) { |
|
157 | 157 | $hofTypes = $hofTypes[$var['view']]; |
158 | 158 | unset($var['view']); |
159 | 159 | } |
160 | 160 | } |
161 | - $viewing.= '<br /><br />'; |
|
161 | + $viewing .= '<br /><br />'; |
|
162 | 162 | return $viewing; |
163 | 163 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | $menuItems[] = array('Link'=>Globals::getPlanetListHREF($alliance_id), 'Text'=>'Defense'); |
13 | 13 | $menuItems[] = array('Link'=>Globals::getPlanetListFinancialHREF($alliance_id), 'Text'=>'Financial'); |
14 | 14 | // make the selected index bold |
15 | - $boldItem =& $menuItems[$selected_index]['Text']; |
|
15 | + $boldItem = & $menuItems[$selected_index]['Text']; |
|
16 | 16 | $boldItem = '<span class="bold">' . $boldItem . '</span>'; |
17 | 17 | $template->assign('MenuItems', $menuItems); |
18 | 18 | } |
@@ -20,13 +20,13 @@ discard block |
||
20 | 20 | static function alliance($alliance_id = null, $alliance_leader_id = FALSE) { |
21 | 21 | global $player, $template, $db; |
22 | 22 | |
23 | - if($alliance_id) { |
|
23 | + if ($alliance_id) { |
|
24 | 24 | $in_alliance = ($alliance_id == $player->getAllianceID()); |
25 | 25 | } |
26 | 26 | else { |
27 | 27 | $in_alliance = $player->hasAlliance(); |
28 | 28 | } |
29 | - if(!$in_alliance) { |
|
29 | + if (!$in_alliance) { |
|
30 | 30 | $db->query('SELECT mb_read, mod_read, planet_land FROM alliance_treaties |
31 | 31 | WHERE (alliance_id_1 = ' . $db->escapeNumber($alliance_id) . ' OR alliance_id_1 = ' . $db->escapeNumber($player->getAllianceID()) . ') |
32 | 32 | AND (alliance_id_2 = ' . $db->escapeNumber($alliance_id) . ' OR alliance_id_2 = ' . $db->escapeNumber($player->getAllianceID()) . ') |
@@ -54,40 +54,40 @@ discard block |
||
54 | 54 | //} |
55 | 55 | $menuItems = array(); |
56 | 56 | if ($in_alliance || in_array($player->getAccountID(), Globals::getHiddenPlayers()) || $modRead) { |
57 | - $menuItems[] = array('Link'=>Globals::getAllianceMotdHREF($alliance_id),'Text'=>'Message of the Day'); |
|
57 | + $menuItems[] = array('Link'=>Globals::getAllianceMotdHREF($alliance_id), 'Text'=>'Message of the Day'); |
|
58 | 58 | } |
59 | - $menuItems[] = array('Link'=>Globals::getAllianceRosterHREF($alliance_id),'Text'=>'Roster'); |
|
59 | + $menuItems[] = array('Link'=>Globals::getAllianceRosterHREF($alliance_id), 'Text'=>'Roster'); |
|
60 | 60 | if (($send && $in_alliance) || in_array($player->getAccountID(), Globals::getHiddenPlayers())) { |
61 | - $menuItems[] = array('Link'=>Globals::getAllianceMessageHREF($alliance_id),'Text'=>'Send Message'); |
|
61 | + $menuItems[] = array('Link'=>Globals::getAllianceMessageHREF($alliance_id), 'Text'=>'Send Message'); |
|
62 | 62 | } |
63 | 63 | if ($in_alliance || in_array($player->getAccountID(), Globals::getHiddenPlayers()) || $mbRead) { |
64 | - $menuItems[] = array('Link'=>Globals::getAllianceMessageBoardHREF($alliance_id),'Text'=>'Message Board'); |
|
64 | + $menuItems[] = array('Link'=>Globals::getAllianceMessageBoardHREF($alliance_id), 'Text'=>'Message Board'); |
|
65 | 65 | } |
66 | 66 | if ($in_alliance || in_array($player->getAccountID(), Globals::getHiddenPlayers()) || $planetLand) { |
67 | - $menuItems[] = array('Link'=>Globals::getPlanetListHREF($alliance_id),'Text'=>'Planets'); |
|
67 | + $menuItems[] = array('Link'=>Globals::getPlanetListHREF($alliance_id), 'Text'=>'Planets'); |
|
68 | 68 | } |
69 | 69 | if ($in_alliance || in_array($player->getAccountID(), Globals::getHiddenPlayers())) { |
70 | - $menuItems[] = array('Link'=>Globals::getAllianceForcesHREF($alliance_id),'Text'=>'Forces'); |
|
71 | - $menuItems[] = array('Link'=>Globals::getAllianceOptionsHREF($alliance_id),'Text'=>'Options'); |
|
70 | + $menuItems[] = array('Link'=>Globals::getAllianceForcesHREF($alliance_id), 'Text'=>'Forces'); |
|
71 | + $menuItems[] = array('Link'=>Globals::getAllianceOptionsHREF($alliance_id), 'Text'=>'Options'); |
|
72 | 72 | } |
73 | - $menuItems[] = array('Link'=>Globals::getAllianceListHREF(),'Text'=>'List Alliances'); |
|
74 | - $menuItems[] = array('Link'=>Globals::getAllianceNewsHREF($alliance_id?$alliance_id:$player->getAllianceID()),'Text'=>'View News'); |
|
73 | + $menuItems[] = array('Link'=>Globals::getAllianceListHREF(), 'Text'=>'List Alliances'); |
|
74 | + $menuItems[] = array('Link'=>Globals::getAllianceNewsHREF($alliance_id ? $alliance_id : $player->getAllianceID()), 'Text'=>'View News'); |
|
75 | 75 | |
76 | - $template->assign('MenuItems',$menuItems); |
|
76 | + $template->assign('MenuItems', $menuItems); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | static function galactic_post() { |
80 | 80 | global $template, $player; |
81 | 81 | $menuItems = array(); |
82 | - $menuItems[] = array('Link'=>SmrSession::getNewHREF(create_container('galactic_post_current.php')),'Text'=>'Current Edition'); |
|
83 | - $menuItems[] = array('Link'=>SmrSession::getNewHREF(create_container('skeleton.php', 'galactic_post_past.php')),'Text'=>'Past Editions'); |
|
82 | + $menuItems[] = array('Link'=>SmrSession::getNewHREF(create_container('galactic_post_current.php')), 'Text'=>'Current Edition'); |
|
83 | + $menuItems[] = array('Link'=>SmrSession::getNewHREF(create_container('skeleton.php', 'galactic_post_past.php')), 'Text'=>'Past Editions'); |
|
84 | 84 | if ($player->isGPWriter()) { |
85 | - $menuItems[] = array('Link'=>SmrSession::getNewHREF(create_container('skeleton.php', 'galactic_post_write_article.php')),'Text'=>'Write an article'); |
|
85 | + $menuItems[] = array('Link'=>SmrSession::getNewHREF(create_container('skeleton.php', 'galactic_post_write_article.php')), 'Text'=>'Write an article'); |
|
86 | 86 | } else { |
87 | - $menuItems[] = array('Link'=>SmrSession::getNewHREF(create_container('skeleton.php', 'galactic_post_application.php')),'Text'=>'Apply as writer!'); |
|
87 | + $menuItems[] = array('Link'=>SmrSession::getNewHREF(create_container('skeleton.php', 'galactic_post_application.php')), 'Text'=>'Apply as writer!'); |
|
88 | 88 | } |
89 | 89 | if ($player->isGPEditor()) { |
90 | - $menuItems[] = array('Link'=>SmrSession::getNewHREF(create_container('skeleton.php', 'galactic_post.php')),'Text'=>'Editor Options'); |
|
90 | + $menuItems[] = array('Link'=>SmrSession::getNewHREF(create_container('skeleton.php', 'galactic_post.php')), 'Text'=>'Editor Options'); |
|
91 | 91 | } |
92 | 92 | $template->assign('MenuItems', $menuItems); |
93 | 93 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | $menuItems[] = ['Link' => SmrSession::getNewHREF($container), |
112 | 112 | 'Text' => 'Game News']; |
113 | 113 | // make the selected index bold |
114 | - $boldItem =& $menuItems[$selected_index]['Text']; |
|
114 | + $boldItem = & $menuItems[$selected_index]['Text']; |
|
115 | 115 | $boldItem = '<b>' . $boldItem . '</b>'; |
116 | 116 | $template->assign('MenuItems', $menuItems); |
117 | 117 | } |
@@ -119,14 +119,14 @@ discard block |
||
119 | 119 | static function messages() { |
120 | 120 | global $player, $template; |
121 | 121 | $menuItems = array(); |
122 | - $menuItems[] = array('Link'=>Globals::getViewMessagesHREF(),'Text'=>'View Messages'); |
|
123 | - $menuItems[] = array('Link'=>Globals::getSendGlobalMessageHREF(),'Text'=>'Send Global Message'); |
|
122 | + $menuItems[] = array('Link'=>Globals::getViewMessagesHREF(), 'Text'=>'View Messages'); |
|
123 | + $menuItems[] = array('Link'=>Globals::getSendGlobalMessageHREF(), 'Text'=>'Send Global Message'); |
|
124 | 124 | if ($player->isOnCouncil()) { |
125 | - $menuItems[] = array('Link'=>Globals::getSendCouncilMessageHREF($player->getRaceID()),'Text'=>'Send Council Message'); |
|
125 | + $menuItems[] = array('Link'=>Globals::getSendCouncilMessageHREF($player->getRaceID()), 'Text'=>'Send Council Message'); |
|
126 | 126 | } |
127 | - $menuItems[] = array('Link'=>Globals::getManageBlacklistHREF(),'Text'=>'Manage Blacklist'); |
|
127 | + $menuItems[] = array('Link'=>Globals::getManageBlacklistHREF(), 'Text'=>'Manage Blacklist'); |
|
128 | 128 | |
129 | - $template->assign('MenuItems',$menuItems); |
|
129 | + $template->assign('MenuItems', $menuItems); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | static function combat_log() { |
@@ -136,51 +136,51 @@ discard block |
||
136 | 136 | $menuItems = array(); |
137 | 137 | |
138 | 138 | $container['action'] = COMBAT_LOG_PERSONAL; |
139 | - $menuItems[] = array('Link'=>SmrSession::getNewHREF($container),'Text'=>'Personal'); |
|
139 | + $menuItems[] = array('Link'=>SmrSession::getNewHREF($container), 'Text'=>'Personal'); |
|
140 | 140 | $container['action'] = COMBAT_LOG_ALLIANCE; |
141 | - $menuItems[] = array('Link'=>SmrSession::getNewHREF($container),'Text'=>'Alliance'); |
|
141 | + $menuItems[] = array('Link'=>SmrSession::getNewHREF($container), 'Text'=>'Alliance'); |
|
142 | 142 | $container['action'] = COMBAT_LOG_FORCE; |
143 | - $menuItems[] = array('Link'=>SmrSession::getNewHREF($container),'Text'=>'Force'); |
|
143 | + $menuItems[] = array('Link'=>SmrSession::getNewHREF($container), 'Text'=>'Force'); |
|
144 | 144 | $container['action'] = COMBAT_LOG_PORT; |
145 | - $menuItems[] = array('Link'=>SmrSession::getNewHREF($container),'Text'=>'Port'); |
|
145 | + $menuItems[] = array('Link'=>SmrSession::getNewHREF($container), 'Text'=>'Port'); |
|
146 | 146 | $container['action'] = COMBAT_LOG_PLANET; |
147 | - $menuItems[] = array('Link'=>SmrSession::getNewHREF($container),'Text'=>'Planet'); |
|
147 | + $menuItems[] = array('Link'=>SmrSession::getNewHREF($container), 'Text'=>'Planet'); |
|
148 | 148 | $container['action'] = COMBAT_LOG_SAVED; |
149 | - $menuItems[] = array('Link'=>SmrSession::getNewHREF($container),'Text'=>'Saved'); |
|
149 | + $menuItems[] = array('Link'=>SmrSession::getNewHREF($container), 'Text'=>'Saved'); |
|
150 | 150 | |
151 | - $template->assign('MenuItems',$menuItems); |
|
151 | + $template->assign('MenuItems', $menuItems); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | static function trader() { |
155 | 155 | global $player, $template; |
156 | 156 | $template->assign('MenuItems', array( |
157 | - array('Link'=>Globals::getTraderStatusHREF(),'Text'=>'Trader Status'), |
|
158 | - array('Link'=>Globals::getPlanetListHREF($player->getAllianceID()),'Text'=>'Planets'), |
|
159 | - array('Link'=>Globals::getAllianceHREF($player->getAllianceID()),'Text'=>'Alliance'), |
|
160 | - array('Link'=>Globals::getCouncilHREF(),'Text'=>'Politics'), |
|
161 | - array('Link'=>Globals::getTraderRelationsHREF(),'Text'=>'Relations'), |
|
162 | - array('Link'=>Globals::getTraderBountiesHREF(),'Text'=>'Bounties'))); |
|
157 | + array('Link'=>Globals::getTraderStatusHREF(), 'Text'=>'Trader Status'), |
|
158 | + array('Link'=>Globals::getPlanetListHREF($player->getAllianceID()), 'Text'=>'Planets'), |
|
159 | + array('Link'=>Globals::getAllianceHREF($player->getAllianceID()), 'Text'=>'Alliance'), |
|
160 | + array('Link'=>Globals::getCouncilHREF(), 'Text'=>'Politics'), |
|
161 | + array('Link'=>Globals::getTraderRelationsHREF(), 'Text'=>'Relations'), |
|
162 | + array('Link'=>Globals::getTraderBountiesHREF(), 'Text'=>'Bounties'))); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | static function planet($planet) { |
166 | 166 | global $template; |
167 | 167 | |
168 | 168 | $menu_array = array(); |
169 | - $menu_array[] = array('Link'=>Globals::getPlanetMainHREF(),'Text'=>'Planet Main'); |
|
169 | + $menu_array[] = array('Link'=>Globals::getPlanetMainHREF(), 'Text'=>'Planet Main'); |
|
170 | 170 | if ($planet->hasMenuOption('CONSTRUCTION')) { |
171 | - $menu_array[] = array('Link'=>Globals::getPlanetConstructionHREF(),'Text'=>'Construction'); |
|
171 | + $menu_array[] = array('Link'=>Globals::getPlanetConstructionHREF(), 'Text'=>'Construction'); |
|
172 | 172 | } |
173 | 173 | if ($planet->hasMenuOption('DEFENSE')) { |
174 | - $menu_array[] = array('Link'=>Globals::getPlanetDefensesHREF(),'Text'=>'Defense'); |
|
174 | + $menu_array[] = array('Link'=>Globals::getPlanetDefensesHREF(), 'Text'=>'Defense'); |
|
175 | 175 | } |
176 | 176 | if ($planet->hasMenuOption('OWNERSHIP')) { |
177 | - $menu_array[] = array('Link'=>Globals::getPlanetOwnershipHREF(),'Text'=>'Ownership'); |
|
177 | + $menu_array[] = array('Link'=>Globals::getPlanetOwnershipHREF(), 'Text'=>'Ownership'); |
|
178 | 178 | } |
179 | 179 | if ($planet->hasMenuOption('STOCKPILE')) { |
180 | - $menu_array[] = array('Link'=>Globals::getPlanetStockpileHREF(),'Text'=>'Stockpile'); |
|
180 | + $menu_array[] = array('Link'=>Globals::getPlanetStockpileHREF(), 'Text'=>'Stockpile'); |
|
181 | 181 | } |
182 | 182 | if ($planet->hasMenuOption('FINANCE')) { |
183 | - $menu_array[] = array('Link'=>Globals::getPlanetFinancesHREF(),'Text'=>'Financial'); |
|
183 | + $menu_array[] = array('Link'=>Globals::getPlanetFinancesHREF(), 'Text'=>'Financial'); |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | $template->assign('MenuItems', $menu_array); |
@@ -196,14 +196,14 @@ discard block |
||
196 | 196 | |
197 | 197 | // player rankings |
198 | 198 | $menu_item = array(); |
199 | - $menu_item['entry'] = create_link(create_container('skeleton.php', 'rankings_player_experience.php'), 'Player Rankings','nav'); |
|
199 | + $menu_item['entry'] = create_link(create_container('skeleton.php', 'rankings_player_experience.php'), 'Player Rankings', 'nav'); |
|
200 | 200 | |
201 | 201 | $menu_subitem = array(); |
202 | - $menu_subitem[] = create_link(create_container('skeleton.php', 'rankings_player_experience.php'), 'Experience','nav'); |
|
203 | - $menu_subitem[] = create_link(create_container('skeleton.php', 'rankings_player_profit.php'), 'Profit','nav'); |
|
204 | - $menu_subitem[] = create_link(create_container('skeleton.php', 'rankings_player_kills.php'), 'Kills','nav'); |
|
205 | - $menu_subitem[] = create_link(create_container('skeleton.php', 'rankings_player_death.php'), 'Deaths','nav'); |
|
206 | - $menu_subitem[] = create_link(create_container('skeleton.php', 'rankings_player_assists.php'), 'Assists','nav'); |
|
202 | + $menu_subitem[] = create_link(create_container('skeleton.php', 'rankings_player_experience.php'), 'Experience', 'nav'); |
|
203 | + $menu_subitem[] = create_link(create_container('skeleton.php', 'rankings_player_profit.php'), 'Profit', 'nav'); |
|
204 | + $menu_subitem[] = create_link(create_container('skeleton.php', 'rankings_player_kills.php'), 'Kills', 'nav'); |
|
205 | + $menu_subitem[] = create_link(create_container('skeleton.php', 'rankings_player_death.php'), 'Deaths', 'nav'); |
|
206 | + $menu_subitem[] = create_link(create_container('skeleton.php', 'rankings_player_assists.php'), 'Assists', 'nav'); |
|
207 | 207 | |
208 | 208 | $menu_item['submenu'] = $menu_subitem; |
209 | 209 | |
@@ -211,14 +211,14 @@ discard block |
||
211 | 211 | |
212 | 212 | // alliance rankings |
213 | 213 | $menu_item = array(); |
214 | - $menu_item['entry'] = create_link(create_container('skeleton.php', 'rankings_alliance_experience.php'), 'Alliance Rankings','nav'); |
|
214 | + $menu_item['entry'] = create_link(create_container('skeleton.php', 'rankings_alliance_experience.php'), 'Alliance Rankings', 'nav'); |
|
215 | 215 | |
216 | 216 | $menu_subitem = array(); |
217 | - $menu_subitem[] = create_link(create_container('skeleton.php', 'rankings_alliance_experience.php'), 'Experience','nav'); |
|
218 | - $menu_subitem[] = create_link(create_container('skeleton.php', 'rankings_alliance_profit.php'), 'Profit','nav'); |
|
219 | - $menu_subitem[] = create_link(create_container('skeleton.php', 'rankings_alliance_kills.php'), 'Kills','nav'); |
|
220 | - $menu_subitem[] = create_link(create_container('skeleton.php', 'rankings_alliance_death.php'), 'Deaths','nav'); |
|
221 | - $menu_subitem[] = create_link(create_container('skeleton.php', 'rankings_alliance_vs_alliance.php'), 'Versus','nav'); |
|
217 | + $menu_subitem[] = create_link(create_container('skeleton.php', 'rankings_alliance_experience.php'), 'Experience', 'nav'); |
|
218 | + $menu_subitem[] = create_link(create_container('skeleton.php', 'rankings_alliance_profit.php'), 'Profit', 'nav'); |
|
219 | + $menu_subitem[] = create_link(create_container('skeleton.php', 'rankings_alliance_kills.php'), 'Kills', 'nav'); |
|
220 | + $menu_subitem[] = create_link(create_container('skeleton.php', 'rankings_alliance_death.php'), 'Deaths', 'nav'); |
|
221 | + $menu_subitem[] = create_link(create_container('skeleton.php', 'rankings_alliance_vs_alliance.php'), 'Versus', 'nav'); |
|
222 | 222 | |
223 | 223 | $menu_item['submenu'] = $menu_subitem; |
224 | 224 | |
@@ -226,12 +226,12 @@ discard block |
||
226 | 226 | |
227 | 227 | // racial rankings |
228 | 228 | $menu_item = array(); |
229 | - $menu_item['entry'] = create_link(create_container('skeleton.php', 'rankings_race.php'), 'Racial Standings','nav'); |
|
229 | + $menu_item['entry'] = create_link(create_container('skeleton.php', 'rankings_race.php'), 'Racial Standings', 'nav'); |
|
230 | 230 | |
231 | 231 | $menu_subitem = array(); |
232 | - $menu_subitem[] = create_link(create_container('skeleton.php', 'rankings_race.php'), 'Experience','nav'); |
|
233 | - $menu_subitem[] = create_link(create_container('skeleton.php', 'rankings_race_kills.php'), 'Kills','nav'); |
|
234 | - $menu_subitem[] = create_link(create_container('skeleton.php', 'rankings_race_death.php'), 'Deaths','nav'); |
|
232 | + $menu_subitem[] = create_link(create_container('skeleton.php', 'rankings_race.php'), 'Experience', 'nav'); |
|
233 | + $menu_subitem[] = create_link(create_container('skeleton.php', 'rankings_race_kills.php'), 'Kills', 'nav'); |
|
234 | + $menu_subitem[] = create_link(create_container('skeleton.php', 'rankings_race_death.php'), 'Deaths', 'nav'); |
|
235 | 235 | |
236 | 236 | $menu_item['submenu'] = $menu_subitem; |
237 | 237 | |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | |
240 | 240 | // sector rankings |
241 | 241 | $menu_item = array(); |
242 | - $menu_item['entry'] = create_link(create_container('skeleton.php', 'rankings_sector_kill.php'), 'Sector Kills','nav'); |
|
242 | + $menu_item['entry'] = create_link(create_container('skeleton.php', 'rankings_sector_kill.php'), 'Sector Kills', 'nav'); |
|
243 | 243 | $menu[] = $menu_item; |
244 | 244 | |
245 | 245 | create_sub_menu($menu, $active_level1, $active_level2); |
@@ -249,14 +249,14 @@ discard block |
||
249 | 249 | global $player; |
250 | 250 | |
251 | 251 | $menu_items[] = create_link(create_container('skeleton.php', 'bank_personal.php'), |
252 | - 'Personal Account','nav'); |
|
252 | + 'Personal Account', 'nav'); |
|
253 | 253 | |
254 | 254 | if ($player->hasAlliance()) |
255 | 255 | $menu_items[] = create_link(create_container('skeleton.php', 'bank_alliance.php'), |
256 | - 'Alliance Account','nav'); |
|
256 | + 'Alliance Account', 'nav'); |
|
257 | 257 | |
258 | 258 | $menu_items[] = create_link(create_container('skeleton.php', 'bank_anon.php'), |
259 | - 'Anonymous Account','nav'); |
|
259 | + 'Anonymous Account', 'nav'); |
|
260 | 260 | create_menu($menu_items); |
261 | 261 | } |
262 | 262 | |
@@ -264,24 +264,24 @@ discard block |
||
264 | 264 | global $player; |
265 | 265 | |
266 | 266 | $menu_items[] = create_link(create_container('skeleton.php', 'council_list.php'), |
267 | - 'View Council','nav'); |
|
267 | + 'View Council', 'nav'); |
|
268 | 268 | |
269 | 269 | $container = create_container('skeleton.php'); |
270 | 270 | $container['body'] = 'council_politics.php'; |
271 | 271 | $container['race_id'] = $race_id; |
272 | - $menu_items[] = create_link($container, 'Political Status','nav'); |
|
272 | + $menu_items[] = create_link($container, 'Political Status', 'nav'); |
|
273 | 273 | |
274 | 274 | $container['body'] = 'council_send_message.php'; |
275 | 275 | $container['race_id'] = $race_id; |
276 | - $menu_items[] = create_link($container, 'Send Message','nav'); |
|
276 | + $menu_items[] = create_link($container, 'Send Message', 'nav'); |
|
277 | 277 | |
278 | - if($player->getRaceID()==$race_id) { |
|
278 | + if ($player->getRaceID() == $race_id) { |
|
279 | 279 | if ($player->isOnCouncil()) |
280 | 280 | $menu_items[] = create_link(create_container('skeleton.php', 'council_vote.php'), |
281 | - 'Voting Center','nav'); |
|
281 | + 'Voting Center', 'nav'); |
|
282 | 282 | if ($player->isPresident()) |
283 | 283 | $menu_items[] = create_link(create_container('skeleton.php', 'council_embassy.php'), |
284 | - 'Embassy','nav'); |
|
284 | + 'Embassy', 'nav'); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | create_menu($menu_items); |
@@ -290,29 +290,29 @@ discard block |
||
290 | 290 | static function bar() { |
291 | 291 | global $template; |
292 | 292 | $template->assign('MenuItems', array( |
293 | - array('Link'=>Globals::getBarMainHREF(),'Text'=>'Bar Main'), |
|
294 | - array('Link'=>Globals::getBarLottoPlayHREF(),'Text'=>'Lotto'), |
|
295 | - array('Link'=>Globals::getBarBlackjackHREF(),'Text'=>'BlackJack'))); |
|
293 | + array('Link'=>Globals::getBarMainHREF(), 'Text'=>'Bar Main'), |
|
294 | + array('Link'=>Globals::getBarLottoPlayHREF(), 'Text'=>'Lotto'), |
|
295 | + array('Link'=>Globals::getBarBlackjackHREF(), 'Text'=>'BlackJack'))); |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | static function news(&$template) { |
299 | 299 | global $var; |
300 | 300 | $menuItems = array(); |
301 | 301 | if (SmrSession::getGameID() == $var['GameID']) { |
302 | - $menuItems[] = array('Link'=>SmrSession::getNewHREF(create_container('skeleton.php', 'news_read_current.php',array('GameID'=>$var['GameID']))),'Text'=>'Read Current News'); |
|
302 | + $menuItems[] = array('Link'=>SmrSession::getNewHREF(create_container('skeleton.php', 'news_read_current.php', array('GameID'=>$var['GameID']))), 'Text'=>'Read Current News'); |
|
303 | 303 | } |
304 | - $menuItems[] = array('Link'=>SmrSession::getNewHREF(create_container('skeleton.php', 'news_read.php',array('GameID'=>$var['GameID']))),'Text'=>'Read Latest News'); |
|
305 | - $menuItems[] = array('Link'=>SmrSession::getNewHREF(create_container('skeleton.php', 'news_read_advanced.php',array('GameID'=>$var['GameID']))),'Text'=>'Advanced News'); |
|
304 | + $menuItems[] = array('Link'=>SmrSession::getNewHREF(create_container('skeleton.php', 'news_read.php', array('GameID'=>$var['GameID']))), 'Text'=>'Read Latest News'); |
|
305 | + $menuItems[] = array('Link'=>SmrSession::getNewHREF(create_container('skeleton.php', 'news_read_advanced.php', array('GameID'=>$var['GameID']))), 'Text'=>'Advanced News'); |
|
306 | 306 | |
307 | 307 | $template->assign('MenuItems', $menuItems); |
308 | 308 | } |
309 | 309 | |
310 | 310 | static function navigation(&$template, &$player) { |
311 | 311 | $menuItems = array(); |
312 | - $menuItems[] = array('Link'=>Globals::getPlotCourseHREF(),'Text'=>'Plot A Course'); |
|
313 | - if(!$player->isLandedOnPlanet()) |
|
314 | - $menuItems[] = array('Link'=>Globals::getLocalMapHREF(),'Text'=>'Local Map'); |
|
315 | - $menuItems[] = array('Link'=>'map_galaxy.php" target="gal_map','Text'=>'Galaxy Map'); |
|
312 | + $menuItems[] = array('Link'=>Globals::getPlotCourseHREF(), 'Text'=>'Plot A Course'); |
|
313 | + if (!$player->isLandedOnPlanet()) |
|
314 | + $menuItems[] = array('Link'=>Globals::getLocalMapHREF(), 'Text'=>'Local Map'); |
|
315 | + $menuItems[] = array('Link'=>'map_galaxy.php" target="gal_map', 'Text'=>'Galaxy Map'); |
|
316 | 316 | $template->assign('MenuItems', $menuItems); |
317 | 317 | } |
318 | 318 | |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | $active = ''; |
344 | 344 | |
345 | 345 | // echo entry itself |
346 | - $return .= ('<td align="center"'.$active.'> ' . $entry['entry'] . '</td>'); |
|
346 | + $return .= ('<td align="center"' . $active . '> ' . $entry['entry'] . '</td>'); |
|
347 | 347 | |
348 | 348 | } |
349 | 349 | $return .= ('</tr>'); |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | $return .= (' | '); |
359 | 359 | |
360 | 360 | if ($sub_number == $active_level2) |
361 | - $return .= ('<span class="bold">'.$sub_entry.'</span>'); |
|
361 | + $return .= ('<span class="bold">' . $sub_entry . '</span>'); |
|
362 | 362 | else |
363 | 363 | $return .= ($sub_entry); |
364 | 364 | } |
@@ -387,5 +387,5 @@ discard block |
||
387 | 387 | $return .= ('</p>'); |
388 | 388 | $template->unassign('MenuItems'); |
389 | 389 | $template->unassign('MenuBar'); |
390 | - $template->assign('SubMenuBar',$return); |
|
390 | + $template->assign('SubMenuBar', $return); |
|
391 | 391 | } |
@@ -13,10 +13,10 @@ discard block |
||
13 | 13 | protected $typeID; |
14 | 14 | protected $weighting; |
15 | 15 | |
16 | - protected $hasChanged=false; |
|
16 | + protected $hasChanged = false; |
|
17 | 17 | |
18 | 18 | public static function &getWeightedRandom($gameID, $accountID, $type, $typeID, $forceUpdate = false) { |
19 | - if($forceUpdate || !isset(self::$CACHE_RANDOMS[$gameID][$accountID][$type][$typeID])) { |
|
19 | + if ($forceUpdate || !isset(self::$CACHE_RANDOMS[$gameID][$accountID][$type][$typeID])) { |
|
20 | 20 | self::$CACHE_RANDOMS[$gameID][$accountID][$type][$typeID] = new WeightedRandom($gameID, $accountID, $type, $typeID); |
21 | 21 | } |
22 | 22 | return self::$CACHE_RANDOMS[$gameID][$accountID][$type][$typeID]; |
@@ -27,10 +27,10 @@ discard block |
||
27 | 27 | } |
28 | 28 | |
29 | 29 | public static function saveWeightedRandoms() { |
30 | - foreach(self::$CACHE_RANDOMS as $gameRandoms) { |
|
31 | - foreach($gameRandoms as $accountRandoms) { |
|
32 | - foreach($accountRandoms as $typeRandoms) { |
|
33 | - foreach($typeRandoms as $random) { |
|
30 | + foreach (self::$CACHE_RANDOMS as $gameRandoms) { |
|
31 | + foreach ($gameRandoms as $accountRandoms) { |
|
32 | + foreach ($accountRandoms as $typeRandoms) { |
|
33 | + foreach ($typeRandoms as $random) { |
|
34 | 34 | $random->update(); |
35 | 35 | } |
36 | 36 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | $this->typeID = $typeID; |
46 | 46 | |
47 | 47 | $this->db = new SmrMySqlDatabase(); |
48 | - $this->db->query('SELECT weighting FROM weighted_random WHERE game_id = '.$this->db->escapeNumber($gameID).' AND account_id = '.$this->db->escapeNumber($accountID).' AND type = '.$this->db->escapeString($type).' AND type_id = '.$this->db->escapeNumber($typeID).' LIMIT 1'); |
|
48 | + $this->db->query('SELECT weighting FROM weighted_random WHERE game_id = ' . $this->db->escapeNumber($gameID) . ' AND account_id = ' . $this->db->escapeNumber($accountID) . ' AND type = ' . $this->db->escapeString($type) . ' AND type_id = ' . $this->db->escapeNumber($typeID) . ' LIMIT 1'); |
|
49 | 49 | if ($this->db->nextRecord()) { |
50 | 50 | $this->weighting = $this->db->getField('weighting'); |
51 | 51 | } |
@@ -75,22 +75,22 @@ discard block |
||
75 | 75 | } |
76 | 76 | |
77 | 77 | public function percentFailed($percent) { |
78 | - $failed = mt_rand(0,99)+$this->weighting >= $percent; |
|
78 | + $failed = mt_rand(0, 99) + $this->weighting >= $percent; |
|
79 | 79 | $this->adjustWeightByPercent(!$failed, $percent); |
80 | 80 | return $failed; |
81 | 81 | } |
82 | 82 | |
83 | 83 | public function adjustWeightByPercent($success, $percent) { |
84 | - $percent = $percent/100; |
|
85 | - if($success) { |
|
84 | + $percent = $percent / 100; |
|
85 | + if ($success) { |
|
86 | 86 | $percent = -1 + $percent; |
87 | 87 | } |
88 | - $this->weighting -= self::WEIGHTING_CHANGE*$percent; |
|
88 | + $this->weighting -= self::WEIGHTING_CHANGE * $percent; |
|
89 | 89 | $this->hasChanged = true; |
90 | 90 | } |
91 | 91 | |
92 | 92 | public function update() { |
93 | - if($this->hasChanged===true) { |
|
93 | + if ($this->hasChanged === true) { |
|
94 | 94 | $this->db->query('REPLACE INTO weighted_random (game_id,account_id,type,type_id,weighting) |
95 | 95 | values |
96 | 96 | (' . $this->db->escapeNumber($this->getGameID()) . |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | ',' . $this->db->escapeString($this->getType()) . |
99 | 99 | ',' . $this->db->escapeNumber($this->getTypeID()) . |
100 | 100 | ',' . $this->db->escapeNumber($this->getWeighting()) . ')'); |
101 | - $this->hasChanged=false; |
|
101 | + $this->hasChanged = false; |
|
102 | 102 | } |
103 | 103 | } |
104 | 104 | } |