Exemplo n.º 1
0
 public function getTechnologies()
 {
     if (!isset($this->objTechnologies)) {
         $this->loadTechnology();
         $this->objTechnologies = array();
         foreach ($this->technologies as $k => $v) {
             if ($v) {
                 $tech = Dolumar_Technology_Technology::getTechnology($k);
                 if ($tech instanceof Dolumar_Technology_Technology) {
                     $this->objTechnologies[] = $tech;
                 }
             }
         }
     }
     return $this->objTechnologies;
 }
Exemplo n.º 2
0
 public function getRequiredTechnologies()
 {
     if (isset($this->requirements['technologies'])) {
         $out = array();
         foreach ($this->requirements['technologies'] as $v) {
             $out[] = Dolumar_Technology_Technology::getTechnology($v);
         }
         return $out;
     }
     return array();
 }
Exemplo n.º 3
0
 public function getUpgradeTechnology($input)
 {
     $s_technology = $input['technology'];
     $technologies = $this->getTechnologyUpgrades();
     $text = Neuron_Core_Text::__getInstance();
     $text->setFile('building');
     $text->setSection('technology');
     $page = new Neuron_Core_Template();
     $page->set('title', $text->get('technology'));
     $village = $this->getVillage();
     if (in_array($s_technology, $technologies) && !$village->hasTechnology($s_technology, true)) {
         $technology = Dolumar_Technology_Technology::getTechnology($s_technology);
         $showForm = true;
         if ($technology->canResearch($this)) {
             if (isset($input['confirm']) && Neuron_Core_Tools::checkConfirmLink($input['confirm'])) {
                 $cost = $technology->getResearchCost();
                 if (isset($cost['runeId']) && $cost['runeId'] == 'random' && isset($input['runeSelection'])) {
                     $cost['runeId'] = $input['runeSelection'];
                 }
                 if ($village->resources->takeResourcesAndRunes($cost)) {
                     if ($village->trainTechnology($technology)) {
                         $showForm = false;
                         $page->set('done', $text->get('done'));
                         reloadStatusCounters();
                     } else {
                         $page->set('error', 'Error: couldn\'t start the research.');
                     }
                 } else {
                     $page->set('error', $text->get('notEnoughResources'));
                 }
             }
             if ($showForm) {
                 $page->set('youSure', Neuron_Core_Tools::putIntoText($text->get('youSure'), array(Neuron_Core_Tools::output_varchar($technology->getName()))));
                 $page->set('description', Neuron_Core_Tools::output_varchar($technology->getDescription()));
                 $page->set('cost', Neuron_Core_Tools::putIntoText($text->get('costTime'), array($this->resourceToText($technology->getResearchCost(), true, true, false, $this->getBuildingId()))));
                 $page->set('duration', Neuron_Core_Tools::putIntoText($text->get('duration'), array(Neuron_Core_Tools::getDuration($technology->getDuration()))));
                 $page->set('confirm', $text->getClickto($text->get('toConfirm')));
                 $page->set('technology', $s_technology);
                 $page->set('confirmation', Neuron_Core_Tools::getConfirmLink());
             }
         } else {
             return '<p>Invalid input: technology not researchable.</p>';
         }
     } else {
         $page->set('notFound', $text->get('notFound'));
     }
     $page->set('return', $text->getClickto($text->get('toReturn')));
     return $page->parse('buildings/general_tech.tpl');
 }
Exemplo n.º 4
0
 public function getRequiredTechnologies()
 {
     $requires = $this->getStat('requires');
     if (isset($requires) && count($requires) > 0) {
         $out = array();
         foreach ($requires as $v) {
             $out[] = Dolumar_Technology_Technology::getTechnology($v);
         }
         return $out;
     }
     return array();
 }
Exemplo n.º 5
0
 private function loadTechnologyCounters($where)
 {
     $db = Neuron_Core_Database::__getInstance();
     $rows = $db->select('villages_tech', array('*'), 'endDate > ' . time() . ' ' . $where);
     $text = Neuron_Core_Text::getInstance();
     $text->setSection('status', 'statusbar');
     foreach ($rows as $v) {
         $village = Dolumar_Players_Village::getVillage($v['vid']);
         $technology = Dolumar_Technology_Technology::getFromId($v['techId'], $village->getRace());
         $txt = Neuron_Core_Tools::putIntoText($text->get('research'), array('technology' => $technology->getName()));
         $this->addCounter($v['endDate'], $village, $txt, 'technology');
     }
 }