public function getContent($msg = null, $failed = false) { $myself = Neuron_GameServer::getPlayer(); if (!$this->village->isActive() || $this->village->getOwner()->getId() != $myself->getId()) { return false; } $page = new Neuron_Core_Template(); $page->setTextSection('formation', 'battle'); // Load battle slots $slots = $this->village->getDefenseSlots(); // Load your units $squads = $this->village->getSquads(false, false, false); // See how much rows that is $rows = $this->countRows($squads, $slots); $page->set('rows', $rows); $page->set('slots', $slots); if (!empty($msg)) { $page->set('message', $msg); $page->set('error', $failed); } foreach ($squads as $v) { if ($v->getUnitsAmount() > 0) { $page->addListValue('squads', array('sName' => Neuron_Core_Tools::output_varchar($v->getName()), 'oUnits' => $v->getUnits(), 'id' => $v->getId())); } } return $page->parse('battle/formation.phpt'); }
public function getContent() { $me = Neuron_GameServer::getPlayer(); $text = Neuron_Core_Text::__getInstance(); $text->setFile('unit'); $text->setSection('equipment'); if ($this->village && $this->village->isActive() && $this->village->getOwner() && $this->village->getOwner()->getId() == $me->getId()) { $page = new Neuron_Core_Template(); $page->set('noItems', $text->get('noItems')); $page->set('available', $text->get('available')); $page->set('total', $text->get('total')); $equipment = $this->village->getEquipment(); $yourEquipment = array(); foreach ($equipment as $type => $items) { if (count($items) > 0) { $yourEquipment[$type] = array('type' => $text->get($type, 'types', 'equipment'), 'items' => array()); foreach ($items as $item) { $yourEquipment[$type]['items'][] = array($item->getName(true), $item->getAvailableAmount(), $item->getAmount(), Neuron_Core_Tools::output_text($item->getStats_text())); } } } $page->set('equipment', $yourEquipment); return $page->parse('equipment.tpl'); } else { return '<p class="false">' . $text->get('login', 'login', 'account') . '</p>'; } }
public function getContent($error = null) { $text = Neuron_Core_Text::__getInstance(); $text->setFile('account'); $text->setSection('premium'); $player = Neuron_GameServer::getPlayer(); if (!$player) { return '<p class="false">' . $text->get('login', 'login', 'account') . '</p>'; } $openid = isset($_SESSION['neuron_openid_identity']) ? md5($_SESSION['neuron_openid_identity']) : false; if ($player && $player->isFound() && ($player->isEmailCertified() || $openid)) { $page = new Neuron_Core_Template(); // Premium account stuff $page->set('premium', $text->get('premium', 'myAccount')); if ($player->isPremium()) { $page->set('premiumLast', Neuron_Core_Tools::putIntoText($text->get('premiumLast', 'myAccount'), array(date(DATETIME, $player->getPremiumEndDate())))); $page->set('extend2', $text->getClickTo($text->get('toPremium', 'myAccount'))); } else { $page->set('notPremium1', $text->get('notPremium', 'myAccount')); $page->set('notPremium2', $text->getClickTo($text->get('toPremium', 'myAccount'))); } $page->set('toUse', $text->getClickTo(Neuron_Core_Tools::putIntoText($text->get('toUseCredit'), array('amount' => PREMIUM_COST_CREDITS)))); $page->set('extend_url', htmlentities($player->getCreditUseUrl(PREMIUM_COST_CREDITS))); $page->set('benefits', $this->getBenefits()); if (!empty($error)) { $page->set('error', $text->get($error)); } return $page->parse('gameserver/account/premium.tpl'); } elseif ($player->isFound()) { return '<p>' . $text->get('validateEmail') . '</p>'; } }
private function prepareCircle($start, $end) { $server = Neuron_GameServer::getServer(); $this->checkForCorrectDistances(); echo "GOAL: Preparing a " . $end . " radius, starting from " . $start . "...\n"; // Move in small steps (25 radius max) // this makes sure that the results are saved // even if the process stops. $inc = ceil(1000 / max(30, $start)); // Only run this for 60 minutes $time = time(); for ($s = $start; $s < $end; $s += $inc) { echo "[" . date("d/m/Y H:i:s") . "]" . " Preparing a " . ($s + $inc) . " radius, starting from " . $s . "...\n"; $tiles = $this->countTiles(); $this->doPrepareCircle($s, $s + $inc); $newtiles = $this->countTiles(); echo "[" . date("d/m/Y H:i:s") . "]" . " There are {$newtiles} tiles now, that's " . ($newtiles - $tiles) . " new onces!\n"; // Done? Let's put this in the database! $server->setData('prepRadD', $s); $inc = ceil(1000 / max(30, $s)); if ($time < time() - self::MAX_EXECUTION_TIME) { break; } } }
public function getBody() { $function = create_function('$data,$title', ' $query = ""; foreach ($data as $k => $v) { $query .= $k . "=" . urlencode ($v) . "&"; } $query = substr ($query, 0, -1); if (is_array ($title)) { return $title[0].\'<a href="\'.ABSOLUTE_URL.\'admin/messages/?\'.$query.\'">\'.$title[1].\'</a>\'.$title[2]; } else { return \'<a href="\'.ABSOLUTE_URL.\'admin/messages/?\'.$query.\'">\'.$title.\'</a>\'; } '); $function2 = create_function('$userid,$title', ' return \'<a href="\'.ABSOLUTE_URL.\'admin/user/?id=\'.$userid.\'">\'.$title.\'</a>\'; '); $objMessages = new Neuron_Structure_Messages(Neuron_GameServer::getPlayer(), 25); $objMessages->setGetUrl($function); $objMessages->setUserUrl($function2); return $objMessages->getPageHTML($_GET); }
public function getContent() { $text = Neuron_Core_Text::__getInstance(); $player = Neuron_GameServer::getPlayer(); if (!$player) { return $this->throwError($text->get('login', 'login', 'account')); } $input = $this->getInputData(); $request = $this->getRequestData(); $mapper = Neuron_GameServer_Mappers_BlockingChatMapper::getInstance(); $total = $mapper->countPrivateMessages($player); if (isset($input['page'])) { $current = $input['page']; $request['page'] = $current; $this->updateRequestData($request); } else { $current = isset($request['page']) ? $request['page'] : 0; } $perpage = 10; $page = new Neuron_Core_Template(); $pages = Neuron_Core_Tools::splitInPages($page, $total, $current, $perpage); $messages = $mapper->getPrivateChats($player, $pages['start'], $pages['perpage']); $page->set('messages', $messages); return $page->parse('gameserver/chat/privatemessages.phpt'); }
public function getRefresh() { $mapper = Neuron_GameServer_Mappers_BlockingChatMapper::getInstance(); $data = $this->getRequestData(); $player = Neuron_GameServer::getPlayer(); if ($player) { $mapper = Neuron_GameServer_Mappers_ChatMapper::getInstance(); if (isset($data['lastId'])) { $updates = $mapper->getPrivateChatUpdates($player, $data['lastId']); if (count($updates) > 0) { $lastId = $updates[0]['pu_id']; // open windows for all updates foreach ($updates as $v) { $this->getServer()->openWindow('PrivateChat', array('id' => $v['pu_from'])); $lastId = max($lastId, $v['pu_id']); } $data['lastId'] = $lastId; $this->updateRequestData($data); } } else { $updates = $mapper->getPrivateChatUpdates($player); if (count($updates) > 0) { $data['lastId'] = $updates[0]['pu_id']; $this->updateRequestData($data); } else { $data['lastId'] = 0; $this->updateRequestData($data); } } } $this->updateRequestData($data); $this->updateContent(); }
protected function getForum() { $requestData = $this->getRequestData(); if (isset($requestData['clan'])) { $clan = new Dolumar_Players_Clan($requestData['clan']); if ($clan) { $login = Neuron_Core_Login::__getInstance(); if ($login->isLogin()) { $me = Neuron_GameServer::getPlayer(); $isMember = $clan->isMember($me); $isModerator = $clan->isModerator($me); //__construct ($iForumType, $iForumId, $objUser = false, $bCanSeeAll = false, $bIsModerator = false) $forum = new Neuron_Forum_Forum(1, $clan->getId(), $me, $isMember, $isModerator); } else { $forum = new Neuron_Forum_Forum(1, $clan->getId(), false, false, false); } // Fetch thze title $text = Neuron_Core_Text::__getInstance(); $forum->setTitle(Neuron_Core_Tools::putIntoText($text->get('title', 'forum', 'clan'), array('clan' => Neuron_Core_Tools::output_varchar($clan->getName())))); return $forum; } else { return false; } } else { return false; } }
public function getBody() { $player = Neuron_GameServer::getPlayer(Neuron_Core_Tools::getInput('_GET', 'id', 'int')); $statistics = $player->getStatistics(); $out = $this->linearArray($statistics); $page = new Neuron_Core_Template(); $page->set('statistics', $out); return $page->parse('gameserver/pages/statistics.phpt'); }
public function getInitialLocation() { $player = Neuron_GameServer::getPlayer(); if ($player) { return $player->getHomeLocation(); } else { return null; } }
protected function getClassname($character, $mood) { $race = null; if ($player = Neuron_GameServer::getPlayer()) { if ($village = $player->getMainVillage()) { $race = $village->getRace()->getName(); } } return $race . ' ' . $character . ' ' . $mood; }
public function __construct($sTable) { $this->sTable = $sTable; $db = Neuron_DB_Database::getInstance(); $this->dbObj = $db->getConnection(); //$this->dbObj = new Mysqli (DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_DATABASE); $this->objMemcache = Neuron_Core_Memcache::getInstance(); $server = Neuron_GameServer::getServer(); $this->iServer = $server->getServerId(); }
public function getContent() { $player = Neuron_GameServer::getPlayer(); if (!$player) { $text = Neuron_Core_Text::__getInstance(); return '<p class="false">' . $text->get('login', 'login', 'account') . '</p>'; } $page = new Neuron_Core_Template(); $page->set('sUrl', ABSOLUTE_URL . '?pref=' . $player->getId()); return $page->parse('account/invite.phpt'); }
public function getContent() { $server = Neuron_GameServer::getServer(); $page = new Neuron_Core_Template(); if ($server->getEndgameStartDate() > time()) { $page->set('endgame_start', Neuron_Core_Tools::getCountdown($server->getEndgameStartDate())); } else { $page->set('endgame_start', '<strong>already started</strong>'); } return $page->parse('dolumar/serversettings.phpt'); }
protected function winnerBenefits(Dolumar_Underworld_Models_Side $side) { $server = Neuron_GameServer::getServer(); // Load clans $side = $this->getMission()->getSideFromSide($side); foreach ($side->getClans() as $v) { $winner = $v->getId(); } $server->setData('winner', $winner); $server->setData('gamestate', Dolumar_Players_Server::GAMESTATE_ENDGAME_FINISHED); }
private function getSocialStatuses($iStatus) { $this->loadSocialStatuses(); $out = array(); foreach ($this->iSocialStatuses as $k => $v) { if ($v == $iStatus) { $out[] = Neuron_GameServer::getPlayer($k); } } return $out; }
public static function getPlayerRanking($startPoint = 0, $length = 10) { $db = Neuron_DB_Database::getInstance(); $data = $db->query("\n\t\t\tSELECT\n\t\t\t\tn_players.*\n\t\t\tFROM\n\t\t\t\tn_players\n\t\t\tWHERE\n\t\t\t\tisPlaying = 1\n\t\t\tORDER BY\n\t\t\t\tp_score DESC,\n\t\t\t\tplid ASC\n\t\t\tLIMIT \n\t\t\t\t{$startPoint}, {$length}\n\t\t"); $o = array(); foreach ($data as $v) { $player = Neuron_GameServer::getPlayer($v['plid']); $player->setData($v); $o[] = $player; } return $o; }
private function getPlayer($id) { if (!isset($this->playermap[$id])) { $player = Neuron_GameServer::getPlayer($id); if ($player) { $this->playermap[$id] = $player; } else { return false; } } return $this->playermap[$id]; }
public function getContent() { $player = Neuron_GameServer::getPlayer(); $premium = false; if ($player && $player->isPremium()) { $premium = true; } $minimap = '<div id="minimap" style="width: 100%; height: 100%;" ' . ($premium ? 'class="premium-minimap"' : null) . '>'; $minimap .= '</div>'; $this->setOnload('initMinimap'); return $minimap; }
protected function getForum() { $text = Neuron_Core_Text::__getInstance(); $login = Neuron_Core_Login::__getInstance(); if ($login->isLogin()) { $me = Neuron_GameServer::getPlayer(); $forum = new Neuron_Forum_Forum(0, 0, $me, $me->isChatModerator(), $me->isChatModerator()); } else { $forum = new Neuron_Forum_Forum(0, 0, false, false, false); } $forum->setTitle($text->get('ingameForum', 'menu', 'main')); return $forum; }
public function processInput() { $login = Neuron_Core_Login::__getInstance(); $data = $this->getInputData(); if ($login->isLogin() && isset($data['openBuilding']) && isset($data['minimap']) && isset($data['advertisement'])) { $myself = Neuron_GameServer::getPlayer(); $myself->setPreferences($data['openBuilding'], $data['minimap'], $data['advertisement'] == '0'); if ($data['advertisement'] == '1' && !$myself->isPremium()) { $this->alert('You must have a premium account to disable the advertisment.'); } $this->reloadWindow(); } }
public function execute($a = null, $b = null, $c = null) { $village = $this->getVillage(); // Add mission $mission = new Dolumar_Underworld_Models_Mission(null); $mission->setMapName('dordaedeloth.map'); $mission->setObjectiveName('DorDaedeloth'); Dolumar_Underworld_Mappers_MissionMapper::create($mission, true); // Update server status $server = Neuron_GameServer::getServer(); $server->setData('gamestate', Dolumar_Players_Server::GAMESTATE_ENDGAME_RUNNING); // And notify all players Neuron_GameServer_Player_Guide::addPublicMessage('end_casted', array($village->getOwner(), $village), 'guide', 'neutral'); }
public function processInput() { $text = Neuron_Core_Text::__getInstance(); $data = $this->getInputData(); $_SESSION['language'] = $data['language']; setcookie('user_language', $data['language'], time() + COOKIE_LIFE, '/'); $text->setLanguage($data['language']); $user = Neuron_GameServer::getPlayer(); if ($user) { $user->setLanguage($text->getCurrentLanguage()); } $this->updateContent($this->getContent($data['language'])); reloadEverything(); $this->reloadMap(); }
protected function getCloseWindow() { $input = $this->getInputData(); $text = Neuron_Core_Text::__getInstance(); if (isset($input['confirm']) && $input['confirm']) { $player = Neuron_GameServer::getPlayer(); if ($player) { $player->setPreference('closeTutorial', 1); } $this->closeWindow(); } else { $out = '<p>' . $text->get('closeTutorial', 'help', 'main') . '</p>'; $out .= '<p><a href="javascript:void(0);" ' . 'onclick="windowAction (this, {\'page\':\'window:close\',\'confirm\':1})">' . $text->get('closeTutorialBtn', 'help', 'main') . '</a></p>'; return $out; } }
public function getContent() { $login = Neuron_Core_Login::__getInstance(); $text = Neuron_Core_Text::__getInstance(); $text->setFile('village'); $text->setSection('economics'); if ($login->isLogin() && $this->village && $this->village->isFound()) { $me = Neuron_GameServer::getPlayer(); if ($this->village->isActive() && ($me->getId() == $this->village->getOwner()->getId() || $me->isModerator())) { $page = new Neuron_Core_Template(); $page->set('resources', $text->get('resources')); $page->set('stock', $text->get('stock')); $page->set('max', $text->get('max')); $page->set('income', $text->get('income')); $page->set('norunes', $text->get('norunes')); $page->set('bruto', $text->get('bruto')); $page->set('consuming', $text->get('consuming')); $page->set('honour', $this->village->honour->getHonour()); $page->set('hourly', $text->get('hourly')); $res = $this->village->resources->getResources(); $income = $this->village->resources->getIncome(); $capacity = $this->village->resources->getCapacity(); $consumption = $this->village->resources->getUnitConsumption(); $bruto = $this->village->resources->getBrutoIncome(); foreach ($res as $k => $v) { $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)); } // Runes $page->set('runes', $text->get('runes')); $runes = $this->village->resources->getRuneSummary(); foreach ($runes as $k => $v) { if ($v > 0) { if ($k == 'random') { $k = 'randomrune'; } $page->addListValue('runes', array('name' => ucfirst($text->get($k, 'runeDouble', 'main')), 'available' => $v['available'], 'key' => $k, 'used' => $v['used'], 'used_percentage' => $v['used_percentage'] * 100)); } } $page->sortList('runes'); return $page->parse('economics.tpl'); } else { return '<p>You are not authorized to view this information: ' . $this->village->getId() . ' != ' . $me->getId() . '</p>'; } } else { return '<p class="false">' . $text->get('login', 'login', 'account') . '</p>'; } }
private function inVacationMode() { $myself = Neuron_GameServer::getPlayer(); $input = $this->getInputData(); $page = new Neuron_Core_Template(); if (isset($input['disable'])) { if ($myself->endVacationMode()) { $page->set('success', true); } else { $page->set('success', false); $page->set('error', $myself->getError()); } } // Get "since" $page->set('since', date(DATETIME, $myself->getVacationStart())); return $page->parse('gameserver/account/vacationModeActive.phpt'); }
protected function getChannelName() { $requestdata = $this->getRequestData(); if (!isset($requestdata['id'])) { throw new Neuron_Exceptions_DataNotSet('id'); } else { $id1 = Neuron_GameServer::getPlayer()->getId(); $player = $this->getTarget(); $id2 = $player->getId(); // Now, do something funny: lowest goes first if ($id1 < $id2) { return 'private:' . $id1 . ':' . $id2; } else { return 'private:' . $id2 . ':' . $id1; } } }
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; }
private function getClan() { $requestData = $this->getRequestData(); if (isset($requestData['clan'])) { $clan = new Dolumar_Players_Clan($requestData['clan']); if ($clan) { $login = Neuron_Core_Login::__getInstance(); if ($login->isLogin()) { $me = Neuron_GameServer::getPlayer(); } else { return null; } if ($clan->isMember($me)) { return $clan; } } } return null; }
public function getContent() { if ($result = $this->getResults()) { return $result; } $page = new Neuron_Core_Template(); // Fetch me villages $premium = false; $player = Neuron_GameServer::getPlayer(); if ($player) { foreach ($player->getVillages() as $v) { $loc = $v->buildings->getTownCenterLocation(); $page->addListValue('villages', array('location' => $loc[0] . ',' . $loc[1], 'name' => Neuron_Core_Tools::output_varchar($v->getName()))); $page->set('premium', $player->isPremium()); } } $page->set('premium', $premium); return $page->parse('search/search.phpt'); }