Ejemplo n.º 1
0
 public function kick(SpleefSessionData $data, $reason, $checkPlayers = true)
 {
     if ($data->isSpectating()) {
         unset($this->specs[$data->getSession()->getUID()]);
     } elseif ($checkPlayers) {
         unset($this->players[$data->getSession()->getUID()]);
         if (count($this->players) === 1) {
             /** @var SpleefSessionData $winner */
             $winner = array_values($this->players)[0];
             $award = 16 * Settings::coinsFactor($winner->getSession());
             $this->broadcast("The match has ended. {$winner->getSession()} won the match and is awarded with {$award} coins.");
             $winner->getSession()->setCoins($coins = $winner->getSession()->getCoins() + $award);
             $winner->getSession()->tell("You now have {$coins} coins.");
             $winner->addWin();
             $this->game->getDefaultChatChannel()->broadcast("{$winner} won a match in {$this}!");
             $this->reset();
         }
         Settings::spleef_updateArenaSigns($this);
     }
     $data->quitArena();
     $data->getSession()->tell("You left {$this->config->name}: {$reason}.");
     $data->getSession()->teleport(Settings::spleef_spawn($this->game->getMain()->getServer()));
 }
Ejemplo n.º 2
0
 public function update()
 {
     $this->game->getMain()->getMySQLi()->query('INSERT INTO spleef(uid,wins,losses,draws,current_streak)VALUES(%d,%d,%d,%d,%d)ON DUPLICATE KEY UPDATE wins=VALUES(wins),losses=VALUES(losses),draws=VALUES(draws),current_streak=VALUES(current_streak);', MysqlConnection::RAW, (int) $this->session->getUID(), (int) $this->getWins(), (int) $this->getLosses(), (int) $this->getDraws(), 0);
 }