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 the door unless unhidden

  • Loading branch information...
commit bb4788a700be527003a6223e6628793256c5d887 1 parent 50aeeb0
Carl Mäsak authored July 18, 2012

Showing 1 changed file with 17 additions and 4 deletions. Show diff stats Hide diff stats

  1. 21  bin/crypt
21  bin/crypt
@@ -469,13 +469,14 @@ class Adventure::Engine {
469 469
     }
470 470
 
471 471
     method !explicit_things_at($location) {
472  
-        sub is_here_and_explicit($_) {
473  
-            %!thing_rooms{$_} eq $location && !%!implicit_things{$_}
  472
+        sub here_visible_and_explicit($_) {
  473
+            %!thing_rooms{$_} eq $location
  474
+                && !%!hidden_things{$_} && !%!implicit_things{$_}
474 475
         }
475 476
 
476 477
         return unless $location;
477 478
         return gather for %!thing_rooms.keys -> $thing {
478  
-            next unless is_here_and_explicit($thing);
  479
+            next unless here_visible_and_explicit($thing);
479 480
             if %!open_things{$thing} && self!contents_of($thing) {
480 481
                 take $thing => self!explicit_things_at("contents:$thing");
481 482
             }
@@ -865,6 +866,8 @@ class Crypt::Game {
865 866
             .make_thing_implicit('grass');
866 867
             .place_thing('door', 'hill');
867 868
             .make_thing_openable('door');
  869
+            .hide_thing('door');
  870
+            .on_examine('grass', { $!engine.unhide_thing('door') });
868 871
 
869 872
             .place_player('clearing');
870 873
         }
@@ -1841,7 +1844,17 @@ multi MAIN('test') {
1841 1844
             Adventure::PlayerOpened.new(
1842 1845
                 :thing<door>,
1843 1846
             ),
1844  
-            'examining the grass and opening the door';
  1847
+            'opening the door (+) having examined the grass';
  1848
+    }
  1849
+
  1850
+    {
  1851
+        my $game = Crypt::Game.new();
  1852
+
  1853
+        $game.walk('east');
  1854
+        throws_exception
  1855
+            { $game.open('door') },
  1856
+            X::Adventure::NoSuchThingHere,
  1857
+            'opening the door (-) without examining the grass';
1845 1858
     }
1846 1859
 
1847 1860
     done;

0 notes on commit bb4788a

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