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 things in inventory

  • Loading branch information...
commit b8f270b6bab68a8332568b9f90250ba3c09e7dfa 1 parent 8325b8e
Carl Mäsak authored July 28, 2012

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

  1. 49  bin/crypt
49  bin/crypt
@@ -690,7 +690,7 @@ class Adventure::Engine {
690 690
             if $pitch_black;
691 691
 
692 692
         die X::Adventure::NoSuchThingHere.new(:$thing)
693  
-            unless self.thing_is_in($thing, $!player_location);
  693
+            unless self.thing_in_room_or_inventory($thing, $!player_location);
694 694
 
695 695
         die X::Adventure::NoSuchThingHere.new(:$thing)
696 696
             if %!hidden_things{$thing};
@@ -717,7 +717,7 @@ class Adventure::Engine {
717 717
             unless defined $!player_location;
718 718
 
719 719
         die X::Adventure::NoSuchThingHere.new(:$thing)
720  
-            unless (%!thing_rooms{$thing} // '') eq $!player_location;
  720
+            unless self.thing_in_room_or_inventory($thing, $!player_location);
721 721
 
722 722
         die X::Adventure::NoSuchThingHere.new(:$thing)
723 723
             if %!hidden_things{$thing};
@@ -759,9 +759,15 @@ class Adventure::Engine {
759 759
         die X::Adventure::NoSuchThingHere.new(:$thing)
760 760
             unless self.thing_in_room_or_inventory($thing, $!player_location);
761 761
 
  762
+        die X::Adventure::NoSuchThingHere.new(:$thing)
  763
+            if %!hidden_things{$thing};
  764
+
762 765
         die X::Adventure::NoSuchThingHere.new(:thing($in))
763 766
             unless self.thing_in_room_or_inventory($in, $!player_location);
764 767
 
  768
+        die X::Adventure::NoSuchThingHere.new(:$thing)
  769
+            if %!hidden_things{$in};
  770
+
765 771
         die X::Adventure::ThingNotCarryable.new(:action<put>, :$thing)
766 772
             unless %!carryable_things{$thing};
767 773
 
@@ -797,8 +803,17 @@ class Adventure::Engine {
797 803
         die X::Adventure::PlayerNowhere.new()
798 804
             unless defined $!player_location;
799 805
 
800  
-        # XXX: should check if the first thing is there
801  
-        # XXX: should check if the second thing is there
  806
+        die X::Adventure::NoSuchThingHere.new(:$thing)
  807
+            unless self.thing_in_room_or_inventory($thing, $!player_location);
  808
+
  809
+        die X::Adventure::NoSuchThingHere.new(:$thing)
  810
+            if %!hidden_things{$thing};
  811
+
  812
+        die X::Adventure::NoSuchThingHere.new(:thing($on))
  813
+            unless self.thing_in_room_or_inventory($on, $!player_location);
  814
+
  815
+        die X::Adventure::NoSuchThingHere.new(:$thing)
  816
+            if %!hidden_things{$on};
802 817
 
803 818
         die X::Adventure::ThingNotCarryable.new(:action<put>, :$thing)
804 819
             unless %!carryable_things{$thing};
@@ -832,6 +847,9 @@ class Adventure::Engine {
832 847
         die X::Adventure::NoSuchThingHere.new(:$thing)
833 848
             unless self.thing_in_room_or_inventory($thing, $!player_location);
834 849
 
  850
+        die X::Adventure::NoSuchThingHere.new(:$thing)
  851
+            if %!hidden_things{$thing};
  852
+
835 853
         die X::Adventure::ThingNotReadable.new(:$thing)
836 854
             unless %!readable_things{$thing};
837 855
 
@@ -872,6 +890,9 @@ class Adventure::Engine {
872 890
         die X::Adventure::NoSuchThingHere.new(:$thing)
873 891
             unless self.thing_is_in($thing, $!player_location);
874 892
 
  893
+        die X::Adventure::NoSuchThingHere.new(:$thing)
  894
+            if %!hidden_things{$thing};
  895
+
875 896
         die X::Adventure::ThingNotCarryable.new(:action<take>, :$thing)
876 897
             unless %!carryable_things{$thing};
877 898
 
@@ -901,6 +922,9 @@ class Adventure::Engine {
901 922
         die X::Adventure::PlayerDoesNotHave.new(:$thing)
902 923
             unless self.thing_is_in($thing, 'player inventory');
903 924
 
  925
+        die X::Adventure::PlayerDoesNotHave.new(:$thing)
  926
+            if %!hidden_things{$thing};
  927
+
904 928
         my @events = Adventure::PlayerDropped.new(:$thing);
905 929
         @events.push(self!tick);
906 930
         self!apply_and_return: @events;
@@ -931,6 +955,9 @@ class Adventure::Engine {
931 955
         die X::Adventure::NoSuchThingHere.new(:$thing)
932 956
             unless self.thing_in_room_or_inventory($thing, $!player_location);
933 957
 
  958
+        die X::Adventure::NoSuchThingHere.new(:$thing)
  959
+            if %!hidden_things{$thing};
  960
+
934 961
         my @events = Adventure::PlayerUsed.new(:$thing);
935 962
         if %!light_sources{$thing} {
936 963
             @events.push(Adventure::LightSourceSwitchedOn.new(:$thing));
@@ -2905,6 +2932,20 @@ multi MAIN('test') {
2905 2932
             'making it out alive with the treasure';
2906 2933
     }
2907 2934
 
  2935
+    {
  2936
+        my $engine = Adventure::Engine.new();
  2937
+
  2938
+        $engine.place_thing('box', 'saloon');
  2939
+        $engine.make_thing_carryable('box');
  2940
+        $engine.place_player('saloon');
  2941
+        $engine.take('box');
  2942
+        is $engine.examine('box'),
  2943
+            Adventure::PlayerExamined.new(
  2944
+                :thing<box>,
  2945
+            ),
  2946
+            'examining a thing (+) in inventory';
  2947
+    }
  2948
+
2908 2949
     done;
2909 2950
 }
2910 2951
 

0 notes on commit b8f270b

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