Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[bin/crypt] looking inside the car works

  • Loading branch information...
commit ae59ad95036c014d42b1539d0283eb1d18356b46 1 parent d570802
@masak authored
Showing with 27 additions and 5 deletions.
  1. +27 −5 bin/crypt
View
32 bin/crypt
@@ -464,16 +464,25 @@ class Adventure::Engine {
self!apply_and_return: @events;
}
+ method !contents_of($thing) {
+ return %!thing_rooms.grep({.value eq "contents:$thing"})>>.key;
+ }
+
method !explicit_things_at($location) {
- return unless $!player_location;
sub is_here_and_explicit($_) {
%!thing_rooms{$_} eq $location && !%!implicit_things{$_}
}
- return %!thing_rooms.keys.grep(&is_here_and_explicit);
- }
- method !contents_of($thing) {
- return %!thing_rooms.grep({.value eq "contents:$thing"})>>.key;
+ return unless $!player_location;
+ return gather for %!thing_rooms.keys -> $thing {
+ next unless is_here_and_explicit($thing);
+ if %!open_things{$thing} && self!contents_of($thing) {
+ take $thing => self!explicit_things_at("contents:$thing");
+ }
+ else {
+ take $thing;
+ }
+ }
}
method walk($direction) {
@@ -1705,6 +1714,19 @@ multi MAIN('test') {
'opening the car';
}
+ {
+ my $game = Crypt::Game.new();
+
+ $game.open('car');
+ is $game.look(),
+ Adventure::PlayerLooked.new(
+ :room<clearing>,
+ :exits<east>,
+ :things(car => <flashlight rope>),
+ ),
+ 'looking inside the car';
+ }
+
done;
}

0 comments on commit ae59ad9

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