Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[bin/crypt] putting in closed container opens it

  • Loading branch information...
commit 38a7ce04933e14c6dfbc0a4a79970cd33d6865aa 1 parent 0161050
Carl Mäsak authored July 11, 2012

Showing 1 changed file with 29 additions and 1 deletion. Show diff stats Hide diff stats

  1. 30  bin/crypt
30  bin/crypt
@@ -462,7 +462,14 @@ class Adventure::Engine {
462 462
         die X::Adventure::CannotPutInNonContainer.new(:$in)
463 463
             unless %!containers{$in};
464 464
 
465  
-        Adventure::PlayerPut.new(:$thing, :$in);
  465
+        my @events;
  466
+
  467
+        if %!openable_things{$in} && !%!open_things{$in} {
  468
+            @events.push(Adventure::PlayerOpened.new(:thing($in)));
  469
+        }
  470
+
  471
+        @events.push(Adventure::PlayerPut.new(:$thing, :$in));
  472
+        @events;
466 473
     }
467 474
 
468 475
     method on_try_exit($room, $direction, &hook) {
@@ -1061,6 +1068,27 @@ multi MAIN('test') {
1061 1068
             };
1062 1069
     }
1063 1070
 
  1071
+    {
  1072
+        my $engine = Adventure::Engine.new();
  1073
+
  1074
+        $engine.place_thing('crate', 'street');
  1075
+        $engine.place_thing('doll', 'street');
  1076
+        $engine.make_thing_a_container('crate');
  1077
+        $engine.make_thing_openable('crate');
  1078
+        $engine.place_player('street');
  1079
+        is $engine.put_thing_in('doll', 'crate'),
  1080
+            [
  1081
+                Adventure::PlayerOpened.new(
  1082
+                    :thing<crate>,
  1083
+                ),
  1084
+                Adventure::PlayerPut.new(
  1085
+                    :thing<doll>,
  1086
+                    :in<crate>,
  1087
+                ),
  1088
+            ],
  1089
+            'putting a thing inside another (+) container was closed';
  1090
+    }
  1091
+
1064 1092
     done;
1065 1093
 }
1066 1094
 

0 notes on commit 38a7ce0

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