- if ($ship =~ m/^\d+/) {
- $need{Fine} = $ship;
- } else {
- $ship =~ y/_/ /;
- open F, "/home/ian/private/puzzle-pirates" or die $!;
- my $this_ship= 0;
- my $the_ship;
- while (<F>) {
- if (!m/\S/ || m/^\s*\#/) {
- $this_ship= 0;
- next;
- }
- if (!m/^\@/) {
- next;
- }
- if (m/^\@(( [A-Z][-a-z]+){2,})\s*$/) {
- $this_ship= (uc $1 eq uc " $ship" or
- uc $+ eq uc " $ship");
- $the_ship= $1;
- next;
+ return unless @want;
+
+ my $rum_want= rum_total(@want);
+
+ my $stocks= @have ? $have[-1] : [qw(0 0 0 0)];
+ my $rum_have= rum_total(@$stocks);
+
+ pr2rs('desired stock level', $rum_want, $want[3]);
+
+ my $rum_need = $rum_want - $rum_have;
+ my $shot_need = $want[3] - $stocks->[3];
+
+ if (@have) {
+ pr2rs('current stock', $rum_have, $stocks->[3]);
+ pr2rs('restock requirement', $rum_need, $shot_need);
+ print "\n";
+ }
+
+ if (@price) {
+ my ($rum_buy,$shot_buy) = ('','');
+ my ($rum_bill,$shot_bill) = qw(0 0);
+ my $ok=1;
+ if ($rum_need > 0) {
+ if (defined $best) {
+ my $rum_qty= $rum_need * 100 / $proofs[$best];
+ $rum_qty= ceil($rum_qty);
+ $rum_buy= sprintf('%12s %-11s ',
+ "** $rum_qty","$kinds[$best] **");
+ $rum_bill= $rum_qty * $price[$best];
+ } else {
+ $rum_buy= ' (rum unavailable)';
+ $ok= 0;