function show_possible_vessels_on_planet($anomaly_id) { assert(is_numeric($anomaly_id)); $anomaly = anomaly_get_anomaly($anomaly_id); // No construction possible when we don't have the right buildings... if (!planet_has_vesselbuilding_capability($anomaly_id)) { print_subtitle("Planet " . $anomaly['name'] . " has no vessel construction capability."); create_submenu(array("Planet view" => "anomaly.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($anomaly_id), "Surface view" => "surface.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($anomaly_id))); return; } print_subtitle("Vessel construction on planet " . $anomaly['name']); $user = user_get_user($anomaly['user_id']); $result = sql_query("SELECT * FROM g_ores WHERE planet_id=" . $anomaly_id); $ores = sql_fetchrow($result); $result = sql_query("SELECT * FROM s_vessels ORDER BY id"); while ($vessel = sql_fetchrow($result)) { $cannot_build = true; // Can we build it? if ($vessel['build_level'] <= $user['vessel_level']) { $cannot_build = false; } if ($cannot_build == false) { vessel_show_type_details($vessel['id'], $anomaly_id, $anomaly['user_id'], $ores['stock_ores']); } } }
function conview_show_sector($user_id, $sector_id, $planets) { assert(is_numeric($user_id)); assert(is_numeric($sector_id)); assert(is_array($planets)); global $_RUN; $tmpvar3 = array(); // Check how many planets we own in this sector. If none, don't show anything... $result = sql_query("SELECT COUNT(*) AS count FROM s_anomalies WHERE sector_id = " . $sector_id . " AND user_id=" . $user_id, JUST_ONE_ALLOWED); $tmp = sql_fetchrow($result); if ($tmp['count'] == 0) { return; } // Get sector information $sector = sector_get_sector($sector_id); // Get planet information for all planets in the sector $result = sql_query("SELECT * FROM s_anomalies WHERE sector_id=" . $sector_id . " AND user_id=" . $user_id . " ORDER BY distance", MULTIPLE_ALLOWED); while ($planet = sql_fetchrow($result)) { // If we can't view the planet, then don't show it... if (!in_array($planet['id'], $planets)) { continue; } // Can we show this planet (eg, is it in our $planets-array) if (!empty($visible_planets) && !in_array($planet['id'], $visible_planets)) { continue; } $tmpvar = array(); $tmpvar['name'] = $planet['name']; $tmpvar['href'] = "anomaly.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($planet['id']); if (anomaly_is_planet($planet['id'])) { $tmpvar['viewstring'] = "View Planet"; } else { $tmpvar['viewstring'] = "View Anomaly"; } $tmpvar2 = array(); if (planet_is_habitable($planet['id']) or planet_is_minable($planet['id'])) { $tmpvar2['href'] = "surface.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($planet['id']); $tmpvar2['str'] = "Surface View"; $tmpvar['href_array'][] = $tmpvar2; $tmpvar2['href'] = "construct.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($planet['id']); $tmpvar2['str'] = "Construction"; $tmpvar['href_array'][] = $tmpvar2; $tmpvar2['href'] = "manufacture.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($planet['id']); $tmpvar2['str'] = "Manufacturing"; $tmpvar['href_array'][] = $tmpvar2; if (planet_has_vesselbuilding_capability($planet['id'])) { $tmpvar2['href'] = "vesselcreate.php?cmd=" . encrypt_get_vars("showaid") . "&aid=" . encrypt_get_vars($planet['id']); $tmpvar2['str'] = "Create Vessel"; $tmpvar['href_array'][] = $tmpvar2; } else { $tmpvar2['href'] = ""; $tmpvar2['str'] = ""; $tmpvar['href_array'][] = $tmpvar2; } } else { $tmpvar2['href'] = ""; $tmpvar2['str'] = ""; $tmpvar['href_array'][] = $tmpvar2; $tmpvar['href_array'][] = $tmpvar2; $tmpvar['href_array'][] = $tmpvar2; $tmpvar['href_array'][] = $tmpvar2; } $tmpvar3[] = $tmpvar; } // while $template = new Smarty(); $template->debugging = true; $template->assign("sector_id", $sector['sector']); $template->assign("sector_name", $sector['name']); $template->assign("planets", $tmpvar3); $template->display($_RUN['theme_path'] . "/conview.tpl"); }
function planet_show_planet($planet_id) { assert(!empty($planet_id)); global $_GALAXY; global $_CONFIG; global $_RUN; if (!anomaly_is_planet($planet_id)) { return; } $planet = anomaly_get_anomaly($planet_id); $result = sql_query("SELECT * FROM g_ores WHERE planet_id=" . $planet_id); $ore = sql_fetchrow($result); $stock_ore = ore_csl_to_list($ore['stock_ores']); $race = user_get_race($planet['user_id']); $sector = sector_get_sector($planet['sector_id']); $result = sql_query("SELECT * FROM s_state WHERE id=" . $planet['state_id']); $state = sql_fetchrow($result); if ($race == "") { $race = "-"; } $extra_attack = 0; $extra_defense = 0; $attack = $planet['cur_attack']; $defense = $planet['cur_attack']; // Count all ships and their attack/defense currently in orbit around the planet $result = sql_query("SELECT COUNT(*) FROM g_vessels AS g, s_vessels AS s WHERE g.planet_id=" . $planet_id . " AND s.id = g.vessel_id AND s.type='" . VESSEL_TYPE_BATTLE . "' AND status='ORBIT' AND created=1"); $tmp = sql_fetchrow($result); $battle_vessels = $tmp[0]; $result = sql_query("SELECT COUNT(*) FROM g_vessels AS g, s_vessels AS s WHERE g.planet_id=" . $planet_id . " AND s.id = g.vessel_id AND s.type='" . VESSEL_TYPE_TRADE . "' AND status='ORBIT' AND created=1"); $tmp = sql_fetchrow($result); $trade_vessels = $tmp[0]; $result = sql_query("SELECT COUNT(*) FROM g_vessels AS g, s_vessels AS s WHERE g.planet_id=" . $planet_id . " AND s.id = g.vessel_id AND s.type='" . VESSEL_TYPE_EXPLORE . "' AND status='ORBIT' AND created=1"); $tmp = sql_fetchrow($result); $explore_vessels = $tmp[0]; $result = sql_query("SELECT SUM(cur_attack) AS CA, SUM(cur_defense) AS CD FROM g_vessels AS g WHERE g.planet_id=" . $planet_id . " AND status='ORBIT' AND created=1"); $tmp = sql_fetchrow($result); if (isset($tmp['CA'])) { $extra_attack = $extra_attack + $tmp['CA']; } if (isset($tmp['CD'])) { $extra_defense = $extra_defense + $tmp['CD']; } $template = new Smarty(); $template->debugging = true; $template->assign("sector_name", $sector['name']); $template->assign("planet_name", $planet['name']); $template->assign("image", $_CONFIG['IMAGE_URL'] . $_GALAXY['image_dir'] . "/planets/" . $planet['image'] . ".jpg"); if ($planet['unknown'] == 1) { $template->assign("cmd", encrypt_get_vars("claim")); $template->assign("formid", generate_form_id()); $template->assign("aid", encrypt_get_vars($planet_id)); $template->assign("rename_form_visible", "true"); } else { $template->assign("rename_form_visible", "false"); } $template->assign("class", $planet['class']); $template->assign("race", $race); $template->assign("state", $state['name']); $template->assign("happieness", planet_get_happy_string($planet['happieness'])); $template->assign("healtieness", planet_get_healty_string($planet['sickness'])); $template->assign("population", $planet['population']); $template->assign("radius", $planet['radius']); $template->assign("distance", $planet['distance']); $template->assign("water", $planet['water']); $template->assign("temperature", $planet['temperature']); for ($i = 0; $i != ore_get_ore_count(); $i++) { $tmp = array(); $tmp['name'] = ore_get_ore_name($i); $tmp['stock'] = $stock_ore[$i]; $tmpvar[] = $tmp; } $template->assign("ores", $tmpvar); $template->assign("attack", $attack); $template->assign("extra_attack", $extra_attack); $template->assign("defense", $defense); $template->assign("extra_defense", $extra_defense); $template->assign("strength", $planet['cur_strength']); $template->assign("orbit_battle", $trade_vessels); $template->assign("orbit_trade", $battle_vessels); $template->assign("orbit_explore", $explore_vessels); $template->assign("description", convert_px_to_html_tags($planet['description'])); $template->display($_RUN['theme_path'] . "/planet-details.tpl"); $commands = array(); // If we have at least 1 ship in orbit, we can view them here... if ($explore_vessels + $trade_vessels + $battle_vessels > 0) { $commands['View Vessels'] = "vessel.php?cmd=" . encrypt_get_vars("showaid") . "&aid=" . encrypt_get_vars($planet_id); } // If it's a solid-class planet (lower than M), we can view the surface. if (planet_is_habitable($planet_id) or planet_is_minable($planet_id)) { $commands['View Surface'] = "surface.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($planet_id); } // If it's our planet we might construct and manufacture,.. if (anomaly_am_i_owner($planet['id'])) { $commands['Change Description'] = "anomaly.php?cmd=" . encrypt_get_vars("description") . "&aid=" . encrypt_get_vars($planet_id); // Only minable or habitable or lower can construct if (planet_is_habitable($planet_id) or planet_is_minable($planet_id)) { $commands['Construct'] = "construct.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($planet_id); $commands['Manufacture'] = "manufacture.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($planet_id); } if (planet_has_vesselbuilding_capability($planet_id)) { $commands['Create Vessel'] = "vesselcreate.php?cmd=" . encrypt_get_vars("showaid") . "&aid=" . encrypt_get_vars($planet_id); } } create_submenu($commands); }