예제 #1
0
 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');
 }
예제 #2
0
 public function showRegisterForm($error = false)
 {
     $text = Neuron_Core_Text::__getInstance();
     $text->setFile('account');
     $text->setSection('register');
     $page = new Neuron_Core_Template();
     $page->setTextSection('register', 'account');
     // Get invitation code
     $data = $this->getInputData();
     $page->set('invCode', isset($data['invCode']) ? $data['invCode'] : null);
     // If an error has occured, add that
     if ($error) {
         $page->set('error', $text->get($error, 'errors'));
     }
     // Check for already found data
     if (isset($data['username'])) {
         $page->set('username_value', Neuron_Core_Tools::output_varchar($data['username']));
     }
     if (isset($data['email'])) {
         $page->set('email_value', Neuron_Core_Tools::output_varchar($data['email']));
     }
     $page->set('register', $text->get('register'));
     $page->set('submit', $text->get('submit'));
     $page->set('email', $text->get('email'));
     $page->set('username', $text->get('username'));
     $page->set('password', $text->get('password'));
     $page->set('password2', $text->get('password2'));
     return $page->parse('register/register.tpl');
 }
 private function getOpenIdForm($sError = false)
 {
     $page = new Neuron_Core_Template();
     $page->setTextSection('openid', 'account');
     $page->set('error', $sError);
     $page->set('url', API_OPENID_URL . 'login/');
     $page->addListValue('popular', array('Yahoo', 'http://www.yahoo.com/'));
     return $page->parse('gameserver/account/openid.phpt');
 }
 public function getHTML($error = null)
 {
     $page = new Neuron_Core_Template();
     $page->setTextSection('chooseTarget', 'main');
     $page->set('canTargetSelf', $this->bTargetSelf);
     $page->set('vid', $this->objVillage->getId());
     // Return action
     if (isset($this->sReturnAction)) {
         $page->set('returnUrl', $this->sReturnAction);
         $page->set('returnText', $this->sReturnText);
     }
     $sQuery = null;
     if (isset($this->aInput['sVillageName'])) {
         $sQuery = $this->aInput['sVillageName'];
         unset($this->aInput['sVillageName']);
     }
     $page->set('input', $this->aInput);
     $page->set('query', Neuron_Core_Tools::output_varchar($sQuery));
     // Fetch all troops
     if (!empty($sQuery)) {
         $db = Neuron_Core_Database::__getInstance();
         $page->set('hasSearched', true);
         $l = $db->getDataFromQuery($db->customQuery("\n\t\t\t\t\tSELECT\n\t\t\t\t\t\t*\n\t\t\t\t\tFROM\n\t\t\t\t\t\tvillages\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tvname LIKE '%" . $db->escape($sQuery) . "%'\n\t\t\t\t\t\tAND isActive = 1\n\t\t\t\t\tORDER BY\n\t\t\t\t\t\tFIELD(vname, '" . $db->escape($sQuery) . "', vname),\n\t\t\t\t\t\tvname ASC\n\t\t\t\t\tLIMIT 10\n\t\t\t\t"));
         if (count($l) > 0) {
             foreach ($l as $v) {
                 $village = Dolumar_Players_Village::getVillage($v['vid'], false);
                 $village->setData($v);
                 $tc = $village->buildings->getTownCenter();
                 if ($tc) {
                     $loc = $tc->getLocation();
                     $page->addListValue('results', array('id' => $village->getId(), 'name' => Neuron_Core_Tools::output_varchar($village->getName()), 'location' => $loc[0] . ',' . $loc[1]));
                 }
             }
         }
     } elseif ($this->bShowTargets) {
         $db = Neuron_DB_Database::__getInstance();
         // Popular targets
         /*
         $l = $db->getDataFromQuery
         (
         	$db->customQuery
         	("
         		SELECT
         			l_vid,
         			villages.*
         		FROM
         			game_log
         		LEFT JOIN
         			villages ON game_log.l_vid = villages.vid
         		WHERE
         			(l_action = 'attack' OR l_action = 'defend') 
         			AND l_vid != ".$this->objVillage->getId ()."
         			AND l_subId = ".$this->objVillage->getId ()."
         			AND isActive = 1
         		GROUP BY
         			l_vid
         		ORDER BY
         			l_date ASC
         		LIMIT 10
         	")
         );
         */
         $l = $this->objVillage->visits->getLastVisits();
         if (count($l) > 0) {
             foreach ($l as $village) {
                 // Only add active villages
                 if ($village->isActive()) {
                     $tc = $village->buildings->getTownCenter();
                     if ($tc) {
                         $loc = $tc->getLocation();
                         $page->addListValue('results', array('id' => $village->getId(), 'name' => Neuron_Core_Tools::output_varchar($village->getName()), 'location' => $loc[0] . ',' . $loc[1]));
                     }
                 }
             }
         }
     }
     if (isset($error)) {
         $page->set('external_error', $error);
     }
     return $page->parse('neuron/structure/chooseTarget.phpt');
 }
