function FleetAvailableMissions($thisgalaxy, $thissystem, $thisplanet, $thisplanettype, $galaxy, $system, $planet, $planettype, $fleet) { $missions = array(); $uni = LoadUniverse(); $origin = LoadPlanet($thisgalaxy, $thissystem, $thisplanet, $thisplanettype); $target = LoadPlanet($galaxy, $system, $planet, $planettype); if ($planet >= 16) { $missions[0] = 15; return $missions; } if ($planettype == 2) { if ($fleet[209] > 0) { $missions[0] = 8; } // Переработать, если во флоте есть рабы return $missions; } if ($target == NULL) { $missions[0] = 3; // Транспорт $missions[1] = 1; // Атака if ($fleet[208] > 0) { $missions[2] = 7; } // Колонизировать, если во флоте есть колонизатор return $missions; } if ($origin['owner_id'] == $target['owner_id']) { $missions[0] = 3; // Транспорт $missions[1] = 4; // Оставить return $missions; } else { $i = 0; $origin_user = LoadUser($origin['owner_id']); $target_user = LoadUser($target['owner_id']); if ($origin_user['ally_id'] == $target_user['ally_id'] && $origin_user['ally_id'] > 0 || IsBuddy($origin_user['player_id'], $target_user['player_id'])) { $missions[$i++] = 3; // Транспорт $missions[$i++] = 1; // Атака if ($uni['acs'] > 0) { $missions[$i++] = 5; } // Держаться if ($fleet[214] > 0 && GetPlanetType($target) == 3) { $missions[$i++] = 9; } // Уничтожить if ($fleet[210] > 0) { $missions[$i++] = 6; } // Шпионаж } else { $missions[$i++] = 3; // Транспорт $missions[$i++] = 1; // Атака if ($fleet[214] > 0 && GetPlanetType($target) == 3) { $missions[$i++] = 9; } // Уничтожить if ($fleet[210] > 0) { $missions[$i++] = 6; } // Шпионаж } // Если целевая планета есть в списке совместных атак, добавить задание $unions = EnumUnion($origin_user['player_id']); foreach ($unions as $u => $union) { $fleet_obj = LoadFleet($union['fleet_id']); $fleet_target = GetPlanet($fleet_obj['target_planet']); if ($fleet_target['planet_id'] == $target['planet_id']) { $missions[$i++] = 2; break; } // Совместная атака } return $missions; } }
} if (!$leftcol) { echo " <th> </th>\n"; echo "</tr>\n"; } ?> </th> </tr> <tr height="20"> <td colspan="2" class="c">Боевые союзы </tr> <?php // Список боевых союзов. $unions = EnumUnion($GlobalUser['player_id'], 1); $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; }
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"; } } }