Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

Or a thing which is in another room.
  • Loading branch information...
commit 20e37abd5b01b6aa535114255f73fe31eb398e56 1 parent 2bfc22d
Carl Mäsak authored

Showing 1 changed file with 31 additions and 0 deletions. Show diff stats Hide diff stats

  1. 31  bin/crypt
31  bin/crypt
@@ -502,6 +502,12 @@ class Adventure::Engine {
502 502
         die X::Adventure::PlayerIsNowhere.new()
503 503
             unless defined $!player_location;
504 504
 
  505
+        die X::Adventure::NoSuchThingHere.new(:$thing)
  506
+            unless (%!thing_rooms{$thing} // '') eq $!player_location;
  507
+
  508
+        die X::Adventure::NoSuchThingHere.new(:$thing)
  509
+            if %!hidden_things{$thing};
  510
+
505 511
         die X::Adventure::ThingNotOpenable.new(:$thing)
506 512
             unless %!openable_things{$thing};
507 513
 
@@ -1321,6 +1327,31 @@ multi MAIN('test') {
1321 1327
             'examining a hidden thing (-) cannot because it is hidden';
1322 1328
     }
1323 1329
 
  1330
+    {
  1331
+        my $engine = Adventure::Engine.new();
  1332
+
  1333
+        $engine.place_thing('flask', 'chamber');
  1334
+        $engine.make_thing_openable('flask');
  1335
+        $engine.hide_thing('flask');
  1336
+        $engine.place_player('chamber');
  1337
+        throws_exception
  1338
+            { $engine.open('flask') },
  1339
+            X::Adventure::NoSuchThingHere,
  1340
+            'opening a hidden thing (-) cannot because it is hidden';
  1341
+    }
  1342
+
  1343
+    {
  1344
+        my $engine = Adventure::Engine.new();
  1345
+
  1346
+        $engine.place_thing('flask', 'chamber');
  1347
+        $engine.make_thing_openable('flask');
  1348
+        $engine.place_player('bedroom');
  1349
+        throws_exception
  1350
+            { $engine.open('flask') },
  1351
+            X::Adventure::NoSuchThingHere,
  1352
+            'opening a thing (-) cannot because it is in another room';
  1353
+    }
  1354
+
1324 1355
     done;
1325 1356
 }
1326 1357
 

0 notes on commit 20e37ab

Please sign in to comment.
Something went wrong with that request. Please try again.