We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 8 |
| Paths | 25 |
| Total Lines | 44 |
| Code Lines | 27 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types=1); |
||
| 3 | function shared_channel_msg_op_list(SmrPlayer $player): array { |
||
| 4 | // get the op info from db |
||
| 5 | $db = Smr\Database::getInstance(); |
||
| 6 | $dbResult = $db->read('SELECT 1 |
||
| 7 | FROM alliance_has_op |
||
| 8 | WHERE alliance_id = ' . $db->escapeNumber($player->getAllianceID()) . ' |
||
| 9 | AND game_id = ' . $db->escapeNumber($player->getGameID())); |
||
| 10 | if (!$dbResult->hasRecord()) { |
||
| 11 | return ['Your leader has not scheduled an op.']; |
||
| 12 | } |
||
| 13 | |||
| 14 | $responses = [ |
||
| 15 | 'YES' => [], |
||
| 16 | 'NO' => [], |
||
| 17 | 'MAYBE' => [], |
||
| 18 | ]; |
||
| 19 | $dbResult = $db->read('SELECT account_id, response |
||
| 20 | FROM alliance_has_op_response |
||
| 21 | WHERE alliance_id = ' . $db->escapeNumber($player->getAllianceID()) . ' |
||
| 22 | AND game_id = ' . $db->escapeNumber($player->getGameID())); |
||
| 23 | foreach ($dbResult->records() as $dbRecord) { |
||
| 24 | $respondingPlayer = SmrPlayer::getPlayer($dbRecord->getInt('account_id'), $player->getGameID(), true); |
||
| 25 | // check that the player is still in this alliance |
||
| 26 | if (!$player->sameAlliance($respondingPlayer)) { |
||
| 27 | continue; |
||
| 28 | } |
||
| 29 | $responses[$dbRecord->getField('response')][] = $respondingPlayer; |
||
| 30 | } |
||
| 31 | |||
| 32 | $results = []; |
||
| 33 | foreach ($responses as $response => $responders) { |
||
| 34 | if (count($responders) > 0) { |
||
| 35 | $results[] = $response . ' (' . count($responders) . '):'; |
||
| 36 | foreach ($responders as $responder) { |
||
| 37 | $results[] = ' * ' . $responder->getPlayerName(); |
||
| 38 | } |
||
| 39 | } |
||
| 40 | } |
||
| 41 | |||
| 42 | if (!$results) { |
||
| 43 | return ['No one has responded to the upcoming op.']; |
||
| 44 | } |
||
| 45 | |||
| 46 | return $results; |
||
| 47 | } |
||
| 48 |