Exemplo n.º 1
0
function RepairDefense($d, $res, $defrepair, $defrepair_delta, $premium = true)
{
    $repaired = array(401 => 0, 402 => 0, 403 => 0, 404 => 0, 405 => 0, 406 => 0, 407 => 0, 408 => 0);
    $exploded = array(401 => 0, 402 => 0, 403 => 0, 404 => 0, 405 => 0, 406 => 0, 407 => 0, 408 => 0);
    $exploded_total = 0;
    if ($premium) {
        $prem = PremiumStatus($d[0]);
    }
    $rounds = count($res['rounds']);
    if ($rounds > 0) {
        // Посчитать взорванную оборону.
        $last = $res['rounds'][$rounds - 1];
        foreach ($exploded as $gid => $amount) {
            $exploded[$gid] = $d[0]['defense'][$gid] - $last['defenders'][0][$gid];
            if ($prem['engineer']) {
                $exploded[$gid] = floor($exploded[$gid] / 2);
            }
            $exploded_total += $exploded[$gid];
        }
        // Восстановить оборону
        if ($exploded_total) {
            foreach ($exploded as $gid => $amount) {
                if ($amount < 10) {
                    for ($i = 0; $i < $amount; $i++) {
                        if (mt_rand(0, 99) < $defrepair) {
                            $repaired[$gid]++;
                        }
                    }
                } else {
                    $repaired[$gid] = floor(mt_rand($defrepair - $defrepair_delta, $defrepair + $defrepair_delta) * $amount / 100);
                }
            }
        }
    }
    return $repaired;
}
Exemplo n.º 2
0
            }
        }
    }
}
$not_enough_deut = ($aktplanet['g'] != $coord_g || $aktplanet['s'] != $coord_s) && $aktplanet['d'] < 10;
// Списать 10 дейтерия за просмотр не домашней системы (только для обычных пользователей)
if (!$not_enough_deut && $GlobalUser['admin'] == 0) {
    if ($aktplanet['g'] != $coord_g || $aktplanet['s'] != $coord_s) {
        AdjustResources(0, 0, 10, $aktplanet['planet_id'], '-');
        $aktplanet = GetPlanet($aktplanet['planet_id']);
    }
}
$result = EnumOwnFleetQueue($GlobalUser['player_id']);
$nowfleet = dbrows($result);
$maxfleet = $GlobalUser['r108'] + 1;
$prem = PremiumStatus($GlobalUser);
if ($prem['admiral']) {
    $maxfleet += 2;
}
PageHeader("galaxy", true);
echo "<!-- CONTENT AREA -->\n";
echo "<div id='content'>\n";
echo "<center>\n\n";
/***** Скрипты. *****/
?>

  <script  language="JavaScript">
  function galaxy_submit(value) {
      document.getElementById('auto').name = value;
      document.getElementById('galaxy_form').submit();
  }
