public function getName() { /* $res, $showRunes = true, $dot = true, $village = false, $runeId = 'rune', $html = true, $income = array (), $capacity = array () */ return Neuron_Core_Tools::resourceToText($this->getLogArray(), false, false, false, false, false); }
private function getChooseSpecialUnits($target, $squads, $error = null) { $page = new Neuron_Core_Template(); $page->setTextSection('specialUnits', 'battle'); $page->set('error', $error); $page->set('target', Neuron_Core_Tools::output_varchar($target->getName())); $page->set('targetId', $target->getId()); $distance = Dolumar_Map_Map::getDistanceBetweenVillages($this->village, $target, false); $page->set('distance', Neuron_Core_Tools::output_distance($distance)); foreach ($this->village->getAttackSlots($target) as $k => $v) { if (isset($squads[$k])) { $unitId = $squads[$k]->getSquad()->getId() . '_' . $squads[$k]->getUnitId(); $page->addListValue('slots', array('id' => $k, 'unit' => $unitId)); } } $duration = $this->village->battle->getMoveDuration($squads, $distance); if ($duration > 60 * 60 * 24) { $page->set('duration', $duration); } $honour = Dolumar_Battle_Battle::getHonourPenalty($this->village, $target); if ($honour > 0) { //$bigger = round ( ($this->village->getScore () / $target->getScore ()) * 100) - 100; $bigger = round(Dolumar_Battle_Battle::getSizeDifference($this->village, $target) * 100 - 100); $page->set('honour', $honour); $page->set('size', $bigger); } // Fetch thze special units $units = $this->village->getSpecialUnits(); foreach ($units as $v) { $actions = $v->getEffects(); // Prepare the actions $aActions = array(); foreach ($actions as $action) { if ($action instanceof Dolumar_Effects_Battle) { $aActions[] = array('name' => $action->getName(), 'id' => $action->getId(), 'cost' => Neuron_Core_Tools::resourceToText($action->getCost($v, $target), false, false, false, 'rune', false)); } } if (count($aActions) > 0) { asort($aActions); // Add the special unit to the list $page->addListValue('specialunits', array('id' => $v->getId(), 'name' => Neuron_Core_Tools::output_varchar($v->getName(false, true)), 'actions' => $aActions)); } } return $page->parse('battle/specialUnits.phpt'); }
protected function getConfirmCast($objUnit, $objSpell, $objTarget, $inputData = null) { $text = Neuron_Core_Text::__getInstance(); $page = new Neuron_Core_Template(); $page->setTextSection('confirm', $this->sTextFile); if (isset($objTarget)) { $page->set('target', Neuron_Core_Tools::output_varchar($objTarget->getName())); } $page->set('spell', Neuron_Core_Tools::output_varchar($objSpell->getName())); $page->set('cost', Neuron_Core_Tools::resourceToText($objSpell->getCost($objUnit, $objTarget))); $page->set('about', Neuron_Core_Tools::output_varchar($objSpell->getDescription())); $page->set('duration', $objSpell->getType_text()); $page->set('difficulty', $objSpell->getDifficulty()); $page->set('probability', $this->getProbability($objUnit, $objSpell, $objTarget)); $page->set('toCast', Neuron_Core_Tools::putIntoText($text->get('toCast', 'confirm', $this->sTextFile), array('spell' => Neuron_Core_Tools::output_varchar($objSpell->getName())))); // Set hidden values $page->set('inputData', $inputData); return $page->parse('magic/confirm.phpt'); }
public static function resourceToText($res, $showRunes = true, $dot = true, $village = false, $runeId = 'rune') { return Neuron_Core_Tools::resourceToText($res, $showRunes, $dot, $village, $runeId); }
public function getOutputData($objUnit, $objTarget) { return array('title' => $this->getName(), 'id' => $this->getId(), 'description' => $this->getDescription(), 'cost' => Neuron_Core_Tools::resourceToText($this->getCost($objUnit, $objTarget)), 'type' => $this->getType_text(), 'difficulty' => $this->getDifficulty()); }
public function getCustomContent($input) { $runes = $this->getUsedRunes(); $runes = array_keys($runes); // Fetch the unit $objUnit = $this->getSpecialUnit(); $page = new Neuron_Core_Template(); if ($this instanceof Dolumar_Buildings_WizardTower) { $page->set('runetype', $runes[0]); } $page->set('bid', $this->getId()); $page->set('vid', $this->getVillage()->getId()); // Check for actions $sAction = isset($input['action']) ? $input['action'] : null; switch ($sAction) { case 'train': if ($this->trainUnit()) { $page->set('isTrained', true); } else { $page->set('isTrained', false); $page->set('trainError', $this->getError()); } break; case 'learn': $spell = isset($input['effect']) ? $input['effect'] : false; $spells = count($this->getKnownEffects()) - count($this->getFreeEffects()); if ($spell && $spells < $this->getLevel()) { $spell = $this->getAvailableEffect($spell); if ($spell && !$this->doesKnowEffect($spell) && $spell->canLearnSpell($this)) { $db = Neuron_Core_Database::__getInstance(); $db->insert('specialUnits_effects', array('b_id' => $this->getId(), 'e_id' => $spell->getId())); $this->aKnownActions = null; } } break; } $page->setTextSection(strtolower($this->getClassName()), 'buildings'); // Textfile $page->set('textfile', $this->sCastTextFile); $page->set('canTrain', $this->canTrainUnits()); $page->set('capacity', $this->getSpecialUnitCapacity()); $page->set('training_cost', Neuron_Core_Tools::resourceToText($objUnit->getTrainingCost())); // Show duration countdown if training if ($this->isTraining()) { $units = $this->getTrainingUnits(); $page->set('training_countdown', Neuron_Core_Tools::getCountdown($units[0]['vsu_tEndDate'])); } // Inhabitans $page->set('inhabitans', $this->getUnitCount(true)); $page->set('inhabitans_in', $this->getUnitCount(false)); // Window $page->set('actionWindow', $objUnit->getWindowAction()); $page->set('freeSpellSlots', $this->countFreeEffectSlots()); $page->set('unitname', $this->getSpecialunit()->getName(false)); $page->set('unitsname', $this->getSpecialunit()->getName(true)); // See if you can choose a new spell $spells = $this->countFreeEffectSlots(); if ($spells > 0) { // Player has to choose a new spell! foreach ($this->getAvailableEffects() as $v) { if (!$this->doesKnowEffect($v) && $v->canLearnSpell($this)) { $page->addListValue('spells', $v->getOutputData($this->getSpecialUnit(), $this->getVillage())); } } } return $page->parse('buildings/specialunits.phpt'); }