コード例 #1
0
ファイル: common.inc.php プロジェクト: nilsine/Astra-Vires
function give_first_ship($login_id, $clan_id, $s_name = "Un-Named")
{
    global $GAME_VARS;
    //create user's first ship
    $ship_stats = load_ship_types($GAME_VARS['start_ship']);
    //ensure valid name
    $ship_stats['ship_name'] = correct_name($s_name);
    //create array with owner details in
    $ship_owner = array('login_id' => $login_id, 'clan_id' => 0);
    //make the ship
    return make_ship($ship_stats, $ship_owner);
}
コード例 #2
0
ファイル: user.inc.php プロジェクト: nilsine/Astra-Vires
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);
}
コード例 #3
0
ファイル: planet_build.php プロジェクト: nilsine/Astra-Vires
    $error_str = $st[90];
} elseif ($user['ship_id'] <= 1 && $user['login_id'] > 1) {
    $error_str = $st[91];
} elseif ($star['event_random'] > 0 && $user['login_id'] != 1) {
    $error_str = $st[92];
} elseif ($user['turns_run'] < $GAME_VARS['turns_before_planet_attack'] && !isset($letme) && $user['login_id'] != 1) {
    print_page($cw['no_landing'], sprintf($st[93], $GAME_VARS[turns_before_planet_attack]));
} elseif ($user['turns'] < 5) {
    $error_str = $st[94];
} elseif (empty($planet_name)) {
    get_var($st[95], 'planet_build.php', $st[96], 'planet_name', '');
} elseif (strlen($planet_name) < 3) {
    $rs = "<p /><a href='javascript:history.back()'>" . $cw['try_again'] . "</a>";
    print_page($cw['invalide_name'], $st[97]);
} else {
    $planet_name = correct_name($planet_name);
    if (!$planet_name || $planet_name == " " || $planet_name == "") {
        $rs = "<p /><a href='javascript:history.back()'>" . $cw['try_again'] . "</a>";
        print_page($cw['invalide_name'], $st[98]);
    }
    // remove gen device, but not from admin.
    if ($user['login_id'] > 1) {
        dbn("update {$db_name}_users set genesis = genesis - 1 where login_id = {$user['login_id']}");
    }
    charge_turns(5);
    if ($user['clan_id']) {
        $clan_id = $user['clan_id'];
    } else {
        $clan_id = -1;
    }
    // build the new planet
コード例 #4
0
ファイル: planet.php プロジェクト: nilsine/Astra-Vires
                dbn("update {$db_name}_planets set tech = {$set_tech} where planet_id = {$user['on_planet']}");
            } else {
                #taking money from planet.
                $give_to_user = $planet['tech'] - $set_tech;
                give_tech($give_to_user);
                $planet['tech'] = $set_tech;
                dbn("update {$db_name}_planets set tech = {$set_tech} where planet_id = {$user['on_planet']}");
            }
        }
    }
}
if (isset($rename)) {
    if ($user['login_id'] != $planet['login_id']) {
        $text .= $st[1671];
    } elseif ($name_to) {
        $name_to = correct_name($name_to);
        if (!$name_to || strlen($name_to) < 3) {
            $rs = "<p /><a href='javascript:history.back()'>" . $cw['try-again'] . "</a>";
            print_page($cw['invalid_name'], $st[1672]);
        }
        #$stuff = addslashes($name_to);
        #echo eregi_replace("'","",$name_to);
        $text .= sprintf($st[1673], $planet[planet_name]) . " <b class='b1'>{$name_to}</b>.";
        dbn("update {$db_name}_planets set planet_name = '{$name_to}' where planet_id = '{$planet['planet_id']}'");
        post_news("<b class='b1'>{$user['login_name']}</b> " . sprintf($st[1674], $planet[planet_name]) . " <b class='b1'>{$name_to}</b>.", $cw['planet']);
    } else {
        $text .= $st[1675];
        $text .= "<FORM method=POST action=planet.php>";
        $text .= "<input type=text name=name_to size=30 value=\"{$planet['planet_name']}\" />";
        $text .= "<input type=hidden name=rename value=1 />";
        $text .= "<input type=hidden name=planet_id value={$planet['planet_id']} />";
コード例 #5
0
ファイル: bm_ships.php プロジェクト: nilsine/Astra-Vires
     $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.
     if ($new_ship_id == 1) {
         $new_ship_id = 2;
         dbn("update {$db_name}_ships set ship_id = '2' where ship_id = '1'");
     }