예제 #1
0
function get_special_buildings_by_sid($sid, $type = 0)
{
    // type 0:
    // S = Jumpgate
    // U = Tradingstation
    // type 1:
    // wie type 0 +
    // F = Orbital Refueling Station
    $planets = get_planets_by_sid($sid);
    if (is_array($planets)) {
        if ($type == 0) {
            for ($i = 0; $i < sizeof($planets); $i++) {
                $sth = mysql_query("select p.special, o.pid from constructions as o, production as p where o.pid=" . $planets[$i] . " and o.prod_id = p.prod_id and (p.special = 'S' or p.special = 'U')");
                if (!$sth) {
                    return 0;
                }
                $j = 0;
                while ($specials = mysql_fetch_array($sth)) {
                    $specials_array[$j][special] = $specials["special"];
                    $specials_array[$j][pid] = $specials["pid"];
                    $j++;
                }
            }
            return $specials_array;
        } else {
            for ($i = 0; $i < sizeof($planets); $i++) {
                $sth = mysql_query("select p.special, o.pid from constructions as o, production as p where o.pid=" . $planets[$i] . " and o.prod_id = p.prod_id and (p.special = 'S' or p.special = 'U' or p.special = 'F')");
                if (!$sth) {
                    return 0;
                }
                $j = 0;
                while ($specials = mysql_fetch_array($sth)) {
                    $specials_array[$j][special] = $specials["special"];
                    $specials_array[$j][pid] = $specials["pid"];
                    $j++;
                }
            }
            // if (is_array($specials_array))
            // $specials_array = array_unique($specials_array);
            return $specials_array;
        }
    }
}
예제 #2
0
function get_true_ETA_by_fid($fid)
{
    global $uid;
    $fleets_target = get_fleets_target($fid);
    // kein ziel
    if ($fleets_target["system"]["tid"] == 0 && $fleets_target["planet"]["tid"] == 0) {
        return 0;
    }
    // ziel = standort
    if ($fleets_target["system"]["tid"] == $fleets_target["system"]["id"] && $fleets_target["planet"]["tid"] == $fleets_target["planet"]["id"]) {
        return 0;
    }
    // innerhalb eines systems
    if ($fleets_target["system"]["tid"] == $fleets_target["system"]["id"] && $fleets_target["planet"]["tid"] != $fleets_planets["planet"]["id"]) {
        return 1;
    } else {
        // Alleierte raussuchen
        $allies = get_allied_ids($uid);
        if (is_array($allies)) {
            array_push($allies, $uid);
        } else {
            $allies[0] = $uid;
        }
        // route besorgen
        $sth = mysql_query("select route from routes where fid={$fid}");
        if (!$sth || !mysql_num_rows($sth)) {
            return false;
        }
        list($route) = mysql_fetch_row($sth);
        $route = unserialize($route);
        // Anzahl sprünge ermitteln
        $jumps = sizeof($route);
        $refueling_stations_count = 0;
        // refueling stations ermitteln
        $refueling_stations = get_prodid_by_special("F");
        // nach refuelingstations auf dem weg suchen
        for ($i = 0; $i < $jumps - 1; $i++) {
            $current_system_planets = get_planets_by_sid($route[$i]);
            // Filtern nach alleierten und eigenen Planeten
            for ($j = 0; $j < sizeof($current_system_planets); $j++) {
                if (in_array(get_uid_by_pid($current_system_planets[$j]), $allies)) {
                    // construction list des planeten heraussuchen
                    $planet_constructions = get_construction_list($current_system_planets[$j]);
                    // gucken ob refuelingstation auf planet gebaut
                    for ($k = 0; $k < sizeof($refueling_stations); $k++) {
                        if (in_array($refueling_stations[$k], $planet_constructions)) {
                            // refueling statoin gefunden
                            $k = sizeof($refueling_stations);
                            $j = sizeof($current_system_planets);
                            $refueling_stations_count++;
                        }
                    }
                }
            }
        }
        // derzeitigen refuel status der flotte ermitteln
        $current_refuel_time = get_reload($fid);
        if ($current_refuel_time == 0) {
            $current_refuel_time = 1;
        }
        $jumps--;
        $max_refuel_time = get_max_reload($fid);
        if ($jumps < 0) {
            $jumps = 0;
        }
        $eta = $current_refuel_time + $jumps * $max_refuel_time - $refueling_stations_count;
        // jetzt noch den weg vom planeten zum system und entgegengesetzt einberechnen
        if ($fleets_target["planet"]["id"] && $current_refuel_time < 2) {
            $eta++;
        }
        if ($fleets_target["planet"]["tid"] != 0) {
            $eta++;
        }
        // lol, nen hack :S
        if ($eta < 1) {
            $eta = 1;
        }
        // weil alles was 0 ist der eigene standort ist und schon am anfang abgefangen wird
    }
    return $eta;
}