if ($port->transaction[$good_id] == 'Sell' && $amount > $ship->cargo[$good_id]) {
    create_error("Scanning your ships indicates you don't have {$amount} pcs. of {$good_name}!");
}
// check if we have enough room for the thing we are going to buy
if ($port->transaction[$good_id] == 'Buy' && $amount > $ship->cargo_left) {
    create_error("Scanning your ships indicates you don't have enough free cargo bay!");
}
// check if the guy has enough money
if ($port->transaction[$good_id] == "Buy" && $player->credits < $bargain_price) {
    create_error("You don't have enough credits!");
}
// get relations for us (global + personal)
$relations = $player->relations[$port->race_id] + $player->relations_global_rev[$port->race_id];
$container = array();
$good_distance = get_good_distance($good_id, $port->transaction[$good_id]);
$ideal_price = get_ideal_price($good_id);
$offered_price = get_offered_price($good_id);
// nothing should happen here but just to avoid / by 0
if ($ideal_price == 0 || $offered_price == 0) {
    create_error("Port calculation error...buy more goods.");
}
// can we accept the current price?
if (!empty($bargain_price) && ($port->transaction[$good_id] == 'Buy' && $bargain_price >= $ideal_price || $port->transaction[$good_id] == 'Sell' && $bargain_price <= $ideal_price)) {
    // the url we going to
    $container["url"] = "skeleton.php";
    /*
    $first = pow($relations, 6);
    $second = pow(1000, 6) + .01;
    
    $factor = ($bargain_price - $offered_price) / (($ideal_price - $offered_price) + .01) + ($first / $second);
    if ($factor > 1)
Beispiel #2
0
$container = array();
$container["url"] = "shop_goods_processing.php";
transfer("amount");
transfer("good_id");
transfer("good_name");
transfer("good_class");
transfer("good_distance");
transfer("offered_price");
transfer("ideal_price");
transfer("number_of_bargains");
transfer("overall_number_of_bargains");
print_form($container);
$relations = $player->relations[$port->race_id] + $player->relations_global_rev[$port->race_id];
$value = round(pow($relations / 1000, 10));
//gives value 0-1
$ideal_price = get_ideal_price();
$offered_price = get_offered_price();
//print("$ideal_price, $offered_price,");
$show_price = abs($offered_price - $ideal_price);
//print("$show_price,");
$show_price = $show_price * $value;
//print("$show_price,");
if ($port->transaction[$good_id] == 'Sell') {
    $show_price = $bargain_price + $show_price;
} else {
    $show_price = $bargain_price - $show_price;
}
//print("$show_price");
print "<input type=\"text\" name=\"bargain_price\" value=\"{$show_price}\" id=\"InputFields\" style=\"width:75;text-align:center;vertical-align:middle;\">&nbsp;";
print '<!-- here are all information that are needed to calculate the ideal price. if you know how feel free to create a trade calculator -->';
print '<!--(' . $var['amount'] . ':' . $port->base_price[$good_id] . ':' . $var['good_distance'] . ':' . $port->amount[$good_id] . ':' . $port->max_amount[$good_id] . ':' . $relations . ':' . $port->level . ')-->';