Beispiel #1
0
function sector_show_sector($sector_id, $user_id)
{
    assert(!empty($sector_id));
    assert(!empty($user_id));
    global $_RUN;
    // Create the submenu where we can easily move between sectors
    $result = sql_query("SELECT * FROM g_sectors WHERE user_id = " . $user_id);
    $tmp = sql_fetchrow($result);
    $sectors = csl($tmp['csl_sector_id']);
    $idx = array_search($sector_id, $sectors);
    $first = reset($sectors);
    $last = end($sectors);
    if ($idx == 0) {
        $prev = $sectors[$idx];
    } else {
        $prev = $sectors[$idx - 1];
    }
    if ($idx == count($sectors) - 1) {
        $next = $sectors[$idx];
    } else {
        $next = $sectors[$idx + 1];
    }
    create_submenu(array("First Sector" => "sector.php?cmd=" . encrypt_get_vars("show") . "&sid=" . encrypt_get_vars($first), "Previous Sector" => "sector.php?cmd=" . encrypt_get_vars("show") . "&sid=" . encrypt_get_vars($prev), "Next Sector" => "sector.php?cmd=" . encrypt_get_vars("show") . "&sid=" . encrypt_get_vars($next), "Last Sector" => "sector.php?cmd=" . encrypt_get_vars("show") . "&sid=" . encrypt_get_vars($last)));
    $sector = sector_get_sector($sector_id);
    $template = new Smarty();
    $template->debugging = true;
    help_set_template_vars($template);
    $template->assign("sector_id", $sector['sector']);
    $template->assign("sector_name", $sector['name']);
    $template->assign("sector_coordinate", $sector['distance'] . " / " . $sector['angle']);
    if ($sector['user_id'] == UID_NOBODY) {
        $template->assign("rename_form_visible", "true");
    } else {
        $template->assign("rename_form_visible", "false");
    }
    // And now, do all anomalies
    $tmp = user_get_all_anomalies_from_user($user_id);
    $anomalies = csl($tmp['csl_discovered_id']);
    $undiscovered_anomalies = csl($tmp['csl_undiscovered_id']);
    $anomalies = csl_merge_fields($anomalies, $tmp['csl_undiscovered_id']);
    // We didn't find any discovered anomalies in this sector per default
    $i = 0;
    $tmpvar = array();
    // Get anomaly information for all anomalies in the sector
    $result = sql_query("SELECT * FROM s_anomalies WHERE sector_id=" . $sector_id . " ORDER BY distance");
    while ($anomaly = sql_fetchrow($result)) {
        // We didn't discover this anomaly yet, continue with another
        if (!in_array($anomaly['id'], $anomalies)) {
            continue;
        }
        // Thread undiscovered planets different...
        if (in_array($anomaly['id'], $undiscovered_anomalies)) {
            $tmp['name'] = "Unknown";
            $tmp['class'] = "";
            $tmp['population'] = "";
            $tmp['owner'] = "";
            $tmp['status'] = "";
            $tmp['radius'] = $anomaly['radius'];
            $tmp['distance'] = $anomaly['distance'];
            $tmpvar[] = $tmp;
            continue;
        }
        // If we are here, we have found an anomaly with we already
        // discovered and explored, show all the info about it...
        $state = sql_get_state($anomaly['state_id']);
        if ($anomaly['user_id'] != 0) {
            $race = user_get_race($anomaly['user_id']);
        } else {
            $race = "Nobody";
        }
        // Show the population status in a different color
        if ($anomaly['population_capacity'] == 0) {
            $p = 0;
        } else {
            $p = $anomaly['population'] / $anomaly['population_capacity'] * 100;
        }
        $popcol = 'people_class1';
        if ($p > 50) {
            $popcol = 'people_class2';
        }
        if ($p > 75) {
            $popcol = 'people_class3';
        }
        if ($p > 99) {
            $popcol = 'people_class4';
        }
        if (!anomaly_is_planet($anomaly['id'])) {
            $anomaly['class'] = "";
            $anomaly['population'] = "";
        }
        // Show the class in different colors, A..J are orange... K..M are white... L..Z are red
        $classcol = "class_normal";
        if (planet_is_habitable($anomaly['id'])) {
            $classcol = 'class_habitable';
        } elseif (planet_is_minable($anomaly['id'])) {
            $classcol = 'class_minable';
        } else {
            $classcol = 'class_unusable';
        }
        $tmp = array();
        $tmp['name_href'] = "anomaly.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($anomaly['id']);
        $tmp['name'] = $anomaly['name'];
        $tmp['class'] = $anomaly['class'];
        $tmp['class_class'] = $classcol;
        if (planet_is_habitable($anomaly['id'])) {
            $tmp['population'] = $anomaly['population'];
        } else {
            $tmp['population'] = "---";
        }
        $tmp['population_class'] = $popcol;
        $tmp['owner'] = $race;
        $tmp['status'] = $state;
        $tmp['radius'] = $anomaly['radius'];
        $tmp['distance'] = $anomaly['distance'];
        $tmpvar[] = $tmp;
    }
    $template->assign("anomalies", $tmpvar);
    $template->display($_RUN['theme_path'] . "/sectors-item.tpl");
}
Beispiel #2
0
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");
}
Beispiel #3
0
function vessel_show_vessels_orbiting_planet($planet_id)
{
    assert(is_numeric($planet_id));
    $planet = anomaly_get_anomaly($planet_id);
    if (!anomaly_is_planet($planet_id)) {
        print_subtitle("This is not a planet!");
        return;
    }
    print_subtitle("All vessels orbiting planet " . $planet['name']);
    $firstrow = 1;
    $userid = 0;
    $result = sql_query("SELECT g.* FROM g_vessels AS g, s_vessels AS s WHERE g.status='ORBIT' AND g.planet_id={$planet_id} AND g.created=1 AND s.id = g.vessel_id ORDER BY g.user_id, s.type");
    while ($vessel = sql_fetchrow($result)) {
        if ($vessel['user_id'] != $userid) {
            $userid = $vessel['user_id'];
            if ($firstrow == 0) {
                echo "</table>\n";
                echo "<br><br>\n";
            } else {
                $firstrow = 0;
            }
            echo "<table align=center border=0>\n";
            echo "  <tr class=wb>";
            echo "<th>Name</th>";
            echo "<th>Type</th>";
            echo "<th>Status</th>";
            echo "<th>Coords</th>";
            echo "<th>Race</th>";
            echo "</tr>\n";
        }
        vessel_show_table_row($vessel['id'], $_SERVER['PHP_SELF'], "SHOW_SPECIES");
    }
    echo "</table>\n";
    echo "<br><br>\n";
}
function vessel_get_current_status($vessel_id, $create_hyperlink = true)
{
    assert(is_numeric($vessel_id));
    assert(is_bool($create_hyperlink));
    $vessel = vessel_get_vessel($vessel_id);
    $status = "Unknown status";
    // Are we in orbit?
    if (vessel_is_in_orbit($vessel_id)) {
        $anomaly = anomaly_get_anomaly($vessel['planet_id']);
        if (anomaly_is_planet($anomaly['id'])) {
            if ($create_hyperlink) {
                $status = "Orbiting planet <a href=anomaly.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($anomaly['id']) . ">" . $anomaly['name'] . "</a>";
            } else {
                $status = "Orbiting planet " . $anomaly['name'];
            }
        }
        if (anomaly_is_nebula($anomaly['id'])) {
            if ($create_hyperlink) {
                $status = "Hiding in nebula <a href=anomaly.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($anomaly['id']) . ">" . $anomaly['name'] . "</a>";
            } else {
                $status = "Hiding in nebula " . $anomaly['name'];
            }
        }
        if (anomaly_is_starbase($anomaly['id'])) {
            if ($create_hyperlink) {
                $status = "Docking at starbase <a href=anomaly.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($anomaly['id']) . ">" . $anomaly['name'] . "</a>";
            } else {
                $status = "Docking at starbase " . $anomaly['name'];
            }
        }
    }
    // Is the vessel flying?
    if (vessel_is_flying($vessel_id)) {
        if ($vessel['dst_planet_id'] == 0) {
            // Are we flying to a sector or deep space?
            if ($vessel['dst_sector_id'] == 0) {
                $status = "Flying to " . $vessel['dst_distance'] . " / " . $vessel['dst_angle'];
            } else {
                $tmp = sector_get_sector($vessel['dst_sector_id']);
                if ($create_hyperlink) {
                    $status = "Flying to sector <a href=sector.php?id=" . encrypt_get_vars($tmp['id']) . ">" . $tmp['name'] . "</a>";
                } else {
                    $status = "Flying to sector " . $tmp['name'];
                }
            }
        } else {
            // Are we flying to a planet?
            $tmp_anomaly = anomaly_get_anomaly($vessel['dst_planet_id']);
            if (anomaly_is_planet($tmp_anomaly['id'])) {
                if (anomaly_is_discovered_by_user($tmp_anomaly['id'], user_ourself())) {
                    if ($create_hyperlink) {
                        $status = "Flying to planet <a href=anomaly.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($tmp_anomaly['id']) . ">" . $tmp_anomaly['name'] . "</a>";
                    } else {
                        $status = "Flying to planet " . $tmp_anomaly['name'];
                    }
                } else {
                    $status = "Flying to an unknown anomaly.";
                }
            }
            if (anomaly_is_starbase($tmp_anomaly['id'])) {
                $status = "Flying to starbase " . $tmp_anomaly['name'];
            }
            if (anomaly_is_nebula($tmp_anomaly['id'])) {
                $status = "Flying to nebula " . $tmp_anomaly['name'];
            }
            if (anomaly_is_wormhole($tmp_anomaly['id'])) {
                $status = "Flying to wormhole " . $tmp_anomaly['name'];
            }
        }
    }
    // Are we halted in deep space?
    if (vessel_is_in_space($vessel_id) and $vessel['sector_id'] == 0) {
        $status = "Located in deep space (" . $vessel['distance'] . " / " . $vessel['angle'] . ")";
    }
    // Or are we bordering a sector?
    if (vessel_is_in_space($vessel_id) and $vessel['sector_id'] != 0) {
        $sector = sector_get_sector($vessel['sector_id']);
        $status = "Bordering sector " . $sector['name'];
    }
    if (vessel_in_traderoute($vessel_id)) {
        $status = "Part of traderoute.";
    }
    // TODO: change this into vessel_is_in_convoy ($vessel_id)
    if ($vessel['status'] == "CONVOY") {
        $result = sql_query("SELECT * FROM s_convoys WHERE id=" . $vessel['convoy_id']);
        $tmp = sql_fetchrow($result);
        if ($create_hyperlink) {
            $status = "Part of convoy <a href=convoy.php?id=" . encrypt_get_vars($tmp['id']) . ">" . $tmp['name'] . "</a>";
        } else {
            $status = "Part of convoy " . $tmp['name'];
        }
    }
    return $status;
}
Beispiel #5
0
function show_anomaly($anomaly_id)
{
    assert(is_numeric($anomaly_id));
    if (anomaly_is_starbase($anomaly_id)) {
        starbase_show_starbase($anomaly_id);
    }
    if (anomaly_is_planet($anomaly_id)) {
        planet_show_planet($anomaly_id);
    }
    if (anomaly_is_wormhole($anomaly_id)) {
        wormhole_show_wormhole($anomaly_id);
    }
    if (anomaly_is_blackhole($anomaly_id)) {
        blackhole_show_blackhole($anomaly_id);
    }
    if (anomaly_is_nebula($anomaly_id)) {
        nebula_show_nebula($anomaly_id);
    }
}
Beispiel #6
0
function trade_create_route($user_id)
{
    assert(is_numeric($user_id));
    $found_at_least_one_ship = false;
    $result = sql_query("SELECT g.* FROM g_vessels AS g, s_vessels AS s WHERE g.user_id={$user_id} AND s.id = g.vessel_id AND s.type='" . VESSEL_TYPE_TRADE . "'");
    while ($vessel = sql_fetchrow($result)) {
        if (!vessel_in_traderoute($vessel['id'])) {
            $found_at_least_one_ship = true;
        }
    }
    if ($found_at_least_one_ship == false) {
        print_line("You do not have any tradeships currently available for setting up a traderoute");
        return;
    }
    print_remark("Create form");
    form_start();
    echo "  <input type=hidden name=cmd value=" . encrypt_get_vars("create2") . ">\n";
    echo "  <table align=center>\n";
    echo "  <tr>\n";
    echo "    <td>&nbsp;Vessel: &nbsp;</td>\n";
    echo "    <td>\n";
    echo "      <select name=vid>\n";
    $result = sql_query("SELECT g.* FROM g_vessels AS g, s_vessels AS s WHERE g.user_id={$user_id} AND s.id = g.vessel_id AND s.type='" . VESSEL_TYPE_TRADE . "'");
    while ($vessel = sql_fetchrow($result)) {
        if (!trade_is_vessel_in_route($vessel['id'])) {
            echo "        <option value=" . encrypt_get_vars($vessel['id']) . ">" . $vessel['name'] . "</option>\n";
        }
    }
    echo "      </select>\n";
    echo "    </td>\n";
    echo "  </tr>\n";
    echo "  <tr><td>&nbsp;</td></tr>\n";
    echo "  <tr>\n";
    echo "    <td>&nbsp;Source Planet: &nbsp;</td>\n";
    echo "    <td>\n";
    echo "      <select name=src_pid>\n";
    $result = sql_query("SELECT a.*,s.name AS sectorname FROM s_anomalies AS a, s_sectors AS s WHERE a.user_id={$user_id} AND a.type='P' AND a.sector_id = s.id");
    while ($planet = sql_fetchrow($result)) {
        if (anomaly_is_planet($planet['id']) and planet_is_minable($planet['id'])) {
            echo "        <option value=" . encrypt_get_vars($planet['id']) . ">" . $planet['sectorname'] . " / " . $planet['name'] . "</option>\n";
        }
    }
    echo "      </select>\n";
    echo "    </td>\n";
    echo "  </tr>\n";
    echo "  <tr>\n";
    echo "    <td>&nbsp;Ores: &nbsp;</td>\n";
    echo "    <td>";
    echo "      <table border=0 cellspacing=0 colspacing=0>\n";
    echo "        <tr>";
    for ($i = 0; $i != ore_get_ore_count(); $i++) {
        if ($i % 3 == 0) {
            echo "        </tr>\n";
            echo "        <tr>\n";
        }
        echo "          <td><input type=checkbox name=src_ore_" . $i . ">" . ore_get_ore_name($i) . "</td>\n";
    }
    echo "        </tr>\n";
    echo "      </table>\n";
    echo "    </td>\n";
    echo "  </tr>\n";
    echo "  <tr><td colspan=2>&nbsp;</td></tr>\n";
    echo "  <tr>\n";
    echo "    <td>&nbsp;Destination Planet: &nbsp;</td>\n";
    echo "    <td>\n";
    echo "      <select name=dst_pid>\n";
    $result = sql_query("SELECT * FROM g_anomalies WHERE user_id={$user_id}");
    $planetlist = csl_create_array($result, 'csl_discovered_id');
    // Get all planets which we own...
    foreach ($planetlist as $planet_id) {
        $planet = anomaly_get_anomaly($planet_id);
        if ($planet['user_id'] == 0) {
            continue;
        }
        if ($planet['user_id'] != $user_id) {
            continue;
        }
        if (user_is_mutual_friend($user_id, $planet['user_id']) and anomaly_is_planet($planet['id']) and planet_is_minable($planet['id'])) {
            $sector = sector_get_sector($planet['sector_id']);
            echo "        <option value=" . encrypt_get_vars($planet['id']) . ">" . $sector['name'] . " / " . $planet['name'] . "</option>\n";
        }
    }
    // And now, all other planets with a different user_id
    foreach ($planetlist as $planet_id) {
        $planet = anomaly_get_anomaly($planet_id);
        if ($planet['user_id'] == 0) {
            continue;
        }
        if ($planet['user_id'] == $user_id) {
            continue;
        }
        if (user_is_mutual_friend($user_id, $planet['user_id']) and anomaly_is_planet($planet['id']) and planet_is_minable($planet)) {
            $sector = sector_get_sector($planet['sector_id']);
            $race = user_get_race($planet['user_id']);
            echo "        <option value=" . encrypt_get_vars($planet['id']) . ">(" . $race . ") " . $sector['name'] . " / " . $planet['name'] . "</option>\n";
        }
    }
    echo "      </select>\n";
    echo "    </td>\n";
    echo "  </tr>\n";
    echo "  <tr>\n";
    echo "    <td>&nbsp;Ores: &nbsp;</td>\n";
    echo "    <td>\n";
    echo "      <table border=0 cellspacing=0 colspacing=0>\n";
    echo "        <tr>\n";
    for ($i = 0; $i != ore_get_ore_count(); $i++) {
        if ($i % 3 == 0) {
            echo "      </tr>\n";
            echo "      <tr>\n";
        }
        echo "        <td><input type=checkbox name=dst_ore_" . $i . ">" . ore_get_ore_name($i) . "</td>\n";
    }
    echo "     </tr>\n";
    echo "    </table>\n";
    echo "      </td>\n";
    echo "    </tr>\n";
    echo "    <tr><td colspan=2>&nbsp;</td></tr>\n";
    echo "    <tr><td></td><td><input type=submit name=submit value='create traderoute'></td></tr>\n";
    echo "  </table>\n";
    form_end();
}
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);
}
Beispiel #8
0
function info_get_anomaly_statistics($user_id)
{
    assert(isset($user_id));
    $minable = 0;
    $habitable = 0;
    $unusable = 0;
    $starbase = 0;
    $wormhole = 0;
    $anomalies = 0;
    $blackhole = 0;
    $result = sql_query("SELECT * FROM s_anomalies WHERE user_id = " . $user_id);
    while ($anomaly = sql_fetchrow($result)) {
        if (anomaly_is_planet($anomaly['id'])) {
            if (planet_is_habitable($anomaly['id'])) {
                $habitable++;
            } elseif (planet_is_minable($anomaly['id'])) {
                $minable++;
            } else {
                $unusable++;
            }
        } elseif (anomaly_is_wormhole($anomaly['id'])) {
            $wormhole++;
        } elseif (anomaly_is_starbase($anomaly['id'])) {
            $starbase++;
        } elseif (anomaly_is_blackhole($anomaly['id'])) {
            $blackhole++;
        } else {
            $anomalies++;
        }
    }
    return array($minable, $habitable, $unusable, $starbase, $wormhole, $blackhole, $anomalies);
}