Exemplo n.º 1
0
 public function DoQuote($bbcode, $action, $name, $default, $params, $content)
 {
     if ($action == BBCODE_CHECK) {
         return true;
     }
     $text = Neuron_Core_Text::getInstance();
     $txtname = 'quote';
     $txtparams = array();
     if (isset($params['name'])) {
         $txtparams['name'] = htmlspecialchars(trim($params['name']));
         $txtname .= '_wrote';
         if (isset($params['date'])) {
             $date = strtotime($params['date']);
             $txtparams['date'] = date(DATETIME, $date);
             $txtname .= '_date';
         }
     } else {
         if (!is_string($default)) {
             // Do nothing
         } else {
             $txtparams['name'] = htmlspecialchars(trim($default));
             $txtname .= '_wrote';
         }
     }
     $title = Neuron_Core_Tools::putIntoText($text->get($txtname, 'textconvert', 'main', ""), $txtparams);
     $out = "\n<blockquote class=\"bbcode_quote\">\n";
     if (!empty($title)) {
         $out .= "<h4 class=\"bbcode_quote_head\">" . $title . "</h4>\n";
     }
     $out .= "<div class=\"bbcode_quote_body\">" . $content . "</div>\n</blockquote>\n";
     return $out;
 }
Exemplo n.º 2
0
 public function getContent($error = null)
 {
     $sUploadUrl = ABSOLUTE_URL . 'page/customsign/?sessionId=' . session_id();
     if (!file_exists(PUBLIC_PATH) || !is_writable(PUBLIC_PATH)) {
         return '<p>Error: ' . PUBLIC_PATH . ' does not exist or is not writeable.</p>';
     }
     if (!isset($this->village)) {
         return '<p class="false">No village defined.</p>';
     }
     $text = Neuron_Core_Text::getInstance();
     $text->setFile('premium');
     $text->setSection('bonusbuilding');
     $page = new Neuron_Core_Template();
     $page->set('upload_url', $sUploadUrl);
     $buildings = $this->getPublicBuildings();
     foreach ($this->getPublicBuildings() as $v) {
         $page->addListValue('buildings', $v);
     }
     $db = Neuron_DB_Database::getInstance();
     $login = Neuron_Core_Login::getInstance();
     $r = $db->query("\n\t\t\tSELECT\n\t\t\t\t*\n\t\t\tFROM\n\t\t\t\tplayers_tiles\n\t\t\tWHERE\n\t\t\t\tt_userid = {$login->getUserId()}\n\t\t\tORDER BY\n\t\t\t\tt_id DESC\n\t\t\tLIMIT\n\t\t\t\t8\n\t\t");
     $data = array();
     foreach ($r as $v) {
         if (file_exists(PUBLIC_PATH . $v['t_imagename'])) {
             $imagename = PUBLIC_URL . $v['t_imagename'];
             $action = new Dolumar_View_SelectBuildLocation(100, 'build bonus building', null, new Neuron_GameServer_Map_Display_Sprite($imagename), $v['t_id']);
             // selectBuildLocation (this, 100, null, 'placeholder', null, <?=$v['id']
             $page->addListValue('signs', array('id' => $v['t_id'], 'image_url' => PUBLIC_URL . $v['t_imagename'], 'credits' => self::CREDIT_COST, 'action' => $action->getAction()));
         }
     }
     if (isset($error)) {
         $page->set($error);
     }
     return $page->parse('dolumar/bonusbuilding/bonusbuilding.phpt');
 }
Exemplo n.º 3
0
 /**
  * @param Neuron_GameServer_Player $objUser
  */
 public function __construct(Neuron_GameServer_Player $objUser)
 {
     $this->objUser = $objUser;
     $this->objCredits = self::getPureCreditsObject();
     if (!$this->objCredits) {
         return;
     }
     if ($this->objUser->isEmailCertified()) {
         $this->objCredits->setEmail($this->getEmail());
     }
     $this->objCredits->setReferal($objUser->getReferal());
     foreach ($objUser->getOpenIDs() as $v) {
         $this->objCredits->addOpenID($v);
     }
     $container = isset($_SESSION['opensocial_container']) ? $_SESSION['opensocial_container'] : null;
     if (isset($container)) {
         $this->objCredits->setContainer($container);
     }
     $fullscreen = isset($_SESSION['fullscreen']) && $_SESSION['fullscreen'] ? 1 : 0;
     $this->objCredits->setFullscreen($fullscreen);
     $this->objCredits->setLanguage(Neuron_Core_Text::getInstance()->getCurrentLanguage());
     $this->objCredits->setUserId($objUser->getId());
     if (isset($_SESSION['birthday'])) {
         $this->objCredits->setBirthday($_SESSION['birthday']);
     }
     if (isset($_SESSION['gender'])) {
         $this->objCredits->setGender(strtolower($_SESSION['gender']) == 'm' ? 'male' : 'female');
     }
 }
