Beispiel #1
0
 public static function onKick(Dog_Server $server, Dog_Channel $channel, Dog_User $user, $message)
 {
     echo "PG: {$message}\n";
     //		$server->sendPRIVMSG($channel->getName(), $user->getName().': '.$message);
     $server->getConnection()->sendRAW(sprintf("KICK %s %s :%s", $channel->getName(), $user->getName(), $message));
     $event = new self(array('lpg_uid' => $user->getID(), 'lpg_time' => time()));
     self::onBan($server, $channel, $user, $message);
 }
Beispiel #2
0
 public function onJoinTell(Dog_Server $server, Dog_User $user)
 {
     if ($user->isRegistered() && !$user->isLoggedIn()) {
         return;
     }
     $userid = $user->getID();
     if (0 == ($count = Dog_Note::countUnread($userid))) {
         return;
     }
     $username = $user->getName();
     if ($count == 1) {
         $user->sendPRIVMSG($this->lang('note1'));
     } else {
         $user->sendPRIVMSG($this->lang('note2'));
     }
     for ($i = 0; $i < $count; $i++) {
         $user->sendPRIVMSG($this->readNext($server, $user));
     }
 }
Beispiel #3
0
 public function play(Dog_User $user, $message)
 {
     $this->cmdtime = time();
     # Command
     $message = strtoupper($message);
     if (0 === preg_match('/^[ ,78910JQKA]+$/D', $message)) {
         return 'Error in play syntax!';
     }
     $cards = preg_split('/[, ]+/', $message);
     $pn = $this->current;
     $cc = $this->current_cards;
     # Identical cards?
     if (count(array_unique($cards)) !== 1) {
         return 'You have to play only 1 kind of a card.';
     }
     # Player has these cards?
     $acv = array_count_values($this->cards[$pn]);
     $check = $cards[0];
     if ($check > 0) {
         $check = (int) $check;
     }
     if (!isset($acv[$check]) || count($cards) > $acv[$check]) {
         return 'You don\'t have the right cards.';
     }
     # Cards are on table.
     if (count($cc) > 0) {
         # Played same ammount of cards:
         if (count($cc) !== count($cards)) {
             return 'You have to play the same number of cards';
         }
         # Are played cards higher?
         if (array_search($cc[0], self::$card_numbers) >= array_search($cards[0], self::$card_numbers)) {
             return sprintf('You have to play higher cards than %s.', implode(" ", $cc));
         }
     }
     #########################
     # All ok => play cards:
     foreach ($cards as $card) {
         $key = array_search($card, $this->cards[$pn]);
         unset($this->cards[$pn][$key]);
     }
     $this->cards[$pn] = array_values($this->cards[$pn]);
     $cards_left = count($this->cards[$pn]);
     $msg = sprintf('%s played %s and has %d cards left.', $user->getName(), implode(' ', $cards), $cards_left);
     $this->output($msg);
     # Player finished:
     if ($cards_left === 0) {
         $this->player_finished($user->getName());
         if (!$this->started) {
             return '';
         }
         if ($cards[0] == "A") {
             $this->current_cards = array();
         } else {
             $this->current_cards = $cards;
         }
         $this->beginner = $this->current;
         $this->output(sprintf('%s`s turn.', $this->players[$this->current]));
     } else {
         if ($cards[0] == "A") {
             $this->player_wins_round();
         } else {
             $this->current_cards = $cards;
             $this->beginner = $this->current;
             $this->next_player();
             $this->output(sprintf('%s`s turn.', $this->players[$this->current]));
         }
     }
     return '';
 }
Beispiel #4
0
 public static function createHuman(Dog_User $user)
 {
     $data = self::applyStartData(self::getPlayerData($user->getID(), $user->getSID()));
     $data['sr4pl_name'] = $user->getName();
     $human = new self($data);
     if (false === $human->insert()) {
         return false;
     }
     $human = self::reloadPlayer($human);
     // 		$human->setVar('sr4pl_uid', $user);
     $human->healHP(10000);
     $human->healMP(10000);
     $party = SR_Party::createParty();
     $party->addUser($human);
     $party->pushAction('outside', 'Redmond');
     return $human;
 }
Beispiel #5
0
 private function addToQueue(IWebSocketConnection $user, Dog_User $dog_user, $message)
 {
     $message = sprintf(":%s!%s@websocket %s", $dog_user->getName(), $dog_user->getName(), $message);
     echo "Adding {$message}\n";
     msg_send($this->queue_in, 1, $user->getId() . ':' . $message, false);
 }
Beispiel #6
0
 private function tryAutoLogin(Dog_Server $server, Dog_User $user)
 {
     if ($user->isRegistered()) {
         $username = $user->getName();
         if (in_array($server->getID(), $this->status, true)) {
             $this->sendNickservStatus($server, $username);
         } else {
             $server->getConnection()->sendRAW("WHOIS {$username}");
         }
     }
 }
Beispiel #7
0
 private function onPrivmsgB(Dog_Server $server, Dog_User $user, $link, $origin, $message)
 {
     echo __METHOD__ . "({$link})";
     $targets = explode(',', $link);
     $spam = false;
     foreach ($targets as $i => $target) {
         list($sid, $chan) = explode(':', $target);
         $sid2 = $server->getID();
         if ($origin === $chan && $sid == $sid2) {
             unset($targets[$i]);
             $spam = true;
         }
     }
     if (!$spam) {
         return;
     }
     $b = chr(2);
     $lamb = Lamb::instance();
     foreach ($targets as $target) {
         list($sid, $chan) = explode(':', $target);
         if (false === ($s = $lamb->getServer($sid))) {
             echo "Can not spam server {$sid}.\n";
             continue;
         }
         if (false === ($c = $s->getChannel($chan))) {
             echo "Can not spam server {$sid} channel {$chan}.\n";
             continue;
         }
         $s->sendPRIVMSG($chan, sprintf("<{$b}%s:%s{$b}>: %s", $server->getID(), $user->getName(), $message));
     }
 }