Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[bin/crypt] can't open a hidden thing

Or a thing which is in another room.
  • Loading branch information...
commit 20e37abd5b01b6aa535114255f73fe31eb398e56 1 parent 2bfc22d
@masak authored
Showing with 31 additions and 0 deletions.
  1. +31 −0 bin/crypt
View
31 bin/crypt
@@ -502,6 +502,12 @@ class Adventure::Engine {
die X::Adventure::PlayerIsNowhere.new()
unless defined $!player_location;
+ die X::Adventure::NoSuchThingHere.new(:$thing)
+ unless (%!thing_rooms{$thing} // '') eq $!player_location;
+
+ die X::Adventure::NoSuchThingHere.new(:$thing)
+ if %!hidden_things{$thing};
+
die X::Adventure::ThingNotOpenable.new(:$thing)
unless %!openable_things{$thing};
@@ -1321,6 +1327,31 @@ multi MAIN('test') {
'examining a hidden thing (-) cannot because it is hidden';
}
+ {
+ my $engine = Adventure::Engine.new();
+
+ $engine.place_thing('flask', 'chamber');
+ $engine.make_thing_openable('flask');
+ $engine.hide_thing('flask');
+ $engine.place_player('chamber');
+ throws_exception
+ { $engine.open('flask') },
+ X::Adventure::NoSuchThingHere,
+ 'opening a hidden thing (-) cannot because it is hidden';
+ }
+
+ {
+ my $engine = Adventure::Engine.new();
+
+ $engine.place_thing('flask', 'chamber');
+ $engine.make_thing_openable('flask');
+ $engine.place_player('bedroom');
+ throws_exception
+ { $engine.open('flask') },
+ X::Adventure::NoSuchThingHere,
+ 'opening a thing (-) cannot because it is in another room';
+ }
+
done;
}
Please sign in to comment.
Something went wrong with that request. Please try again.