Exemplo n.º 4
0
 public function getName()
 {
     $data = $this->getLogArray();
     //print_r ($data);
     $id = $data['building'];
     $race = Dolumar_Races_Race::getFromId($data['race']);
     list($locationX, $locationY) = array($data['x'], $data['y']);
     $level = $data['level'];
     $building = Dolumar_Buildings_Building::getBuilding($id, $race, $locationX, $locationY);
     if ($building) {
         $text = Neuron_Core_Text::getInstance();
         return $building->getName() . ' ' . $text->get('lvl', 'building', 'building') . ' ' . $level;
     } else {
         return 'Building not found: ' . print_r($data);
     }
 }
Exemplo n.º 5
0
 public function getContent()
 {
     $player = Neuron_GameServer::getPlayer();
     if ($player && $player->isPlaying()) {
         $page = new Neuron_Core_Template();
         // Check for welcome message
         if (isset($_SESSION['welcome_html'])) {
             $page->set('welcome', $_SESSION['welcome_html']);
         }
         $server = Neuron_GameServer_Server::getInstance();
         $txt = $server->getText('headline');
         $page->set('headline', isset($txt) ? Neuron_Core_Tools::output_text($txt) : null);
         $page->set('nickname', $player->getDisplayName());
         $page->set('isPremium', $player->isPremium());
         $page->set('date', date(DATE, $player->getPremiumEndDate()));
         $page->set('isFreePremium', !$player->isProperPremium());
         $msg = Neuron_GameServer_Mappers_CachedChatMapper::getInstance();
         $messages = $msg->countUnreadMessages($player);
         $page->set('inbox', $messages);
         $clans = $player->getClans();
         $page->set('hasclan', count($clans) > 0);
         if (count($clans) > 0) {
             $objlogs = Dolumar_Players_ClanLogs::getInstance();
             $objlogs->clearMyVillages();
             foreach ($player->getVillages() as $village) {
                 $objlogs->addMyVillage($village);
             }
             $logs = $objlogs->getClanLogs($clans, 0, 3);
             foreach ($logs as $v) {
                 $page->addListValue('logs', array('date' => date(DATETIME, $v['timestamp']), 'text' => $objlogs->getLogText($v)));
             }
         }
         // Fetch thze news
         if (defined('GAMENEWS_RSS_URL')) {
             $text = Neuron_Core_Text::getInstance();
             $localized_link = str_replace('{lang}', $text->getCurrentLanguage(), GAMENEWS_RSS_URL);
             $rss = new Neuron_Core_RSSParser($localized_link);
             $rss->setCache(Neuron_Core_Cache::getInstance('newsfeed/'));
             foreach ($rss->getItems(3) as $v) {
                 $page->addListValue('gamenews', array('date' => $v['date'] ? date(DATETIME, $v['date']) : null, 'title' => $v['title'], 'url' => $v['url']));
             }
         }
         return $page->parse('dolumar/welcome/welcome.phpt');
     }
     return false;
 }
Exemplo n.º 6
0
 private function getSend()
 {
     $text = Neuron_Core_Text::getInstance();
     $page = new Neuron_Core_Template();
     $player = Neuron_GameServer::getPlayer();
     $results = $player->invitePeople('runesender', 'gifts', 'runereceiver', 'gifts');
     if ($results['success']) {
         if (!empty($results['iframe'])) {
             $width = isset($results['width']) ? $results['width'] : 500;
             $height = isset($results['height']) ? $results['height'] : 400;
             $this->closeWindow();
             Neuron_GameServer::getInstance()->openWindow('Iframe', array('title' => $text->get('gifts', 'menu', 'main'), 'url' => $results['iframe'], 'width' => $width, 'height' => $height));
         } else {
             return $page->parse('dolumar/gifts/done.phpt');
         }
     } else {
         return '<p class="false">' . $results['error'] . '</p>';
     }
 }
