my @fleets;
while ($file =~ m{<th class="center">([^<]+)</th>}g) {
- push @fleets, {name => $1, ships => []};
+ push @fleets, {name => $1, mission => 'Military', ships => []};
}
+ push @fleets, {name => 'Military', mission => 'Full fleet', ships => []};
+ my $total = 0;
while ($file =~ m{<tr><td class="left">([^<]+)</td>(.+?)</tr>}g) {
my $ship = $1;
next if $ship eq 'Total Ships';
my $amounts = $2;
+ my $tot_amount = 0;
my $i = 0;
while ($amounts =~ m{<td class="center">([\d,]+)</td>}g) {
my $fleet = $fleets[$i];
if ($ship eq 'Total Visible Ships') {
$fleet->{amount} = $amount;
} elsif ($amount > 0) {
+ $tot_amount += $amount;
+ $total += $amount;
push @{$fleet->{ships}}, {ship => $ship, amount => $amount};
}
++$i;
}
+
+ if ($tot_amount > 0) {
+ push @{$fleets[4]->{ships}}, {ship => $ship, amount => $tot_amount};
+ }
}
+ $fleets[4]->{amount} = $total;
return @fleets;
}
my @fleets = parseMilScan($file);
for my $fleet (@fleets) {
- next if $fleet->{amount} == 0;
- $addfleet->execute($fleet->{name},$scan->{type},$scan->{pid}
+ next if $fleet->{amount} == 0 && $fleet->{mission} eq 'Military';
+ $addfleet->execute($fleet->{name},$fleet->{mission},$scan->{pid}
,$scan->{tick}, $fleet->{amount});
my ($id) = $addfleet->fetchrow_array;
$fleetscan->execute($id,$scan->{id}) or die $dbh->errstr;