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 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"; } }