Exemplo n.º 7
0
 private function getResults()
 {
     $input = $this->getInputData();
     if (isset($input['search']) && $input['search'] == 'result') {
         $db = Neuron_DB_Database::getInstance();
         $count = $this->getCountQuery();
         if (empty($count)) {
             $text = Neuron_Core_Text::getInstance();
             $this->alert($text->get('notEnoughFields', 'form', 'search'));
             return false;
         }
         $amount = $db->query($count);
         $total = $amount[0]['amount'];
         $page = new Neuron_Core_Template();
         $limit = Neuron_Core_Tools::splitInPages($page, $total, isset($input['page']) ? $input['page'] : 0, $this->perpage, 10, $input, 'searchplayers');
         $query = $this->getSearchQuery($limit);
         $this->printResults($page, $db->query($query));
         return $page->parse('search/results.phpt');
     }
     return false;
 }
 public function getContent()
 {
     $text = Neuron_Core_Text::getInstance();
     $player = Neuron_GameServer::getPlayer();
     if (!$player) {
         return $this->throwError($text->get('login', 'login', 'account'));
     }
     $page = new Neuron_Core_Template();
     $page->set('nickname', '');
     // Ignore a player.
     $input = $this->getInputData();
     $nickname = isset($input['nickname']) ? $input['nickname'] : null;
     if (!empty($nickname)) {
         $target = Neuron_GameServer_Player::getFromName($nickname);
         if ($target && $target->getId() == $player->getId()) {
             $page->set('error', 'ignore_yourself');
         } else {
             if ($target) {
                 $player->setIgnoring($target);
             } else {
                 $page->set('nickname', $nickname);
                 $page->set('error', 'player_not_found');
             }
         }
     }
     // Unignore a player
     if (isset($input['unignore'])) {
         $target = Neuron_GameServer::getPlayer($input['unignore']);
         if ($target) {
             $player->setIgnoring($target, false);
         }
     }
     foreach ($player->getIgnoredPlayers() as $v) {
         $page->addListValue('players', array('id' => $v->getId(), 'name' => Neuron_Core_Tools::output_varchar($v->getName())));
     }
     return $page->parse('gameserver/account/ignorelist.phpt');
 }
Exemplo n.º 9
0
 public function getBody()
 {
     $myself = Neuron_GameServer::getPlayer();
     if (!$myself->isAdmin()) {
         return '<p>You are not allowed to execute the commands. Only admins are.</p>';
     }
     $page = new Neuron_Core_Template();
     $login = Neuron_Core_Login::getInstance();
     if (!$login->isLogin()) {
         $userid = 0;
     } else {
         $userid = $login->getUserId();
     }
     $text = Neuron_Core_Text::getInstance();
     $content = array();
     foreach ($text->getLanguages() as $v) {
         $page->addListValue('languages', $v);
         $content[$v] = array('title' => Neuron_Core_Tools::getInput('_POST', 'title_' . $v, 'varchar'), 'description' => Neuron_Core_Tools::getInput('_POST', 'description_' . $v, 'varchar'));
     }
     if (isset($_FILES['imagefile'])) {
         $im = $this->getImageFromInput($_FILES['imagefile']);
         if ($im) {
             $new = $this->getGeneratedImage($im);
             if (!is_dir(PUBLIC_PATH . 'signs/')) {
                 mkdir(PUBLIC_PATH . 'signs/');
                 chmod(PUBLIC_PATH . 'signs/', 0755);
             }
             $filename = $userid . '_' . date('dmYHis') . '.png';
             imagepng($new, PUBLIC_PATH . 'signs/' . $filename);
             chmod(PUBLIC_PATH . 'signs/' . $filename, 0755);
             $db = Neuron_DB_Database::getInstance();
             $db->query("\n\t\t\t\t\tINSERT INTO\n\t\t\t\t\t\tplayers_tiles\n\t\t\t\t\tSET\n\t\t\t\t\t\tt_userid = " . intval($userid) . ",\n\t\t\t\t\t\tt_imagename = 'signs/" . $db->escape($filename) . "',\n\t\t\t\t\t\tt_isPublic = 1,\n\t\t\t\t\t\tt_description = '{$db->escape(json_encode($content))}'\n\t\t\t\t");
         }
     }
     return $page->parse('dolumar/pages/admin/bonusbuilding/bonusbuilding.phpt');
 }
Exemplo n.º 10
0
 private function getCounterHTML()
 {
     $text = Neuron_Core_Text::getInstance();
     // Loop trough the list
     $p = '';
     $l = '';
     $showVillageName = $this->bShowVillageNames;
     asort($this->counters);
     foreach ($this->counters as $v) {
         // Can speed up?
         if (isset($v[5])) {
             $s = ' <a class="speedup" href="javascript:void(0);" onclick="openWindow(\'Speedup\', ' . htmlentities(json_encode($v[5])) . ');">' . $text->get('speedup', 'status', 'statusbar') . '</a>';
         } else {
             $s = '';
         }
         if ($v[0] > time()) {
             if ($showVillageName || $v[4]) {
                 $p .= '<li class="' . $v[3] . '">[' . Neuron_Core_Tools::getCountdown($v[0]) . '] ' . $v[1] . ': ' . $v[2] . $s . '</li>';
             } else {
                 $p .= '<li class="' . $v[3] . '">[' . Neuron_Core_Tools::getCountdown($v[0]) . '] ' . $v[2] . $s . '</li>';
             }
         } elseif ($v[0] === null) {
             if ($showVillageName || $v[4]) {
                 $l .= '<li class="' . $v[3] . '">' . $v[1] . ': ' . $v[2] . $s . '</li>';
             } else {
                 $l .= '<li class="' . $v[3] . '">' . $v[2] . $s . '</li>';
             }
         }
     }
     return '<ul class="statusbar">' . $p . $l . '</ul>';
 }
