function show_surface($planet_id) { global $_GALAXY; // Get global information from the user $planet = anomaly_get_anomaly($planet_id); $user = user_get_user($planet['user_id']); $sector = sector_get_sector($planet['sector_id']); $totals = calc_planet_totals($planet_id); // Generate text color for the power if ($totals['power_out'] == 0) { $power_p = 0; } else { $power_p = $totals['power_in'] / $totals['power_out'] * 100; } $power_color = "white"; if ($power_p > 50) { $power_color = "yellow"; } if ($power_p > 75) { $power_color = "orange"; } if ($power_p > 99) { $power_color = "red"; } // Generate text color for the crew if ($planet['population_capacity'] == 0) { $crew_p = 0; } else { $crew_p = $planet['population'] / $planet['population_capacity'] * 100; } $crew_color = "white"; if ($crew_p > 50) { $crew_color = "yellow"; } if ($crew_p > 75) { $crew_color = "orange"; } if ($crew_p > 99) { $crew_color = "red"; } print_subtitle("Surface View on planet " . $planet['name']); // ------------------------------------------------------------------ echo "<table width=75% align=center border=1>\n"; echo " <tr><th colspan=2>Global Information on<br>Sector " . $sector['name'] . " / Planet " . $planet['name'] . "</th></tr>\n"; echo " <tr><td>\n"; echo " <table width=100% border=0 cellpadding=0 cellspacing=0>\n"; echo " <tr><td> Power Generated </td><td> " . $totals['power_out'] . " </td></tr>\n"; echo " <tr><td> Power Needed </td><td> " . $totals['power_in'] . " </td></tr>\n"; echo " <tr><td> <font color={$power_color}><b>Power Left </b></font> </td><td> <font color={$power_color}><b>" . ($totals['power_out'] - $totals['power_in']) . "</b></font> </td></tr>\n"; echo " </table>\n"; echo " </td><td>\n"; echo " <table width=100% border=0 cellpadding=0 cellspacing=0>\n"; echo " <tr><td> <font color={$crew_color}>Inhabitants</font> </td><td> <font color={$crew_color}>" . $planet['population'] . "</font> </td></tr>\n"; echo " <tr><td> <font color={$crew_color}>Capacity</font> </td><td> <font color={$crew_color}>" . $planet['population_capacity'] . "</font> </td></tr>\n"; echo " <tr><td> </td><td> </td></tr>\n"; echo " </table>\n"; echo " </td></tr>\n"; echo "</table>\n"; echo "<br>\n"; echo "<br>\n"; // Get all buildings and cargo on the planet $surface = planet_get_surface($planet_id); $current_buildings = csl($surface['csl_building_id']); $current_buildings = array_count_values($current_buildings); $current_cargo = csl($surface['csl_cargo_id']); $current_cargo = array_count_values($current_cargo); // ------------------------------------------------------------------ // Show current buildings on the surface // echo "<table width=75% align=center border=0 cellpadding=0 cellspacing=0>\n"; echo "<table width=75% align=center border=0>\n"; echo " <tr class=wb><th colspan=5>Buildings on the planet</th></tr>\n"; echo " <tr class=bl>"; echo "<th>Qty</th>"; echo "<th>Name</th>"; echo "<th>Power In</th>"; echo "<th>Power Out</th>"; echo "<th>Description</th>"; echo "</tr>\n"; reset($current_buildings); while (list($building_id, $quantity) = each($current_buildings)) { $building = building_get_building(building_active_or_inactive($building_id)); if (building_is_active($building_id)) { } else { } if (building_is_active($building_id)) { $active = "<img alt=Active src=" . $_CONFIG['URL'] . $_GALAXY['image_dir'] . "/general/active.gif>"; echo " <tr class=bl>\n"; echo " <td> " . $quantity . " </td>\n"; echo " <td> " . $active . " " . $building['name'] . " </td>\n"; echo " <td> " . $building['power_in'] . " </td>\n"; echo " <td> " . $building['power_out'] . " </td>\n"; echo " <td> " . $building['rule'] . " </td>\n"; echo " </tr>\n"; } else { $active = "<img alt=Inactive src=" . $_CONFIG['URL'] . $_GALAXY['image_dir'] . "/general/inactive.gif>"; echo " <tr class=bl>\n"; echo " <td><font color=red> " . $quantity . " </font></td>\n"; echo " <td><font color=red> " . $active . " " . $building['name'] . " </font></td>\n"; echo " <td colspan=3><font color=red> Building not active </font></td>\n"; echo " </tr>\n"; } } echo "</table>\n"; echo "<br><br>\n"; // ------------------------------------------------------------------ // Show current items on the surface echo "<table width=75% align=center border=0>\n"; echo " <tr class=wb><th colspan=5>Cargo and machines on planet</th></tr>\n"; echo " <tr class=bl>"; echo "<th>Qty</th>"; echo "<th>Name</th>"; echo "<th>Description</th>"; echo "</tr>\n"; reset($current_cargo); while (list($item_id, $quantity) = each($current_cargo)) { $invention = item_get_item($item_id); if (invention_is_active_on_planet($invention)) { $activeimg = "alt=Active src=" . $_CONFIG['URL'] . $_GALAXY['image_dir'] . "/general/active.gif"; } else { $activeimg = "alt=Inactive src=" . $_CONFIG['URL'] . $_GALAXY['image_dir'] . "/general/inactive.gif"; } echo " <tr class=bl>\n"; echo " <td> " . $quantity . " </td>\n"; echo " <td> <img " . $activeimg . "> " . $invention['name'] . " </td>\n"; echo " <td> " . $invention['rule'] . " </td>\n"; echo " </tr>\n"; } echo "</table>\n"; echo "<br><br>\n"; }
function smt_upkeep_ores($cannot_build, $invention_id, $user_id, $stock_ores) { assert(is_bool((bool) $cannot_build)); assert(is_numeric($invention_id)); assert(is_numeric($user_id)); assert(is_array($stock_ores)); $invention = item_get_item($invention_id); $invention_upkeep_ores = ore_csl_to_list($invention['upkeep_ores']); if ($user_id == 0) { $build_option = 0; } else { $build_option = 1; $user = user_get_user($user_id); } $class = "t"; echo "<table border=0 cellpadding=0 cellspacing=0 width=100%>\n"; echo " <tr><th colspan=3>Upkeep costs</th></tr>"; echo " <tr>\n"; echo " <td class=" . $class . " width=33%> <strong>Credits</strong> </td>\n"; echo " <td class=" . $class . " width=1%> <strong>:</strong> </td>\n"; echo " <td class=" . $class . " width=34%> " . $invention['upkeep_costs'] . " cr </td>\n"; echo " </tr>\n"; // Do all ores for ($i = 0; $i != ore_get_ore_count(); $i++) { echo " <tr>\n"; echo " <td class=" . $class . " width=33%> <strong>" . ore_get_ore_name($i) . "</strong> </td>\n"; echo " <td class=" . $class . " width=1%> <strong>:</strong> </td>\n"; echo " <td class=" . $class . " width=34%> " . $invention_upkeep_ores[$i] . " tons </td>\n"; echo " </tr>\n"; } echo "</table>\n"; return $cannot_build; }
function queue_print($user_id) { assert(is_numeric($user_id)); global $_RUN; $totalcount = 0; $template = new Smarty(); $template->debugging = true; // Buildings $count = 0; $tmpvar = array(); $result = sql_query("SELECT * FROM h_queue WHERE type='" . QUEUE_BUILD . "' AND user_id=" . $user_id); while ($queue = sql_fetchrow($result)) { $totalcount++; $count++; $building = building_get_building($queue['building_id']); $planet = anomaly_get_anomaly($queue['planet_id']); $tmpvar['what'][] = "Building " . $building['name'] . " on " . $planet['name']; $tmpvar['ticks'][] = $queue['ticks']; } $tmpvar['count'] = $count; $template->assign("building", $tmpvar); // Items $count = 0; $tmpvar = array(); $result = sql_query("SELECT * FROM h_queue WHERE type='" . QUEUE_INVENTION . "' AND user_id=" . $user_id); while ($queue = sql_fetchrow($result)) { $totalcount++; $count++; $item = item_get_item($queue['building_id']); $planet = anomaly_get_anomaly($queue['planet_id']); $tmpvar['what'][] = "Manufacturing " . $item['name'] . " on " . $planet['name']; $tmpvar['ticks'][] = $queue['ticks']; } $tmpvar['count'] = $count; $template->assign("item", $tmpvar); // Vessels $count = 0; $tmpvar = array(); $result = sql_query("SELECT * FROM h_queue WHERE type='" . QUEUE_VESSEL . "' AND user_id=" . $user_id); while ($queue = sql_fetchrow($result)) { $totalcount++; $count++; $vessel = vessel_get_vessel($queue['vessel_id']); $planet = anomaly_get_anomaly($queue['planet_id']); $tmpvar['what'][] = "Building " . $vessel['name'] . " on " . $planet['name']; $tmpvar['ticks'][] = $queue['ticks']; } $tmpvar['count'] = $count; $template->assign("vessel", $tmpvar); // Upgrade (NOTE: THESE ARE ALSO PART OF THE VESSEL[] ARRAY $count = 0; $tmpvar = array(); $result = sql_query("SELECT * FROM h_queue WHERE type='" . QUEUE_UPGRADE . "' AND user_id=" . $user_id); while ($queue = sql_fetchrow($result)) { $totalcount++; $count++; $vessel = vessel_get_vessel($queue['vessel_id']); $planet = anomaly_get_anomaly($queue['planet_id']); $tmpvar['what'][] = "Upgrading " . $vessel['name'] . " on " . $planet['name']; $tmpvar['ticks'][] = $queue['ticks']; } $tmpvar['count'] = $count; $template->assign("vessel", $tmpvar); // Flights $count = 0; $tmpvar = array(); $result = sql_query("SELECT * FROM h_queue WHERE type='" . QUEUE_FLIGHT . "' AND user_id=" . $user_id); while ($queue = sql_fetchrow($result)) { $totalcount++; $count++; $result2 = sql_query("SELECT * FROM g_vessels WHERE id=" . $queue['vessel_id']); $vessel = sql_fetchrow($result2); if ($vessel['dst_planet_id'] == 0) { if ($vessel['dst_sector_id'] == 0) { $tmpvar['what'][] = "Flying " . $vessel['name'] . " to outer space."; } else { $sector = sector_get_sector($vessel['dst_sector_id']); $tmpvar['what'][] = "Flying " . $vessel['name'] . " to sector " . $sector['name']; } } else { $planet = anomaly_get_anomaly($vessel['dst_planet_id']); $tmpvar['what'][] = "Flying " . $vessel['name'] . " to " . $planet['name']; } $tmpvar['ticks'][] = $queue['ticks']; } $tmpvar['count'] = $count; $template->assign("flight", $tmpvar); $template->assign("itemcount", $totalcount); $template->display($_RUN['theme_path'] . "/order-queue.tpl"); }
function vessel_show_cargo($vessel_id) { assert(is_numeric($vessel_id)); global $_GALAXY; $vessel = vessel_get_vessel($vessel_id); // Get all buildings that are currently build on the planet $result = sql_query("SELECT * FROM i_vessels WHERE vessel_id=" . $vessel_id); $vessel_cargo = csl_create_array($result, "csl_cargo_id"); $vessel_cargo = array_count_values($vessel_cargo); // Find out if we just travelled through a wormhole, or if we are nearby a wormhole. $located_in_wormhole = false; $result = sql_query("SELECT * FROM w_wormhole"); while ($wormhole = sql_fetchrow($result)) { if ($vessel['distance'] == $wormhole['distance'] and $vessel['angle'] == $wormhole['angle']) { $located_in_wormhole = true; } } // Do not show the array when it's empty... if (count($vessel_cargo) == 0) { // echo "<table align=center border=0 width=75%>"; // echo "<tr class=wb><th colspan=2>No items on board</th></tr>"; // echo "</table>"; // echo "<br><br>"; } else { echo "<table align=center border=0 width=75%>"; echo "<tr class=wb><th colspan=3>Vessel Items</th></tr>"; echo "<tr class=bl>"; echo "<th>Quantity</th>"; echo "<th width=100%>Name</th>"; echo "<th> </th>"; echo "</tr>"; reset($vessel_cargo); while (list($cargo_id, $q) = each($vessel_cargo)) { $invention = item_get_item($cargo_id); if (invention_is_active_on_vessel($invention, $vessel)) { $activeimg = "alt=Active src=" . $_CONFIG['URL'] . $_GALAXY['image_dir'] . "/general/active.gif"; } else { $activeimg = "alt=Inactive src=" . $_CONFIG['URL'] . $_GALAXY['image_dir'] . "/general/inactive.gif"; } echo "<tr class=bl>"; echo " <td> " . $q . " </td>"; echo " <td> <img " . $activeimg . "> " . $invention['name'] . " </td>"; if ($vessel['planet_id'] == 0) { echo " <td nowrap> </td>"; } else { echo " <td nowrap> <a href=vessel.php?cmd=" . encrypt_get_vars("load_v2p") . "&vid=" . encrypt_get_vars($vessel['id']) . "&aid=" . encrypt_get_vars($vessel['planet_id']) . "&iid=" . encrypt_get_vars($invention['id']) . ">Move to planet</a> </td>"; } echo "</tr>"; } echo "</table>"; echo "<br><br>"; } // Only show planet cargo when there we are orbitting a planet. if ($vessel['planet_id'] == 0) { return; } // Get all buildings that are currently build on the planet $surface = planet_get_surface($vessel['planet_id']); $planet_cargo = csl($surface['csl_cargo_id']); $planet_cargo = array_count_values($planet_cargo); // Do not show the array when it's empty... if (count($planet_cargo) == 0) { // echo "<table align=center border=0 width=75%>\n"; // echo " <tr class=wb><th colspan=3>No items on planet</th></tr>\n"; // echo "</table>\n"; // echo "<br><br>\n"; } else { form_start(); echo "<table align=center border=0 width=75%>\n"; echo " <tr class=wb><th colspan=3>Planet Items</th></tr>\n"; echo " <tr class=bl>"; echo "<th>Qty</th>"; echo "<th width=100%>Name</th>"; echo "<th> </th>"; echo "</tr>\n"; reset($planet_cargo); while (list($cargo_id, $q) = each($planet_cargo)) { $invention = item_get_item($cargo_id); if (invention_is_active_on_planet($invention)) { $activeimg = "alt=Active src=" . $_CONFIG['URL'] . $_GALAXY['image_dir'] . "/general/active.gif"; } else { $activeimg = "alt=Inactive src=" . $_CONFIG['URL'] . $_GALAXY['image_dir'] . "/general/inactive.gif"; } echo " <tr class=bl>\n"; echo " <td> " . $q . " </td>\n"; echo " <td> <img " . $activeimg . "> " . $invention['name'] . " </td>\n"; echo " <td nowrap> <a href=vessel.php?cmd=" . encrypt_get_vars("load_p2v") . "&vid=" . encrypt_get_vars($vessel['id']) . "&aid=" . encrypt_get_vars($vessel['planet_id']) . "&iid=" . encrypt_get_vars($invention['id']) . ">Move to vessel</a> </td>\n"; echo " </tr>\n"; } echo "</table>\n"; form_end(); echo "<br><br>\n"; } }
function vessel_calc_extra_attack_and_defense_points($vessel_id) { assert(is_numeric($vessel_id)); $result = sql_query("SELECT * FROM i_vessels WHERE vessel_id=" . $vessel_id); $current_items = csl_create_array($result, "csl_weapon_id"); $current_items = array_count_values($current_items); $total_attack = 0; $total_defense = 0; reset($current_items); while (list($item_id, $quantity) = each($current_items)) { $invention = item_get_item($item_id); $total_attack += $invention['attack'] * $quantity; $total_defense += $invention['defense'] * $quantity; } return array(floor($total_attack / 100), floor($total_defense / 100)); }
show_inventions(user_get_home_planet(user_ourself())); } else { show_inventions($aid); } } if ($cmd == "manufacture") { $ok = ""; $errors['PARAMS'] = "Incorrect parameters specified..\n"; $errors['CREDITS'] = "You don't have enough cash to construct the item...\n"; $errors['ORE'] = "You don't have enough ores to construct the item...\n"; $errors['MAX'] = "You cannot build anymore items of this type on the planet...\n"; $errors['DEPS'] = "You cannot build this item before you have build all dependencies...\n"; $data['anomaly_id'] = $aid; $data['item_id'] = $iid; if (comm_send_to_server("MANUFACTURE", $data, $ok, $errors) == 1) { $invention = item_get_item($data['item_id']); echo "<br><br><br><br>"; echo "<table align=center border=0>"; echo " <tr><th>New construction in progress</th></tr>"; echo " <tr><td align=center><img align=center src=\"" . $_CONFIG['URL'] . $_GALAXY['image_dir'] . "/inventions/" . $invention['image'] . ".jpg\" width=150 height=150></td></tr>"; echo "</table>"; } } print_footer(); exit; // ============================================================================================ // // // Description: // //