public static function format(array $players, $withRoles = false)
{
$playerList = [];
foreach ($players as $player) {
$str = '@' . $player->getUsername();
if ($withRoles) {
$str .= ' (' . $player->role->getName() . ')';
}
$playerList[] = $str;
}
return implode(', ', $playerList);
}
/** * {@inheritdoc} */ public function fire() { $this->game->removeLobbyPlayer($this->userId); $playersList = PlayerListFormatter::format($this->game->getLobbyPlayers()); if ($playersList) { $this->gameManager->sendMessageToChannel($this->game, "Current lobby: " . $playersList); } else { $this->gameManager->sendMessageToChannel($this->game, "Lobby is now empty"); } }