Exemplo n.º 11
0
 private function getAttackVillage($target)
 {
     $text = Neuron_Core_Text::getInstance();
     // Cannot attack yourself.
     if ($target->getOwner()->equals($this->village->getOwner())) {
         return $this->getChooseUnits($target);
     }
     $canAttack = true;
     if ($target->getOwner()->isClanMember($this->village->getOwner())) {
         $this->error = $text->get('isClanmember', 'challenge', 'battle');
         $canAttack = false;
     }
     $input = $this->getInputData();
     $confirmed = isset($input['confirm']) ? $input['confirm'] == 'yes' : false;
     $squads = $this->getSquadsFromInput($target);
     $specials = $this->getSpecialUnitsFromInput();
     if ($confirmed && count($squads) > 0 && $canAttack) {
         if ($this->village->attackVillage($target, $squads, $specials)) {
             reloadStatusCounters();
             return '<p>' . $text->get('bdone', 'challenge', 'battle') . '</p>';
         } else {
             return $this->getChooseSpecialUnits($target, $squads, $this->village->getError());
         }
     } elseif (count($squads) > 0) {
         return $this->getChooseSpecialUnits($target, $squads);
     } else {
         $text = Neuron_Core_Text::getInstance();
         if (isset($input['selected_troops'])) {
             $this->alert($text->get('dragTroops', 'challenge', 'battle'));
         }
         return $this->getChooseUnits($target);
     }
 }
Exemplo n.º 12
0
 private function getDefaultChannel()
 {
     $text = Neuron_Core_Text::getInstance();
     return '#' . $text->getCurrentLanguage();
 }
Exemplo n.º 13
0
 private function getCost($item)
 {
     $text = Neuron_Core_Text::getInstance();
     return Neuron_Core_Tools::putIntoText($text->get('cost', 'crafting', 'buildings'), array($item->getName(), $item->getCraftCost_text($this->getVillage())));
 }
Exemplo n.º 14
0
 public function processInput()
 {
     $login = Neuron_Core_Login::getInstance();
     $text = Neuron_Core_Text::getInstance();
     $input = $this->getInputData();
     if ($login->isLogin()) {
         if (isset($input['message'])) {
             $message = trim($input['message']);
             if (!empty($message)) {
                 $user = Neuron_GameServer::getPlayer();
                 if (!$user->isPlaying()) {
                     $this->alert($text->get('registerfirst'));
                 } elseif (!$user->isEmailVerified()) {
                     $this->alert($text->get('validateEmail_short', 'main', 'account'));
                 } elseif ($user->isBanned('chat')) {
                     $end = $user->getBanDuration('chat');
                     $duration = Neuron_Core_Tools::getCountdown($end);
                     $this->alert(Neuron_Core_Tools::putIntoText($text->get('banned'), array('duration' => $duration)));
                 } else {
                     // Post message
                     $this->postMessage($input['message']);
                 }
             }
         }
     }
     // Check for input: load older messages
     if (isset($input['loadprevious'])) {
         $before = $input['loadprevious'];
         if ($html = $this->getOlderMessages($before)) {
             $this->addHtmlToElement('messagecontainer', $html, 'top');
         } else {
             $this->addHtmlToElement('messagecontainer', '<div></div>', 'top');
         }
     }
     // If not using blocking, we can "safely" process it right now
     if (!self::USE_BLOCKING) {
         $this->getRefresh();
     }
 }
Exemplo n.º 15
0
 public function sendNewsletter($newsletter, $data)
 {
     $text = Neuron_Core_Text::getInstance();
     $credits = Neuron_GameServer_Credits::getPureCreditsObject();
     $plaintext = $text->getTemplate('newsletters/' . $newsletter, $data);
     $subject = Neuron_Core_Tools::putIntoText($text->get($newsletter, 'subjects', 'newsletters'), $data);
     // Now put it in html
     $page = new Neuron_Core_Template();
     $page->set('subject', $subject);
     $page->set('content', Neuron_Core_Tools::output_text($plaintext));
     $content = $page->parse('mailtemplate.phpt');
     //echo $page->parse ('mailtemplate.phpt');
     //exit;
     $credits->sendNewsletter($subject, $content, $plaintext, 'en');
 }
