Beispiel #1
0
                $loop_txt .= "<b class='b1'>{$this_ship['ship_name']}</b> {$st['746']}<br />";
                dbn("update {$db_name}_ships set login_id = '{$target['login_id']}', fleet_id = '1', clan_id = {$target['clan_id']}, metal=0, fuel=0, elect=0, colon=0 where ship_id = '{$ship_id}'");
                //ensure don't go over the limit
                if ($this_ship['is_warship'] == 1) {
                    $target_ship_count['warships']++;
                } else {
                    $target_ship_count['other_ships']++;
                }
                $transfer_counter++;
            }
        }
        $text .= sprintf($st[747], $transfer_counter, $num_ships) . "<p />" . $loop_txt;
        if ($transfer_counter > 0) {
            $total_cost = $cost_per_transfer * $transfer_counter;
            $text .= "<p />{$st['7480']} {$total_cost} " . $cw['credits'];
            take_cash($total_cost);
            post_news("<b class='b1'>" . sprintf($st[748], $user[login_name], $transfer_counter, $target[login_name]), "ship");
            send_message($target['login_id'], sprintf($st[749], $transfer_counter, $user[login_name]));
            insert_history($user['login_id'], sprintf($st[750], $transfer_counter, $target[login_name]));
        }
    }
    print_page($cw['transfer_ship'], $text);
}
$text .= sprintf($st[751], $target[login_name]) . "<br /><br />";
$text .= "<b class='b1'>" . $st[752] . "<br />";
$text .= "<form action=send_ship.php method=POST name=transfer_ships><table>";
db("select ship_name, class_name, location, fighters, max_fighters, shields, max_shields, armour, max_armour, config, ship_id from {$db_name}_ships where login_id = '{$user['login_id']}' && ship_id != '{$user['ship_id']}' order by class_name");
$ships = dbr(1);
if (!isset($ships)) {
    #ensure there are some ships to display
    $text .= $st[753];
Beispiel #2
0
    } elseif ($planet['research_fac'] != 0) {
        $out .= $st[111];
    } elseif ($num_research[0] > 1) {
        $out .= $st[112];
    } elseif (!isset($_POST['sure'])) {
        get_var($cw['buy_research_facility'], $_SERVER['PHP_SELF'], sprintf($st[113], $GAME_VARS[hourly_tech]) . popup_help("help.php?topic=Blackmarkets&sub_topic=Research_Facilities_and_Support_Units&popup=1", 500, 400, $cw['click_here']) . ".", 'sure', 'yes');
    } else {
        take_cash($research_fac_cost);
        $out .= sprintf($st[114], $planet[planet_name], $research_fac_cost);
        dbn("update {$db_name}_planets set research_fac = '1' where planet_id = '{$planet['planet_id']}'");
    }
    #build a shield generator
} elseif (isset($_REQUEST['shield_gen'])) {
    $header = $cw['shield_generator_construction'];
    if ($user['cash'] < $shield_gen_cost) {
        $out .= $st[115];
    } elseif (!avail_check(3000)) {
        $out .= $st[110];
    } elseif ($planet['shield_gen'] > 0) {
        $out .= $st[116];
    } elseif (!isset($sure)) {
        get_var($cw['buy_shield_generator'], 'add_planetary.php', $st[117] . popup_help("help.php?topic=Planets&popup=1&sub_topic=Shield_Generators", 400, 220, $cw['click_here']) . ".", 'sure', 'yes');
    } else {
        take_cash($shield_gen_cost);
        $out .= sprintf($st[118], $planet[planet_name], $shield_gen_cost);
        dbn("update {$db_name}_planets set shield_gen = '3' where planet_id = '{$planet['planet_id']}'");
    }
} else {
    $out = $st[119];
}
print_page($header, $out . "<p /><a href='planet.php?planet_id={$planet_id}'>" . $st[120] . "</a>");
Beispiel #3
0
    }
    $amount = (int) $_POST['amount'];
    if (!avail_check(4001)) {
        $out .= $st[432];
    } elseif ($user['turns'] < 1) {
        $out .= $st[433];
    } elseif ($amount <= 0) {
        get_var('Take Colonists', $_SERVER['PHP_SELF'], "<a href='{$_SERVER['PHP_SELF']}?all_colon=1'>Fill Ship</a><p />Combien de colons voulez-vous acheter ?<br />Chaque colon coûte <b>{$GAME_VARS['cost_colonist']}</b> crédits.<p />", 'amount', $fill);
    } elseif ($fill < 1) {
        $out .= $st[1892] . "<p />";
    } elseif ($amount > $user_ship['empty_bays']) {
        $out .= "You can't carry that many colonists.<p />";
    } elseif ($amount * $GAME_VARS['cost_colonist'] > $user['cash']) {
        $out .= "You can't afford that many colonists.<p />";
    } else {
        take_cash($GAME_VARS['cost_colonist'] * $amount);
        charge_turns(1);
        dbn("update {$db_name}_ships set colon = colon + '{$amount}' where ship_id = '{$user['ship_id']}'");
        $user_ship['colon'] += $amount;
        $user_ship['empty_bays'] -= $amount;
    }
    //the ship shop. listing ships
} elseif (isset($_GET['ship_shop'])) {
    $out .= $st[1800] . '<br /><br />';
    $array_ships = array("Cargo" => "", "Bataille" => "", "Transport" => "", "Modulaires" => "", "Autres" => "");
    $ship_types = load_ship_types(0);
    foreach ($ship_types as $type_id => $ship_stats) {
        if ($type_id < 3 || $ship_stats['tcost'] != 0) {
            //skip the EP and SD, as well as BM ships.
            continue;
        } else {
Beispiel #4
0
    } else {
        settype($trans_amount, "integer");
        db2("select * from user_accounts where login_id = '{$trans_target_id}' LIMIT 1");
        $user_transferto = dbr2();
        db2("select * from user_accounts where login_id = '" . $user['login_id'] . "' LIMIT 1");
        $user_transferfrom = dbr2();
        if ($trans_amount <= 0) {
            print_page($cw['transfer_error'], $st[1505] . "<br /><a href='javascript:back()'>" . $cw['go_back'] . "</a><br />");
        } elseif ($user['cash'] < $trans_amount) {
            print_page($cw['transfer_error'], $st[1506] . "<br /><a href='javascript:back()'>" . $cw['go_back'] . "</a><br />");
        } elseif ($user['joined_game'] > time() - $min_before_transfer * 86400 && $user['login_id'] > 1) {
            print_page($cw['transfer_error'], sprintf($st[1507], $GAME_VARS[min_before_transfer]) . " <br /><a href='javascript:back()'>" . $cw['go_back'] . "</a><br />");
        } elseif ($user_transferfrom['last_ip'] == $user_transferto['last_ip']) {
            print_page($cw['transfer_error'], sprintf($st[1890], $user_transferto['login_name']));
        } else {
            take_cash($trans_amount);
            dbn("update {$db_name}_users set cash = cash + {$trans_amount} where login_id = '" . $trans_target_id . "'");
            send_message($trans_target_id, "<b class='b1'>{$user['login_name']}</b> " . $st[1508] . " <b>{$trans_amount}</b> " . $cw['credits'] . ".");
            insert_history($user['login_id'], sprintf($st[1509], $trans_amount, $trans_target));
            print_page($cw['transfer_complete'], sprintf($st[1510], $trans_amount) . " <b class='b1'>{$trans_target}</b>.");
        }
    }
}
db("select u.*, pu.*, pu.login_name as generic_l_name, u.login_name as login_name from {$db_name}_users u, user_accounts pu where u.login_id = '{$target}' && pu.login_id = u.login_id");
$player = dbr();
#used to calculate percentages
db("select sum(cash) as cash, sum(fighters_killed) as fighters_killed, sum(fighters_lost) as fighters_lost, sum(score) as score, sum(tech) as tech, sum(ships_killed) as ships_killed, sum(ships_lost) as ships_lost, sum(ships_killed_points) as ships_killed_points, sum(ships_lost_points) as ships_lost_points, sum(turns_run) as turns_run, sum(turns) as turns, sum(game_login_count) as game_login_count, sum(approx_value) as approx_value from {$db_name}_users where login_id > '5'");
$all_player = dbr();
# Won't display alien or pirate information, or the other two reserved accounts.
# they have login_id 2 or 3, or 4,5 for the reserved ones.
# Minimum login id is 0 (or 1, but then as admin gets 1, it must be 2 for players cos its auto increment).
Beispiel #5
0
function make_standard_upgrade($upgrade_str, $config_addon, $cost, $developement_id, $tech_cost = 0)
{
    global $user, $user_ship, $db_name, $cw, $st;
    if ($user['cash'] < $cost) {
        return sprintf($st[197], $upgrade_str);
    } elseif ($user['tech'] < $tech_cost && $tech_cost > 0) {
        return $st[198];
    } elseif (!avail_check($developement_id)) {
        return sprintf($st[199], $upgrade_str);
    } elseif (config_check($config_addon, $user_ship)) {
        return sprintf($st[600], $upgrade_str);
    } elseif ($user_ship['upgrade_slots'] < 1) {
        return "";
    } else {
        take_cash($cost);
        take_tech($tech_cost);
        $user_ship['config'] .= "," . $config_addon;
        dbn("update {$db_name}_ships set config = '{$user_ship['config']} ', upgrade_slots = upgrade_slots - 1 where ship_id = '{$user['ship_id']}'");
        $user_ship['upgrade_slots']--;
        return "<b class='b1'>{$upgrade_str}</b>, " . sprintf($st[601], $user_ship[ship_name], $cost) . "<p />";
    }
}
Beispiel #6
0
        $user['genesis']++;
        dbn("update {$db_name}_users set genesis = genesis + 1 where login_id = '{$user['login_id']}'");
    }
} elseif ($buy == 8) {
    //Terra Imploder
    if ($user['cash'] < $terra_i_c) {
        $error_str .= $st[409];
    } elseif ($user['tech'] < $terra_i_t) {
        $error_str .= $st[410];
    } elseif (!avail_check(1000)) {
        $error_str .= $st[411];
    } elseif (!isset($sure)) {
        get_var($cw['purchase_terra_emploder'], $filename, $st[412], 'sure', '');
    } else {
        $error_str .= sprintf($st[413], $terra_i_c, $terra_i_t);
        take_cash($terra_i_c);
        take_tech($terra_i_t);
        $user['terra_imploder']++;
        dbn("update {$db_name}_users set terra_imploder = terra_imploder + 1 where login_id = '{$user['login_id']}'");
    }
} elseif ($buy == 9) {
    //Advanced Engine Upgrade
    if ($user_ship['move_turn_cost'] < 3) {
        $error_str .= $st[414];
    } elseif (config_check("e1", $user_ship)) {
        $error_str .= $st[415];
    } elseif (!isset($sure)) {
        get_var($cw['purchase_advanced_engine_upgrade'], $filename, $st[416] . "<b class='b1'>{$user_ship['ship_name']}</b>?", 'sure', '');
    } else {
        $error_str .= make_standard_upgrade($cw['advanced_engine_upgrade'], "e2", $advanced_engine_c, 5003, $advanced_engine_t);
        $user_ship['move_turn_cost'] = $user_ship['move_turn_cost'] - 2;
Beispiel #7
0
        dbn("update {$db_name}_planets set alloc_elect = {$num_pop_set_2} where planet_id = {$user['on_planet']}");
    }
} elseif (isset($monetary)) {
    #ensure all are rounded & valid
    $set_cash = round($set_cash);
    settype($set_cash, "integer");
    if ($set_cash >= 0 && $set_cash != $planet['cash']) {
        #cash dispensary
        if ($set_cash > $user['cash'] + $planet['cash']) {
            #ensure user doesn't go over the limit.
            $set_cash = $user['cash'] + $planet['cash'];
        }
        if ($set_cash > $planet['cash']) {
            #user putting money onto planet.
            $take_from_user = $set_cash - $planet['cash'];
            take_cash($take_from_user);
            $planet['cash'] = $set_cash;
            dbn("update {$db_name}_planets set cash = {$set_cash} where planet_id = {$user['on_planet']}");
        } else {
            #taking money from planet.
            $give_to_user = $planet['cash'] - $set_cash;
            give_cash($give_to_user);
            $planet['cash'] = $set_cash;
            dbn("update {$db_name}_planets set cash = {$set_cash} where planet_id = {$user['on_planet']}");
        }
    }
    if (isset($set_tech) && $GAME_VARS['uv_num_bmrkt'] > 0) {
        #tech units
        $set_tech = round($set_tech);
        settype($set_tech, "integer");
        if ($set_tech >= 0 && $set_tech != $planet['tech']) {
Beispiel #8
0
     } else {
         #no commodity to sell
         $error_str .= sprintf($st[762], $resource_str) . "<p />";
     }
 } else {
     #user has entered amount of resource to play with
     if ($buy_sell == 0) {
         # buy continued
         if ($amount * $buy_cost > $user['cash'] && $user['login_id'] != 1) {
             $error_str .= $st[763] . $resource_str . ".<p />";
         } elseif ($GAME_VARS['alternate_play_1'] == 1 && ($deal == 1 || $deal == 2)) {
             print_page($cw['error'], $st[764]);
         } elseif ($amount > $user_ship['empty_bays']) {
             $error_str .= "{$st['765']} {$resource_str}.<p />";
         } else {
             take_cash($amount * $buy_cost);
             dbn("update {$db_name}_ships set {$resource_deal} = {$resource_deal} + {$amount} where ship_id = {$user['ship_id']}");
             $user_ship[$resource_deal] += $amount;
             $error_str .= sprintf($st[766], $amount, $resource_str) . $amount * $buy_cost . "</b> " . $cw['credits'] . ".<p />";
         }
     } elseif ($buy_sell == 1) {
         #sell metal
         if ($amount > $user_ship[$resource_deal]) {
             $error_str .= "{$st['767']} {$resource_str}.<p />";
         } else {
             give_cash($amount * $sell_cost);
             dbn("update {$db_name}_ships set {$resource_deal} = {$resource_deal} - {$amount} where ship_id = {$user['ship_id']}");
             $user_ship[$resource_deal] -= $amount;
             $error_str .= sprintf($st[768], $amount, $resource_str) . " <b>" . $amount * $sell_cost . "</b> " . $cw['credits'] . ".<p />";
         }
     }
Beispiel #9
0
     $error_str = sprintf($st[371], $num_ships[warships], $GAME_VARS[max_warships]);
 } elseif ($num_ships['other_reached'] && !config_check("bs", $ship_stats)) {
     $error_str = sprintf($st[372], $num_ships[other_ships], $GAME_VARS[max_other_ships]);
 } elseif ($ship_type == 1 || $ship_type == 0) {
     $error_str = $st[373];
 } elseif (!avail_check($ship_type)) {
     $error_str .= $st[374];
 } elseif ($user['cash'] < $ship_stats['cost']) {
     $error_str = sprintf($st[375], $ship_stats[name]);
 } elseif ($user['tech'] < $ship_stats['tcost']) {
     $error_str = sprintf($st[376], $ship_stats[name]);
 } elseif (!isset($ship_name)) {
     $rs = "<p /><a href='bm_ships.php'>" . $cw['return_to_blacmarket_ships'] . "</a>";
     get_var($cw['name_your_new_ship'], 'bm_ships.php', sprintf($st[377], $num_ships[total_ships]) . "<b class='b1'>{$ship_stats['name']}</b>:(20 Char Max)", 'ship_name', '');
 } else {
     take_cash($ship_stats['cost']);
     take_tech($ship_stats['tcost']);
     // remove old escape pods
     dbn("delete from {$db_name}_ships where login_id = '{$user['login_id']}' && class_name REGEXP 'Escape'");
     $ship_name = correct_name($ship_name);
     if (empty($user_ship['fleet_id']) || $user_ship['fleet_id'] < 1) {
         $user_ship['fleet_id'] = 1;
     }
     // build the new ship
     $q_string = "insert into {$db_name}_ships (";
     $q_string = $q_string . "ship_name, login_id, location, clan_id, shipclass, class_name, class_name_abbr, fighters, max_fighters, max_shields, armour, max_armour, cargo_bays, mine_rate_metal, mine_rate_fuel, config, size, upgrade_slots, move_turn_cost, point_value, num_pc, num_ot, num_dt, num_ew, fleet_id";
     $q_string = $q_string . ") values(";
     $q_string = $q_string . "'{$ship_name}', '{$login_id}', {$user['location']}, '{$user['clan_id']}', '{$ship_stats['type_id']}', '{$ship_stats['name']}', '{$ship_stats['class_abbr']}', '{$ship_stats['fighters']}', '{$ship_stats['max_fighters']}', '{$ship_stats['max_shields']}', '{$ship_stats['max_armour']}', '{$ship_stats['max_armour']}', '{$ship_stats['cargo_bays']}', '{$ship_stats['mine_rate_metal']}', '{$ship_stats['mine_rate_fuel']}', '{$ship_stats['config']}', '{$ship_stats['size']}', '{$ship_stats['upgrade_slots']}', '{$ship_stats['move_turn_cost']}', '{$ship_stats['point_value']}', '{$ship_stats['num_pc']}', '{$ship_stats['num_ot']}', '{$ship_stats['num_dt']}', '{$ship_stats['num_ew']}', '{$user_ship['fleet_id']}')";
     dbn($q_string);
     $new_ship_id = mysql_insert_id();
     #the game goes all screwy if a player get's hold of ship_id 1.
Beispiel #10
0
function make_basic_upgrade($upgrade_str, $upgrade_sql, $inc_amount, $cost)
{
    global $user, $user_ship, $db_name;
    if ($user['cash'] < $cost) {
        return $st[662];
    } elseif ($user_ship['upgrade_slots'] < 1) {
        return "";
    } else {
        take_cash($cost);
        dbn("update {$db_name}_ships set {$upgrade_sql} = {$upgrade_sql} + '{$inc_amount}', upgrade_slots = upgrade_slots - 1 where ship_id = '{$user_ship['ship_id']}'");
        $user_ship['upgrade_slots']--;
        $user_ship[$upgrade_sql] += $inc_amount;
        if ($upgrade_sql == "cargo_bays") {
            $user_ship['empty_bays'] += $cargo_inc;
        }
        return sprintf($st[663], $user_ship[ship_name], $upgrade_str, $inc_amount, $cost);
    }
}
Beispiel #11
0
function buy_basic($item_sql, $item_max_sql, $item_str, $cost)
{
    global $amount, $user, $user_ship, $db_name, $st, $cw;
    settype($amount, "int");
    //security check
    $ret_str = "";
    if ($user_ship[$item_sql] >= $user_ship[$item_max_sql]) {
        $ret_str .= sprintf($st[1052], $item_str);
    } elseif ($amount < 1) {
        $amount_can_buy = floor($user['cash'] / $cost);
        if ($amount_can_buy > $user_ship[$item_max_sql] - $user_ship[$item_sql]) {
            $amount_can_buy = $user_ship[$item_max_sql] - $user_ship[$item_sql];
        }
        get_var($cw['buy'] . " {$item_str}", 'equip_shop.php', sprintf($st[759], $item_str), 'amount', $amount_can_buy);
    } else {
        $total_cost = $amount * $cost;
        if ($user['cash'] < $total_cost) {
            $ret_str .= $st[1054] . "<b class='b1'>{$item_str}</b>.<p />";
        } elseif ($user_ship[$item_sql] + $amount > $user_ship[$item_max_sql]) {
            $ret_str .= $st[1055] . " <b class='b1'>{$item_str}</b>.<p />";
        } else {
            $ret_str .= "<b>{$amount}</b> <b class='b1'>{$item_str}</b> " . $cw['purchased_for'] . " <b>{$total_cost}</b> " . $cw['credits.'] . "<p />";
            take_cash($total_cost);
            dbn("update {$db_name}_ships set {$item_sql} = {$item_sql} + '{$amount}' where ship_id = '{$user_ship['ship_id']}'");
            $user_ship[$item_sql] += $amount;
        }
    }
    return $ret_str;
}
Beispiel #12
0
    } elseif ($new_bid) {
        settype($new_bid, "integer");
        $new_price = round($item[going_price] / 100 * $rate) + $item[going_price];
        if ($new_bid > $user[cash]) {
            $text .= $st[352];
        } elseif ($new_price > $new_bid) {
            $text .= sprintf($st[353], $rate, $new_price);
        } elseif ($new_bid < 1) {
            $text .= $st[354];
        } else {
            if ($item['bidder_id'] > 0) {
                dbn("update {$db_name}_users set cash= cash + '{$item['going_price']}' where login_id='{$item['bidder_id']}'");
                dbn("insert into {$db_name}_messages (timestamp,sender_name, sender_id, login_id, text) values(" . time() . ",'Bilkos','{$user['login_id']}','{$item['bidder_id']}','Your bid on the <b class=\\'b1\\'>{$item['item_name']}</b> has been beaten by <b class=\\'b1\\'>{$user['login_name']}</b> who has put a new bid of <b>{$new_bid}</b> Credits on the item.<p />The lot will remain open for a further <b>{$GAME_VARS['bilkos_time']} hrs</b>. If there are no new bidders, then <b class=\\'b1\\'>{$user['login_name']}</b> will take the lot.<p />You have been refunded the money you deposited on the lot.')");
            }
            dbn("update {$db_name}_bilkos set timestamp=" . time() . ", bidder_id={$user['login_id']},going_price = '{$new_bid}' where item_id = '{$bid}'");
            take_cash($new_bid);
            $text .= sprintf($st[355], $GAME_VARS[bilkos_time], $item[item_name]);
        }
    } else {
        $new_price = round($item[going_price] / 100 * $rate) + $item[going_price];
        $text .= sprintf($st[356], $item[item_name], $item[going_price], $new_price);
        $text .= "<form method=post action=bilkos.php name=bid_form>";
        $text .= "<input type=hidden name=bid value={$bid} />";
        $text .= "<input type=text name=new_bid size=10 />";
        $text .= " - <input type='submit' value=" . $cw['bid'] . " /></form><p />";
        $rs = "<a href='bilkos.php'>Back to Bilkos</a>";
        print_page($st[357], $text);
    }
} elseif ($view) {
    #Show all items in a particular catagory.
    $text .= $st[358] . "<p />";