Skip to content

Commit

Permalink
Warn about decreasing quantity on an empty slot rather than erroring out
Browse files Browse the repository at this point in the history
  • Loading branch information
sartak committed Nov 21, 2009
1 parent 704638d commit 418d067
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/NetHack/Inventory.pm
Expand Up @@ -157,6 +157,11 @@ sub decrease_quantity {
my $by = shift || 1;

my $item = $self->get($slot);
if (!$item) {
warn "Inventory->decrease_quantity called on an empty slot '$slot'";
return 0;
}

my $orig_quantity = $item->quantity;

if ($by >= $orig_quantity) {
Expand Down

0 comments on commit 418d067

Please sign in to comment.