Exemplo n.º 16
0
 public function getContent()
 {
     $guide_img = IMAGE_URL . 'characters/guide.png';
     $guide_icon_img = IMAGE_URL . 'characters/guide-icon.png';
     $text = Neuron_Core_Text::getInstance();
     $player = Neuron_GameServer::getPlayer();
     $input = $this->getInputData();
     $page = isset($input['page']) ? $input['page'] : null;
     if (isset($input['action'])) {
         switch ($input['action']) {
             case 'show':
                 $this->updateRequestData(array('display' => 'show'));
                 break;
             case 'hide':
                 $this->updateRequestData(array('display' => 'hide'));
                 break;
         }
     }
     $data = $this->getRequestData();
     $openup = false;
     if (isset($data['display']) && $data['display'] == 'show' || ($openup = $player && $this->hasUnreadMessages($player))) {
         $txt = $this->getRightMessage($page);
         $page = $txt['page'];
         $lastrec = isset($data['record']) ? $data['record'] : 0;
         if (!empty($txt['highlight']) && $txt['record'] != $lastrec) {
             $this->highlight($txt['highlight']);
         }
         $this->updateRequestData(array('display' => 'show', 'record' => $txt['record']));
         $hide_url = Neuron_URLBuilder::getInstance()->getUpdateUrl('Guide', $text->get('hide', 'navigation', 'guide'), array('action' => 'hide'), $text->get('hide', 'navigation', 'guide'));
         $next_url = false;
         $previous_url = false;
         if ($page > 0) {
             $next_url = Neuron_URLBuilder::getInstance()->getUpdateUrl('Guide', $text->get('next', 'navigation', 'guide'), array('page' => $page - 1), $text->get('shownext', 'navigation', 'guide'));
         }
         if ($player && $this->hasPrevious($player, $page)) {
             $previous_url = Neuron_URLBuilder::getInstance()->getUpdateUrl('Guide', $text->get('previous', 'navigation', 'guide'), array('page' => $page + 1), $text->get('showprevious', 'navigation', 'guide'));
         }
         $out = '<blockquote class="bubble triangle-right right">' . $txt['html'] . '<ul class="navigation">';
         if ($previous_url) {
             $out .= '<li>' . $previous_url . '</li>';
         }
         if ($next_url) {
             $out .= '<li>' . $next_url . '</li>';
         }
         if ($page < 1) {
             $out .= '<li>' . $hide_url . '</li>';
         }
         $out .= '</ul>' . '</blockquote><div class="avatar ' . $txt['class'] . '"></div>';
         return $out;
     } else {
         $url = Neuron_URLBuilder::getInstance()->getUpdateUrl('Guide', '<span>' . $text->get('callguide', 'navigation', 'guide') . '</span>', array('action' => 'show'), $text->get('callguide', 'navigation', 'guide'));
         return '<div class="icon">' . $url . '</div>';
     }
 }
Exemplo n.º 17
0
 private function getTextKey($key)
 {
     $text = Neuron_Core_Text::getInstance();
     if (!isset($key)) {
         return $text->getCurrentLanguage();
     }
     return $key;
 }
Exemplo n.º 18
0
 private function prcAttack(Dolumar_Underworld_Models_Army $target = null)
 {
     $text = Neuron_Core_Text::getInstance();
     if (!isset($target)) {
         $target = Dolumar_Underworld_Mappers_ArmyMapper::getFromId($this->getInput('target'), $this->getServer()->getMap());
         if (!isset($target)) {
             $this->alert('Invalid input, target not found.');
         }
     }
     if (!$this->army->isEnemy($target)) {
         $this->alert('Invalid input: not an enemy.');
     }
     $confirmed = $this->getInput('confirmed');
     // Dialog to confirm
     if (!$confirmed == '1') {
         $this->dialog(Neuron_Core_Tools::putIntoText($text->get('attack', 'squad', 'underworld'), array($target->getDisplayName())), $text->get('dyes', 'main', 'main'), "windowAction (this, {'id':" . $this->army->getId() . ",'action':'attack','confirmed':1,'target':" . $target->getId() . "});", $text->get('dno', 'main', 'main'), 'void(0);');
     } else {
         if (!$this->army->attack($this->me, $target)) {
             $this->alert($this->army->getError());
         }
     }
 }
