Esempio n. 1
0
     }
 }
 $sql = 'SELECT SUM(st.value_11) AS sum_sensors, SUM(st.value_12) AS sum_cloak
         FROM (ships s, ship_fleets f)
         INNER JOIN (ship_templates st) ON st.id = s.template_id
         WHERE s.user_id IN (' . implode(',', $allied_user) . ') AND
               s.fleet_id = f.fleet_id AND
               f.planet_id = ' . $move['dest'];
 if (($friendly_ships = $db->queryrow($sql)) === false) {
     message(DATABASE_ERROR, '- Error: Could not select friendly fleets data! SKIP');
     break;
 }
 $dest_sum_sensors = !empty($friendly_ships['sum_sensors']) ? (int) $friendly_ships['sum_sensors'] : 0;
 $dest_sum_cloak = !empty($friendly_ships['sum_cloak']) ? (int) $friendly_ships['sum_cloak'] : 0;
 $flight_duration = $move['move_finish'] - $move['move_begin'];
 $visibility = GetVisibility($move_sum_sensors, $move_sum_cloak, $move['n_ships'], $dest_sum_sensors, $dest_sum_cloak, ($move['dest_building_7'] + 1) * PLANETARY_SENSOR_VALUE, $flight_duration);
 $travelled = 100 / $flight_duration * ($ACTUAL_TICK - $move['move_begin']);
 if ($travelled < $visibility + (100 - $visibility) / 4) {
     $move['n_ships'] = 0;
 }
 if ($travelled < $visibility + 2 * ((100 - $visibility) / 4)) {
     $move['action_code'] = 0;
 }
 $attack = time() + ($move['move_finish'] - $ACTUAL_TICK) * 300;
 $game->out('<tr><td>' . $move['planet_name'] . '</td><td>' . $move['defender'] . '</td><td>' . $move['attacker'] . '</td><td>' . date('d.m.y H:i', $attack) . '</td><td>' . $move['action_code'] . '</td></tr>');
 /*        $sql = 'UPDATE planets
                 SET planet_next_attack = '.(time() + ($move['move_finish'] - $ACTUAL_TICK) * 300).',
                     planet_attack_ships = '.$move['n_ships'].',
                     planet_attack_type= '.$move['action_code'].'
                 WHERE planet_id= '.$move['dest'];
 
        // Todo: Fleets queries, calculate values:
        //array('n_ships', 'sum_sensors', 'sum_cloak')
        /* 30/06/08 - AC: Planet sensors depends on target planet NOT on currently active planet!  */
        //$sensor2 = get_friendly_orbit_fleets($move['dest_id']);
        $sensor2['sum_sensors'] = 0;
        $sensor2['sum_cloak'] = 0;
        if ($fleets_sensors) {
            $sensor3['sum_sensors'] = get_system_fleet_sensors($move['dest_id']);
        } else {
            // $sensor3['sum_sensors'] = ($move['dest_sensors'] + 1) * PLANETARY_SENSOR_VALUE;
            $sensor3['sum_sensors'] = get_system_planetary_sensors($move['dest_id']) * PLANETARY_SENSOR_VALUE;
            //$sensor3['sum_cloak'] = 0;
        }
        /* 25/11/08 - AC: Spacedock sensors must be added to orbit fleets NOT to incoming fleets... */
        $flight_duration = $move['move_finish'] - $move['move_begin'];
        $visibility = GetVisibility($sensor1['sum_sensors'], $sensor1['sum_cloak'], $sensor1['n_ships'], $sensor2['sum_sensors'], $sensor2['sum_cloak'], $sensor3['sum_sensors'], $flight_duration);
        $travelled = 100 / $flight_duration * ($ACTUAL_TICK - $move['move_begin']);
    } else {
        // Ferengi(NPC) doesn't have ships templates stored in the DB
        if ($move['move_id'] != 46) {
            $sensor1['torso'][1] = $move['n_ships'];
        }
    }
    if ($travelled >= $visibility || in_array($move['action_code'], $visible_actions)) {
        $game->out('

<table border="0" width="200" align="center" cellpadding="2" cellspacing="2" class="style_outer">
  <tr>
    <td>
      <table border="0" width="200" align="center" cellpadding="2" cellspacing="2" class="style_inner">
        <tr>
              u1.user_alliance = ' . $game->player['user_alliance'] . ' AND
              ss.move_status = 0 AND
              ss.dest = p1.planet_id AND
              ss.action_code IN  (24,25,40,41,42,43,44,45,46,50,51,52,53,54,55)
        GROUP BY ss.move_id
        ORDER BY p1.planet_next_attack ASC';
if (!($q_moves = $db->query($sql))) {
    message(DATABASE_ERROR, 'Could not query moves data');
}
$commands = array(41 => constant($game->sprache("TEXT16")), 42 => constant($game->sprache("TEXT16")), 46 => constant($game->sprache("TEXT27")), 51 => constant($game->sprache("TEXT16")), 52 => '(error)', 53 => constant($game->sprache("TEXT25")), 54 => constant($game->sprache("TEXT26")), 55 => constant($game->sprache("TEXT28")));
while ($move = $db->fetchrow($q_moves)) {
    $dest_fleets = get_friendly_orbit_fleets($move['dest'], $move['dest_user_id']);
    $flight_duration = $move['move_finish'] - $move['move_begin'];
    // Move 46 shall be always visible
    if ($move['action_code'] != 46) {
        $visibility = GetVisibility($move['sum_atk_sensors'], $move['sum_atk_cloak'], $move['n_ships'], $dest_fleets['sum_sensors'], $dest_fleets['sum_cloak'], ($move['dest_spacedock'] + 1) * PLANETARY_SENSOR_VALUE, $flight_duration);
    } else {
        $visibility = 0;
    }
    $travelled = 100 / $flight_duration * ($ACTUAL_TICK - $move['move_begin']);
    if ($travelled >= $visibility) {
        $n_ships = $travelled >= $visibility + (100 - $visibility) / 4 ? $move['n_ships'] : '-';
        $command = $travelled >= $visibility + 2 * ((100 - $visibility) / 4) ? $commands[$move['action_code']] : '-';
        $game->out('
        <tr>
          <td><a href="' . parse_link('a=stats&a2=viewplayer&id=' . $move['dest_user_id']) . '">' . $move['dest_user_name'] . '</a></td>
          <td><a href="' . parse_link('a=tactical_cartography&planet_id=' . encode_planet_id($move['dest'])) . '">' . $move['dest_name'] . '</a></td>
          <td><a href="' . parse_link('a=stats&a2=viewplayer&id=' . $move['start_user_id']) . '">' . $move['start_user_name'] . '</a>' . (!empty($move['start_alliance_id']) ? ' [<a href="' . parse_link('a=stats&a2=viewalliance&id=' . $move['start_alliance_id']) . '">' . $move['start_alliance_tag'] . '</a>]' : '') . '</td>
          <td>' . $n_ships . '</td>
          <td>' . $command . '</td>
          <td>' . format_time(($move['move_finish'] - $ACTUAL_TICK) * TICK_DURATION) . '</td>