本文整理汇总了PHP中Neuron_Core_Tools::getDuration方法的典型用法代码示例。如果您正苦于以下问题:PHP Neuron_Core_Tools::getDuration方法的具体用法?PHP Neuron_Core_Tools::getDuration怎么用?PHP Neuron_Core_Tools::getDuration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Neuron_Core_Tools
的用法示例。
在下文中一共展示了Neuron_Core_Tools::getDuration方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getContent
public function getContent()
{
$map = $this->getServer()->getMap();
if (!$map instanceof Dolumar_Underworld_Map_Map) {
$this->reloadWindow();
return '<p>Mission is finished.</p>';
}
$mission = $map->getMission();
$sides = $mission->getSides();
$objective = $mission->getObjective();
// Check the victory conditions
$objective->checkVictoryConditions();
if ($objective instanceof Dolumar_Underworld_Models_Objectives_TakeAndHold) {
$out = '<p>Hold the center castle until the counter reaches 0.</p>';
$scores = $objective->getScores();
$out .= '<ul>';
foreach ($scores as $v) {
$timeleft = $objective->getHoldDuration() - $v['score'];
if ($timeleft > 0) {
if ($v['increasing']) {
$timeleft = Neuron_Core_Tools::getCountdown(NOW + $timeleft);
} else {
$timeleft = Neuron_Core_Tools::getDuration($timeleft);
}
} else {
$timeleft = 0;
}
$out .= '<li>' . $v['side']->getDisplayName() . ': ' . $timeleft . '</li>';
}
$out .= '</ul>';
} else {
$out = '<p>Just explore ^^</p>';
}
/*
foreach ($sides as $v)
{
$checkpoints = $objective->getConqueredCheckpoints ($v);
$score = count ($checkpoints);
$out .= '<p>- Team ' . $v->getId () . ': ' . $score . '</p>';
}*/
$out .= '<p>' . Neuron_URLBuilder::getInstance()->getOpenUrl('Battle', 'Battle reports', array()) . '</p>';
return $out;
}
示例2: getConfirmDonation
private function getConfirmDonation($target, $resources, $runes, $equipment)
{
$page = new Neuron_Core_Template();
$input = $this->aInput;
$input['confirmed'] = 1;
$page->set('input', json_encode($input));
$premium = $this->isPremium($target);
$costs = $this->calculateCosts($target, $resources, $runes, $premium);
// Count transactions
$t1 = $this->splitInTransactions($resources, self::RESOURCES_PER_TRANSPORTER);
$t2 = $this->splitInTransactions($runes, self::RUNES_PER_TRANSPORTER);
$t3 = $equipment;
$max_transactions = $this->countMaximumTransfers($premium);
$total_transactions = count($t1) + count($t2) + count($t3);
// Get duration
$duration = $this->getTransferDuration($target);
if (!$premium) {
$premiumcost = $this->calculateCosts($target, $resources, $runes, true);
if ($premiumcost) {
$page->set('premiumcost', $this->resourceToText($premiumcost));
// Check who's fault it is.
if ($this->getVillage()->getOwner()->isPremium()) {
$page->set('premiumerror', 'nothim');
} elseif ($target->getOwner()->isPremium()) {
$page->set('premiumerror', 'notyou');
} else {
$page->set('premiumerror', 'notboth');
}
}
}
if ($costs) {
$page->set('costs', $this->resourceToText($costs));
}
$page->set('target', Neuron_Core_Tools::output_varchar($target->getName()));
$page->set('targetid', $target->getId());
$page->set('resources', $this->resourceToText($resources));
$crunes = 0;
foreach ($runes as $k => $v) {
$crunes += $v;
}
$page->set('hasResources', $this->isFilled($resources));
$page->set('hasRunes', $this->isFilled($runes));
$page->set('hasEquipment', count($equipment) > 0);
$page->set('transactions', $total_transactions);
$page->set('maxtransactions', $max_transactions);
$page->set('duration', Neuron_Core_Tools::getDuration($duration));
$page->set('canConfirm', $total_transactions <= $this->countTransfersLeft($premium));
$page->set('runes', $crunes);
$page->set('tab', isset($input['tab']) ? $input['tab'] : 'resources');
foreach ($equipment as $v) {
$page->addListValue('equipment', array('id' => $v['equipment']->getId(), 'name' => $v['equipment']->getName($v['amount'] > 1), 'amount' => $v['amount']));
}
return $page->parse('buildings/market_confirm.phpt');
}
示例3: getCraftItem
private function getCraftItem($id, $input)
{
$db = Neuron_Core_Database::__getInstance();
// Check if this building is crafting already
$l = $db->select('villages_items', array('i_id'), "i_bid = '" . $this->getId() . "' AND i_endCraft > '" . time() . "'");
if (count($l) > 0) {
$text = Neuron_Core_Text::__getInstance();
$page = new Neuron_Core_Template();
$page->set('working', $text->get('working', 'crafting', 'buildings'));
$page->set('toReturn', $text->getClickTo($text->get('toReturn', 'crafting', 'buildings')));
return $page->parse('buildings/working.tpl');
} else {
$equipment = $this->getCraftableItems();
// Search for key
$key = false;
$equips = $this->getCraftableItems();
foreach ($equips as $k => $v) {
if ($v->getId() == $id) {
$key = $k;
}
}
if ($key !== false) {
$item = $equips[$key];
$text = Neuron_Core_Text::__getInstance();
$text->setFile('buildings');
$text->setSection('crafting');
// Check for input
if (isset($input['amount']) && is_numeric($input['amount'])) {
$aantal = abs(floor($input['amount']));
$cost = $item->getCraftCost($this->getVillage(), $aantal);
// Remove resources
if ($this->getVillage()->resources->takeResourcesAndRunes($cost)) {
$this->getVillage()->craftEquipment($this, $item, $item->getCraftDuration($this->getVillage(), $aantal), $aantal);
//return $this->getOverview ();
return '<p>' . $text->get('done') . '</p>';
} else {
$error = $text->get('noResources');
}
}
$page = new Neuron_Core_Template();
// Get max craftable
$player = $this->getVillage()->getOwner();
if ($player->isPremium()) {
$page->set('maxcraftable', Neuron_Core_Tools::putIntoText($text->get('maxcraftable'), array('amount' => $this->calculateMaxCraftable($item), 'items' => $item->getName(true))));
}
if (isset($error)) {
$page->set('error', $error);
}
$page->set('title', $text->get('title'));
$page->set('amount', $text->get('amount'));
$page->set('submit', $text->get('submit'));
$page->set('itemId', $item->getId());
$page->set('section', 'crafting');
$page->set('cost', $this->getCost($item));
$page->set('duration', Neuron_Core_Tools::putIntoText($text->get('duration'), array($item->getName(), Neuron_Core_Tools::getDuration($item->getCraftDuration($this->getVillage())))));
$page->set('stats', Neuron_Core_Tools::output_text($item->getStats_text(), false));
$page->set('about', Neuron_Core_Tools::putIntoText($text->get('craft'), array($item->getName(true))));
$page->set('return', $text->getClickTo($text->get('toReturn')));
return $page->parse('buildings/crafting.tpl');
} else {
return $this->getOverview();
}
}
}
示例4: getCustomContent
protected function getCustomContent($input)
{
$db = Neuron_Core_Database::__getInstance();
$text = Neuron_Core_Text::__getInstance();
$text->setFile('buildings');
$text->setSection('townCenter');
$page = new Neuron_Core_Template();
// Just to make sure we're not displaying old rune scouts.
$this->getVillage()->resources->getRunes();
// Change village name
if (isset($input['villageName'])) {
$input['villageName'] = strip_tags($input['villageName']);
if (!$this->getVillage()->setName($input['villageName'])) {
$page->set('changename_err', $text->get($this->getVillage()->getError()));
} else {
reloadEverything();
}
}
// Let's check if we are already searching for runes
$runeCheck = $db->select('villages_scouting', array('count(scoutId)'), "vid = '" . $this->getVillage()->getId() . "'");
$alreadyScouting = $runeCheck[0]['count(scoutId)'] > 0;
if (isset($input['do'])) {
if ($input['do'] == 'scout') {
$this->hideGeneralOptions();
$this->hideTechnologyUpgrades();
$currentPage = isset($input['pageid']) ? $input['pageid'] : 1;
if ($currentPage < 1) {
$currentPage = 1;
}
Neuron_Core_Tools::splitInPages($page, $currentPage * 4 + 8, $currentPage, 4, 4, array('do' => 'scout'), null, 'pageid');
if ($alreadyScouting) {
$page->set('scoutResults', $text->get('alreadyScouting'));
$page->set('scoutResult_isGood', false);
} else {
if (isset($input['runes']) && is_numeric($input['runes'])) {
$runes = intval($input['runes']);
// Let's start scouting
$village = $this->getVillage();
//$cost = $village->getScoutLandsCost ($runes);
if ($village->scout($runes)) {
$page->set('scoutResults', $text->get('doneScouting'));
$page->set('scoutResult_isGood', true);
} else {
$page->set('scoutResults', $text->get('searchNoRunes'));
$page->set('scoutResult_isGood', false);
}
} else {
$scoutoptions = array();
$start = ($currentPage - 1) * 4 + 1;
$end = $start + 4;
for ($i = $start; $i < $end; $i++) {
$duration = $this->getVillage()->getScoutLandsDuration($i);
$cost = $this->resourceToText($this->getVillage()->getScoutLandsCost($i));
$duration = Neuron_Core_Tools::getDuration($duration);
$scoutoptions[] = array('runes' => $i, 'scoutDuration' => $duration, 'scoutCost' => $cost);
}
$page->set('scoutoptions', $scoutoptions);
}
}
return $page->parse('buildings/townCenter_scoutRunes.phpt');
} else {
if ($input['do'] == 'explore') {
/*
* TODO ;-)
*
$village = $this->getVillage ();
$village->lookForNPCs ();
*/
}
}
}
$page->set('vid', $this->getVillage()->getId());
// Search for new runes
$page->set('searchRunes', $text->get('searchRunes'));
$page->set('scoutLands', $text->get('scoutLands'));
$page->set('scoutCost', $text->get('scoutCost'));
// Change name
$page->set('changeName', $text->get('changeName'));
$page->set('villageName', $text->get('villageName'));
$page->set('change', $text->get('change'));
$page->set('villageName_value', Neuron_Core_Tools::output_varchar($this->getVillage()->getName()));
$page->set('overview', $text->getClickTo($text->get('overview')));
$page->set('techniques', $text->getClickTo($text->get('techniques')));
$page->set('toScout', $text->getClickTo($text->get('toScout')));
return $page->parse('buildings/townCenter.phpt');
}
示例5: getContent
public function getContent($errorInput = null, $putIntoText = array())
{
// Keep original value in seperate variable!
$error = $errorInput;
$text = Neuron_Core_Text::__getInstance();
$login = Neuron_Core_Login::__getInstance();
$me = Neuron_GameServer::getPlayer();
$input = $this->getInputData();
if ($login->isLogin() && $this->village && $this->village->isActive() && $this->village->getOwner()->getId() == $me->getId()) {
// Make sure you are not in vacation mode.
if ($this->village->getOwner()->inVacationMode()) {
return '<p class="false">' . $text->get('vacationMode', 'main', 'main') . '</p>';
}
$page = new Neuron_Core_Template();
$page->set('intro', $text->get('intro', 'build', 'building'));
$page->set('construct', $text->get('construct', 'build', 'building'));
$page->set('click', $text->get('click', 'build', 'building'));
$selectrunewarning = addslashes($text->get('selectRune', 'build', 'building'));
$page->set('selectRune', $selectrunewarning);
$page->set('village', $this->village->getId());
// Workers are working.
if (!isset($error) && !$this->village->readyToBuild()) {
$error = 'stillConstructing';
}
// Show error.
if (isset($error)) {
$txterr = Neuron_Core_Tools::putIntoText($text->get($error, 'buildError', 'building'), $putIntoText);
$page->set('error', $txterr);
$page->set('errorV', $error);
if (isset($errorInput) && !empty($errorInput) && $errorInput != 'done') {
if ($error != 'done') {
switch ($error) {
case 'noRunes':
case 'noResources':
case 'stillConstructing':
$data = $this->getInputData();
$jsondata = json_encode(array('action' => 'queue', 'building' => $data['building'], 'x' => $data['x'], 'y' => $data['y'], 'rune' => $data['rune']));
$this->dialog($txterr, $text->get('queueBuild', 'queue', 'building'), 'windowAction (this, ' . $jsondata . ');', $text->get('okay', 'main', 'main'), 'void(0);');
break;
default:
$this->alert($txterr);
break;
}
}
}
}
// Get all buildings (even those who can't be build)
$buildings = Dolumar_Buildings_Building::getAllBuildings();
$buildings_out = array();
$race = $this->village->getRace();
foreach ($buildings as $buildingV) {
$building = Dolumar_Buildings_Building::getBuildingFromName($buildingV, $this->village->getRace());
if ($building->canBuildBuilding($this->village)) {
$duration = $building->getConstructionTime($this->village);
$dur = Neuron_Core_Tools::getDuration($duration);
$size = $building->getSize();
$buildings_out[] = array($building->getName(), $building->getBuildingCost_Text($this->village), $building->getDescription(), $building->getSmallImage($race), $building->getBuildingId(), $dur, $building->getImage($this->village->getRace()), $size[0], $size[1], 'canBuild' => $building->checkBuildingLevels($this->village), 'upgrade' => Neuron_Core_Tools::putIntoText($text->get('upgradeFirst', 'build', 'building'), array('name' => $building->getName(true))), 'myBuildingsName' => $building->getName($this->village->buildings->getBuildingAmount($building) > 1), 'action' => new Dolumar_View_SelectBuildLocation($building->getBuildingId(), 'build', 'building_' . $building->getBuildingId(), $building->getDisplayObject($race), null, $selectrunewarning));
}
}
// Order the list
//$page->sortList ('buildings');
usort($buildings_out, array($this, 'order_buildings'));
$page->set('list_buildings', $buildings_out);
return $page->parse('build.tpl');
} else {
return '<p class="false">' . $text->get('login', 'login', 'account') . '</p>';
}
}
示例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();
}
}
示例7: getUpgradeTechnology
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');
}
示例8: getFightReport
public function getFightReport($now = NOW, $logid = null, $showAll = false)
{
$text = Neuron_Core_Text::__getInstance();
$this->loadData();
$data = $this->data['battleLog'];
// Check how much "report" can be seen
$fightStart = $this->data['fightDate'];
$out = array();
$data = explode(';', $data);
array_pop($data);
$lastAction = null;
$out[] = Neuron_Core_Tools::putIntoText($text->getRandomLine('introtext', 'battlereport', $this->id), array('attacker' => $this->getAttacker()->getName(), 'defender' => $this->getDefender()->getName()));
$isDone = $showAll || $this->isDone();
$slots = json_decode($this->data['slots'], true);
if (isset($slots['attacking']) && isset($slots['defending'])) {
// Create thze battle report
$attacking = $this->parseUnitSlots($slots['attacking']);
$defending = $this->parseUnitSlots($slots['defending']);
$this->oBattlefield = new Dolumar_Battle_Battlefield($attacking, $defending);
} else {
$this->oBattlefield = new Dolumar_Battle_Battlefield(null, null);
}
$i = 0;
foreach ($data as $v) {
$facts = explode('|', $v);
$orgfacts = $facts;
if (count($facts) > 3) {
// Fetch the date from the data
$iDate = array_shift($facts);
// Jump out of the loop if date is in the future
if (!$isDone && $iDate + $fightStart > time()) {
break;
}
$iAction = intval(array_shift($facts));
$iRandom = array_shift($facts);
// $iTeam: attacker = 1, defender = 2.
$iTeam = array_shift($facts);
$isAttacker = $iTeam == 1;
$date = Neuron_Core_Tools::getDuration($iDate);
// Check for "empty" status report
if ($lastAction === 0 && $iAction === 0) {
array_pop($out);
}
$lastAction = $iAction;
// Check if we should push this log to the battlefield
if ($logid != null && $logid == $i) {
$selected = true;
$usefield = true;
} else {
$selected = false;
$usefield = $logid === null || $logid > $i;
}
switch ($iAction) {
// Status
case 0:
//$out[] = null;
$out[] = $text->getRandomLine('status_' . $facts[0], 'battlereport', $iRandom);
if ($usefield) {
$this->oBattlefield->nextround();
}
break;
// Move
// Move
case 1:
$unit = $this->getUnitData($facts[0]);
$out[] = Neuron_Core_Tools::putIntoText($text->getRandomLine('move', 'battlereport', $iRandom, $unit), array('unit' => (string) $unit, 'from' => $facts[1], 'to' => $facts[2]));
if ($usefield) {
$this->oBattlefield->move($isAttacker, $facts[1], $facts[2], $unit);
}
break;
// Stunned
// Stunned
case 2:
$unit = $this->getUnitData($facts[0]);
$slot = $this->getUnitSlot($facts[0]);
$out[] = Neuron_Core_Tools::putIntoText($text->getRandomLine('stunned', 'battlereport', $iRandom), array('unit' => (string) $unit));
if ($usefield) {
$this->oBattlefield->stunned(!$isAttacker, $slot, $unit);
}
break;
// Magic
// Magic
case 5:
/* 112|5|68|1|1:1|3|4:3:7::0:50|8 */
// unit | effect | probability
$unitData = explode(':', array_shift($facts));
$unit = Dolumar_SpecialUnits_SpecialUnits::getFromId($unitData[0]);
if ($unit) {
$unit->setLevel($unitData[1]);
$unit->setVillage($this->getAttacker());
$effectId = array_shift($facts);
$effect = Dolumar_Effects_Effect::getFromId($effectId);
$probability = array_shift($facts);
if ($effect && $effect instanceof Dolumar_Effects_Battle) {
$out[] = $effect->getBattleLog($this, $unit, $probability, $facts);
if ($usefield) {
$this->oBattlefield->specialunit_action($isAttacker, $unit, $effect, true);
}
} else {
$out[] = 'Unidentified battle effect: ' . $effectId;
//.........这里部分代码省略.........