Exemplo n.º 19
0
 private function getMissionOverview($input)
 {
     if (isset($input['id'])) {
         $mission = Dolumar_Underworld_Mappers_MissionMapper::getFromId($input['id']);
     }
     if (!isset($mission)) {
         return '<p class="false">Mission not found.</p>';
     }
     $text = Neuron_Core_Text::getInstance();
     $page = new Neuron_Core_Template();
     $page->set('id', $mission->getId());
     $page->set('mission', $mission->getName());
     $page->set('openmission', Neuron_URLBuilder::getInstance()->getOpenUrl('Underworld', $text->get('openmission', 'clanportal', 'buildings'), array('id' => $mission->getId()), null, $mission->getUrl()));
     $page->set('return', Neuron_URLBuilder::getInstance()->getUpdateUrl('Building', $text->get('return', 'clanportal', 'buildings'), array('action' => 'overview')));
     // Get free regiments
     $units = array();
     $addunits = array();
     $unitsdata = $this->getVillage()->getSquads(false, true, true);
     foreach ($unitsdata as $v) {
         if (!$v->isIdle()) {
             continue;
         }
         $add = true;
         // Check for adding
         if (isset($input['unit_' . $v->getId()]) && $input['unit_' . $v->getId()]) {
             $addunits[] = $v;
             $add = false;
         }
         if ($add) {
             $units[] = array('id' => $v->getId(), 'name' => $v->getDisplayName());
         }
     }
     // The spawnpionts
     $side = $mission->getPlayerSide(Neuron_GameServer::getPlayer());
     $spawnpoints = $mission->getSpawnpoints($side);
     // Group the spawnpoints
     $groupedspawnpoints = array();
     foreach ($spawnpoints as $v) {
         if (!isset($groupedspawnpoints[$v->getGroup()->getId()])) {
             $groupedspawnpoints[$v->getGroup()->getId()] = $v->getGroup();
         }
     }
     $page->set('spawnpoints', $groupedspawnpoints);
     // Add the units
     if (count($addunits) > 0) {
         $spanwpointId = null;
         if (isset($input['spawnpoint'])) {
             $spanwpointId = $input['spawnpoint'];
         }
         $army = $mission->addSquads(Neuron_GameServer::getPlayer(), $side, $addunits, $spanwpointId);
     }
     $page->set('units', $units);
     return $page->parse('buildings/clanportals_mission.phpt');
 }
Exemplo n.º 20
0
 private function getBuyResources()
 {
     $text = Neuron_Core_Text::getInstance();
     $input = $this->getInputData();
     $player = Neuron_GameServer::getPlayer();
     $page = new Neuron_Core_Template();
     $villages = $player->getVillages();
     if (count($villages) === 1) {
         $input['village'] = $villages[0]->getId();
     }
     $village = $player->getMyVillage(isset($input['village']) ? $input['village'] : false);
     if ($village) {
         $res = $village->resources->getResources();
         $income = $village->resources->getIncome();
         $capacity = $village->resources->getCapacity();
         $consumption = $village->resources->getUnitConsumption();
         $bruto = $village->resources->getBrutoIncome();
         foreach ($res as $k => $v) {
             $data = array('action' => 'buyresources', 'village' => $village->getId(), 'resource' => $k);
             $page->addListValue('resources', array(ucfirst($text->get($k, 'resources', 'main')), $v, $capacity[$k], $income[$k], 'resource' => $k, 'bruto' => isset($bruto[$k]) ? $bruto[$k] : 0, 'consuming' => isset($consumption[$k]) ? $consumption[$k] : 0, 'fillup' => htmlentities($player->getCreditUseUrl(self::COST_RESOURCES_ONE, $data, 'Fill resources')), 'cost' => $this->convertCredits(self::COST_RESOURCES_ONE), 'full' => $v >= $capacity[$k]));
         }
         $data = array('action' => 'buyresources', 'village' => $village->getId(), 'resource' => 'all');
         $page->set('costAll', $this->convertCredits(self::COST_RESOURCES_ALL));
         $page->set('fillup_all', htmlentities($player->getCreditUseUrl(self::COST_RESOURCES_ALL, $data, 'Fill all resources')));
         $page->set('fillup_all_cost', $this->convertCredits(self::COST_RESOURCES_ALL));
         return $page->parse('dolumar/premium/buyresources.phpt');
     } else {
         foreach ($villages as $v) {
             $page->addListValue('villages', array('id' => $v->getId(), 'name' => Neuron_Core_Tools::output_varchar($v->getName())));
         }
         $page->set('village', isset($village) && $village ? $village->getId() : $player->getCurrentVillage()->getId());
         $page->set('action', 'buyresources');
         return $page->parse('dolumar/premium/selectvillage.phpt');
     }
 }
Exemplo n.º 21
0
 public function getName()
 {
     $text = Neuron_Core_Text::getInstance();
     return $text->get('report', 'general', 'effects');
 }
