示例#1
0
 protected function onSendNotifications(BrowserGamesHub_Notification $notification)
 {
     foreach ($this->getVillages() as $v) {
         $loc = $v->buildings->getTownCenterLocation();
         $width = 600;
         $height = 400;
         $zoom = mt_rand(50, 100);
         $loc[0] += mt_rand(0, 10) - 5;
         $loc[1] += mt_rand(0, 10) - 5;
         $notification->addImage(ABSOLUTE_URL . 'image/snapshot/?zoom=' . $zoom . '&x=' . $loc[0] . '&y=' . $loc[1] . '&width=' . $width . '&height=' . $height, $v->getName(), ABSOLUTE_URL . '#' . $loc[0] . ',' . $loc[1]);
     }
 }
 private function sendOpenIDNotifications($msg, $txtMsgKey, $txtMsgSection, $inputData, $objSender, $isPublic)
 {
     // First: load this users OpenID notification urls
     $db = Neuron_DB_Database::__getInstance();
     $openid_rows = Neuron_GameServer_Mappers_PlayerMapper::getOpenIDs($this);
     if (count($openid_rows) > 0) {
         $text = $this->getRightLanguage();
         // Load OpenID accounts and send Browser Games Hub notifications
         $objNot = new BrowserGamesHub_Notification($msg, time(), $text->getCurrentLanguage());
         $objNot->setIcon(STATIC_URL . 'icon.png');
         $objNot->setId($txtMsgSection, $txtMsgKey);
         $objNot->setTargetData($this->getBrowserBasedGamesData());
         if ($objSender instanceof Dolumar_Players_Player) {
             $objNot->setSenderData($objSender->getBrowserBasedGamesData());
         }
         // Keep in mind that the notification does not like actual names,
         // so we will replace all key names with their numeric value.
         $keys = array_keys($inputData);
         $replace_keys = array();
         foreach ($keys as $k => $v) {
             if ($v != 'actor') {
                 $replace_keys[$v] = '{' . $k . '}';
             } else {
                 $replace_keys[$v] = '{target}';
             }
         }
         $objNot->setSkeleton(Neuron_Core_Tools::putIntoText($text->get($txtMsgKey, $txtMsgSection, 'notifications'), $replace_keys));
         $desc = $text->get($txtMsgKey . '_long', $txtMsgSection, 'notifications', '');
         if (!empty($desc)) {
             $objNot->setDescription(Neuron_Core_Tools::putIntoText($desc, $replace_keys));
         }
         // Take all the value strings and put them in there aswell
         foreach ($inputData as $v) {
             if ($v instanceof Dolumar_Players_Player) {
                 $objNot->addArgument($v->getName(), 'user', $v->getBrowserBasedGamesData());
             } elseif ($v instanceof Neuron_GameServer_Interfaces_Logable) {
                 $objNot->addArgument($v->getName(), 'text');
             } else {
                 $objNot->addArgument($v, 'text');
             }
         }
         // Visibliity
         $objNot->setVisibility($isPublic ? 'public' : 'private');
         $this->onSendNotifications($objNot);
         // Send the notification
         foreach ($openid_rows as $v) {
             $objNot->send($v['notify_url']);
         }
     }
 }