Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[bin/crypt] you can read the sign

  • Loading branch information...
commit 116c42168608affbafbad7eb327ac5f4ced8e635 1 parent 5d29eb5
Carl Mäsak authored July 20, 2012

Showing 1 changed file with 21 additions and 2 deletions. Show diff stats Hide diff stats

  1. 23  bin/crypt
23  bin/crypt
@@ -706,7 +706,8 @@ class Adventure::Engine {
706 706
         die X::Adventure::PlayerNowhere.new()
707 707
             unless defined $!player_location;
708 708
 
709  
-        # XXX: should check if the thing is there
  709
+        die X::Adventure::NoSuchThingHere.new(:$thing)
  710
+            unless self!thing_in_room_or_inventory($thing);
710 711
 
711 712
         die X::Adventure::ThingNotReadable.new(:$thing)
712 713
             unless %!readable_things{$thing};
@@ -929,6 +930,7 @@ class Crypt::Game {
929 930
             .place_thing('basket', 'chamber');
930 931
             .make_thing_a_container('basket');
931 932
             .place_thing('sign', 'chamber');
  933
+            .make_thing_readable('sign');
932 934
             .on_put(
933 935
                 'basket',
934 936
                 -> $_ {
@@ -970,6 +972,10 @@ class Crypt::Game {
970 972
         return $!engine.put_thing_on($thing, $on);
971 973
     }
972 974
 
  975
+    method read($thing) {
  976
+        return $!engine.read($thing);
  977
+    }
  978
+
973 979
     method save {
974 980
         $!engine.save;
975 981
     }
@@ -1136,6 +1142,9 @@ multi MAIN() {
1136 1142
                     when Adventure::GameRemarked {
1137 1143
                         say %descriptions{"remark:{.remark}"};
1138 1144
                     }
  1145
+                    when Adventure::PlayerRead {
  1146
+                        say %descriptions{"{.thing}"};
  1147
+                    }
1139 1148
                 }
1140 1149
                 CATCH {
1141 1150
                     when X::Adventure { say .message, '.' }
@@ -1995,7 +2004,7 @@ multi MAIN('test') {
1995 2004
                 Adventure::PlayerLooked.new(
1996 2005
                     :room<chamber>,
1997 2006
                     :exits<south north>,
1998  
-                    :things<basket>,
  2007
+                    :things<basket sign>,
1999 2008
                 ),
2000 2009
             ],
2001 2010
             'walking into the hill (+) after opening the door';
@@ -2065,6 +2074,16 @@ multi MAIN('test') {
2065 2074
             'putting the leaves in the basket';
2066 2075
     }
2067 2076
 
  2077
+    {
  2078
+        my $game = game_from_chamber();
  2079
+
  2080
+        is $game.read('sign'),
  2081
+            Adventure::PlayerRead.new(
  2082
+                :thing<sign>,
  2083
+            ),
  2084
+            'reading the sign';
  2085
+    }
  2086
+
2068 2087
     done;
2069 2088
 }
2070 2089
 

0 notes on commit 116c421

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