function starbase_show_starbase($starbase_id)
{
    assert(!empty($starbase_id));
    global $_GALAXY;
    if (!anomaly_is_starbase($starbase_id)) {
        return;
    }
    $starbase = anomaly_get_anomaly($starbase_id);
    $sector = sector_get_sector($starbase['sector_id']);
    $race = user_get_race($starbase['user_id']);
    if ($race == "") {
        $race = "-";
    }
    echo "<table border=1 width=500 align=center>";
    echo "  <tr><td align=center><b><i>Starbase: " . $starbase['name'] . "</i></b></td></tr>";
    echo "  <tr><td>";
    echo "    <table border=0 cellpadding=0 cellspacing=0 width=100%>";
    echo "      <tr><td width=200>";
    echo "          <table border=0 cellpadding=0 cellspacing=0 width=100%>";
    echo "            <tr><th>Starbase View</th></tr>";
    echo "            <tr><td width=100%><center><img src=\"" . $_CONFIG['URL'] . $_GALAXY['image_dir'] . "/starbase/" . $starbase['image'] . ".jpg\" width=150 height=150></center></td></tr>";
    echo "            <tr><th>&nbsp;</th></tr>";
    echo "          </table>";
    echo "        </td>";
    echo "        <td>&nbsp;</td>";
    echo "        <td nowrap valign=top>";
    echo "          <table border=0 cellpadding=0 cellspacing=0 width=100%>";
    echo "            <tr><td nowrap width=40%><strong>Starbase Name        </strong></td><td nowrap width=1%><b>:</b></td>";
    if ($starbase['unknown'] == 1) {
        form_start();
        echo "<td nowrap>";
        echo "  <input type=hidden name=aid value=" . encrypt_get_vars($starbase_id) . ">";
        echo "  <input type=hidden name=cmd value=" . encrypt_get_vars("claim") . ">";
        echo "  <input type=text size=15 maxlength=30 name=ne_name> ";
        echo "  <input name=submit type=submit value=\"Claim\">";
        echo "</td>";
        form_end();
    } else {
        echo "<td nowrap>" . $starbase['name'] . "</td>";
    }
    echo "             </tr>";
    echo "            <tr><td colspan=3>&nbsp;</td></tr>";
    echo "            <tr><td nowrap width=40%><strong>Caretaker   </strong></td><td nowrap width=1%><b>:</b>&nbsp;</td><td nowrap>" . $race . "</td></tr>";
    echo "            <tr><td colspan=3>&nbsp;</td></tr>";
    echo "            <tr><td nowrap width=40%><strong>Attack      </strong></td><td nowrap width=1%><b>:</b>&nbsp;</td><td nowrap>" . $starbase['cur_attack'] . "</td></tr>";
    echo "            <tr><td nowrap width=40%><strong>Defense     </strong></td><td nowrap width=1%><b>:</b>&nbsp;</td><td nowrap>" . $starbase['cur_defense'] . "</td></tr>";
    echo "            <tr><td nowrap width=40%><strong>Strength    </strong></td><td nowrap width=1%><b>:</b>&nbsp;</td><td nowrap>" . $starbase['cur_strength'] . "</td></tr>";
    echo "            <tr><td colspan=3>&nbsp;</td></tr>";
    echo "          </table>";
    echo "        </td>";
    echo "      </tr>";
    echo "    </table>";
    echo "    </td>";
    echo "  </tr>";
    echo "</table>";
    echo "<br><br>";
}
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);
}