Esempio n. 1
0
<table width='519'>
<td class='c' colspan='2'>Вместимость: <?php 
                                        echo $deut_avail;
                                        ?>
/<?php 
                                        echo $depot_cap;
                                        ?>
</td>
<?php 
                                        $fmap = array_reverse($fleetmap);
                                        $result = GetHoldingFleets($aktplanet['planet_id']);
                                        $rows = dbrows($result);
                                        $c = 1;
                                        while ($rows--) {
                                            $fleet_obj = dbarray($result);
                                            $queue = GetFleetQueue($fleet_obj['fleet_id']);
                                            $user = LoadUser($fleet_obj['owner_id']);
                                            $load = $queue['end'] - $now;
                                            echo "  <tr>\n";
                                            echo "    <th>Флот " . $user['oname'] . ":<br>";
                                            $cons = 0;
                                            foreach ($fmap as $i => $id) {
                                                $amount = $fleet_obj["ship" . $id];
                                                if ($amount > 0) {
                                                    echo loca("NAME_" . $id) . ":" . $amount . "<br>";
                                                    $cons += $amount * FleetCons($id, $user['r115'], $user['r117'], $user['r118']) / 10;
                                                }
                                            }
                                            echo "</th>\n";
                                            echo "    <th>\n";
                                            echo "      зарядка<br>{$load} сек<br>\n";
Esempio n. 2
0
$union_count = 0;
foreach ($unions as $i => $union) {
    $fleet_obj = LoadFleet($union['fleet_id']);
    if ($fleet_obj['union_id'] == $union['union_id']) {
        $union_count++;
    }
}
if ($union_count > 0) {
    echo "<input type=\"hidden\" name=\"union2\" value=\"0\" >";
    $now = time();
    foreach ($unions as $i => $union) {
        $fleet_obj = LoadFleet($union['fleet_id']);
        if ($fleet_obj['union_id'] != $union['union_id']) {
            continue;
        }
        $queue = GetFleetQueue($union['fleet_id']);
        $target = GetPlanet($fleet_obj['target_planet']);
        echo "  <tr height=\"20\">";
        echo "<th><div id='bxx" . ($i + 1) . "' title='" . max($queue['end'] - $now, 0) . "'star='" . $queue['end'] . "'></div></th>";
        echo "<th><a href=\"javascript:setTarget(" . $target['g'] . "," . $target['s'] . "," . $target['p'] . "," . GetPlanetType($target) . "); setUnion(" . $union['union_id'] . "); shortInfo()\">";
        echo $union['name'] . " [" . $target['g'] . ":" . $target['s'] . ":" . $target['p'] . "]</a></th></tr>\n";
    }
    echo "<script language=javascript>anz=" . $union_count . ";t();</script>\n\n";
} else {
    echo " <tr height=\"20\"><th colspan=\"2\">-</th></tr>\n";
}
?>

<tr height="20">
 <th colspan="2">
  <input type="submit" value="Дальше" />
Esempio n. 3
0
function UpdateFleetTime($fleet_id, $when)
{
    global $db_prefix;
    $queue = GetFleetQueue($fleet_id);
    $queue_id = $queue['task_id'];
    $query = "UPDATE " . $db_prefix . "queue SET end = {$when} WHERE task_id = {$queue_id}";
    dbquery($query);
}
function PhalanxEventList($planet_id)
{
    $planet = GetPlanet($planet_id);
    $user = LoadUser($planet['owner_id']);
    $fleetmap = array(202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215);
    $result = EnumPlanetFleets($planet_id);
    $rows = dbrows($result);
    $task = array();
    $tasknum = 0;
    $unions = array();
    while ($rows--) {
        $fleet_obj = dbarray($result);
        $queue = GetFleetQueue($fleet_obj['fleet_id']);
        // Союзные флоты собираются отдельно
        if ($fleet_obj['union_id'] > 0 && $fleet_obj['target_planet'] == $planet_id && !$unions[$fleet_obj['union_id']]) {
            $task[$tasknum]['end_time'] = $queue['end'];
            // Флоты
            $acs_result = EnumUnionFleets($fleet_obj['union_id']);
            $task[$tasknum]['fleets'] = $acs_rows = dbrows($acs_result);
            $f = 0;
            while ($acs_rows--) {
                $fleet_obj = dbarray($acs_result);
                $task[$tasknum]['fleet'][$f] = array();
                foreach ($fleetmap as $id => $gid) {
                    $task[$tasknum]['fleet'][$f][$gid] = $fleet_obj["ship{$gid}"];
                }
                $task[$tasknum]['fleet'][$f]['owner_id'] = $fleet_obj['owner_id'];
                $task[$tasknum]['fleet'][$f]['origin_id'] = $fleet_obj['start_planet'];
                $task[$tasknum]['fleet'][$f]['target_id'] = $fleet_obj['target_planet'];
                $task[$tasknum]['fleet'][$f]['mission'] = GetMission($fleet_obj);
                $task[$tasknum]['fleet'][$f]['dir'] = 1;
                // на планету
                $f++;
            }
            $unions[$fleet_obj['union_id']] = 1;
            $tasknum++;
            continue;
        }
        if ($fleet_obj['union_id'] > 0 && $fleet_obj['target_planet'] == $planet_id && $fleet_obj['mission'] != 21) {
            continue;
        }
        // Не показывать отправление и возврат Оставить.
        if ($fleet_obj['mission'] == 104) {
            continue;
        }
        if ($fleet_obj['mission'] == 4 && $fleet_obj['start_planet'] == $planet_id) {
            continue;
        }
        // Не показывать возвращающиеся с целевой планеты флоты.
        if ($fleet_obj['mission'] > 100 && $fleet_obj['mission'] < 200 && $fleet_obj['target_planet'] == $planet_id) {
            continue;
        }
        // Время прибытия
        if ($fleet_obj['mission'] < 100 && $fleet_obj['start_planet'] == $planet_id) {
            if ($fleet_obj['mission'] != 15) {
                $task[$tasknum]['end_time'] = $queue['end'] + $fleet_obj['flight_time'];
            } else {
                $task[$tasknum]['end_time'] = $queue['end'];
            }
        } else {
            $task[$tasknum]['end_time'] = $queue['end'];
        }
        // Флот
        $task[$tasknum]['fleets'] = 1;
        $task[$tasknum]['fleet'][0] = array();
        foreach ($fleetmap as $i => $gid) {
            $task[$tasknum]['fleet'][0][$gid] = $fleet_obj["ship{$gid}"];
        }
        $task[$tasknum]['fleet'][0]['owner_id'] = $fleet_obj['owner_id'];
        $task[$tasknum]['fleet'][0]['origin_id'] = $fleet_obj['start_planet'];
        $task[$tasknum]['fleet'][0]['target_id'] = $fleet_obj['target_planet'];
        $task[$tasknum]['fleet'][0]['mission'] = GetMission($fleet_obj);
        if (GetMission($fleet_obj) == 15) {
            if ($fleet_obj['mission'] < 100) {
                $task[$tasknum]['fleet'][0]['dir'] = 1;
            } else {
                if ($fleet_obj['mission'] < 200) {
                    $task[$tasknum]['fleet'][0]['dir'] = 0;
                } else {
                    $task[$tasknum]['fleet'][0]['dir'] = 2;
                }
            }
        } else {
            if (GetMission($fleet_obj) == 5) {
                if ($fleet_obj['mission'] < 100) {
                    $task[$tasknum]['fleet'][0]['dir'] = 1;
                } else {
                    if ($fleet_obj['mission'] < 200) {
                        $task[$tasknum]['fleet'][0]['dir'] = 0;
                    } else {
                        $task[$tasknum]['fleet'][0]['dir'] = 2;
                    }
                }
            } else {
                if ($fleet_obj['target_planet'] == $planet_id) {
                    $task[$tasknum]['fleet'][0]['dir'] = 1;
                } else {
                    $task[$tasknum]['fleet'][0]['dir'] = 0;
                }
                // возврат
            }
        }
        if ($fleet_obj['mission'] == 20) {
            $task[$tasknum]['fleet'][0]['ipm_amount'] = $fleet_obj['ipm_amount'];
            $task[$tasknum]['fleet'][0]['ipm_target'] = $fleet_obj['ipm_target'];
        }
        $tasknum++;
        // Для убывающей экспедиции добавить псевдозадание удерживания.
        // Не показывать чужие флоты.
        if ($fleet_obj['mission'] == 15 && $fleet_obj['owner_id'] == $user['player_id']) {
            // Время отправления и прибытия
            $task[$tasknum]['end_time'] = $queue['end'] + $fleet_obj['deploy_time'];
            // Флот
            $task[$tasknum]['fleets'] = 1;
            $task[$tasknum]['fleet'][0] = array();
            foreach ($fleetmap as $i => $gid) {
                $task[$tasknum]['fleet'][0][$gid] = $fleet_obj["ship{$gid}"];
            }
            $task[$tasknum]['fleet'][0]['owner_id'] = $fleet_obj['owner_id'];
            $task[$tasknum]['fleet'][0]['origin_id'] = $fleet_obj['start_planet'];
            $task[$tasknum]['fleet'][0]['target_id'] = $fleet_obj['target_planet'];
            $task[$tasknum]['fleet'][0]['mission'] = GetMission($fleet_obj);
            $task[$tasknum]['fleet'][0]['dir'] = 2;
            $tasknum++;
        }
        // Для прибывающего задания Держаться добавить псевдозадание удерживания.
        if ($fleet_obj['mission'] == 5 && $fleet_obj['owner_id'] != $user['player_id']) {
            // Время отправления и прибытия
            $task[$tasknum]['end_time'] = $queue['end'] + $fleet_obj['deploy_time'];
            // Флот
            $task[$tasknum]['fleets'] = 1;
            $task[$tasknum]['fleet'][0] = array();
            foreach ($fleetmap as $i => $gid) {
                $task[$tasknum]['fleet'][0][$gid] = $fleet_obj["ship{$gid}"];
            }
            $task[$tasknum]['fleet'][0]['owner_id'] = $fleet_obj['owner_id'];
            $task[$tasknum]['fleet'][0]['origin_id'] = $fleet_obj['start_planet'];
            $task[$tasknum]['fleet'][0]['target_id'] = $fleet_obj['target_planet'];
            $task[$tasknum]['fleet'][0]['mission'] = GetMission($fleet_obj);
            $task[$tasknum]['fleet'][0]['dir'] = 2;
            $tasknum++;
        }
        // Для убывающих или удерживаемых экспедиций добавить псевдозадание возврата.
        if (($fleet_obj['mission'] == 15 || $fleet_obj['mission'] == 215) && $fleet_obj['owner_id'] == $user['player_id']) {
            // Время отправления и прибытия
            if ($fleet_obj['mission'] > 200) {
                $task[$tasknum]['end_time'] = $queue['end'] + $fleet_obj['deploy_time'];
            } else {
                $task[$tasknum]['end_time'] = $queue['end'] + $fleet_obj['deploy_time'] + $fleet_obj['flight_time'];
            }
            // Флот
            $task[$tasknum]['fleets'] = 1;
            $task[$tasknum]['fleet'][0] = array();
            foreach ($fleetmap as $i => $gid) {
                $task[$tasknum]['fleet'][0][$gid] = $fleet_obj["ship{$gid}"];
            }
            $task[$tasknum]['fleet'][0]['owner_id'] = $fleet_obj['owner_id'];
            $task[$tasknum]['fleet'][0]['origin_id'] = $fleet_obj['target_planet'];
            $task[$tasknum]['fleet'][0]['target_id'] = $fleet_obj['start_planet'];
            $task[$tasknum]['fleet'][0]['mission'] = GetMission($fleet_obj);
            $task[$tasknum]['fleet'][0]['dir'] = 0;
            $tasknum++;
        }
    }
    $anz = 0;
    if ($tasknum > 0) {
        sksort($task, 'end_time', true);
        // Сортировать по времени прибытия.
        $now = time();
        foreach ($task as $i => $t) {
            $seconds = max($t['end_time'] - $now, 0);
            if ($seconds <= 0) {
                continue;
            }
            if ($t['fleets'] > 1) {
                echo "<tr class=''>\n";
            } else {
                if ($t['direction'] == 1) {
                    echo "<tr class='flight'>\n";
                } else {
                    if ($t['direction'] == 0) {
                        echo "<tr class='return'>\n";
                    } else {
                        if ($t['direction'] == 2) {
                            echo "<tr class='holding'>\n";
                        }
                    }
                }
            }
            echo "<th><div id='bxx" . ($i + 1) . "' title='" . $seconds . "'star='" . $t['end_time'] . "'></div></th>\n";
            echo "<th colspan='3'>";
            for ($fl = 0; $fl < $t['fleets']; $fl++) {
                echo FleetSpan($t['fleet'][$fl]);
                if ($t['fleets'] > 1) {
                    echo "<br /><br />";
                }
            }
            echo "</th></tr>\n\n";
            $anz++;
        }
        if ($anz) {
            echo "<script language=javascript>anz=" . $anz . ";t();</script>\n\n";
        }
    }
}
<?php 
    echo "  <tr height=\"20\">\n";
    echo "     <td class=\"c\"><span class=\"error\"> Флот не удалось отправить!</span></td>\n";
    echo "  </tr>\n";
    echo "{$FleetErrorText}\n";
} else {
    // Fleet lock
    $fleetlock = "temp/fleetlock_" . $aktplanet['planet_id'];
    if (file_exists($fleetlock)) {
        MyGoto("flotten1");
    }
    $f = fopen($fleetlock, 'w');
    fclose($f);
    $fleet_id = DispatchFleet($fleet, $origin, $target, $order, $flighttime, $cargo_m, $cargo_k, $cargo_d, $cons['fleet'] + $cons['probes'], time(), $union_id, $hold_time);
    $queue = GetFleetQueue($fleet_id);
    UserLog($aktplanet['owner_id'], "FLEET", "Отправка флота {$fleet_id}: " . GetMissionNameDebug($order) . " " . $origin['name'] . " [" . $origin['g'] . ":" . $origin['s'] . ":" . $origin['p'] . "] -&gt; " . $target['name'] . " [" . $target['g'] . ":" . $target['s'] . ":" . $target['p'] . "]<br>" . DumpFleet($fleet) . "<br>" . "Время полёта: " . BuildDurationFormat($flighttime) . ", удержание: " . BuildDurationFormat($hold_time) . ", затраты дейтерия: " . nicenum($cons['fleet'] + $cons['probes']) . ", союз: " . $union_id);
    if ($union_id) {
        $union_time = UpdateUnionTime($union_id, $queue['end'], $fleet_id);
        UpdateFleetTime($fleet_id, $union_time);
    }
    // Поднять флот с планеты.
    AdjustResources($cargo_m, $cargo_k, $cargo_d + $cons['fleet'] + $cons['probes'], $origin['planet_id'], '-');
    AdjustShips($fleet, $origin['planet_id'], '-');
    unlink($fleetlock);
    //    echo "<br>";
    //    print_r ( $queue);
    PageHeader("flottenversand", false, true, "flotten1", 1);
    ?>

<!-- CONTENT AREA -->
function EventList()
{
    global $GlobalUser;
    $fleetmap = array(202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215);
    // Одиночные флоты
    $tasklist = EnumFleetQueue($GlobalUser['player_id']);
    $rows = dbrows($tasklist);
    $task = array();
    $tasknum = 0;
    while ($rows--) {
        $queue = dbarray($tasklist);
        // Время отправления и прибытия
        $task[$tasknum]['start_time'] = $queue['start'];
        $task[$tasknum]['end_time'] = $queue['end'];
        $fleet_obj = LoadFleet($queue['sub_id']);
        if ($fleet_obj['union_id'] > 0) {
            continue;
        }
        // Союзные флоты собираются отдельно
        // Флот
        $task[$tasknum]['fleets'] = 1;
        $task[$tasknum]['fleet'][0] = array();
        foreach ($fleetmap as $i => $gid) {
            $task[$tasknum]['fleet'][0][$gid] = $fleet_obj["ship{$gid}"];
        }
        $task[$tasknum]['fleet'][0]['owner_id'] = $fleet_obj['owner_id'];
        $task[$tasknum]['fleet'][0]['m'] = $fleet_obj['m'];
        $task[$tasknum]['fleet'][0]['k'] = $fleet_obj['k'];
        $task[$tasknum]['fleet'][0]['d'] = $fleet_obj['d'];
        if ($fleet_obj['mission'] < 100 || $fleet_obj['mission'] > 200) {
            $task[$tasknum]['fleet'][0]['origin_id'] = $fleet_obj['start_planet'];
            $task[$tasknum]['fleet'][0]['target_id'] = $fleet_obj['target_planet'];
        } else {
            $task[$tasknum]['fleet'][0]['origin_id'] = $fleet_obj['target_planet'];
            $task[$tasknum]['fleet'][0]['target_id'] = $fleet_obj['start_planet'];
        }
        $task[$tasknum]['fleet'][0]['mission'] = GetMission($fleet_obj);
        if ($fleet_obj['mission'] == 20) {
            $task[$tasknum]['fleet'][0]['ipm_amount'] = $fleet_obj['ipm_amount'];
            $task[$tasknum]['fleet'][0]['ipm_target'] = $fleet_obj['ipm_target'];
        }
        GetDirectionAssignment($fleet_obj, $task[$tasknum]['fleet'][0]['dir'], $task[$tasknum]['fleet'][0]['assign']);
        $tasknum++;
        // Для убывающей экспедиции или держаться добавить псевдозадание удерживания.
        // Не показывать чужие флоты.
        if (($fleet_obj['mission'] == 5 || $fleet_obj['mission'] == 15) && $fleet_obj['owner_id'] == $GlobalUser['player_id']) {
            // Время отправления и прибытия
            $task[$tasknum]['start_time'] = $queue['end'];
            $task[$tasknum]['end_time'] = $task[$tasknum]['start_time'] + $fleet_obj['deploy_time'];
            // Флот
            $task[$tasknum]['fleets'] = 1;
            $task[$tasknum]['fleet'][0] = array();
            foreach ($fleetmap as $i => $gid) {
                $task[$tasknum]['fleet'][0][$gid] = $fleet_obj["ship{$gid}"];
            }
            $task[$tasknum]['fleet'][0]['owner_id'] = $fleet_obj['owner_id'];
            $task[$tasknum]['fleet'][0]['m'] = $task[$tasknum]['fleet'][0]['k'] = $task[$tasknum]['fleet'][0]['d'] = 0;
            $task[$tasknum]['fleet'][0]['origin_id'] = $fleet_obj['start_planet'];
            $task[$tasknum]['fleet'][0]['target_id'] = $fleet_obj['target_planet'];
            $task[$tasknum]['fleet'][0]['mission'] = GetMission($fleet_obj);
            $task[$tasknum]['fleet'][0]['dir'] = 2;
            $task[$tasknum]['fleet'][0]['assign'] = 0;
            $tasknum++;
        }
        // Для прибывающего задания Держаться добавить псевдозадание удерживания.
        if ($fleet_obj['mission'] == 5 && $fleet_obj['owner_id'] != $GlobalUser['player_id']) {
            // Время отправления и прибытия
            $task[$tasknum]['start_time'] = $queue['end'];
            $task[$tasknum]['end_time'] = $task[$tasknum]['start_time'] + $fleet_obj['deploy_time'];
            // Флот
            $task[$tasknum]['fleets'] = 1;
            $task[$tasknum]['fleet'][0] = array();
            foreach ($fleetmap as $i => $gid) {
                $task[$tasknum]['fleet'][0][$gid] = $fleet_obj["ship{$gid}"];
            }
            $task[$tasknum]['fleet'][0]['owner_id'] = $fleet_obj['owner_id'];
            $task[$tasknum]['fleet'][0]['m'] = $task[$tasknum]['fleet'][0]['k'] = $task[$tasknum]['fleet'][0]['d'] = 0;
            $task[$tasknum]['fleet'][0]['origin_id'] = $fleet_obj['start_planet'];
            $task[$tasknum]['fleet'][0]['target_id'] = $fleet_obj['target_planet'];
            $task[$tasknum]['fleet'][0]['mission'] = GetMission($fleet_obj);
            $task[$tasknum]['fleet'][0]['dir'] = 2;
            $task[$tasknum]['fleet'][0]['assign'] = 2;
            $tasknum++;
        }
        // Для убывающих или удерживаемых флотов добавить псевдозадание возврата.
        // Не показывать возвраты чужих флотов, задание Оставить и Ракетную атаку.
        if (($fleet_obj['mission'] < 100 || $fleet_obj['mission'] > 200) && $fleet_obj['owner_id'] == $GlobalUser['player_id'] && $fleet_obj['mission'] != 4 && $fleet_obj['mission'] != 20) {
            // Время отправления и прибытия
            $task[$tasknum]['start_time'] = $queue['end'];
            $task[$tasknum]['end_time'] = 2 * $queue['end'] - $queue['start'];
            if (GetMission($fleet_obj) == 5 || GetMission($fleet_obj) == 15) {
                if ($fleet_obj['mission'] > 200) {
                    $task[$tasknum]['end_time'] = $task[$tasknum]['start_time'] + $fleet_obj['deploy_time'];
                } else {
                    $task[$tasknum]['end_time'] = $task[$tasknum]['start_time'] + $fleet_obj['deploy_time'] + $fleet_obj['flight_time'];
                }
            }
            // Флот
            $task[$tasknum]['fleets'] = 1;
            $task[$tasknum]['fleet'][0] = array();
            foreach ($fleetmap as $i => $gid) {
                $task[$tasknum]['fleet'][0][$gid] = $fleet_obj["ship{$gid}"];
            }
            $task[$tasknum]['fleet'][0]['owner_id'] = $fleet_obj['owner_id'];
            $task[$tasknum]['fleet'][0]['m'] = $task[$tasknum]['fleet'][0]['k'] = $task[$tasknum]['fleet'][0]['d'] = 0;
            $task[$tasknum]['fleet'][0]['origin_id'] = $fleet_obj['target_planet'];
            $task[$tasknum]['fleet'][0]['target_id'] = $fleet_obj['start_planet'];
            $task[$tasknum]['fleet'][0]['mission'] = GetMission($fleet_obj);
            $task[$tasknum]['fleet'][0]['dir'] = 1;
            $task[$tasknum]['fleet'][0]['assign'] = 0;
            $tasknum++;
        }
    }
    // Союзные флоты
    $unions = EnumUnion($GlobalUser['player_id']);
    foreach ($unions as $u => $union) {
        // Флоты
        $result = EnumUnionFleets($union['union_id']);
        $rows = dbrows($result);
        if ($rows > 0) {
            $task[$tasknum]['fleets'] = $rows;
            $f = 0;
            $tn = $tasknum;
            while ($rows--) {
                $fleet_obj = dbarray($result);
                $queue = GetFleetQueue($fleet_obj['fleet_id']);
                $task[$tn]['end_time'] = $queue['end'];
                // Для убывающих или удерживаемых флотов добавить псевдозадание возврата.
                // Не показывать возвраты чужих флотов и задание Оставить.
                if ($fleet_obj['mission'] < 100 && $fleet_obj['owner_id'] == $GlobalUser['player_id']) {
                    $tasknum++;
                    // Время отправления и прибытия
                    $task[$tasknum]['end_time'] = $queue['end'] + $fleet_obj['flight_time'];
                    // Флот
                    $task[$tasknum]['fleets'] = 1;
                    $task[$tasknum]['fleet'][0] = array();
                    foreach ($fleetmap as $i => $gid) {
                        $task[$tasknum]['fleet'][0][$gid] = $fleet_obj["ship{$gid}"];
                    }
                    $task[$tasknum]['fleet'][0]['owner_id'] = $fleet_obj['owner_id'];
                    $task[$tasknum]['fleet'][0]['m'] = $task[$tasknum]['fleet'][0]['k'] = $task[$tasknum]['fleet'][0]['d'] = 0;
                    $task[$tasknum]['fleet'][0]['origin_id'] = $fleet_obj['target_planet'];
                    $task[$tasknum]['fleet'][0]['target_id'] = $fleet_obj['start_planet'];
                    $task[$tasknum]['fleet'][0]['mission'] = GetMission($fleet_obj);
                    $task[$tasknum]['fleet'][0]['dir'] = 1;
                    $task[$tasknum]['fleet'][0]['assign'] = 0;
                }
                $task[$tn]['fleet'][$f] = array();
                foreach ($fleetmap as $id => $gid) {
                    $task[$tn]['fleet'][$f][$gid] = $fleet_obj["ship{$gid}"];
                }
                $task[$tn]['fleet'][$f]['owner_id'] = $fleet_obj['owner_id'];
                $task[$tn]['fleet'][$f]['m'] = $fleet_obj['m'];
                $task[$tn]['fleet'][$f]['k'] = $fleet_obj['k'];
                $task[$tn]['fleet'][$f]['d'] = $fleet_obj['d'];
                $task[$tn]['fleet'][$f]['origin_id'] = $fleet_obj['start_planet'];
                $task[$tn]['fleet'][$f]['target_id'] = $fleet_obj['target_planet'];
                $task[$tn]['fleet'][$f]['mission'] = GetMission($fleet_obj);
                GetDirectionAssignment($fleet_obj, $task[$tn]['fleet'][$f]['dir'], $task[$tn]['fleet'][$f]['assign']);
                $f++;
            }
            $tasknum++;
        }
    }
    $anz = 0;
    if ($tasknum > 0) {
        sksort($task, 'end_time', true);
        // Сортировать по времени прибытия.
        $now = time();
        foreach ($task as $i => $t) {
            $seconds = max($t['end_time'] - $now, 0);
            if ($seconds <= 0) {
                continue;
            }
            if ($t['fleets'] > 1) {
                echo "<tr class=''>\n";
            } else {
                if ($t['dir'] == 0) {
                    echo "<tr class='flight'>\n";
                } else {
                    if ($t['dir'] == 1) {
                        echo "<tr class='return'>\n";
                    } else {
                        if ($t['dir'] == 2) {
                            echo "<tr class='holding'>\n";
                        }
                    }
                }
            }
            echo "<th><div id='bxx" . ($i + 1) . "' title='" . $seconds . "'star='" . $t['end_time'] . "'></div></th>\n";
            echo "<th colspan='3'>";
            for ($fl = 0; $fl < $t['fleets']; $fl++) {
                echo FleetSpan($t['fleet'][$fl]);
                if ($t['fleets'] > 1) {
                    echo "<br /><br />";
                }
            }
            echo "</th></tr>\n\n";
            $anz++;
        }
        if ($anz) {
            echo "<script language=javascript>anz=" . $anz . ";t();</script>\n\n";
        }
    }
}
Esempio n. 7
0
function RocketAttack($fleet_id, $planet_id)
{
    global $UnitParam;
    $fleet = LoadFleet($fleet_id);
    $amount = $fleet['ipm_amount'];
    $primary = $fleet['ipm_target'];
    $origin = GetPlanet($fleet['start_planet']);
    $target = GetPlanet($planet_id);
    $origin_user = LoadUser($origin['owner_id']);
    $target_user = LoadUser($target['owner_id']);
    // Отбить атаку МПР перехватчиками
    $ipm = $amount;
    $abm = $target['d502'];
    $ipm = max(0, $ipm - $abm);
    $ipm_destroyed = $amount - $ipm;
    $target['d502'] -= $ipm_destroyed;
    $maxdamage = $ipm * 12000 * (1 + $origin_user['r109'] / 10);
    // Произвести атаку первичной цели
    if ($primary > 0 && $ipm > 0) {
        $armor = $UnitParam[$primary][0] * (1 + 0.1 * $target_user['r111']) / 10;
        $count = $target["d{$primary}"];
        $destroyed = min(floor($maxdamage / $armor), $count);
        $target["d{$primary}"] -= $destroyed;
        $maxdamage -= $destroyed * $armor;
        $maxdamage -= $destroyed;
    }
    // Расчитать потери обороны, если еще остались МПР
    if ($maxdamage > 0) {
        $defmap = array(401, 402, 403, 404, 405, 406, 407, 408, 502, 503);
        foreach ($defmap as $i => $id) {
            if ($id == $primary) {
                continue;
            }
            $armor = $UnitParam[$id][0] * (1 + 0.1 * $target_user['r111']) / 10;
            $count = $target["d{$id}"];
            if ($count == 0) {
                continue;
            }
            $destroyed = min(floor($maxdamage / $armor), $count);
            $target["d{$id}"] -= $destroyed;
            $maxdamage -= $destroyed * $armor;
            $maxdamage -= $destroyed;
            if ($maxdamage <= 0) {
                break;
            }
        }
    }
    // Записать назад потери обороны.
    SetPlanetDefense($planet_id, $target);
    // Изменить статистику игроков
    RecalcRanks();
    $text = "{$amount} ракетам из общего числа выпущенных ракет с планеты " . $origin['name'] . " <a href=# onclick=showGalaxy(" . $origin['g'] . "," . $origin['s'] . "," . $origin['p'] . "); >[" . $origin['g'] . ":" . $origin['s'] . ":" . $origin['p'] . "]</a>  ";
    $text .= "удалось попасть на Вашу планету " . $target['name'] . " <a href=# onclick=showGalaxy(" . $target['g'] . "," . $target['s'] . "," . $target['p'] . "); >[" . $target['g'] . ":" . $target['s'] . ":" . $target['p'] . "]</a> !<br>";
    if ($ipm_destroyed) {
        $text .= "{$ipm_destroyed} ракет(-ы) было уничтожено Вашими ракетами-перехватчиками<br>:<br>";
    }
    $defmap = array(503, 502, 408, 407, 406, 405, 404, 403, 402, 401);
    $text .= "<table width=400><tr><td class=c colspan=4>Поражённая оборона</td></tr>";
    $n = 0;
    foreach ($defmap as $i => $gid) {
        if ($n % 2 == 0) {
            $text .= "</tr>";
        }
        if ($target["d{$gid}"]) {
            $text .= "<td>" . loca("NAME_{$gid}") . "</td><td>" . nicenum($target["d{$gid}"]) . "</td>";
            $n++;
        }
    }
    $text .= "</table><br>\n";
    // Обновить активность на планете.
    $queue = GetFleetQueue($fleet_id);
    UpdatePlanetActivity($planet_id, $queue['end']);
    SendMessage($target_user['player_id'], "Командование флотом", "Ракетная атака", $text, 2);
}