Exemplo n.º 22
0
 protected function doCastSpell($objUnit, $objSpell, $objTarget, $visible = true)
 {
     // Just feed the random number generator, just to be sure.
     mt_srand();
     $page = new Neuron_Core_Template();
     $text = Neuron_Core_Text::getInstance();
     $page->setTextSection('result', $this->sTextFile);
     // Now let's start the checking
     $cost = $objSpell->getCost($objUnit, $objTarget);
     if ($this->village->resources->takeResourcesAndRunes($cost)) {
         $dif = $this->getProbability($objUnit, $objSpell, $objTarget);
         $rand = mt_rand(0, 100);
         $objSpell->setVillage($this->village);
         $objSpell->setTarget($objTarget);
         $objSpell->prepare();
         // Some spells are not castable for some reason.
         if (!$objSpell->isCastable()) {
             $page->set('success', false);
             $page->set('message', $text->get($objSpell->getError(), 'errors', $this->sTextFile));
         } else {
             if ($rand < $dif) {
                 $objSpell->execute($visible);
                 reloadStatusCounters();
                 $page->set('success', true);
                 $page->set('message', $objSpell->getSuccessMessage());
                 // Call the trigger!
                 $objUnit->onSuccess();
                 // Update request data (to return to overview)
                 //$this->updateRequestData (array ('building' => $'village' => $this->village->getId ()));
                 $page->set('extra', $objSpell->getExtraContent());
                 $success = true;
             } else {
                 $page->set('success', false);
                 $page->set('message', $objSpell->getFailedMessage());
                 // Call the trigger!
                 $objUnit->onFail();
                 if ($objUnit->isAlive()) {
                     $page->set('retry', true);
                     $page->set('inputData', $this->getInputData());
                 }
                 $success = false;
             }
             $toTarget = $success || !$visible;
             if (!$success) {
                 $visible = true;
             }
             $objTarget = $objSpell->getTarget();
             $log = Dolumar_Players_Logs::getInstance();
             $log->addEffectLog($objTarget, $objSpell, $this->village, $success, $visible, $toTarget, $this->sTextFile);
             reloadEverything();
         }
     } else {
         $page->set('success', false);
         $page->set('error', 'err_resources');
     }
     return $page->parse('magic/result.phpt');
 }
Exemplo n.º 23
0
 protected function getChannelName()
 {
     $language = Neuron_Core_Text::getInstance();
     return 'public:' . $language->getCurrentLanguage();
 }
Exemplo n.º 24
0
 private function getChooseAmount($target)
 {
     $page = new Neuron_Core_Template();
     $text = Neuron_Core_Text::getInstance();
     $tab = isset($this->aInput['tab']) ? $this->aInput['tab'] : 'resources';
     switch ($tab) {
         case 'resources':
         case 'runes':
         case 'equipment':
             break;
         default:
             $tab = 'resources';
             break;
     }
     $this->setTabUrl($page, 'resources', $target);
     $this->setTabUrl($page, 'runes', $target);
     $this->setTabUrl($page, 'equipment', $target);
     $page->set('target', $target->getId());
     $page->set('tab', $tab);
     switch ($tab) {
         case 'resources':
             $res = $this->getVillage()->resources->getResources();
             foreach ($res as $k => $v) {
                 $page->addListValue('resources', array('name' => $k, 'amount' => 0, 'available' => $v));
             }
             break;
         case 'runes':
             $runes = $this->getVillage()->resources->getRunes();
             foreach ($runes as $k => $v) {
                 $page->addListValue('runes', array('name' => $k, 'amount' => 0, 'available' => $v));
             }
             break;
         case 'equipment':
             $equipment = $this->getVillage()->equipment->getEquipment();
             $output = array();
             foreach ($equipment as $type => $vv) {
                 $output[$type] = array('name' => $text->get($type, 'types', 'equipment'), 'equipment' => array());
                 foreach ($vv as $v) {
                     $output[$type]['equipment'][] = array('id' => $v->getId(), 'name' => $v->getName(true), 'amount' => 0, 'available' => $v->getAmount(), 'formid' => 'equipment_' . $v->getId());
                 }
             }
             $page->set('equipment', $output);
             break;
     }
     $page->set('canTrade', $this->isValidTarget($target, $tab));
     $page->set('tradeerror', Neuron_Core_Tools::putIntoText($text->get($this->sError, 'market', 'buildings', $this->sError), array('percentage' => self::MAX_PERCENTAGE)));
     return $page->parse('buildings/market.phpt');
 }
Exemplo n.º 25
0
 private function processTrainUnits($unit, $amount, $queue = false)
 {
     // Get resources
     $village = $this->getVillage();
     $res = $unit->multiplyCost($unit->getTrainingCost(), $amount);
     // Check building capacity and income etc
     $capacity = $this->getVillage()->getUnitCapacity($this, 'absolute');
     $currentUnits = $this->getVillage()->getUnitBuildingCount($this, 'absolute');
     // Add the new amount
     $currentUnits += $amount * $unit->getRequiredSpace();
     $success = false;
     if ($queue) {
         $success = true;
         $this->getVillage()->premium->addQueueAction('training', array('building' => $this->getId(), 'unit' => $unit->getUnitId(), 'amount' => $amount));
         reloadStatusCounters();
     } elseif ($currentUnits > $capacity) {
         $this->myErrors[] = 'noRoom';
     } elseif (!$village->resources->takeResourcesAndRunes($res)) {
         $this->myErrors[] = 'noResources';
     } else {
         $village->trainUnits($unit, $amount, $this);
         $village->reloadUnits();
         $success = true;
     }
     if (!$success) {
         $text = Neuron_Core_Text::getInstance();
         $error = $this->myErrors[count($this->myErrors) - 1];
         $txterr = $text->get($error, 'training', 'buildings');
         $jsondata = json_encode(array('amount' => $amount, 'unit' => $unit->getClassName(), 'queue' => true));
         // Propose a queued solution.
         $this->objWindow->dialog($txterr, $text->get('queueTraining', 'training', 'buildings'), 'windowAction (this, ' . $jsondata . ');', $text->get('okay', 'main', 'main'), 'void(0);');
     }
     return $success;
 }
