Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[bin/crypt] putting in closed container opens it

  • Loading branch information...
commit 38a7ce04933e14c6dfbc0a4a79970cd33d6865aa 1 parent 0161050
@masak authored
Showing with 29 additions and 1 deletion.
  1. +29 −1 bin/crypt
View
30 bin/crypt
@@ -462,7 +462,14 @@ class Adventure::Engine {
die X::Adventure::CannotPutInNonContainer.new(:$in)
unless %!containers{$in};
- Adventure::PlayerPut.new(:$thing, :$in);
+ my @events;
+
+ if %!openable_things{$in} && !%!open_things{$in} {
+ @events.push(Adventure::PlayerOpened.new(:thing($in)));
+ }
+
+ @events.push(Adventure::PlayerPut.new(:$thing, :$in));
+ @events;
}
method on_try_exit($room, $direction, &hook) {
@@ -1061,6 +1068,27 @@ multi MAIN('test') {
};
}
+ {
+ my $engine = Adventure::Engine.new();
+
+ $engine.place_thing('crate', 'street');
+ $engine.place_thing('doll', 'street');
+ $engine.make_thing_a_container('crate');
+ $engine.make_thing_openable('crate');
+ $engine.place_player('street');
+ is $engine.put_thing_in('doll', 'crate'),
+ [
+ Adventure::PlayerOpened.new(
+ :thing<crate>,
+ ),
+ Adventure::PlayerPut.new(
+ :thing<doll>,
+ :in<crate>,
+ ),
+ ],
+ 'putting a thing inside another (+) container was closed';
+ }
+
done;
}
Please sign in to comment.
Something went wrong with that request. Please try again.