コード例 #1
0
function anomaly_is_discovered_by_user($anomaly_id, $user_id)
{
    assert(is_numeric($anomaly_id));
    assert(is_numeric($user_id));
    $tmp = user_get_all_anomalies_from_user($user_id);
    $undiscovered_anomalies = csl($tmp['csl_undiscovered_id']);
    $discovered_anomalies = csl($tmp['csl_discovered_id']);
    if (in_array($anomaly_id, $discovered_anomalies)) {
        return true;
    }
    return false;
}
コード例 #2
0
function conview_show_all_sectors($user_id)
{
    assert(is_numeric($user_id));
    // Get all sectors that we can see
    $result = sql_query("SELECT * FROM g_sectors WHERE user_id=" . $user_id);
    $sectors = csl_create_array($result, "csl_sector_id");
    $user = user_get_user($user_id);
    $tmp = user_get_all_anomalies_from_user($user_id);
    $anomalies = csl($tmp['csl_discovered_id']);
    foreach ($sectors as $sector_id) {
        conview_show_sector($user_id, $sector_id, $anomalies);
        exit;
    }
}
コード例 #3
0
ファイル: sector.php プロジェクト: jaytaph/perihelion-oldcode
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");
}