示例#1
0
<?php

require_once get_file_loc("smr_port.inc");
print_topic("PORT RAID");
print "<font color=red>WARNING WARNING</font> port assault about to commence!!<br>";
print "Are you sure you want to attack this port?<br><br>";
$port = new SMR_PORT($player->sector_id, $player->game_id);
$time = time();
if ($port->refresh_defense < $time) {
    //defences restock (check for fed arrival)
    $minsToStay = 30;
    if ($port->refresh_defense + $minsToStay * 60 > $time) {
        $federal_mod = ($time - $port->refresh_defense - $minsToStay * 60) / (-6 * $minsToStay);
    } else {
        $federal_mod = 0;
    }
    if ($federal_mod < 0) {
        $federal_mod = 0;
    }
    if ($federal_mod > 0) {
        print "Ships dispatched by the Federal Government have just arrived and are in a defensive position around the port.<br>";
    }
    $rich_mod = floor($port->credits * 1.0E-7);
    if ($rich_mod < 0) {
        $rich_mod = 0;
    }
    $port->shields = round($port->level * 1000 + 1000 + $rich_mod * 500 + $federal_mod * 500);
    $port->armor = round($port->level * 1000 + 1000 + $rich_mod * 500 + $federal_mod * 500);
    $port->drones = round($port->level * 100 + 100 + $rich_mod * 50 + $federal_mod * 50);
    $port->update();
}
<?php

require_once get_file_loc('smr_sector.inc');
$sector = new SMR_SECTOR($player->sector_id, SmrSession::$game_id, SmrSession::$old_account_id);
require_once get_file_loc("smr_port.inc");
require_once get_file_loc("smr_battle.inc");
$port = new SMR_PORT($player->sector_id, $player->game_id);
if ($player->newbie_turns > 0) {
    create_error("You are under newbie protection!");
}
if ($player->is_fed_protected()) {
    create_error("You are under federal protection! That wouldn't be fair.");
}
if (!$sector->has_port()) {
    create_error("There is no port in that sector!");
}
// check if he got enough turns
if ($player->get_info('turns') < 3) {
    create_error("You do not have enough turns to attack this port!");
}
$db->query("SELECT * FROM ship_has_weapon NATURAL JOIN weapon_type " . "WHERE account_id = {$player->account_id} AND " . "game_id = {$player->game_id} " . "ORDER BY order_id");
if (!$db->next_record()) {
    //do we have drones to attack?
    $db->query("SELECT * FROM ship_has_hardware WHERE hardware_type_id = HARDWARE_COMBAT AND account_id = {$player->account_id} AND game_id = {$player->game_id}");
    if (!$db->next_record()) {
        create_error("What are you gonna do? Insult it to death?");
    }
}
//set the attack start time
$time = time();
//only 1 shot per 2 seconds (stop double port raids)
$GLOBALS['good_id'] = null;
$GLOBALS['amount'] = null;
$GLOBALS['good_distance'] = null;
$GLOBALS['relations'] = null;
$GLOBALS['ideal_price'] = null;
$GLOBALS['offered_price'] = null;
$GLOBALS['ideal_price'] = null;
$GLOBALS['bargain_price'] = null;
$GLOBALS['port'] = null;
$GLOBALS['amount'] = null;
global $port, $good_id, $amount, $good_distance, $relations, $ideal_price, $offered_price, $ideal_price, $bargain_price, $amount;
// initialize random generator.
mt_srand((double) microtime() * 1000000);
require_once "shop_goods.inc";
// creates needed objects
$port = new SMR_PORT($player->sector_id, SmrSession::$game_id);
$amount = get_amount();
$bargain_price = get_bargain_price();
if (!is_numeric($amount)) {
    create_error("Numbers only please");
}
if (!is_numeric($bargain_price)) {
    create_error("Numbers only please");
}
// get good name, id, ...
$good_id = $var["good_id"];
$good_name = $var["good_name"];
$good_class = $var["good_class"];
// do we have enough turns?
if ($player->turns == 0) {
    create_error("You don't have enough turns to trade.");