예제 #5
0
파일: Battle.php 프로젝트: Toxicat/dolumar
 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');
 }
예제 #6
0
파일: Magic.php 프로젝트: Toxicat/dolumar
 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');
 }
예제 #7
0
파일: Clan.php 프로젝트: Toxicat/dolumar
 private function getOverview($clan)
 {
     $_SESSION['clan_overview_lastrefresh'] = time();
     // Change the title
     $text = Neuron_Core_Text::__getInstance();
     $this->setTitle($text->get('clan', 'menu', 'main') . ': ' . Neuron_Core_Tools::output_varchar($clan->getName()));
     $page = new Neuron_Core_Template();
     // Check for errors
     $error = $clan->getError();
     if (isset($error)) {
         $page->set('error', $text->get($error, 'errors', 'clan'));
     }
     $myself = Neuron_GameServer::getPlayer();
     $canJoin = $myself && !$clan->isMember($myself);
     $canLeave = $myself && $clan->isMember($myself);
     $page->setTextSection('overview', 'clan');
     $page->set('clanname', Neuron_Core_Tools::output_varchar($clan->getName()));
     $page->set('clanid', $clan->getId());
     foreach ($clan->getMembers() as $v) {
         $status = $clan->getMemberStatus($v);
         $page->addListValue('members', array('id' => $v->getId(), 'name' => Neuron_Core_Tools::output_varchar($v->getNickname()), 'status' => $status, 'status_t' => $text->get($status, 'roles', 'clan'), 'online' => $v->isOnline() ? 'online' : 'offline'));
     }
     // Check if it's possible to join
     $page->set('canJoin', $canJoin);
     $page->set('canLeave', $canLeave);
     $page->set('canGovern', $clan->isLeader($myself));
     $desc = $clan->getDescription();
     if (!empty($desc)) {
         $page->set('description', Neuron_Core_Tools::output_text($desc));
     }
     return $page->parse('clan/overview.phpt');
 }
예제 #8
0
 private function commandMoveUnit($building, $unit)
 {
     $input = $this->getInputData();
     $id = isset($input['target']) ? intval($input['target']) : null;
     if ($id > 0 && $id != $unit->getLocation()->getId()) {
         // Calculate distance & duration
         $target = Dolumar_Players_Village::getVillage($id);
         if (!$target) {
             return '<p>Invalid input: target village not found.</p>';
         }
         if (isset($input['confirm'])) {
             $page = new Neuron_Core_Template();
             $page->setTextSection('moveUnit', 'thievery');
             $page->set('input', array('building' => $building->getId()));
             // Move the bloody unit
             $unit->moveUnit($target);
             return $page->parse('thieves/doneMoving.phpt');
         } else {
             $page = new Neuron_Core_Template();
             $page->setTextSection('moveUnit', 'thievery');
             $distance = Dolumar_Map_Map::getDistanceBetweenVillages($unit->getLocation(), $target);
             // Calculate duration
             $duration = $unit->getTravelDuration($distance);
             $page->set('input', array_merge($input, array('confirm' => 'true')));
             $page->set('distance', Neuron_Core_Tools::output_distance($distance));
             $page->set('duration', Neuron_Core_Tools::getDuration($duration));
             return $page->parse('thieves/moveThief.phpt');
         }
     } else {
         $structure = new Neuron_Structure_ChooseTarget($this->getInputData(), $this->village, true, true);
         $structure->setReturnData(array('building' => $building->getId()));
         return $structure->getHTML();
     }
 }
예제 #9
0
 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');
 }