當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Globals::getHardwareName方法代碼示例

本文整理匯總了PHP中Globals::getHardwareName方法的典型用法代碼示例。如果您正苦於以下問題:PHP Globals::getHardwareName方法的具體用法?PHP Globals::getHardwareName怎麽用?PHP Globals::getHardwareName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Globals的用法示例。


在下文中一共展示了Globals::getHardwareName方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: create_error

<?php

$amount = $_REQUEST['amount'];
if (!is_numeric($amount)) {
    create_error('Numbers only please');
}
// only whole numbers allowed
$amount = floor($amount);
$hardware_id = $var['hardware_id'];
$hardware_name = Globals::getHardwareName($hardware_id);
$cost = Globals::getHardwareCost($hardware_id);
// no negative amounts are allowed
if ($amount <= 0) {
    create_error('You must actually enter an amount greater than zero!');
}
// do we have enough cash?
if ($player->getCredits() < $cost * $amount) {
    create_error('You don\'t have enough credits to buy ' . $amount . ' items!');
}
// chec for max. we can hold!
if ($amount > $ship->getMaxHardware($hardware_id) - $ship->getHardware($hardware_id)) {
    create_error('You can\'t buy more ' . $hardware_name . ' than you can transport!');
}
// take the money from the user
$player->decreaseCredits($cost * $amount);
$player->update();
// now adjust add to ship
$ship->increaseHardware($hardware_id, $amount);
$ship->updateHardware();
$ship->removeUnderAttack();
//HoF
開發者ID:smrealms,項目名稱:smrv2.0,代碼行數:31,代碼來源:shop_hardware_processing.php

示例2: foreach

        }
        if ($sector->hasLocation()) {
            $locationsString = 'Locations=';
            $locations =& $sector->getLocations();
            foreach ($locations as &$location) {
                $locationsString .= inify($location->getName()) . ',';
            }
            unset($location);
            unset($locations);
            $file .= substr($locationsString, 0, -1) . EOL;
        }
        if ($adminCreate === false && $sector->hasFriendlyForces($player)) {
            $forcesString = 'FriendlyForces=';
            $friendlyForces =& $sector->getFriendlyForces($player);
            foreach ($friendlyForces as &$forces) {
                $forcesString .= inify($forces->getOwner()->getPlayerName()) . '=' . inify(Globals::getHardwareName(HARDWARE_MINE)) . '=' . $forces->getMines() . ';' . inify(Globals::getHardwareName(HARDWARE_COMBAT)) . '=' . $forces->getCDs() . ';' . inify(Globals::getHardwareName(HARDWARE_SCOUT)) . '=' . $forces->getSDs() . ',';
            }
            unset($forces);
            unset($friendlyForces);
            $file .= substr($forcesString, 0, -1) . EOL;
        }
    }
    unset($sector);
}
unset($galaxy);
$size = strlen($file);
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Cache-Control: private', false);
header('Content-Type: application/force-download');
開發者ID:smrealms,項目名稱:smrv2.0,代碼行數:31,代碼來源:smr_file_create.php

示例3: doUNO

function doUNO($hardwareID, $amount)
{
    debug('Buying ' . $amount . ' units of "' . Globals::getHardwareName($hardwareID) . '"');
    $_REQUEST['amount'] = $amount;
    return create_container('shop_hardware_processing.php', '', array('hardware_id' => $hardwareID));
}
開發者ID:smrealms,項目名稱:smrv2.0,代碼行數:6,代碼來源:npc.php


注:本文中的Globals::getHardwareName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。