| Conditions | 269 |
| Paths | 4518 |
| Total Lines | 892 |
| Lines | 848 |
| Ratio | 95.07 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 84 | private function checkTowers($keyID, $vCode) |
||
| 85 | { |
||
| 86 | |||
| 87 | $url = "https://api.eveonline.com/corp/AssetList.xml.aspx?keyID={$keyID}&vCode={$vCode}"; |
||
| 88 | $xml = makeApiRequest($url); |
||
| 89 | $siloCount = 0; |
||
| 90 | foreach ($xml->result->rowset->row as $structures) { |
||
| 91 | //Check silos |
||
| 92 | if ($structures->attributes()->typeID == 14343) { |
||
| 93 | if (isset($structures->rowset->row)) { |
||
| 94 | $locationID = $structures->attributes()->locationID; |
||
| 95 | $towerRace = $this->getTowerRace($keyID, $vCode, $locationID); |
||
| 96 | $towerMulti = 0; |
||
| 97 | $towerFull = 20000; |
||
| 98 | $cleanFull = number_format($towerFull); |
||
| 99 | if ($towerRace === '1') { |
||
| 100 | $towerMulti = 0.50; |
||
| 101 | $towerFull = 30000; |
||
| 102 | $cleanFull = number_format($towerFull); |
||
| 103 | } |
||
| 104 | if ($towerRace === '2') { |
||
| 105 | $towerMulti = 1; |
||
| 106 | $towerFull = 40000; |
||
| 107 | $cleanFull = number_format($towerFull); |
||
| 108 | } |
||
| 109 | if ($towerRace === '3') { |
||
| 110 | $towerMulti = 0; |
||
| 111 | $towerFull = 20000; |
||
| 112 | $cleanFull = number_format($towerFull); |
||
| 113 | } |
||
| 114 | foreach ($structures->rowset->row as $silo) { |
||
| 115 | $moonGoo = $silo->attributes()->typeID; |
||
| 116 | switch ($moonGoo) { |
||
| 117 | View Code Duplication | case 16634: |
|
| 118 | $typeName = getTypeName(16634); |
||
| 119 | $systemName = getSystemName($structures->attributes()->locationID); |
||
| 120 | $towerWarn = 180000 + (180000 * $towerMulti); |
||
| 121 | if ($silo->attributes()->quantity >= $towerWarn) { |
||
| 122 | $siloID = $structures->attributes()->itemID; |
||
| 123 | $lastAmount = getPermCache("silo{$siloID}Amount"); |
||
| 124 | $gooAmount = $silo->attributes()->quantity; |
||
| 125 | $gooDifference = $gooAmount - $lastAmount; |
||
| 126 | //Check if silo has been checked before |
||
| 127 | if (!isset($lastAmount) || $gooDifference < 0) { |
||
| 128 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 129 | continue 3; |
||
| 130 | } |
||
| 131 | $gooVolume = 0.1; |
||
| 132 | $gooCurrent = $gooAmount * $gooVolume; |
||
| 133 | //double check tower race |
||
| 134 | if ((int)$towerFull === 20000 && (int)$gooCurrent > 20000) { |
||
| 135 | $towerFull = 30000; |
||
| 136 | } |
||
| 137 | if ((int)$towerFull === 20000 || 30000 && (int)$gooCurrent > 30000) { |
||
| 138 | $towerFull = 40000; |
||
| 139 | } |
||
| 140 | $cleanNumber = number_format($gooCurrent); |
||
| 141 | $msg = "**{$typeName} Silo Nearing Capacity**\n"; |
||
| 142 | if ($gooCurrent === $towerFull && $lastAmount === $gooCurrent) { |
||
| 143 | $msg = "**{$typeName} Silo Full**\n"; |
||
| 144 | } elseif ($gooCurrent === $towerFull && $lastAmount !== $gooCurrent) { |
||
| 145 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 146 | continue 3; |
||
| 147 | } |
||
| 148 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 149 | $msg .= "**System: **{$systemName}\n"; |
||
| 150 | $msg .= "**Capacity: **{$cleanNumber}/{$cleanFull}m3\n"; |
||
| 151 | $this->logger->addInfo("siloFull: {$typeName} Silo nearing capacity in {$systemName}"); |
||
| 152 | // Send the msg to the channel; |
||
| 153 | $channelID = $this->toDiscordChannel; |
||
| 154 | queueMessage($msg, $channelID, $this->guild); |
||
| 155 | $this->logger->addInfo('siloFull: Silo Alert queued'); |
||
| 156 | $siloCount++; |
||
| 157 | } |
||
| 158 | break; |
||
| 159 | View Code Duplication | case 16643: |
|
| 160 | $typeName = getTypeName(16643); |
||
| 161 | $systemName = getSystemName($structures->attributes()->locationID); |
||
| 162 | $towerWarn = 45000 + (45000 * $towerMulti); |
||
| 163 | if ($silo->attributes()->quantity >= $towerWarn) { |
||
| 164 | $siloID = $structures->attributes()->itemID; |
||
| 165 | $lastAmount = getPermCache("silo{$siloID}Amount"); |
||
| 166 | $gooAmount = $silo->attributes()->quantity; |
||
| 167 | $gooDifference = $gooAmount - $lastAmount; |
||
| 168 | //Check if silo has been checked before |
||
| 169 | if (!isset($lastAmount) || $gooDifference < 0) { |
||
| 170 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 171 | continue 3; |
||
| 172 | } |
||
| 173 | $gooVolume = 0.4; |
||
| 174 | $gooCurrent = $gooAmount * $gooVolume; |
||
| 175 | //double check tower race |
||
| 176 | if ((int)$towerFull === 20000 && (int)$gooCurrent > 20000) { |
||
| 177 | $towerFull = 30000; |
||
| 178 | } |
||
| 179 | if ((int)$towerFull === 20000 || 30000 && (int)$gooCurrent > 30000) { |
||
| 180 | $towerFull = 40000; |
||
| 181 | } |
||
| 182 | $cleanNumber = number_format($gooCurrent); |
||
| 183 | $msg = "**{$typeName} Silo Nearing Capacity**\n"; |
||
| 184 | if ($gooCurrent === $towerFull && $lastAmount === $gooCurrent) { |
||
| 185 | $msg = "**{$typeName} Silo Full**\n"; |
||
| 186 | } elseif ($gooCurrent === $towerFull && $lastAmount !== $gooCurrent) { |
||
| 187 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 188 | continue 3; |
||
| 189 | } |
||
| 190 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 191 | $msg .= "**System: **{$systemName}\n"; |
||
| 192 | $msg .= "**Capacity: **{$cleanNumber}/{$cleanFull}m3\n"; |
||
| 193 | $this->logger->addInfo("siloFull: {$typeName} Silo nearing capacity in {$systemName}"); |
||
| 194 | // Send the msg to the channel; |
||
| 195 | $channelID = $this->toDiscordChannel; |
||
| 196 | queueMessage($msg, $channelID, $this->guild); |
||
| 197 | $this->logger->addInfo('siloFull: Silo Alert queued'); |
||
| 198 | $siloCount++; |
||
| 199 | } |
||
| 200 | break; |
||
| 201 | View Code Duplication | case 16647: |
|
| 202 | $typeName = getTypeName(16647); |
||
| 203 | $systemName = getSystemName($structures->attributes()->locationID); |
||
| 204 | $towerWarn = 22500 + (22500 * $towerMulti); |
||
| 205 | if ($silo->attributes()->quantity >= $towerWarn) { |
||
| 206 | $siloID = $structures->attributes()->itemID; |
||
| 207 | $lastAmount = getPermCache("silo{$siloID}Amount"); |
||
| 208 | $gooAmount = $silo->attributes()->quantity; |
||
| 209 | $gooDifference = $gooAmount - $lastAmount; |
||
| 210 | //Check if silo has been checked before |
||
| 211 | if (!isset($lastAmount) || $gooDifference < 0) { |
||
| 212 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 213 | continue 3; |
||
| 214 | } |
||
| 215 | $gooVolume = 0.8; |
||
| 216 | $gooCurrent = $gooAmount * $gooVolume; |
||
| 217 | //double check tower race |
||
| 218 | if ((int)$towerFull === 20000 && (int)$gooCurrent > 20000) { |
||
| 219 | $towerFull = 30000; |
||
| 220 | } |
||
| 221 | if ((int)$towerFull === 20000 || 30000 && (int)$gooCurrent > 30000) { |
||
| 222 | $towerFull = 40000; |
||
| 223 | } |
||
| 224 | $cleanNumber = number_format($gooCurrent); |
||
| 225 | $msg = "**{$typeName} Silo Nearing Capacity**\n"; |
||
| 226 | if ($gooCurrent === $towerFull && $lastAmount === $gooCurrent) { |
||
| 227 | $msg = "**{$typeName} Silo Full**\n"; |
||
| 228 | } elseif ($gooCurrent === $towerFull && $lastAmount !== $gooCurrent) { |
||
| 229 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 230 | continue 3; |
||
| 231 | } |
||
| 232 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 233 | $msg .= "**System: **{$systemName}\n"; |
||
| 234 | $msg .= "**Capacity: **{$cleanNumber}/{$cleanFull}m3\n"; |
||
| 235 | $this->logger->addInfo("siloFull: {$typeName} Silo nearing capacity in {$systemName}"); |
||
| 236 | // Send the msg to the channel; |
||
| 237 | $channelID = $this->toDiscordChannel; |
||
| 238 | queueMessage($msg, $channelID, $this->guild); |
||
| 239 | $this->logger->addInfo('siloFull: Silo Alert queued'); |
||
| 240 | $siloCount++; |
||
| 241 | } |
||
| 242 | break; |
||
| 243 | View Code Duplication | case 16641: |
|
| 244 | $typeName = getTypeName(16641); |
||
| 245 | $systemName = getSystemName($structures->attributes()->locationID); |
||
| 246 | $towerWarn = 30000 + (30000 * $towerMulti); |
||
| 247 | if ($silo->attributes()->quantity >= $towerWarn) { |
||
| 248 | $siloID = $structures->attributes()->itemID; |
||
| 249 | $lastAmount = getPermCache("silo{$siloID}Amount"); |
||
| 250 | $gooAmount = $silo->attributes()->quantity; |
||
| 251 | $gooDifference = $gooAmount - $lastAmount; |
||
| 252 | //Check if silo has been checked before |
||
| 253 | if (!isset($lastAmount) || $gooDifference < 0) { |
||
| 254 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 255 | continue 3; |
||
| 256 | } |
||
| 257 | $gooVolume = 0.6; |
||
| 258 | $gooCurrent = $gooAmount * $gooVolume; |
||
| 259 | //double check tower race |
||
| 260 | if ((int)$towerFull === 20000 && (int)$gooCurrent > 20000) { |
||
| 261 | $towerFull = 30000; |
||
| 262 | } |
||
| 263 | if ((int)$towerFull === 20000 || 30000 && (int)$gooCurrent > 30000) { |
||
| 264 | $towerFull = 40000; |
||
| 265 | } |
||
| 266 | $cleanNumber = number_format($gooCurrent); |
||
| 267 | $msg = "**{$typeName} Silo Nearing Capacity**\n"; |
||
| 268 | if ($gooCurrent === $towerFull && $lastAmount === $gooCurrent) { |
||
| 269 | $msg = "**{$typeName} Silo Full**\n"; |
||
| 270 | } elseif ($gooCurrent === $towerFull && $lastAmount !== $gooCurrent) { |
||
| 271 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 272 | continue 3; |
||
| 273 | } |
||
| 274 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 275 | $msg .= "**System: **{$systemName}\n"; |
||
| 276 | $msg .= "**Capacity: **{$cleanNumber}/{$cleanFull}m3\n"; |
||
| 277 | $this->logger->addInfo("siloFull: {$typeName} Silo nearing capacity in {$systemName}"); |
||
| 278 | // Send the msg to the channel; |
||
| 279 | $channelID = $this->toDiscordChannel; |
||
| 280 | queueMessage($msg, $channelID, $this->guild); |
||
| 281 | $this->logger->addInfo('siloFull: Silo Alert queued'); |
||
| 282 | $siloCount++; |
||
| 283 | } |
||
| 284 | break; |
||
| 285 | View Code Duplication | case 16640: |
|
| 286 | $typeName = getTypeName(16640); |
||
| 287 | $systemName = getSystemName($structures->attributes()->locationID); |
||
| 288 | $towerWarn = 45000 + (45000 * $towerMulti); |
||
| 289 | if ($silo->attributes()->quantity >= $towerWarn) { |
||
| 290 | $siloID = $structures->attributes()->itemID; |
||
| 291 | $lastAmount = getPermCache("silo{$siloID}Amount"); |
||
| 292 | $gooAmount = $silo->attributes()->quantity; |
||
| 293 | $gooDifference = $gooAmount - $lastAmount; |
||
| 294 | //Check if silo has been checked before |
||
| 295 | if (!isset($lastAmount) || $gooDifference < 0) { |
||
| 296 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 297 | continue 3; |
||
| 298 | } |
||
| 299 | $gooVolume = 0.4; |
||
| 300 | $gooCurrent = $gooAmount * $gooVolume; |
||
| 301 | //double check tower race |
||
| 302 | if ((int)$towerFull === 20000 && (int)$gooCurrent > 20000) { |
||
| 303 | $towerFull = 30000; |
||
| 304 | } |
||
| 305 | if ((int)$towerFull === 20000 || 30000 && (int)$gooCurrent > 30000) { |
||
| 306 | $towerFull = 40000; |
||
| 307 | } |
||
| 308 | $cleanNumber = number_format($gooCurrent); |
||
| 309 | $msg = "**{$typeName} Silo Nearing Capacity**\n"; |
||
| 310 | if ($gooCurrent === $towerFull && $lastAmount === $gooCurrent) { |
||
| 311 | $msg = "**{$typeName} Silo Full**\n"; |
||
| 312 | } elseif ($gooCurrent === $towerFull && $lastAmount !== $gooCurrent) { |
||
| 313 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 314 | continue 3; |
||
| 315 | } |
||
| 316 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 317 | $msg .= "**System: **{$systemName}\n"; |
||
| 318 | $msg .= "**Capacity: **{$cleanNumber}/{$cleanFull}m3\n"; |
||
| 319 | $this->logger->addInfo("siloFull: {$typeName} Silo nearing capacity in {$systemName}"); |
||
| 320 | // Send the msg to the channel; |
||
| 321 | $channelID = $this->toDiscordChannel; |
||
| 322 | queueMessage($msg, $channelID, $this->guild); |
||
| 323 | $this->logger->addInfo('siloFull: Silo Alert queued'); |
||
| 324 | $siloCount++; |
||
| 325 | } |
||
| 326 | break; |
||
| 327 | View Code Duplication | case 16635: |
|
| 328 | $typeName = getTypeName(16635); |
||
| 329 | $systemName = getSystemName($structures->attributes()->locationID); |
||
| 330 | $towerWarn = 180000 + (180000 * $towerMulti); |
||
| 331 | if ($silo->attributes()->quantity >= $towerWarn) { |
||
| 332 | $siloID = $structures->attributes()->itemID; |
||
| 333 | $lastAmount = getPermCache("silo{$siloID}Amount"); |
||
| 334 | $gooAmount = $silo->attributes()->quantity; |
||
| 335 | $gooDifference = $gooAmount - $lastAmount; |
||
| 336 | //Check if silo has been checked before |
||
| 337 | if (!isset($lastAmount) || $gooDifference < 0) { |
||
| 338 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 339 | continue 3; |
||
| 340 | } |
||
| 341 | $gooVolume = 0.1; |
||
| 342 | $gooCurrent = $gooAmount * $gooVolume; |
||
| 343 | //double check tower race |
||
| 344 | if ((int)$towerFull === 20000 && (int)$gooCurrent > 20000) { |
||
| 345 | $towerFull = 30000; |
||
| 346 | } |
||
| 347 | if ((int)$towerFull === 20000 || 30000 && (int)$gooCurrent > 30000) { |
||
| 348 | $towerFull = 40000; |
||
| 349 | } |
||
| 350 | $cleanNumber = number_format($gooCurrent); |
||
| 351 | $msg = "**{$typeName} Silo Nearing Capacity**\n"; |
||
| 352 | if ($gooCurrent === $towerFull && $lastAmount === $gooCurrent) { |
||
| 353 | $msg = "**{$typeName} Silo Full**\n"; |
||
| 354 | } elseif ($gooCurrent === $towerFull && $lastAmount !== $gooCurrent) { |
||
| 355 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 356 | continue 3; |
||
| 357 | } |
||
| 358 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 359 | $msg .= "**System: **{$systemName}\n"; |
||
| 360 | $msg .= "**Capacity: **{$cleanNumber}/{$cleanFull}m3\n"; |
||
| 361 | $this->logger->addInfo("siloFull: {$typeName} Silo nearing capacity in {$systemName}"); |
||
| 362 | // Send the msg to the channel; |
||
| 363 | $channelID = $this->toDiscordChannel; |
||
| 364 | queueMessage($msg, $channelID, $this->guild); |
||
| 365 | $this->logger->addInfo('siloFull: Silo Alert queued'); |
||
| 366 | $siloCount++; |
||
| 367 | } |
||
| 368 | break; |
||
| 369 | View Code Duplication | case 16648: |
|
| 370 | $typeName = getTypeName(16648); |
||
| 371 | $systemName = getSystemName($structures->attributes()->locationID); |
||
| 372 | $towerWarn = 22500 + (22500 * $towerMulti); |
||
| 373 | if ($silo->attributes()->quantity >= $towerWarn) { |
||
| 374 | $siloID = $structures->attributes()->itemID; |
||
| 375 | $lastAmount = getPermCache("silo{$siloID}Amount"); |
||
| 376 | $gooAmount = $silo->attributes()->quantity; |
||
| 377 | $gooDifference = $gooAmount - $lastAmount; |
||
| 378 | //Check if silo has been checked before |
||
| 379 | if (!isset($lastAmount) || $gooDifference < 0) { |
||
| 380 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 381 | continue 3; |
||
| 382 | } |
||
| 383 | $gooVolume = 0.8; |
||
| 384 | $gooCurrent = $gooAmount * $gooVolume; |
||
| 385 | //double check tower race |
||
| 386 | if ((int)$towerFull === 20000 && (int)$gooCurrent > 20000) { |
||
| 387 | $towerFull = 30000; |
||
| 388 | } |
||
| 389 | if ((int)$towerFull === 20000 || 30000 && (int)$gooCurrent > 30000) { |
||
| 390 | $towerFull = 40000; |
||
| 391 | } |
||
| 392 | $cleanNumber = number_format($gooCurrent); |
||
| 393 | $msg = "**{$typeName} Silo Nearing Capacity**\n"; |
||
| 394 | if ($gooCurrent === $towerFull && $lastAmount === $gooCurrent) { |
||
| 395 | $msg = "**{$typeName} Silo Full**\n"; |
||
| 396 | } elseif ($gooCurrent === $towerFull && $lastAmount !== $gooCurrent) { |
||
| 397 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 398 | continue 3; |
||
| 399 | } |
||
| 400 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 401 | $msg .= "**System: **{$systemName}\n"; |
||
| 402 | $msg .= "**Capacity: **{$cleanNumber}/{$cleanFull}m3\n"; |
||
| 403 | $this->logger->addInfo("siloFull: {$typeName} Silo nearing capacity in {$systemName}"); |
||
| 404 | // Send the msg to the channel; |
||
| 405 | $channelID = $this->toDiscordChannel; |
||
| 406 | queueMessage($msg, $channelID, $this->guild); |
||
| 407 | $this->logger->addInfo('siloFull: Silo Alert queued'); |
||
| 408 | $siloCount++; |
||
| 409 | } |
||
| 410 | break; |
||
| 411 | View Code Duplication | case 16633: |
|
| 412 | $typeName = getTypeName(16633); |
||
| 413 | $systemName = getSystemName($structures->attributes()->locationID); |
||
| 414 | $towerWarn = 180000 + (180000 * $towerMulti); |
||
| 415 | if ($silo->attributes()->quantity >= $towerWarn) { |
||
| 416 | $siloID = $structures->attributes()->itemID; |
||
| 417 | $lastAmount = getPermCache("silo{$siloID}Amount"); |
||
| 418 | $gooAmount = $silo->attributes()->quantity; |
||
| 419 | $gooDifference = $gooAmount - $lastAmount; |
||
| 420 | //Check if silo has been checked before |
||
| 421 | if (!isset($lastAmount) || $gooDifference < 0) { |
||
| 422 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 423 | continue 3; |
||
| 424 | } |
||
| 425 | $gooVolume = 0.1; |
||
| 426 | $gooCurrent = $gooAmount * $gooVolume; |
||
| 427 | //double check tower race |
||
| 428 | if ((int)$towerFull === 20000 && (int)$gooCurrent > 20000) { |
||
| 429 | $towerFull = 30000; |
||
| 430 | } |
||
| 431 | if ((int)$towerFull === 20000 || 30000 && (int)$gooCurrent > 30000) { |
||
| 432 | $towerFull = 40000; |
||
| 433 | } |
||
| 434 | $cleanNumber = number_format($gooCurrent); |
||
| 435 | $msg = "**{$typeName} Silo Nearing Capacity**\n"; |
||
| 436 | if ($gooCurrent === $towerFull && $lastAmount === $gooCurrent) { |
||
| 437 | $msg = "**{$typeName} Silo Full**\n"; |
||
| 438 | } elseif ($gooCurrent === $towerFull && $lastAmount !== $gooCurrent) { |
||
| 439 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 440 | continue 3; |
||
| 441 | } |
||
| 442 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 443 | $msg .= "**System: **{$systemName}\n"; |
||
| 444 | $msg .= "**Capacity: **{$cleanNumber}/{$cleanFull}m3\n"; |
||
| 445 | $this->logger->addInfo("siloFull: {$typeName} Silo nearing capacity in {$systemName}"); |
||
| 446 | // Send the msg to the channel; |
||
| 447 | $channelID = $this->toDiscordChannel; |
||
| 448 | queueMessage($msg, $channelID, $this->guild); |
||
| 449 | $this->logger->addInfo('siloFull: Silo Alert queued'); |
||
| 450 | $siloCount++; |
||
| 451 | } |
||
| 452 | break; |
||
| 453 | View Code Duplication | case 16646: |
|
| 454 | $typeName = getTypeName(16646); |
||
| 455 | $systemName = getSystemName($structures->attributes()->locationID); |
||
| 456 | $towerWarn = 22500 + (22500 * $towerMulti); |
||
| 457 | if ($silo->attributes()->quantity >= $towerWarn) { |
||
| 458 | $siloID = $structures->attributes()->itemID; |
||
| 459 | $lastAmount = getPermCache("silo{$siloID}Amount"); |
||
| 460 | $gooAmount = $silo->attributes()->quantity; |
||
| 461 | $gooDifference = $gooAmount - $lastAmount; |
||
| 462 | //Check if silo has been checked before |
||
| 463 | if (!isset($lastAmount) || $gooDifference < 0) { |
||
| 464 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 465 | continue 3; |
||
| 466 | } |
||
| 467 | $gooVolume = 0.8; |
||
| 468 | $gooCurrent = $gooAmount * $gooVolume; |
||
| 469 | //double check tower race |
||
| 470 | if ((int)$towerFull === 20000 && (int)$gooCurrent > 20000) { |
||
| 471 | $towerFull = 30000; |
||
| 472 | } |
||
| 473 | if ((int)$towerFull === 20000 || 30000 && (int)$gooCurrent > 30000) { |
||
| 474 | $towerFull = 40000; |
||
| 475 | } |
||
| 476 | $cleanNumber = number_format($gooCurrent); |
||
| 477 | $msg = "**{$typeName} Silo Nearing Capacity**\n"; |
||
| 478 | if ($gooCurrent === $towerFull && $lastAmount === $gooCurrent) { |
||
| 479 | $msg = "**{$typeName} Silo Full**\n"; |
||
| 480 | } elseif ($gooCurrent === $towerFull && $lastAmount !== $gooCurrent) { |
||
| 481 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 482 | continue 3; |
||
| 483 | } |
||
| 484 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 485 | $msg .= "**System: **{$systemName}\n"; |
||
| 486 | $msg .= "**Capacity: **{$cleanNumber}/{$cleanFull}m3\n"; |
||
| 487 | $this->logger->addInfo("siloFull: {$typeName} Silo nearing capacity in {$systemName}"); |
||
| 488 | // Send the msg to the channel; |
||
| 489 | $channelID = $this->toDiscordChannel; |
||
| 490 | queueMessage($msg, $channelID, $this->guild); |
||
| 491 | $this->logger->addInfo('siloFull: Silo Alert queued'); |
||
| 492 | $siloCount++; |
||
| 493 | } |
||
| 494 | break; |
||
| 495 | View Code Duplication | case 16651: |
|
| 496 | $typeName = getTypeName(16651); |
||
| 497 | $systemName = getSystemName($structures->attributes()->locationID); |
||
| 498 | $towerWarn = 18000 + (18000 * $towerMulti); |
||
| 499 | if ($silo->attributes()->quantity >= $towerWarn) { |
||
| 500 | $siloID = $structures->attributes()->itemID; |
||
| 501 | $lastAmount = getPermCache("silo{$siloID}Amount"); |
||
| 502 | $gooAmount = $silo->attributes()->quantity; |
||
| 503 | $gooDifference = $gooAmount - $lastAmount; |
||
| 504 | //Check if silo has been checked before |
||
| 505 | if (!isset($lastAmount) || $gooDifference < 0) { |
||
| 506 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 507 | continue 3; |
||
| 508 | } |
||
| 509 | $gooVolume = 1; |
||
| 510 | $gooCurrent = $gooAmount * $gooVolume; |
||
| 511 | //double check tower race |
||
| 512 | if ((int)$towerFull === 20000 && (int)$gooCurrent > 20000) { |
||
| 513 | $towerFull = 30000; |
||
| 514 | } |
||
| 515 | if ((int)$towerFull === 20000 || 30000 && (int)$gooCurrent > 30000) { |
||
| 516 | $towerFull = 40000; |
||
| 517 | } |
||
| 518 | $cleanNumber = number_format($gooCurrent); |
||
| 519 | $msg = "**{$typeName} Silo Nearing Capacity**\n"; |
||
| 520 | if ($gooCurrent === $towerFull && $lastAmount === $gooCurrent) { |
||
| 521 | $msg = "**{$typeName} Silo Full**\n"; |
||
| 522 | } elseif ($gooCurrent === $towerFull && $lastAmount !== $gooCurrent) { |
||
| 523 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 524 | continue 3; |
||
| 525 | } |
||
| 526 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 527 | $msg .= "**System: **{$systemName}\n"; |
||
| 528 | $msg .= "**Capacity: **{$cleanNumber}/{$cleanFull}m3\n"; |
||
| 529 | $this->logger->addInfo("siloFull: {$typeName} Silo nearing capacity in {$systemName}"); |
||
| 530 | // Send the msg to the channel; |
||
| 531 | $channelID = $this->toDiscordChannel; |
||
| 532 | queueMessage($msg, $channelID, $this->guild); |
||
| 533 | $this->logger->addInfo('siloFull: Silo Alert queued'); |
||
| 534 | $siloCount++; |
||
| 535 | } |
||
| 536 | break; |
||
| 537 | View Code Duplication | case 16650: |
|
| 538 | $typeName = getTypeName(16650); |
||
| 539 | $systemName = getSystemName($structures->attributes()->locationID); |
||
| 540 | $towerWarn = 18000 + (18000 * $towerMulti); |
||
| 541 | if ($silo->attributes()->quantity >= $towerWarn) { |
||
| 542 | $siloID = $structures->attributes()->itemID; |
||
| 543 | $lastAmount = getPermCache("silo{$siloID}Amount"); |
||
| 544 | $gooAmount = $silo->attributes()->quantity; |
||
| 545 | $gooDifference = $gooAmount - $lastAmount; |
||
| 546 | //Check if silo has been checked before |
||
| 547 | if (!isset($lastAmount) || $gooDifference < 0) { |
||
| 548 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 549 | continue 3; |
||
| 550 | } |
||
| 551 | $gooVolume = 1; |
||
| 552 | $gooCurrent = $gooAmount * $gooVolume; |
||
| 553 | //double check tower race |
||
| 554 | if ((int)$towerFull === 20000 && (int)$gooCurrent > 20000) { |
||
| 555 | $towerFull = 30000; |
||
| 556 | } |
||
| 557 | if ((int)$towerFull === 20000 || 30000 && (int)$gooCurrent > 30000) { |
||
| 558 | $towerFull = 40000; |
||
| 559 | } |
||
| 560 | $cleanNumber = number_format($gooCurrent); |
||
| 561 | $msg = "**{$typeName} Silo Nearing Capacity**\n"; |
||
| 562 | if ($gooCurrent === $towerFull && $lastAmount === $gooCurrent) { |
||
| 563 | $msg = "**{$typeName} Silo Full**\n"; |
||
| 564 | } elseif ($gooCurrent === $towerFull && $lastAmount !== $gooCurrent) { |
||
| 565 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 566 | continue 3; |
||
| 567 | } |
||
| 568 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 569 | $msg .= "**System: **{$systemName}\n"; |
||
| 570 | $msg .= "**Capacity: **{$cleanNumber}/{$cleanFull}m3\n"; |
||
| 571 | $this->logger->addInfo("siloFull: {$typeName} Silo nearing capacity in {$systemName}"); |
||
| 572 | // Send the msg to the channel; |
||
| 573 | $channelID = $this->toDiscordChannel; |
||
| 574 | queueMessage($msg, $channelID, $this->guild); |
||
| 575 | $this->logger->addInfo('siloFull: Silo Alert queued'); |
||
| 576 | $siloCount++; |
||
| 577 | } |
||
| 578 | break; |
||
| 579 | View Code Duplication | case 16644: |
|
| 580 | $typeName = getTypeName(16644); |
||
| 581 | $systemName = getSystemName($structures->attributes()->locationID); |
||
| 582 | $towerWarn = 18000 + (18000 * $towerMulti); |
||
| 583 | if ($silo->attributes()->quantity >= $towerWarn) { |
||
| 584 | $siloID = $structures->attributes()->itemID; |
||
| 585 | $lastAmount = getPermCache("silo{$siloID}Amount"); |
||
| 586 | $gooAmount = $silo->attributes()->quantity; |
||
| 587 | $gooDifference = $gooAmount - $lastAmount; |
||
| 588 | //Check if silo has been checked before |
||
| 589 | if (!isset($lastAmount) || $gooDifference < 0) { |
||
| 590 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 591 | continue 3; |
||
| 592 | } |
||
| 593 | $gooVolume = 1; |
||
| 594 | $gooCurrent = $gooAmount * $gooVolume; |
||
| 595 | //double check tower race |
||
| 596 | if ((int)$towerFull === 20000 && (int)$gooCurrent > 20000) { |
||
| 597 | $towerFull = 30000; |
||
| 598 | } |
||
| 599 | if ((int)$towerFull === 20000 || 30000 && (int)$gooCurrent > 30000) { |
||
| 600 | $towerFull = 40000; |
||
| 601 | } |
||
| 602 | $cleanNumber = number_format($gooCurrent); |
||
| 603 | $msg = "**{$typeName} Silo Nearing Capacity**\n"; |
||
| 604 | if ($gooCurrent === $towerFull && $lastAmount === $gooCurrent) { |
||
| 605 | $msg = "**{$typeName} Silo Full**\n"; |
||
| 606 | } elseif ($gooCurrent === $towerFull && $lastAmount !== $gooCurrent) { |
||
| 607 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 608 | continue 3; |
||
| 609 | } |
||
| 610 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 611 | $msg .= "**System: **{$systemName}\n"; |
||
| 612 | $msg .= "**Capacity: **{$cleanNumber}/{$cleanFull}m3\n"; |
||
| 613 | $this->logger->addInfo("siloFull: {$typeName} Silo nearing capacity in {$systemName}"); |
||
| 614 | // Send the msg to the channel; |
||
| 615 | $channelID = $this->toDiscordChannel; |
||
| 616 | queueMessage($msg, $channelID, $this->guild); |
||
| 617 | $this->logger->addInfo('siloFull: Silo Alert queued'); |
||
| 618 | $siloCount++; |
||
| 619 | } |
||
| 620 | break; |
||
| 621 | View Code Duplication | case 16652: |
|
| 622 | $typeName = getTypeName(16652); |
||
| 623 | $systemName = getSystemName($structures->attributes()->locationID); |
||
| 624 | $towerWarn = 18000 + (18000 * $towerMulti); |
||
| 625 | if ($silo->attributes()->quantity >= $towerWarn) { |
||
| 626 | $siloID = $structures->attributes()->itemID; |
||
| 627 | $lastAmount = getPermCache("silo{$siloID}Amount"); |
||
| 628 | $gooAmount = $silo->attributes()->quantity; |
||
| 629 | $gooDifference = $gooAmount - $lastAmount; |
||
| 630 | //Check if silo has been checked before |
||
| 631 | if (!isset($lastAmount) || $gooDifference < 0) { |
||
| 632 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 633 | continue 3; |
||
| 634 | } |
||
| 635 | $gooVolume = 1; |
||
| 636 | $gooCurrent = $gooAmount * $gooVolume; |
||
| 637 | //double check tower race |
||
| 638 | if ((int)$towerFull === 20000 && (int)$gooCurrent > 20000) { |
||
| 639 | $towerFull = 30000; |
||
| 640 | } |
||
| 641 | if ((int)$towerFull === 20000 || 30000 && (int)$gooCurrent > 30000) { |
||
| 642 | $towerFull = 40000; |
||
| 643 | } |
||
| 644 | $cleanNumber = number_format($gooCurrent); |
||
| 645 | $msg = "**{$typeName} Silo Nearing Capacity**\n"; |
||
| 646 | if ($gooCurrent === $towerFull && $lastAmount === $gooCurrent) { |
||
| 647 | $msg = "**{$typeName} Silo Full**\n"; |
||
| 648 | } elseif ($gooCurrent === $towerFull && $lastAmount !== $gooCurrent) { |
||
| 649 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 650 | continue 3; |
||
| 651 | } |
||
| 652 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 653 | $msg .= "**System: **{$systemName}\n"; |
||
| 654 | $msg .= "**Capacity: **{$cleanNumber}/{$cleanFull}m3\n"; |
||
| 655 | $this->logger->addInfo("siloFull: {$typeName} Silo nearing capacity in {$systemName}"); |
||
| 656 | // Send the msg to the channel; |
||
| 657 | $channelID = $this->toDiscordChannel; |
||
| 658 | queueMessage($msg, $channelID, $this->guild); |
||
| 659 | $this->logger->addInfo('siloFull: Silo Alert queued'); |
||
| 660 | $siloCount++; |
||
| 661 | } |
||
| 662 | break; |
||
| 663 | View Code Duplication | case 16639: |
|
| 664 | $typeName = getTypeName(16639); |
||
| 665 | $systemName = getSystemName($structures->attributes()->locationID); |
||
| 666 | $towerWarn = 45000 + (45000 * $towerMulti); |
||
| 667 | if ($silo->attributes()->quantity >= $towerWarn) { |
||
| 668 | $siloID = $structures->attributes()->itemID; |
||
| 669 | $lastAmount = getPermCache("silo{$siloID}Amount"); |
||
| 670 | $gooAmount = $silo->attributes()->quantity; |
||
| 671 | $gooDifference = $gooAmount - $lastAmount; |
||
| 672 | //Check if silo has been checked before |
||
| 673 | if (!isset($lastAmount) || $gooDifference < 0) { |
||
| 674 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 675 | continue 3; |
||
| 676 | } |
||
| 677 | $gooVolume = 0.4; |
||
| 678 | $gooCurrent = $gooAmount * $gooVolume; |
||
| 679 | //double check tower race |
||
| 680 | if ((int)$towerFull === 20000 && (int)$gooCurrent > 20000) { |
||
| 681 | $towerFull = 30000; |
||
| 682 | } |
||
| 683 | if ((int)$towerFull === 20000 || 30000 && (int)$gooCurrent > 30000) { |
||
| 684 | $towerFull = 40000; |
||
| 685 | } |
||
| 686 | $cleanNumber = number_format($gooCurrent); |
||
| 687 | $msg = "**{$typeName} Silo Nearing Capacity**\n"; |
||
| 688 | if ($gooCurrent === $towerFull && $lastAmount === $gooCurrent) { |
||
| 689 | $msg = "**{$typeName} Silo Full**\n"; |
||
| 690 | } elseif ($gooCurrent === $towerFull && $lastAmount !== $gooCurrent) { |
||
| 691 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 692 | continue 3; |
||
| 693 | } |
||
| 694 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 695 | $msg .= "**System: **{$systemName}\n"; |
||
| 696 | $msg .= "**Capacity: **{$cleanNumber}/{$cleanFull}m3\n"; |
||
| 697 | $this->logger->addInfo("siloFull: {$typeName} Silo nearing capacity in {$systemName}"); |
||
| 698 | // Send the msg to the channel; |
||
| 699 | $channelID = $this->toDiscordChannel; |
||
| 700 | queueMessage($msg, $channelID, $this->guild); |
||
| 701 | $this->logger->addInfo('siloFull: Silo Alert queued'); |
||
| 702 | $siloCount++; |
||
| 703 | } |
||
| 704 | break; |
||
| 705 | View Code Duplication | case 16636: |
|
| 706 | $typeName = getTypeName(16636); |
||
| 707 | $systemName = getSystemName($structures->attributes()->locationID); |
||
| 708 | $towerWarn = 180000 + (180000 * $towerMulti); |
||
| 709 | if ($silo->attributes()->quantity >= $towerWarn) { |
||
| 710 | $siloID = $structures->attributes()->itemID; |
||
| 711 | $lastAmount = getPermCache("silo{$siloID}Amount"); |
||
| 712 | $gooAmount = $silo->attributes()->quantity; |
||
| 713 | $gooDifference = $gooAmount - $lastAmount; |
||
| 714 | //Check if silo has been checked before |
||
| 715 | if (!isset($lastAmount) || $gooDifference < 0) { |
||
| 716 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 717 | continue 3; |
||
| 718 | } |
||
| 719 | $gooVolume = 0.1; |
||
| 720 | $gooCurrent = $gooAmount * $gooVolume; |
||
| 721 | //double check tower race |
||
| 722 | if ((int)$towerFull === 20000 && (int)$gooCurrent > 20000) { |
||
| 723 | $towerFull = 30000; |
||
| 724 | } |
||
| 725 | if ((int)$towerFull === 20000 || 30000 && (int)$gooCurrent > 30000) { |
||
| 726 | $towerFull = 40000; |
||
| 727 | } |
||
| 728 | $cleanNumber = number_format($gooCurrent); |
||
| 729 | $msg = "**{$typeName} Silo Nearing Capacity**\n"; |
||
| 730 | if ($gooCurrent === $towerFull && $lastAmount === $gooCurrent) { |
||
| 731 | $msg = "**{$typeName} Silo Full**\n"; |
||
| 732 | } elseif ($gooCurrent === $towerFull && $lastAmount !== $gooCurrent) { |
||
| 733 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 734 | continue 3; |
||
| 735 | } |
||
| 736 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 737 | $msg .= "**System: **{$systemName}\n"; |
||
| 738 | $msg .= "**Capacity: **{$cleanNumber}/{$cleanFull}m3\n"; |
||
| 739 | $this->logger->addInfo("siloFull: {$typeName} Silo nearing capacity in {$systemName}"); |
||
| 740 | // Send the msg to the channel; |
||
| 741 | $channelID = $this->toDiscordChannel; |
||
| 742 | queueMessage($msg, $channelID, $this->guild); |
||
| 743 | $this->logger->addInfo('siloFull: Silo Alert queued'); |
||
| 744 | $siloCount++; |
||
| 745 | } |
||
| 746 | break; |
||
| 747 | View Code Duplication | case 16649: |
|
| 748 | $typeName = getTypeName(16649); |
||
| 749 | $systemName = getSystemName($structures->attributes()->locationID); |
||
| 750 | $towerWarn = 18000 + (18000 * $towerMulti); |
||
| 751 | if ($silo->attributes()->quantity >= $towerWarn) { |
||
| 752 | $siloID = $structures->attributes()->itemID; |
||
| 753 | $lastAmount = getPermCache("silo{$siloID}Amount"); |
||
| 754 | $gooAmount = $silo->attributes()->quantity; |
||
| 755 | $gooDifference = $gooAmount - $lastAmount; |
||
| 756 | //Check if silo has been checked before |
||
| 757 | if (!isset($lastAmount) || $gooDifference < 0) { |
||
| 758 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 759 | continue 3; |
||
| 760 | } |
||
| 761 | $gooVolume = 1; |
||
| 762 | $gooCurrent = $gooAmount * $gooVolume; |
||
| 763 | //double check tower race |
||
| 764 | if ((int)$towerFull === 20000 && (int)$gooCurrent > 20000) { |
||
| 765 | $towerFull = 30000; |
||
| 766 | } |
||
| 767 | if ((int)$towerFull === 20000 || 30000 && (int)$gooCurrent > 30000) { |
||
| 768 | $towerFull = 40000; |
||
| 769 | } |
||
| 770 | $cleanNumber = number_format($gooCurrent); |
||
| 771 | $msg = "**{$typeName} Silo Nearing Capacity**\n"; |
||
| 772 | if ($gooCurrent === $towerFull && $lastAmount === $gooCurrent) { |
||
| 773 | $msg = "**{$typeName} Silo Full**\n"; |
||
| 774 | } elseif ($gooCurrent === $towerFull && $lastAmount !== $gooCurrent) { |
||
| 775 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 776 | continue 3; |
||
| 777 | } |
||
| 778 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 779 | $msg .= "**System: **{$systemName}\n"; |
||
| 780 | $msg .= "**Capacity: **{$cleanNumber}/{$cleanFull}m3\n"; |
||
| 781 | $this->logger->addInfo("siloFull: {$typeName} Silo nearing capacity in {$systemName}"); |
||
| 782 | // Send the msg to the channel; |
||
| 783 | $channelID = $this->toDiscordChannel; |
||
| 784 | queueMessage($msg, $channelID, $this->guild); |
||
| 785 | $this->logger->addInfo('siloFull: Silo Alert queued'); |
||
| 786 | $siloCount++; |
||
| 787 | } |
||
| 788 | break; |
||
| 789 | View Code Duplication | case 16653: |
|
| 790 | $typeName = getTypeName(16653); |
||
| 791 | $systemName = getSystemName($structures->attributes()->locationID); |
||
| 792 | $towerWarn = 18000 + (18000 * $towerMulti); |
||
| 793 | if ($silo->attributes()->quantity >= $towerWarn) { |
||
| 794 | $siloID = $structures->attributes()->itemID; |
||
| 795 | $lastAmount = getPermCache("silo{$siloID}Amount"); |
||
| 796 | $gooAmount = $silo->attributes()->quantity; |
||
| 797 | $gooDifference = $gooAmount - $lastAmount; |
||
| 798 | //Check if silo has been checked before |
||
| 799 | if (!isset($lastAmount) || $gooDifference < 0) { |
||
| 800 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 801 | continue 3; |
||
| 802 | } |
||
| 803 | $gooVolume = 1; |
||
| 804 | $gooCurrent = $gooAmount * $gooVolume; |
||
| 805 | //double check tower race |
||
| 806 | if ((int)$towerFull === 20000 && (int)$gooCurrent > 20000) { |
||
| 807 | $towerFull = 30000; |
||
| 808 | } |
||
| 809 | if ((int)$towerFull === 20000 || 30000 && (int)$gooCurrent > 30000) { |
||
| 810 | $towerFull = 40000; |
||
| 811 | } |
||
| 812 | $cleanNumber = number_format($gooCurrent); |
||
| 813 | $msg = "**{$typeName} Silo Nearing Capacity**\n"; |
||
| 814 | if ($gooCurrent === $towerFull && $lastAmount === $gooCurrent) { |
||
| 815 | $msg = "**{$typeName} Silo Full**\n"; |
||
| 816 | } elseif ($gooCurrent === $towerFull && $lastAmount !== $gooCurrent) { |
||
| 817 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 818 | continue 3; |
||
| 819 | } |
||
| 820 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 821 | $msg .= "**System: **{$systemName}\n"; |
||
| 822 | $msg .= "**Capacity: **{$cleanNumber}/{$cleanFull}m3\n"; |
||
| 823 | $this->logger->addInfo("siloFull: {$typeName} Silo nearing capacity in {$systemName}"); |
||
| 824 | // Send the msg to the channel; |
||
| 825 | $channelID = $this->toDiscordChannel; |
||
| 826 | queueMessage($msg, $channelID, $this->guild); |
||
| 827 | $this->logger->addInfo('siloFull: Silo Alert queued'); |
||
| 828 | $siloCount++; |
||
| 829 | } |
||
| 830 | break; |
||
| 831 | View Code Duplication | case 16638: |
|
| 832 | $typeName = getTypeName(16638); |
||
| 833 | $systemName = getSystemName($structures->attributes()->locationID); |
||
| 834 | $towerWarn = 45000 + (45000 * $towerMulti); |
||
| 835 | if ($silo->attributes()->quantity >= $towerWarn) { |
||
| 836 | $siloID = $structures->attributes()->itemID; |
||
| 837 | $lastAmount = getPermCache("silo{$siloID}Amount"); |
||
| 838 | $gooAmount = $silo->attributes()->quantity; |
||
| 839 | $gooDifference = $gooAmount - $lastAmount; |
||
| 840 | //Check if silo has been checked before |
||
| 841 | if (!isset($lastAmount) || $gooDifference < 0) { |
||
| 842 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 843 | continue 3; |
||
| 844 | } |
||
| 845 | $gooVolume = 0.4; |
||
| 846 | $gooCurrent = $gooAmount * $gooVolume; |
||
| 847 | //double check tower race |
||
| 848 | if ((int)$towerFull === 20000 && (int)$gooCurrent > 20000) { |
||
| 849 | $towerFull = 30000; |
||
| 850 | } |
||
| 851 | if ((int)$towerFull === 20000 || 30000 && (int)$gooCurrent > 30000) { |
||
| 852 | $towerFull = 40000; |
||
| 853 | } |
||
| 854 | $cleanNumber = number_format($gooCurrent); |
||
| 855 | $msg = "**{$typeName} Silo Nearing Capacity**\n"; |
||
| 856 | if ($gooCurrent === $towerFull && $lastAmount === $gooCurrent) { |
||
| 857 | $msg = "**{$typeName} Silo Full**\n"; |
||
| 858 | } elseif ($gooCurrent === $towerFull && $lastAmount !== $gooCurrent) { |
||
| 859 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 860 | continue 3; |
||
| 861 | } |
||
| 862 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 863 | $msg .= "**System: **{$systemName}\n"; |
||
| 864 | $msg .= "**Capacity: **{$cleanNumber}/{$cleanFull}m3\n"; |
||
| 865 | $this->logger->addInfo("siloFull: {$typeName} Silo nearing capacity in {$systemName}"); |
||
| 866 | // Send the msg to the channel; |
||
| 867 | $channelID = $this->toDiscordChannel; |
||
| 868 | queueMessage($msg, $channelID, $this->guild); |
||
| 869 | $this->logger->addInfo('siloFull: Silo Alert queued'); |
||
| 870 | $siloCount++; |
||
| 871 | } |
||
| 872 | break; |
||
| 873 | View Code Duplication | case 16637: |
|
| 874 | $typeName = getTypeName(16637); |
||
| 875 | $systemName = getSystemName($structures->attributes()->locationID); |
||
| 876 | $towerWarn = 45000 + (45000 * $towerMulti); |
||
| 877 | if ($silo->attributes()->quantity >= $towerWarn) { |
||
| 878 | $siloID = $structures->attributes()->itemID; |
||
| 879 | $lastAmount = getPermCache("silo{$siloID}Amount"); |
||
| 880 | $gooAmount = $silo->attributes()->quantity; |
||
| 881 | $gooDifference = $gooAmount - $lastAmount; |
||
| 882 | //Check if silo has been checked before |
||
| 883 | if (!isset($lastAmount) || $gooDifference < 0) { |
||
| 884 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 885 | continue 3; |
||
| 886 | } |
||
| 887 | $gooVolume = 0.4; |
||
| 888 | $gooCurrent = $gooAmount * $gooVolume; |
||
| 889 | //double check tower race |
||
| 890 | if ((int)$towerFull === 20000 && (int)$gooCurrent > 20000) { |
||
| 891 | $towerFull = 30000; |
||
| 892 | } |
||
| 893 | if ((int)$towerFull === 20000 || 30000 && (int)$gooCurrent > 30000) { |
||
| 894 | $towerFull = 40000; |
||
| 895 | } |
||
| 896 | $cleanNumber = number_format($gooCurrent); |
||
| 897 | $msg = "**{$typeName} Silo Nearing Capacity**\n"; |
||
| 898 | if ($gooCurrent === $towerFull && $lastAmount === $gooCurrent) { |
||
| 899 | $msg = "**{$typeName} Silo Full**\n"; |
||
| 900 | } elseif ($gooCurrent === $towerFull && $lastAmount !== $gooCurrent) { |
||
| 901 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 902 | continue 3; |
||
| 903 | } |
||
| 904 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 905 | $msg .= "**System: **{$systemName}\n"; |
||
| 906 | $msg .= "**Capacity: **{$cleanNumber}/{$cleanFull}m3\n"; |
||
| 907 | $this->logger->addInfo("siloFull: {$typeName} Silo nearing capacity in {$systemName}"); |
||
| 908 | // Send the msg to the channel; |
||
| 909 | $channelID = $this->toDiscordChannel; |
||
| 910 | queueMessage($msg, $channelID, $this->guild); |
||
| 911 | $this->logger->addInfo('siloFull: Silo Alert queued'); |
||
| 912 | $siloCount++; |
||
| 913 | } |
||
| 914 | break; |
||
| 915 | View Code Duplication | case 16642: |
|
| 916 | $typeName = getTypeName(16642); |
||
| 917 | $systemName = getSystemName($structures->attributes()->locationID); |
||
| 918 | $towerWarn = 18000 + (18000 * $towerMulti); |
||
| 919 | if ($silo->attributes()->quantity >= $towerWarn) { |
||
| 920 | $siloID = $structures->attributes()->itemID; |
||
| 921 | $lastAmount = getPermCache("silo{$siloID}Amount"); |
||
| 922 | $gooAmount = $silo->attributes()->quantity; |
||
| 923 | $gooDifference = $gooAmount - $lastAmount; |
||
| 924 | //Check if silo has been checked before, and if it's an input silo ignore |
||
| 925 | if (!isset($lastAmount) || $gooDifference < 0) { |
||
| 926 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 927 | continue 3; |
||
| 928 | } |
||
| 929 | $gooVolume = 1; |
||
| 930 | $gooCurrent = $gooAmount * $gooVolume; |
||
| 931 | //double check tower race |
||
| 932 | if ((int)$towerFull === 20000 && (int)$gooCurrent > 20000) { |
||
| 933 | $towerFull = 30000; |
||
| 934 | } |
||
| 935 | if ((int)$towerFull === 20000 || 30000 && (int)$gooCurrent > 30000) { |
||
| 936 | $towerFull = 40000; |
||
| 937 | } |
||
| 938 | $cleanNumber = number_format($gooCurrent); |
||
| 939 | $msg = "**{$typeName} Silo Nearing Capacity**\n"; |
||
| 940 | if ($gooCurrent === $towerFull && $lastAmount === $gooCurrent) { |
||
| 941 | $msg = "**{$typeName} Silo Full**\n"; |
||
| 942 | } elseif ($gooCurrent === $towerFull && $lastAmount !== $gooCurrent) { |
||
| 943 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 944 | continue 3; |
||
| 945 | } |
||
| 946 | setPermCache("silo{$siloID}Amount", $gooAmount); |
||
| 947 | $msg .= "**System: **{$systemName}\n"; |
||
| 948 | $msg .= "**Capacity: **{$cleanNumber}/{$cleanFull}m3\n"; |
||
| 949 | $this->logger->addInfo("siloFull: {$typeName} Silo nearing capacity in {$systemName}"); |
||
| 950 | // Send the msg to the channel; |
||
| 951 | $channelID = $this->toDiscordChannel; |
||
| 952 | queueMessage($msg, $channelID, $this->guild); |
||
| 953 | $this->logger->addInfo('siloFull: Silo Alert queued'); |
||
| 954 | $siloCount++; |
||
| 955 | } |
||
| 956 | break; |
||
| 957 | } |
||
| 958 | } |
||
| 959 | } |
||
| 960 | } |
||
| 961 | } |
||
| 962 | $cached = $xml->cachedUntil[0]; |
||
| 963 | $baseUnix = strtotime($cached); |
||
| 964 | $cacheClr = $baseUnix - 13500; |
||
| 965 | View Code Duplication | if ($cacheClr <= time()) { |
|
| 966 | $weirdTime = time() + 21700; |
||
| 967 | $cacheTimer = gmdate('Y-m-d H:i:s', $weirdTime); |
||
| 968 | setPermCache("siloLastChecked{$keyID}", $weirdTime); |
||
| 969 | } else { |
||
| 970 | $cacheTimer = gmdate('Y-m-d H:i:s', $cacheClr); |
||
| 971 | setPermCache("siloLastChecked{$keyID}", $cacheClr); |
||
| 972 | } |
||
| 973 | $this->logger->addInfo("siloFull: Silo Check Complete Next Check At {$cacheTimer}"); |
||
| 974 | return null; |
||
| 975 | } |
||
| 976 | |||
| 996 | } |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.