Пример #1
0
 protected function getPlayerInitialization($registrationTracker = false)
 {
     // Check if we can actually register
     $server = Neuron_GameServer::getServer();
     if (!$server->canRegister()) {
         return '<p>This server has gone into "endgame" mode. You can not register here anymore. But stay tuned, a new game will start soon.</p>';
     }
     $data = $this->getInputData();
     $me = Neuron_GameServer::getPlayer();
     if (isset($data['race'])) {
         // Check for clans
         $clan = isset($data['clan']) ? intval($data['clan']) : 0;
         $location = isset($data['location']) ? $data['location'] : null;
         $objClan = false;
         if ($clan > 0) {
             $objClan = new Dolumar_Players_Clan($clan);
             if ($objClan->isFound()) {
                 // Check for password
                 if ($objClan->isPasswordProtected()) {
                     // Break out of the function if the password is not correct.
                     if (!isset($data['password']) || !$objClan->checkPassword($data['password'])) {
                         return $this->requestClanPassword($data['race'], $objClan);
                     }
                 }
                 $members = $objClan->getMembers();
                 if (count($members) > 0) {
                     $member = $members[rand(0, count($members) - 1)];
                     // Fetch towncenter
                     $village = $member->getMainVillage();
                     if ($village) {
                         // Overwrite location with the location of this towncenter.
                         $location = $village->buildings->getTownCenterLocation();
                     } else {
                         $location = array(0, 0);
                     }
                 } else {
                     $location = array(0, 0);
                 }
             }
         }
         if ($me->initializeAccount($data['race'], $location, $objClan)) {
             // Scroll to the right location
             $me = Neuron_GameServer::getPlayer();
             $home = $me->getHomeLocation();
             $this->mapJump($home[0], $home[1]);
             // Reload area
             $this->reloadLocation($home[0], $home[1]);
             reloadEverything();
             return $this->getContent(false);
         } else {
             //return $this->getPlayerInitialization ();
         }
     }
     $text = Neuron_Core_Text::__getInstance();
     $text->setFile('account');
     $text->setSection('selectRace');
     $data = $this->getInputData();
     // Show form
     $page = new Neuron_Core_Template();
     $error = Neuron_GameServer::getPlayer()->getError();
     if (!empty($error)) {
         $page->set('error', $text->get($error, 'errors', 'account', $error));
     }
     // Loop trough races
     foreach (Dolumar_Races_Race::getRaces() as $k => $v) {
         $race = Dolumar_Races_Race::getFromId($k);
         if ($race->canPlayerSelect(Neuron_GameServer::getPlayer())) {
             $page->addListValue('races', array($text->get($v, 'races', 'races', $v), $text->get($v, 'desc', 'races', 'null'), $k));
         }
     }
     $page->sortList('races');
     // Some text values
     $page->set('submit', $text->get('submit'));
     $page->set('select', $text->get('select'));
     $page->set('location', $text->get('location'));
     if ($registrationTracker === true) {
         $tracker = Neuron_GameServer::getPlayer()->getTrackerUrl('registration');
         $page->set('tracker_url', htmlentities($tracker));
     }
     // Locations
     $page->addListValue('directions', array($text->get('r', 'directions', 'main'), 'r'));
     $page->addListValue('directions', array($text->get('n', 'directions', 'main'), 'n'));
     $page->addListValue('directions', array($text->get('ne', 'directions', 'main'), 'ne'));
     $page->addListValue('directions', array($text->get('e', 'directions', 'main'), 'e'));
     $page->addListValue('directions', array($text->get('es', 'directions', 'main'), 'es'));
     $page->addListValue('directions', array($text->get('s', 'directions', 'main'), 's'));
     $page->addListValue('directions', array($text->get('sw', 'directions', 'main'), 'sw'));
     $page->addListValue('directions', array($text->get('w', 'directions', 'main'), 'w'));
     $page->addListValue('directions', array($text->get('wn', 'directions', 'main'), 'wn'));
     // Fetch a list of all clans
     $db = Neuron_Core_Database::__getInstance();
     $clans = $db->select('clans', array('*'));
     // Add a list of all clans ;-)
     foreach ($clans as $v) {
         $clan = new Dolumar_Players_Clan($v['c_id'], $v);
         $page->addListValue('clans', array('id' => $clan->getId(), 'name' => Neuron_Core_Tools::output_varchar($clan->getName()), 'isLocked' => $clan->isPasswordProtected(), 'isFull' => $clan->isFull()));
     }
     return $page->parse('account/selectRace.phpt');
 }