function wormhole_show_wormhole($wormhole_id)
{
    assert(!empty($wormhole_id));
    global $_GALAXY;
    if (!anomaly_is_wormhole($wormhole_id)) {
        return;
    }
    $wormhole = anomaly_get_anomaly($wormhole_id);
    $sector = sector_get_sector($wormhole['sector_id']);
    $race = user_get_race($wormhole['user_id']);
    $result = sql_query("SELECT * FROM w_wormhole WHERE id=" . $wormhole['id']);
    $dst_wormhole = sql_fetchrow($result);
    if ($race == "") {
        $race = "-";
    }
    echo "<table border=1 width=500 align=center>\n";
    echo "  <tr><td align=center><b><i>Sector: " . $sector['name'] . " / Anomaly: " . $wormhole['name'] . "</i></b></td></tr>\n";
    echo "  <tr><td>\n";
    echo "    <table border=0 cellpadding=0 cellspacing=0 width=100%>\n";
    echo "      <tr><td width=200>\n";
    echo "          <table border=0 cellpadding=0 cellspacing=0 width=100%>\n";
    echo "            <tr><th>Anomaly View</th></tr>\n";
    echo "            <tr><td width=100%><center><img src=\"" . $_CONFIG['URL'] . $_GALAXY['image_dir'] . "/wormholes/" . $wormhole['image'] . ".jpg\" width=150 height=150></center></td></tr>\n";
    echo "            <tr><th>&nbsp;</th></tr>\n";
    echo "          </table>\n";
    echo "        </td>\n";
    echo "        <td>&nbsp;</td>\n";
    echo "        <td nowrap valign=top>\n";
    echo "          <table border=0 cellpadding=0 cellspacing=0 width=100%>\n";
    echo "            <tr><td nowrap width=40%><strong>Wormhole Name        </strong></td><td nowrap width=1%><b>:</b></td>\n";
    if ($wormhole['unknown'] == 1) {
        form_start();
        echo "<td nowrap>\n";
        echo "  <input type=hidden name=aid value=" . encrypt_get_vars($wormhole_id) . ">\n";
        echo "  <input type=hidden name=cmd value=" . encrypt_get_vars("claim") . ">\n";
        echo "  <input type=text size=15 maxlength=30 name=ne_name>\n";
        echo "  <input name=submit type=submit value=\"Claim\">\n";
        echo "</td>\n";
        form_end();
    } else {
        echo "<td nowrap>" . $wormhole['name'] . "</td>\n";
    }
    echo "             </tr>\n";
    echo "            <tr><td colspan=3>&nbsp;</td></tr>\n";
    echo "            <tr><td nowrap width=40%><strong>Caretaker          </strong></td><td nowrap width=1%><b>:</b>&nbsp;</td><td nowrap>" . $race . "</td></tr>\n";
    echo "            <tr><td nowrap width=40%><strong>Radius             </strong></td><td nowrap width=1%><b>:</b>&nbsp;</td><td nowrap>" . $wormhole['radius'] . " km</td></tr>\n";
    echo "            <tr><td nowrap width=40%><strong>Distance to sun    </strong></td><td nowrap width=1%><b>:</b>&nbsp;</td><td nowrap>" . $wormhole['distance'] . " km (10<sup>6</sup>)</td></tr>\n";
    echo "            <tr><td colspan=3>&nbsp;</td></tr>\n";
    echo "            <tr><td nowrap width=40%><strong>Destination        </strong></td><td nowrap width=1%><b>:</b>&nbsp;</td><td nowrap>" . $dst_wormhole['distance'] . " / " . $dst_wormhole['angle'] . "</td></tr>\n";
    echo "            <tr><td nowrap width=40%><strong>Stability          </strong></td><td nowrap width=1%><b>:</b>&nbsp;</td><td nowrap>" . wormhole_get_wormhole_stability($dst_wormhole['next_jump']) . " </td></tr>\n";
    echo "          </table>\n";
    echo "        </td>\n";
    echo "      </tr>\n";
    echo "    </table>\n";
    echo "    </td>\n";
    echo "  </tr>\n";
    echo "</table>\n";
    echo "<br><br>\n";
}
Esempio n. 2
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);
    }
}
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;
}
Esempio n. 4
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);
}