Beispiel #1
0
 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>';
     }
 }
Beispiel #2
0
 public function getContent($language = false)
 {
     $login = Neuron_Core_Login::__getInstance();
     $text = Neuron_Core_Text::__getInstance();
     $page = new Neuron_Core_Template();
     $text->setFile('account');
     $text->setSection('language');
     $page->set('language', $text->get('language'));
     $page->set('submit', $text->get('submit'));
     $page->set('current_language', $language ? $language : $text->getCurrentLanguage());
     // Get languages
     $lang = $text->getLanguages();
     foreach ($lang as $v) {
         $text = new Neuron_Core_Text($v);
         $page->addListValue('languages', array($v, $text->get($v, 'languages', 'languages', $v)));
         $page->sortList('languages');
     }
     return $page->parse('language.tpl');
 }
Beispiel #3
0
 public function getContent()
 {
     $login = Neuron_Core_Login::__getInstance();
     $text = Neuron_Core_Text::__getInstance();
     $text->setFile('main');
     $text->setSection('menu');
     $page = new Neuron_Core_Template();
     // Add text elements
     $page->set('myAccount', Neuron_Core_Tools::output_varchar($text->get('myAccount')));
     $page->set('build', Neuron_Core_Tools::output_varchar($text->get('build')));
     $page->set('bonusbuild', Neuron_Core_Tools::output_varchar($text->get('bonusbuild')));
     $page->set('economy', Neuron_Core_Tools::output_varchar($text->get('economy')));
     $page->set('preferences', Neuron_Core_Tools::output_varchar($text->get('preferences')));
     $page->set('help', Neuron_Core_Tools::output_varchar($text->get('help')));
     $page->set('language', Neuron_Core_Tools::output_varchar($text->get('language')));
     $page->set('ranking', Neuron_Core_Tools::output_varchar($text->get('ranking')));
     $page->set('units', Neuron_Core_Tools::output_varchar($text->get('units')));
     $page->set('chat', Neuron_Core_Tools::output_varchar($text->get('chat')));
     $page->set('battle', Neuron_Core_Tools::output_varchar($text->get('battle')));
     $page->set('battleCalc', Neuron_Core_Tools::output_varchar($text->get('battleCalc')));
     $page->set('forum', Neuron_Core_Tools::output_varchar($text->get('forum')));
     $page->set('ingameForum', Neuron_Core_Tools::output_varchar($text->get('ingameForum')));
     $page->set('contact', Neuron_Core_Tools::output_varchar($text->get('contact')));
     $page->set('equipment', Neuron_Core_Tools::output_varchar($text->get('equipment')));
     $page->set('magic', Neuron_Core_Tools::output_varchar($text->get('magic')));
     $page->set('invite', Neuron_Core_Tools::output_varchar($text->get('friendinvite')));
     if (!defined('HIDE_IMPRINT') || !HIDE_IMPRINT) {
         $page->set('imprint', Neuron_Core_Tools::output_varchar($text->get('imprint')));
     }
     $page->set('simulator', Neuron_Core_Tools::output_varchar($text->get('simulator')));
     $localized_forum = str_replace('{lang}', $text->getCurrentLanguage(), FORUM_URL);
     $page->set('forum_url', $localized_forum);
     $page->set('ignorelist', $text->get('ignorelist'));
     $page->set('flag', $text->getCurrentLanguage());
     $noVillage = true;
     if ($login->isLogin()) {
         $me = Neuron_GameServer::getPlayer();
         $page->set('messages', $text->get('messages'));
         $villages = $me->getVillages();
         if (count($villages) > 0) {
             $noVillage = false;
             if (count($villages) > 1 || $this->SHOW_ONLY_VILLAGE && count($villages) > 0) {
                 foreach ($villages as $v) {
                     // Add the links
                     $page->addListValue('villages', array(Neuron_Core_Tools::output_varchar($v->getName()), $v->getId()));
                 }
                 $page->sortList('villages');
             }
             // Set the current village ID.
             $page->set('vid', $me->getCurrentVillage()->getId());
         }
         // Administration links
         if ($me->isModerator()) {
             $page->set('adminForum', 'Admin Forum');
         }
         // Clans
         foreach ($me->getClans() as $v) {
             $page->addListValue('clans', array('id' => $v->getId(), 'name' => Neuron_Core_Tools::output_varchar($v->getName())));
         }
         $page->set('donation', $text->get('donation'));
     }
     if ($noVillage) {
         $page->set('vid', 0);
     }
     // Premium
     /*
     $player = Neuron_GameServer::getPlayer ();
     
     if ($player)
     {
     	$credits = $player->getCredits ();
     	$page->set ('premium', $credits);
     }
     */
     return $page->parse('menu.tpl');
 }
Beispiel #4
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');
 }
