- $i++;
- my $row = "odd";
- $row = "even" if ($i % 2 == 0);
- $scantext .= "<tr class=\"$row\"><td>$1</td><td>$2</td></tr>\n";
- $total += $2;
- $sec = $2 if ($1 eq 'Security Centre');
- $dist = $2 if ($1 eq 'Wave Distorter');
- $f->execute($1);
- if (my $ship = $f->fetchrow_hashref){
- $total{$ship->{class}} += $2;
- $visible{$ship->{class}} += $2 unless $ship->{type} eq 'Cloak';
- }
- }
- if ($type =~ 'Unit'){
- my $scan .= q{<table>
- <tr><th>Class</th><th>Total</th><th>Visible</th></tr>};
- my $i = 0;
- for my $type (qw/Fighter Corvette Frigate Destroyer Cruiser Battleship/){
- next unless $total{$type};
- $i++;
- my $row = "odd";
- $row = "even" if ($i % 2 == 0);
- $visible{$type} = 0 unless $visible{$type};
- $scan .= "<tr class=\"$row\"><td>$type</td><td>".$total{$type}."</td><td>".$visible{$type}."</td></tr>\n";
- }
- $scan .= "</table>\n";
- $addScan->execute($tick-1,$scan[0],'Ship Classes',$scan,$planet);
- }
- $scantext .= "<tr class=\"odd\"><td>No</td><td>Ships</td></tr>\n" unless $i;
- $scantext .= "</table>\n";
-
- if($type eq 'Surface Analysis'){
- my $f = $dbh->prepare("UPDATE covop_targets SET structures = ?, sec_centres = ?, dists = ? WHERE planet = ?");
- if ($f->execute($total,$sec,$dist,$planet) < 1){
- $f = $dbh->prepare("INSERT INTO covop_targets (planet,structures, sec_centres, dists) VALUES(?,?,?,?)");
- $f->execute($planet,$total,$sec,$dist);
- }
- }
- } elsif($type eq 'Military'){
- $scantext .= "<table>\n";
- my $i = 1;
- my @totals = (0,0,0,0);
- my @eta = (8,8,8,8);
- my $f = $dbh->prepare(qq{SELECT "type","class" FROM ship_stats WHERE name = ?});
- while($file =~ m/big left">((?:[a-zA-Z]| )+)<\/t[dh]>.*?center>(\d+).*?center>(\d+).*?center>(\d+).*?center>(\d+)/sg){
- next if ($2+$3+$4+$5 == 0);
- my @ships = ($2,$3,$4,$5);
- my $row = "odd";
- my ($type,$class) = $dbh->selectrow_array($f,undef,$1);
- #print "$1 $type\n";
- $row = "even" if ($i % 2 == 0);
- $scantext .= "<tr class=\"$row\"><td>$1</td><td>$2</td><td>$3</td><td>$4</td><td>$5</td></tr>\n";
- $i++;
- unless ($type eq "Cloak"){
- $totals[0] += $2;
- $totals[1] += $3;
- $totals[2] += $4;
- $totals[3] += $5;
- }
- foreach my $i (0,1,2,3){
- if ($ships[$i] > 0 && $eta[$i] < 9 && ($class =~ /Frigate|Destroyer/)){
- $eta[$i] = 9;
- }elsif ($ships[$i] > 0 && $eta[$i] < 10 && ($class =~ /Cruiser|Battleship/)){
- $eta[$i] = 10;
- }
- }