本文整理汇总了PHP中Neuron_Core_Tools::output_distance方法的典型用法代码示例。如果您正苦于以下问题:PHP Neuron_Core_Tools::output_distance方法的具体用法?PHP Neuron_Core_Tools::output_distance怎么用?PHP Neuron_Core_Tools::output_distance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Neuron_Core_Tools
的用法示例。
在下文中一共展示了Neuron_Core_Tools::output_distance方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: printResults
private function printResults($page, $query)
{
foreach ($query as $v) {
$displayname = Neuron_URLBuilder::getInstance()->getOpenUrl('PlayerProfile', Neuron_Core_Tools::output_varchar($v['nickname']), array('plid' => $v['plid']));
$villagename = Neuron_URLBuilder::getInstance()->getOpenUrl('VillageProfile', Neuron_Core_Tools::output_varchar($v['vname']), array('village' => $v['vid']));
$page->addListValue('results', array('id' => $v['plid'], 'nickname' => $v['nickname'], 'displayname' => $displayname, 'village' => $v['vname'], 'displayvillage' => $villagename, 'distance' => Neuron_Core_Tools::output_distance($v['distance']), 'networth' => $v['networth']));
}
}
示例2: getVillageRanking
public function getVillageRanking()
{
$text = Neuron_Core_Text::__getInstance();
$db = Neuron_Core_Database::__getInstance();
$input = $this->getInputData();
$page = new Neuron_Core_Template();
$text->setFile('ranking');
$text->setSection('ranking');
$page->set('title', $text->get('villageRating'));
$page->set('village', $text->get('village'));
$page->set('value', $text->get('value'));
$data = $this->getRequestData();
$perPage = 25;
$myDefaultPage = 1;
if (isset($data['village'])) {
$village = Dolumar_Players_Village::getVillageFromId($data['village']);
$myVillageId = $data['village'];
$myRank = $village->getRank();
$myDefaultPage = floor($myRank[0] / $perPage) + 1;
} else {
$myVillageId = 0;
// Load "main village" from this user
$myself = Neuron_GameServer::getPlayer();
if ($myself) {
$village = $myself->getMainVillage();
if ($village) {
$myVillageId = $village->getId();
$myRank = $village->getRank();
$myDefaultPage = floor($myRank[0] / $perPage) + 1;
}
}
}
$currentPage = isset($input['page']) ? $input['page'] : $myDefaultPage;
$limit = Neuron_Core_Tools::splitInPages($page, Dolumar_Players_Ranking::countRanking(), $currentPage, $perPage, 6);
$l = Dolumar_Players_Ranking::getRanking($limit['start'], $limit['perpage']);
// Get my villages
$myself = Neuron_GameServer::getPlayer();
if ($myself && $myself->isPremium()) {
$distances = $myself->getVillages();
} else {
$distances = array();
}
$i = $limit['start'];
foreach ($l as $v) {
$i++;
// Calcualte the distances
$w_distances = array();
foreach ($distances as $k => $vv) {
$w_distances[$k] = Neuron_Core_Tools::output_distance(Dolumar_Map_Map::getDistanceBetweenVillages($vv, $v), true, true);
}
$page->addListValue('ranking', array($i, Neuron_Core_Tools::output_varchar($v->getName()), $v->getId(), $v->getNetworth(), $v->getId() == $myVillageId, $w_distances));
//$v->__destruct ();
}
// Add the footnote
$t_distances = array();
foreach ($distances as $k => $v) {
$t_distances[$k] = Neuron_Core_Tools::output_varchar($v->getName());
}
$page->set('distances', $t_distances);
return $page->parse('ranking/ranking.tpl');
}
示例3: getVillageProfile
public function getVillageProfile($objVillage)
{
if (!$objVillage || !$objVillage->isFound()) {
return '<p>Village not found.</p>';
return null;
}
$text = Neuron_Core_Text::__getInstance();
$text->setFile('village');
$text->setSection('profile');
$townCenter = $objVillage->buildings->getTownCenter();
if ($townCenter) {
$l = $townCenter->getLocation();
} else {
$l = array('?', '?');
}
$page = new Neuron_Core_Template();
$page->set('village', Neuron_Core_Tools::output_varchar($objVillage->getName()));
$page->set('location', $text->get('location'));
$page->set('villageProfile', $text->get('villageProfile'));
$page->set('location_value', '[' . $l[0] . ',' . $l[1] . ']');
$page->set('locX', $l[0]);
$page->set('locY', $l[1]);
// Owner
$owner = $objVillage->getOwner();
$page->set('owner', $text->get('owner'));
$page->set('owner_value', Neuron_Core_Tools::output_varchar($owner->getNickname()));
$page->set('pid', $owner->getId());
// Ranking
$rank = $objVillage->getRank();
$page->set('rank', $text->get('rank'));
$page->set('rank_value', Neuron_Core_Tools::putIntoText($text->get('ranking'), array($rank[0], $rank[1])));
// Race
$race = $objVillage->getRace();
$page->set('race', $text->get('race'));
$page->set('race_value', Neuron_Core_Tools::output_varchar($race->getRaceName()));
$page->set('score', $objVillage->getNetworth());
$me = Neuron_GameServer::getPlayer();
if ($me && $objVillage->isActive()) {
foreach ($me->getVillages() as $v) {
if (!$v->equals($objVillage)) {
// Register the visit
$v->visits->registerVisit($objVillage);
$page->addListValue('challenges', array(Neuron_Core_Tools::putIntoText($text->get('challenge'), array(Neuron_Core_Tools::output_varchar($v->getName()))), htmlentities(json_encode(array('vid' => $v->getId(), 'target' => $objVillage->getId())))));
$distance = Dolumar_Map_Map::getDistanceBetweenVillages($v, $objVillage);
$page->addListValue('distances', array('id' => $v->getId(), 'name' => Neuron_Core_Tools::output_varchar($v->getName()), 'distance' => Neuron_Core_Tools::output_distance($distance, false, false)));
}
}
} elseif (!$objVillage->isActive()) {
$page->set('notActive', $text->get('notActive'));
}
// Set honour
$page->set('honour_value', $objVillage->honour->getHonour());
return $page->parse('villageProfile.tpl');
}
示例4: getChooseSpecialUnits
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');
}
示例5: getNoClan
private function getNoClan($profile, $err = false)
{
$page = new Neuron_Core_Template();
$page->setTextSection('noclan', 'clan');
$page->set('distance', Neuron_Core_Tools::output_distance(MAXCLANDISTANCE));
if ($err) {
$page->set('error', $err);
}
$clans = $this->getClosebyClans($profile);
foreach ($clans as $v) {
$page->addListValue('clans', array('id' => $v->getId(), 'name' => Neuron_Core_Tools::output_varchar($v->getName())));
}
return $page->parse('clan/noclan.phpt');
}
示例6: commandMoveUnit
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();
}
}