diff --git a/lib/NetHack/ItemPool/Tracker/Wand.pm b/lib/NetHack/ItemPool/Tracker/Wand.pm index 6fb6e17..f8e7c08 100644 --- a/lib/NetHack/ItemPool/Tracker/Wand.pm +++ b/lib/NetHack/ItemPool/Tracker/Wand.pm @@ -50,7 +50,20 @@ sub engrave_useful { sub no_engrave_message { my $self = shift; - $self->rule_out_all_but(map { "wand of $_" } 'locking', 'nothing', 'opening', 'probing', 'undead turning', 'secret door detection'); + $self->rule_out_all_but('wand of locking', 'wand of nothing', 'wand of opening', 'wand of probing', 'wand of undead turning', 'wand of secret door detection'); +} + +sub is_nomessage { + my $self = shift; + my %is_nomessage = map { $_ => 1 } 'wand of locking', 'wand of nothing', 'wand of opening', 'wand of probing', 'wand of undead turning', 'wand of secret door detection'; + + for my $possibility ($self->possibilities) { + if (!$is_nomessage{$possibility}) { + return 0; + } + } + + return 1; } __PACKAGE__->meta->make_immutable; diff --git a/t/701-wand-engrave.t b/t/701-wand-engrave.t index cf08cde..d957c9b 100644 --- a/t/701-wand-engrave.t +++ b/t/701-wand-engrave.t @@ -1,15 +1,18 @@ #!/usr/bin/env perl use strict; use warnings; -use Test::More tests => 6; +use Test::More tests => 14; use NetHack::ItemPool; my $pool = NetHack::ItemPool->new; my $balsa = $pool->new_item("a balsa wand"); ok($balsa->tracker->engrave_useful); +ok(!$balsa->tracker->is_nomessage); $balsa->tracker->rule_out_all_but('wand of fire', 'wand of sleep', 'wand of death'); +ok(!$balsa->tracker->is_nomessage); ok($balsa->tracker->engrave_useful, 'engrave is useful'); $balsa->tracker->rule_out('wand of fire'); +ok(!$balsa->tracker->is_nomessage); ok(!$balsa->tracker->engrave_useful, 'engrave is no longer useful'); my $other_balsa = $pool->new_item("a blessed balsa wand"); @@ -19,4 +22,12 @@ $other_balsa->tracker->rule_out('wand of sleep'); is($other_balsa->identity, 'wand of death'); is($balsa->identity, 'wand of death'); +ok(!$balsa->tracker->is_nomessage); + +my $glass = $pool->new_item("a glass wand"); +ok(!$glass->tracker->is_nomessage); +ok($glass->tracker->engrave_useful); +$glass->tracker->no_engrave_message; +ok(!$glass->tracker->engrave_useful); +ok($glass->tracker->is_nomessage);