Exemplo n.º 26
0
 private function getSpeedUpBuilding($data)
 {
     $text = Neuron_Core_Text::getInstance();
     $inputData = $this->getInputData();
     $id = isset($data['building']) ? $data['building'] : null;
     $building = Dolumar_Buildings_Building::getFromId($id);
     if (!$building) {
         return '<p>Invalid input: building not found: ' . $id . '</p>';
     }
     $price = PREMIUM_SPEEDUP_BUILDINGS_PRICE;
     $unit = PREMIUM_SPEEDUP_BUILDINGS_UNIT;
     if (isset($inputData['duration'])) {
         $selected = abs(intval($inputData['duration']));
         $desc = Neuron_Core_Tools::putIntoText($text->get('confdesc_building', 'speedup', 'statusbar'), array('building' => $building->getName(), 'amount' => Neuron_Core_Tools::getDurationText($selected * $unit)));
         return $this->getConfirm($price, $unit, $selected, $desc);
     }
     $time = $building->getTimeLeft();
     return $this->getSpeedUpHTML('building', $time, $price, $unit);
 }
Exemplo n.º 27
0
 private function getTranslatedContent($content, $tkey)
 {
     $text = Neuron_Core_Text::getInstance();
     $key = $text->getCurrentLanguage();
     $dkey = 'en';
     if (isset($content[$key]) && !empty($content[$key][$tkey])) {
         return $content[$key][$tkey];
     } elseif (isset($content[$dkey]) && !empty($content[$dkey][$tkey])) {
         return $content[$dkey][$tkey];
     }
     return null;
 }
Exemplo n.º 28
0
             //}
         } else {
             header('WWW-Authenticate: Basic realm="Profile Logs"');
             header('HTTP/1.0 401 Unauthorized');
             echo 'Please login to access your profile logs.';
             exit;
         }
         break;
     case 'messagebundle':
         /*
         $output_type = 'xml';
         $xml_name = 'messagebundle';
         $xml_version = null;
         */
         header('Content-type: text/xml');
         $text = Neuron_Core_Text::getInstance();
         echo Neuron_Core_MessageBundle::text2bundle($text);
         exit;
         break;
     case 'getsession':
         session_write_close();
         session_start();
         $id = session_id();
         echo $id;
         exit;
         break;
     default:
         $output['content'] = array();
         break;
 }
 $pgen->stop();
Exemplo n.º 29
0
 /**
  * @param $user
  * @param bool $cookies
  * @param string $email
  * @return bool
  * @throws Neuron_Exceptions_InvalidParameter
  */
 public function doLogin($user, $cookies = false, $email = null)
 {
     $server = Neuron_GameServer::getServer();
     if (!$server->isOnline()) {
         $this->warning = 'server_not_online';
         return false;
     }
     if (!is_object($user) && is_numeric($user)) {
         $user = Neuron_GameServer::getPlayer(intval($user));
     }
     /**
      * @var Neuron_GameServer_Player $user
      */
     // Login is accepted
     if ($user) {
         if ($email) {
             $user->setEmail($email);
         }
         $admins = getAdminUserEmailAddresses();
         $email = strtolower($user->getEmail());
         if (isset($admins[$email]) && $user->getAdminStatus() !== $admins[$email]) {
             $user->setAdminStatus($admins[$email]);
         }
         $_SESSION['just_logged_in'] = true;
         $this->uid = $user->getId();
         $this->name = $user->getNickname();
         $_SESSION['plid'] = $this->uid;
         $this->logLogin($this->uid);
         // Set the cookies
         if ($cookies) {
             setcookie('dolumar_plid' . $this->level, $this->uid, time() + COOKIE_LIFETIME, '/');
             setcookie('dolumar_pass' . $this->level, $user->getPasswordHash(), time() + COOKIE_LIFETIME, '/');
         }
         // Set current language
         $text = Neuron_Core_Text::getInstance();
         $user->setLanguage($text->getCurrentLanguage());
         return true;
     } else {
         $this->warning = 'user_not_found';
         return false;
     }
 }