Beispiel #5
0
 private function getChooseUnits($target, $error = null)
 {
     $text = Neuron_Core_Text::__getInstance();
     $text->setFile('battle');
     $text->setSection('challenge');
     $page = new Neuron_Core_Template();
     $page->set('target', Neuron_Core_Tools::output_varchar($target->getName()));
     $page->set('action', 'attack');
     $page->set('target_id', $target->getId());
     $showForm = true;
     if ($target->getOwner()->equals($this->village->getOwner())) {
         $page->set('error', $text->get('ownVillage'));
         $showForm = false;
     }
     $page->set('showForm', $showForm);
     foreach ($this->village->getAttackSlots($target) as $k => $v) {
         $page->addListValue('slots', array('id' => $k, 'sType' => $text->get($v->getName(), 'slots', 'battle'), 'sName' => $v->getName()));
     }
     if (!empty($error)) {
         $page->set('error', $text->get($error));
     }
     $page->set('challenge', Neuron_Core_Tools::putIntoText($text->get('challenge'), array(Neuron_Core_Tools::output_varchar($target->getName()))));
     // Calculate distance
     $afstand = Dolumar_Map_Map::getDistanceBetweenVillages($this->village, $target, false);
     $page->set('distance', Neuron_Core_Tools::putIntoText($text->get('distance'), array(Neuron_Core_Tools::output_distance($afstand))));
     // Make a list of available squads
     $squads = $this->getSquads();
     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()));
         }
     }
     // Sort the list
     $page->sortList('units');
     if (isset($this->error)) {
         $page->set('error', $this->error);
     }
     return $page->parse('battle/chooseUnits.tpl');
 }
Beispiel #6
0
 protected function getCastSpell($objUnit, $addInputData = array(), $aReturnData = null)
 {
     $data = $this->getRequestData();
     $page = new Neuron_Core_Template();
     $page->setTextSection('cast', $this->sTextFile);
     $page->set('input', $addInputData);
     $spells = $objUnit->getEffects();
     foreach ($spells as $spell) {
         if ($spell instanceof Dolumar_Effects_Boost || $spell instanceof Dolumar_Effects_Instant) {
             $page->addListValue('spells', $spell->getOutputData($objUnit, $this->village));
         }
     }
     $page->sortList('spells');
     $page->set('returnData', $aReturnData);
     return $page->parse('magic/cast.phpt');
 }
Beispiel #7
0
 public function getContent()
 {
     $this->me = Neuron_GameServer::getPlayer();
     if (!$this->me) {
         return '<p>Please login.</p>';
     }
     if (!isset($this->army)) {
         return '<p>Army not found.</p>';
     }
     if (!$this->army->canView($this->me)) {
         return $this->getOutsiderView();
     }
     $action = $this->getInput('action');
     switch ($action) {
         case 'move':
             $this->prcMove();
             break;
         case 'player':
             $this->prcPlayer();
             break;
         case 'merge':
             $this->prcMerge();
             break;
         case 'attack':
             $this->prcAttack();
             break;
         case 'split':
             return $this->prcSplit();
             break;
         case 'withdraw':
             $this->prcWithdraw();
             break;
     }
     $page = new Neuron_Core_Template();
     // Show them a list of all squads
     $squads = $this->army->getSquads();
     foreach ($squads as $v) {
         $data = array('name' => $v->getDisplayName(), 'units' => array(), 'owner' => $v->getVillage()->getOwner()->getDisplayName());
         foreach ($v->getUnits() as $vv) {
             $data['units'][] = array('name' => $vv->getDisplayName(), 'amount' => $vv->getAmount(), 'image' => $vv->getImageUrl(), 'numberedname' => $vv->getAmount() . ' ' . $vv->getDisplayName($vv->getAmount() > 1), 'morale' => $vv->getMorale());
         }
         $page->addListValue('squads', $data);
     }
     // Players
     $players = $this->army->getPlayers();
     foreach ($players as $v) {
         $page->addListValue('players', array('status' => $this->army->isLeader($v) ? 'leader' : 'normal', 'id' => $v->getId(), 'name' => $v->getDisplayName(), 'canPromote' => $this->army->canPromote($this->me, $v), 'canDemote' => $this->army->canDemote($this->me, $v)));
         $page->sortList('players');
     }
     $page->set('movepoints', $this->army->getMovepoints());
     $nextpoint = $this->army->getNextMovepointDate();
     if (isset($nextpoint) && $this->me->isPremium()) {
         $page->set('nextpoint', Neuron_Core_Tools::getCountdown($nextpoint));
     }
     return $page->parse('dolumar/underworld/windows/regiment.phpt');
 }
Beispiel #8
0
 public function getOutput()
 {
     $page = new Neuron_Core_Template();
     $page->set('type', $this->type);
     $page->set('date', date(DATETIME, $this->date));
     if (isset($this->target)) {
         $page->set('target', $this->target->getDisplayName());
     }
     foreach ($this->data as $v) {
         $page->addListValue('records', $this->getRecordOutput($v));
     }
     $page->sortList('records');
     return $page->parse('dolumar/report/general.phpt');
 }