Exemplo n.º 1
0
 /**
  * Create a table with a specific number of seats.
  * All seats are assigned a computer player until a real player joins.
  *
  * @param int $seats
  *
  * @return Table
  */
 public function createTable($seats = 5)
 {
     $table = new WebSocketObservableTable($seats);
     $index = 0;
     foreach ($table->getSeats() as $seat) {
         $player = $this->playerFactory->newServerPlayer('Bot' . $index++, $seat, 5000);
         $seat->setPlayer($player);
     }
     $this->logger->info('Created new table', ['id' => $table->getId()]);
     $loop = $this->tableLoopFactory->createLoop($table);
     $this->tableLoopMap->attach($table, $loop);
     $this->tables->pushBack($table);
     return $table;
 }
 public function closeTable(WebSocketObservableTable $table)
 {
     $table->broadcast(new TableClosedMessage($table));
     $connections = $this->getConnectionsSubscribedToTable($table);
     foreach ($connections as $connection) {
         $this->unsubscribe($connection);
     }
 }