Exemplo n.º 3
0
function SpyArrive($queue, $fleet_obj, $fleet, $origin, $target)
{
    global $UnitParam;
    $fleetmap = array(202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215);
    $defmap = array(401, 402, 403, 404, 405, 406, 407, 408, 502, 503);
    $buildmap = array(1, 2, 3, 4, 12, 14, 15, 21, 22, 23, 24, 31, 33, 34, 41, 42, 43, 44);
    $resmap = array(106, 108, 109, 110, 111, 113, 114, 115, 117, 118, 120, 121, 122, 123, 124, 199);
    $now = $queue['end'];
    $origin_user = LoadUser($origin['owner_id']);
    $target_user = LoadUser($target['owner_id']);
    $origin_ships = $target_ships = $origin_cost = 0;
    foreach ($fleetmap as $i => $gid) {
        $origin_ships += $fleet_obj["ship{$gid}"];
        $origin_cost += $fleet_obj["ship{$gid}"] * $UnitParam[$gid][0];
        $target_ships += $target["f{$gid}"];
    }
    $origin_prem = PremiumStatus($origin_user);
    $target_prem = PremiumStatus($target_user);
    $origin_tech = $origin_user['r106'];
    if ($origin_prem['technocrat']) {
        $origin_tech += 2;
    }
    $target_tech = $target_user['r106'];
    if ($target_prem['technocrat']) {
        $target_tech += 2;
    }
    loca_add("technames", $origin_user['lang']);
    /*
        $diff = abs ( $target_tech - $origin_tech );
        if ( $target_tech > $origin_tech ) {
            $level = $fleet_obj['ship210'] - pow ( $diff, 2 );
            $counter_max = min (100, floor((($target_ships / 4) * $origin_ships) * pow ( 2, $diff )));
        }
        else {
            $level = $fleet_obj['ship210'] + pow ( $diff, 2 );
            $counter_max = min (100, floor((($target_ships / 4) * $origin_ships) / pow ( 2, $diff )));
        }
        $counter = mt_rand ( 0, $counter_max );
    */
    $level = $origin_tech - $target_tech;
    $level = $level * abs($level) - 1 + $origin_ships;
    $cost = $origin_cost / 1000 / 400;
    $c = sqrt(pow(2, $origin_ships - ($level + 1))) * ($cost * sqrt($target_ships) * 5);
    if ($c > 2) {
        $c = 2;
    }
    $c = rand(0, $c * 100) / 100;
    if ($c < 0) {
        $c = 0;
    }
    if ($c > 1) {
        $c = 1;
    }
    $counter = $c * 100;
    $subj = "\n<span class=\"espionagereport\">\n" . "Разведданные с " . $target['name'] . "\n" . "<a onclick=\"showGalaxy(" . $target['g'] . "," . $target['s'] . "," . $target['p'] . ");\" href=\"#\">[" . $target['g'] . ":" . $target['s'] . ":" . $target['p'] . "]</a>\n";
    $report = "";
    // Шапка
    $report .= "<table width=400><tr><td class=c colspan=4>Сырьё на " . $target['name'] . " <a href=# onclick=showGalaxy(" . $target['g'] . "," . $target['s'] . "," . $target['p'] . "); >[" . $target['g'] . ":" . $target['s'] . ":" . $target['p'] . "]</a> (Игрок \\'" . $target_user['oname'] . "\\')<br /> на " . date("m-d H:i:s", $now) . "</td></tr>\n";
    $report .= "</div></font></TD></TR><tr><td>металла:</td><td>" . nicenum($target['m']) . "</td>\n";
    $report .= "<td>кристалла:</td><td>" . nicenum($target['k']) . "</td></tr>\n";
    $report .= "<tr><td>дейтерия:</td><td>" . nicenum($target['d']) . "</td>\n";
    $report .= "<td>энергии:</td><td>" . nicenum($target['emax']) . "</td></tr>\n";
    $report .= "</table>\n";
    // Активность
    $report .= "<table width=400><tr><td class=c colspan=4>     </td></tr>\n";
    $report .= "<TR><TD colspan=4><div onmouseover=\\'return overlib(\"&lt;font color=white&gt;Активность означает, что сканируемый игрок был активен на своей планете, либо на него был произведён вылет флота другого игрока.&lt;/font&gt;\", STICKY, MOUSEOFF, DELAY, 750, CENTER, WIDTH, 100, OFFSETX, -130, OFFSETY, -10);\\' onmouseout=\\'return nd();\\'></TD></TR></table>\n";
    // Флот на удержании
    $result = GetHoldingFleets($target['planet_id']);
    $holding_fleet = array();
    while ($fobj = dbarray($result)) {
        foreach ($fleetmap as $i => $gid) {
            $holding_fleet[$gid] += $fobj["ship{$gid}"];
        }
    }
    // Флот
    if ($level > 0) {
        $report .= "<table width=400><tr><td class=c colspan=4>Флоты     </td></tr>\n";
        $count = 0;
        foreach ($fleetmap as $i => $gid) {
            $amount = $target["f{$gid}"] + $holding_fleet[$gid];
            if ($count % 2 == 0) {
                $report .= "</tr>\n";
            }
            if ($amount > 0) {
                $report .= "<td>" . loca("NAME_{$gid}") . "</td><td>" . nicenum($amount) . "</td>\n";
                $count++;
            }
        }
        $report .= "</table>\n";
    }
    // Оборона
    if ($level > 1) {
        $report .= "<table width=400><tr><td class=c colspan=4>Оборона     </td></tr>\n";
        $count = 0;
        foreach ($defmap as $i => $gid) {
            $amount = $target["d{$gid}"];
            if ($count % 2 == 0) {
                $report .= "</tr>\n";
            }
            if ($amount > 0) {
                $report .= "<td>" . loca("NAME_{$gid}") . "</td><td>" . nicenum($amount) . "</td>\n";
                $count++;
            }
        }
        $report .= "</table>\n";
    }
    // Постройки
    if ($level > 3) {
        $report .= "<table width=400><tr><td class=c colspan=4>Постройки     </td></tr>\n";
        $count = 0;
        foreach ($buildmap as $i => $gid) {
            $amount = $target["b{$gid}"];
            if ($count % 2 == 0) {
                $report .= "</tr>\n";
            }
            if ($amount > 0) {
                $report .= "<td>" . loca("NAME_{$gid}") . "</td><td>" . nicenum($amount) . "</td>\n";
                $count++;
            }
        }
        $report .= "</table>\n";
    }
    // Исследования
    if ($level > 5) {
        $report .= "<table width=400><tr><td class=c colspan=4>Исследования     </td></tr>\n";
        $count = 0;
        foreach ($resmap as $i => $gid) {
            $amount = $target_user["r{$gid}"];
            if ($count % 2 == 0) {
                $report .= "</tr>\n";
            }
            if ($amount > 0) {
                $report .= "<td>" . loca("NAME_{$gid}") . "</td><td>" . nicenum($amount) . "</td>\n";
                $count++;
            }
        }
        $report .= "</table>\n";
    }
    $report .= "<center> Шанс на защиту от шпионажа:" . floor($counter) . "%</center>\n";
    $report .= "<center><a href=\\'#\\' onclick=\\'showFleetMenu(" . $target['g'] . "," . $target['s'] . "," . $target['p'] . "," . GetPlanetType($target) . ",1);\\'>Атака</a></center>\n";
    SendMessage($fleet_obj['owner_id'], "Командование флотом", $subj, $report, 1, $queue['end']);
    // Отправить сообщение чужому игроку о шпионаже.
    $text = "\nЧужой флот с планеты " . $origin['name'] . "\n" . "<a onclick=\"showGalaxy(" . $origin['g'] . "," . $origin['s'] . "," . $origin['p'] . ");\" href=\"#\">[" . $origin['g'] . ":" . $origin['s'] . ":" . $origin['p'] . "]</a>\n" . "был обнаружен вблизи от планеты " . $target['name'] . "\n" . "<a onclick=\"showGalaxy(" . $target['g'] . "," . $target['s'] . "," . $target['p'] . ");\" href=\"#\">[" . $target['g'] . ":" . $target['s'] . ":" . $target['p'] . "]</a>\n" . ". Шанс на защиту от шпионажа: {$counter} %\n" . "</td>\n";
    SendMessage($target['owner_id'], "Наблюдение", "Шпионаж", $text, 5, $queue['end']);
    // Обновить активность на чужой планете.
    UpdatePlanetActivity($fleet_obj['target_planet'], $queue['end']);
    // Вернуть флот.
    if (mt_rand(0, 100) < $counter) {
        StartBattle($fleet_obj['fleet_id'], $fleet_obj['target_planet'], $queue['end']);
    } else {
        DispatchFleet($fleet, $origin, $target, 106, $fleet_obj['flight_time'], $fleet_obj['m'], $fleet_obj['k'], $fleet_obj['d'], $fleet_obj['fuel'] / 2, $queue['end']);
    }
}
Exemplo n.º 4
0
function ProdResources($planet, $time_from, $time_to)
{
    global $db_prefix, $GlobalUni;
    if (!($planet['type'] > 0 && $planet['type'] < 10000)) {
        return $planet;
    }
    // НЕ планета
    $user = LoadUser($planet['owner_id']);
    if ($user['player_id'] == 99999) {
        return $planet;
    }
    // технический аккаунт space
    $diff = $time_to - $time_from;
    $unitab = $GlobalUni;
    $speed = $unitab['speed'];
    $prem = PremiumStatus($user);
    if ($prem['geologist']) {
        $g_factor = 1.1;
    } else {
        $g_factor = 1.0;
    }
    $hourly = prod_metal($planet['b1'], $planet['mprod']) * $planet['factor'] * $speed * $g_factor + 20 * $speed;
    // Металл
    if ($planet['m'] < $planet['mmax']) {
        $planet['m'] += $hourly * $diff / 3600;
        if ($planet['m'] >= $planet['mmax']) {
            $planet['m'] = $planet['mmax'];
        }
    }
    $hourly = prod_crys($planet['b2'], $planet['kprod']) * $planet['factor'] * $speed * $g_factor + 10 * $speed;
    // Кристалл
    if ($planet['k'] < $planet['kmax']) {
        $planet['k'] += $hourly * $diff / 3600;
        if ($planet['k'] >= $planet['kmax']) {
            $planet['k'] = $planet['kmax'];
        }
    }
    $hourly = prod_deut($planet['b3'], $planet['temp'] + 40, $planet['dprod']) * $planet['factor'] * $speed * $g_factor;
    // Дейтерий
    $hourly -= cons_fusion($planet['b12'], $planet['fprod']) * $speed;
    // термояд
    if ($planet['d'] < $planet['dmax']) {
        $planet['d'] += $hourly * $diff / 3600;
        if ($planet['d'] >= $planet['dmax']) {
            $planet['d'] = $planet['dmax'];
        }
    }
    $planet_id = $planet['planet_id'];
    $query = "UPDATE " . $db_prefix . "planets SET m = '" . $planet['m'] . "', k = '" . $planet['k'] . "', d = '" . $planet['d'] . "', lastpeek = '" . $time_to . "' WHERE planet_id = {$planet_id}";
    dbquery($query);
    $planet['lastpeek'] = $time_to;
    return $planet;
}
Exemplo n.º 5
0
function GetPlanet($planet_id)
{
    global $db_prefix;
    $query = "SELECT * FROM " . $db_prefix . "planets WHERE planet_id = '" . $planet_id . "' LIMIT 1";
    $result = dbquery($query);
    if (dbrows($result) == 0) {
        return NULL;
    }
    $planet = dbarray($result);
    $user = LoadUser($planet['owner_id']);
    $prem = PremiumStatus($user);
    if ($prem['engineer']) {
        $e_factor = 1.1;
    } else {
        $e_factor = 1.0;
    }
    $planet['mmax'] = store_capacity($planet['b22']);
    $planet['kmax'] = store_capacity($planet['b23']);
    $planet['dmax'] = store_capacity($planet['b24']);
    $planet['emax'] = prod_solar($planet['b4'], $planet['sprod']) * $e_factor + prod_fusion($planet['b12'], $user['r113'], $planet['fprod']) * $e_factor + prod_sat($planet['temp'] + 40) * $planet['f212'] * $planet['ssprod'] * $e_factor;
    $planet['econs'] = cons_metal($planet['b1']) * $planet['mprod'] + cons_crys($planet['b2']) * $planet['kprod'] + cons_deut($planet['b3']) * $planet['dprod'];
    $planet['e'] = floor($planet['emax'] - $planet['econs']);
    $planet['factor'] = 1;
    if ($planet['e'] < 0) {
        $planet['factor'] = max(0, 1 - abs($planet['e']) / $planet['econs']);
    }
    return $planet;
}
Exemplo n.º 6
0
function StartResearch($player_id, $planet_id, $id, $now)
{
    global $db_prefix, $GlobalUni;
    $uni = $GlobalUni;
    $planet = GetPlanet($planet_id);
    UserLog($player_id, "RESEARCH", "Запустить исследование " . loca("NAME_{$id}") . " на планете {$planet_id}");
    // Получить уровень исследования.
    $user = LoadUser($player_id);
    $level = $user['r' . $id] + 1;
    $prem = PremiumStatus($user);
    if ($prem['technocrat']) {
        $r_factor = 1.1;
    } else {
        $r_factor = 1.0;
    }
    // Проверить условия.
    $text = CanResearch($user, $planet, $id, $level);
    if ($text === "") {
        $speed = $uni['speed'];
        if ($now == 0) {
            $now = time();
        }
        $reslab = ResearchNetwork($planet['planet_id'], $id);
        $seconds = ResearchDuration($id, $level, $reslab, $speed * $r_factor);
        // Списать ресурсы.
        $res = ResearchPrice($id, $level);
        AdjustResources($res['m'], $res['k'], $res['d'], $planet_id, '-');
        //echo "--------------------- Запустить исследование $id на планете $planet_id игрока $player_id, уровень $level, продолжительность $seconds" ;
        AddQueue($player_id, "Research", $planet_id, $id, $level, $now, $seconds);
    }
}
Exemplo n.º 7
0
function BotResearch($obj_id)
{
    global $BotID, $BotNow, $GlobalUni;
    $user = LoadUser($BotID);
    $aktplanet = GetPlanet($user['aktplanet']);
    $level = $aktplanet['r' . $obj_id] + 1;
    $text = StartResearch($user[player_id], $user[aktplanet], $obj_id, 0);
    if ($text === '') {
        $speed = $uni['speed'];
        if ($now == 0) {
            $now = time();
        }
        $reslab = ResearchNetwork($user['planet_id'], $obj_id);
        $prem = PremiumStatus($user);
        if ($prem['technocrat']) {
            $r_factor = 1.1;
        } else {
            $r_factor = 1.0;
        }
        $seconds = ResearchDuration($obj_id, $level, $reslab, $speed * $r_factor);
        UpdatePlanetActivity($user['aktplanet'], $BotNow);
        return $seconds;
    } else {
        return 0;
    }
}