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 examine the grass and open the door

  • Loading branch information...
commit 50aeeb08534b73d37ffc12ba0fe6ce78b40887cc 1 parent 21ccca8
Carl Mäsak authored July 18, 2012

Showing 1 changed file with 23 additions and 5 deletions. Show diff stats Hide diff stats

  1. 28  bin/crypt
28  bin/crypt
@@ -486,13 +486,9 @@ class Adventure::Engine {
486 486
     }
487 487
 
488 488
     method !is_thing_in($sought, $location) {
489  
-        sub is_here_and_explicit($_) {
490  
-            %!thing_rooms{$_} eq $location && !%!implicit_things{$_}
491  
-        }
492  
-
493 489
         return unless $location;
494 490
         for %!thing_rooms.keys -> $thing {
495  
-            next unless is_here_and_explicit($thing);
  491
+            next unless %!thing_rooms{$thing} eq $location;
496 492
             return True if $thing eq $sought;
497 493
             if %!open_things{$thing} && self!contents_of($thing) {
498 494
                 return True if self!is_thing_in($sought, "contents:$thing");
@@ -844,6 +840,7 @@ class Crypt::Game {
844 840
         $!engine = Adventure::Engine.new();
845 841
 
846 842
         given $!engine {
  843
+            # Rooms
847 844
             .connect(<clearing hill>, 'east');
848 845
             .alias_direction('hill', 'in', 'south');
849 846
             .alias_direction('chamber', 'out', 'north');
@@ -854,12 +851,21 @@ class Crypt::Game {
854 851
                 say "You try to walk past the fire, but it's too hot!";
855 852
                 False;
856 853
             });
  854
+
  855
+            # Things in clearing
857 856
             .place_thing('car', 'clearing');
858 857
             .place_thing('flashlight', 'contents:car');
859 858
             .make_thing_carryable('flashlight');
860 859
             .place_thing('rope', 'contents:car');
861 860
             .make_thing_carryable('rope');
862 861
             .make_thing_openable('car');
  862
+
  863
+            # Things on hill
  864
+            .place_thing('grass', 'hill');
  865
+            .make_thing_implicit('grass');
  866
+            .place_thing('door', 'hill');
  867
+            .make_thing_openable('door');
  868
+
863 869
             .place_player('clearing');
864 870
         }
865 871
     }
@@ -1826,6 +1832,18 @@ multi MAIN('test') {
1826 1832
             'examining the flashlight in the car';
1827 1833
     }
1828 1834
 
  1835
+    {
  1836
+        my $game = Crypt::Game.new();
  1837
+
  1838
+        $game.walk('east');
  1839
+        $game.examine('grass');
  1840
+        is $game.open('door'),
  1841
+            Adventure::PlayerOpened.new(
  1842
+                :thing<door>,
  1843
+            ),
  1844
+            'examining the grass and opening the door';
  1845
+    }
  1846
+
1829 1847
     done;
1830 1848
 }
1831 1849
 

0 notes on commit 50aeeb0

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