コード例 #1
0
<?php

$good_id = $var['good_id'];
$good_name = Globals::getGoodName($good_id);
if (isset($_REQUEST['amount'])) {
    SmrSession::updateVar('amount', $_REQUEST['amount']);
}
$amount = $var['amount'];
if (!is_numeric($amount)) {
    create_error('Numbers only please!');
}
if ($amount <= 0) {
    create_error('You must actually enter an ammount > 0!');
}
if ($player->isLandedOnPlanet()) {
    create_error('You can\'t dump cargo while on a planet!');
}
if ($player->getTurns() < 1) {
    create_error('You do not have enough turns to dump cargo!');
}
//lets make sure there is actually that much on the ship
if ($amount > $ship->getCargo($good_id)) {
    create_error('You can\'t dump more than you have.');
}
$sector =& $player->getSector();
if ($sector->offersFederalProtection()) {
    create_error('You can\'t dump cargo in a Federal Sector!');
}
require_once 'shop_goods.inc';
// get the distance
$x = Globals::getGood($good_id);
コード例 #2
0
$planet =& $player->getSectorPlanet();
$action = $_REQUEST['action'];
// transfer to ship
if ($action == 'Ship') {
    // do we want transfer more than we have?
    if ($amount > $planet->getStockpile($var['good_id'])) {
        create_error('You can\'t take more than on planet!');
    }
    // do we want to transfer more than we can carry?
    if ($amount > $ship->getEmptyHolds()) {
        create_error('You can\'t take more than you can carry!');
    }
    // now transfer
    $planet->decreaseStockpile($var['good_id'], $amount);
    $ship->increaseCargo($var['good_id'], $amount);
    $account->log(LOG_TYPE_PLANETS, 'Player takes ' . $amount . ' ' . Globals::getGoodName($var['good_id']) . ' from planet.', $player->getSectorID());
    // transfer to planet
} elseif ($action == 'Planet') {
    // do we want transfer more than we have?
    if ($amount > $ship->getCargo($var['good_id'])) {
        create_error('You can\'t store more than you carry!');
    }
    // do we want to transfer more than the planet can hold?
    if ($amount > $planet->getRemainingStockpile($var['good_id'])) {
        create_error('You can only put 600 per item at planet!');
    }
    // now transfer
    $planet->increaseStockpile($var['good_id'], $amount);
    $ship->decreaseCargo($var['good_id'], $amount);
}
// update both