Exemple #1
0
                    print_page($cw['command_failed'], sprintf($st[5], $dist, $user[turns]));
                } else {
                    $header = $cw['remote_command'];
                    charge_turns($dist);
                    $user_loc_message .= sprintf($st[6], $dist);
                }
            }
        } else {
            $user_loc_message .= $cw['command_transfered'] . ".<p />";
        }
        explore_sys($user, $temp_ship['location']);
        dbn("update {$db_name}_users set ship_id = '{$command}' where login_id = '{$user['login_id']}'");
        $user['ship_id'] = $command;
        $user['location'] = $temp_ship['location'];
        get_star();
        get_user_ship($command);
    }
}
//subspace jump
if (!empty($subspace)) {
    db("select count(ship_id) from {$db_name}_ships where fleet_id = '{$user_ship['fleet_id']}' && location = '{$user_ship['location']}' && ship_id != '{$user['ship_id']}' && login_id = '{$user['login_id']}'");
    $num_towed1 = dbr();
    $num_towed = $num_towed1[0];
    db("select count(star_id) from {$db_name}_stars");
    $num_ss = dbr();
    $turn = round(get_star_dist($user['location'], $subspace) / 2 + 1);
    $exp_sys_arr = explode(",", $user['explored_sys']);
    if (!config_check("sj", $user_ship)) {
        $user_loc_message .= $st[8];
    } elseif ($subspace == $user['location']) {
        $user_loc_message .= $st[9];
Exemple #2
0
     //				echo 'aici';
     //				exit();
 }
 //ensure that we have some ships to update.
 if (isset($update_ships_sql[0])) {
     //update the ships
     foreach ($update_ships_sql as $sql) {
         dbn($sql);
     }
 }
 //update the users
 foreach ($update_users_sql as $sql) {
     dbn($sql);
 }
 if ($reload_ship == 1) {
     get_user_ship($user['ship_id']);
 }
 //update planet records
 if (!empty($target_planets)) {
     foreach ($target_planets as $p_id => $p_details) {
         if ($planet_attack == 0) {
             //assisting planets
             dbn("update {$db_name}_planets set planet_engaged = 0, fighters = (fighters - allocated_to_fleet) + '{$p_details['fighters']}', allocated_to_fleet = '{$p_details['fighters']}' where planet_id = '{$p_id}'");
         } else {
             //target planet
             if ($ships_in_system == 1) {
                 //damage is done only to unallocated fighters
                 dbn("update {$db_name}_planets set planet_engaged = 0, fighters = allocated_to_fleet + '{$p_details['fighters']}' where planet_id = '{$p_id}'");
             } else {
                 //fighter damage is done to all fighters
                 dbn("update {$db_name}_planets set planet_engaged = 0, fighters = '{$p_details['fighters']}' where planet_id = '{$p_id}'");
Exemple #3
0
function bulk_buy_1($num, $ship_name, $ship_cost, $dupe, $ship_stats, $specific, $cost_text)
{
    global $GAME_VARS, $num_ships, $user, $user_ship, $db_name, $bmrkt_id, $cw, $st;
    $rs = "<p /><a href='earth.php'>" . $cw['back to Earth'] . "</a>";
    $rs .= "<br /><a href='earth.php?ship_shop=1'>" . $cw['return to Ship Shop'] . "</a>";
    $error_str = "";
    if ($dupe == 1) {
        $dupe_text = $cw['duplicate'];
    } else {
        $dupe_text = "";
    }
    if (config_check("bs", $ship_stats)) {
        $w_ship = 1;
        $max_ships = $GAME_VARS['max_warships'];
        $num_ships['applic'] = $num_ships['warships'];
    } else {
        $max_ships = $GAME_VARS['max_other_ships'];
        $num_ships['applic'] = $num_ships['other_ships'];
        $w_ship = 0;
    }
    if ($ship_stats['type_id'] < 3) {
        //trying to build an improper ship
        print_page($cw['error'], $st[168]);
    }
    if ($num_ships['war_reached'] == 1 && $w_ship == 1) {
        $error_str = sprintf($st[169], $num_ships[warships], $GAME_VARS[max_warships]);
    } elseif ($num_ships['other_reached'] == 1 && $w_ship == 0) {
        $error_str = sprintf($st[170], $num_ships[other_ships], $GAME_VARS[max_other_ships]);
        //check to allow user to enter the number of ships they want to buy.
    } elseif ($num < 1 || empty($ship_name)) {
        $error_str = "<script type='text/javascript'>\n\n\t\t\t\t\tjQuery(document).ready(function(\$) {\n\t\t\t\t\t   \$('#generate_button').click(function() {\n\t\t\t\t\t   \t\t\$.get('ajax.php',\n\t\t\t\t\t\t\t   { cmd: 'generateVesselName' },\n\t\t\t\t\t\t\t   function(data) {\n\t\t\t\t\t\t\t\t\t\$(\"input[name = 'ship_name']\").val(data);\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\n\t\t\t\t  </script>";
        $t7676 = $max_ships - $num_ships['applic'];
        if ($t7676 * $ship_cost > $user['cash']) {
            $t7676 = floor($user['cash'] / $ship_cost);
        }
        if ($ship_stats['tcost'] > 0 && $t7676 * $ship_stats['tcost'] > $user['tech']) {
            $t7676 = floor($user['tech'] / $ship_stats['tcost']);
        }
        $error_str .= sprintf($st[171], $num_ships[total_ships], $num_ships[warships], $num_ships[other_ships]);
        $error_str .= "<form name='mass_buy' action='{$_SERVER['PHP_SELF']}' method='post'>";
        $error_str .= "<input type='hidden' name='{$specific}' value='{$ship_stats['type_id']}' />";
        $error_str .= "<input type='hidden' name='bmrkt_id' value='{$bmrkt_id}' />";
        $error_str .= $st[172] . "<input type='text' name='ship_name' value='' size='15' />&nbsp;";
        $error_str .= "<input type='button' value='G&eacute;n&eacute;rer' id='generate_button'/> <br />";
        $error_str .= sprintf($st[173], $dupe_text, $ship_stats[name] . "<input type='text' name=num value='{$t7676}' size=3 />" . $cost_text);
        $error_str .= "<p /><input type='submit' value='" . $cw['submit'] . "' /></form><p />";
    } elseif ($num_ships['warships'] + $num > $GAME_VARS['max_warships'] && $w_ship == 1) {
        // check to ensure they are not trying to buy too many warships
        $error_str .= sprintf($st[174], $num_ships[warships], $GAME_VARS[max_warships]);
    } elseif ($num_ships['other_ships'] + $num > $GAME_VARS['max_other_ships'] && $w_ship == 0) {
        // check to ensure they are not trying to buy too many other ships
        $error_str .= sprintf($st[175], $num_ships[other_ships], $GAME_VARS[max_other_ships]);
    } elseif ($user['cash'] < $ship_cost * $num) {
        //check to see if the user can afford them
        print_page($cw['error'], sprintf($st[176], $num, $ship_stats[name]));
    } elseif ($ship_stats['tcost'] > 0 && $user['tech'] < $ship_stats['tcost'] * $num) {
        print_page($cw['error'], sprintf($st[177], $num, $ship_stats[name]));
    } else {
        //do the processing.
        $ship_name = correct_name($ship_name);
        $quotes = $ship_name;
        // remove old escape pods
        dbn("delete from {$db_name}_ships where login_id = '{$user['login_id']}' && class_name REGEXP 'Escape'");
        //ensure we don't duplicate extra armour!
        $ship_stats['armour'] = $ship_stats['max_armour'];
        //duplication requires the ship to be somewhat modified from the base stats.
        if ($dupe == 1) {
            $ship_stats['config'] = $user_ship['config'];
            $ship_stats['num_ot'] = $user_ship['num_ot'];
            $ship_stats['num_dt'] = $user_ship['num_dt'];
            $ship_stats['upgrade_slots'] = $user_ship['upgrade_slots'];
            $ship_stats['move_turn_cost'] = $user_ship['move_turn_cost'];
            $ship_stats['max_fighters'] = $user_ship['max_fighters'];
            $ship_stats['max_shields'] = $user_ship['max_shields'];
            $ship_stats['max_armour'] = $user_ship['max_armour'];
            $ship_stats['cargo_bays'] = $user_ship['cargo_bays'];
        }
        for ($s = 1; $s <= $num; $s++) {
            if ($s < 10) {
                $s_name = $ship_name . " 0" . $s;
            } else {
                $s_name = $ship_name . " " . $s;
            }
            if (empty($user_ship['fleet_id']) || $user_ship['fleet_id'] < 1) {
                $user_ship['fleet_id'] = 1;
            }
            $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_dt, num_ot, num_pc, num_ew, fleet_id";
            $q_string = $q_string . ") values(";
            $q_string = $q_string . "'{$s_name}', '{$user['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['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_dt']}', '{$ship_stats['num_ot']}', '{$ship_stats['num_pc']}', '{$ship_stats['num_ew']}', '{$user_ship['fleet_id']}')";
            dbn($q_string);
        }
        //puts the user into the newest ship, but only if they are in a EP, or ship destroyed.
        if ($user['ship_id'] == 1 || $user_ship['shipclass'] < 3) {
            $new_ship_id = mysql_insert_id();
            dbn("update {$db_name}_users set ship_id = '{$new_ship_id}' where login_id = '{$user['login_id']}'");
            $user['ship_id'] = $new_ship_id;
        }
        get_user_ship($user['ship_id']);
        $x1 = $num * $ship_cost;
        $tcost = $num * $ship_stats['tcost'];
        $x2 = $quotes . " 1";
        $x3 = $quotes . " {$num}";
        $x4 = $num_ships['total_ships'] + $num;
        take_cash($x1);
        if ($ship_stats['tcost'] > 0) {
            take_tech($tcost);
            $xtra_tech = ' ' . $cw['and'] . " <b>{$tcost}</b> " . $cw['tech_units'];
        } else {
            $xtra_tech = "";
        }
        $error_str .= sprintf($st[178], $num, $dupe_text, $ship_stats[name], $x1, $xtra_tech, $x2, $x3, $x4, $user_ship[fleet_id]);
    }
    print_page($cw['bulk buying'], $error_str);
}
Exemple #4
0
 }
 // build the new ship
 $q_string = "insert into {$db_name}_ships (";
 $q_string = $q_string . "ship_name, login_id, 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_dt, num_ot, num_pc, num_ew, fleet_id";
 $q_string = $q_string . ") values(";
 $q_string = $q_string . "'" . mysql_real_escape_string($ship_name) . "', '{$login_id}', '{$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_dt']}', '{$ship_stats['num_ot']}', '{$ship_stats['num_pc']}', '{$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.
 if ($new_ship_id == 1) {
     $new_ship_id = 2;
     dbn("update {$db_name}_ships set ship_id = '2' where ship_id = '1'");
 }
 dbn("update {$db_name}_users set ship_id = '{$new_ship_id}' where login_id = '" . $user['login_id'] . "'");
 $user['ship_id'] = $new_ship_id;
 get_user_ship($new_ship_id);
 $oo_str = "";
 if (config_check("oo", $ship_stats)) {
     if ($user['one_brob']) {
         dbn("update {$db_name}_users set one_brob = one_brob + one_brob where login_id = '{$user['login_id']}'");
     } else {
         dbn("update {$db_name}_users set one_brob = 2 where login_id = '{$user['login_id']}'");
     }
     $oo_str = "<p />" . $st[729];
 }
 $error_str .= sprintf($st[730], $ship_stats[cost], $ship_stats[name], $user_ship[fleet_id]);
 if ($user_ship['fighters'] < $user_ship['max_fighters'] && $user_ship['max_fighters'] > 0) {
     $error_str .= "<p /><a href='equip_shop.php?buy=1'>" . $cw['buy_some_fighter'] . "</a>";
 }
 if ($user_ship['upgrade_slots'] > 0) {
     $error_str .= "<br /><a href='upgrade.php'>" . $st[731] . "</a>";