Skip to content

Commit

Permalink
[bin/crypt] putting things in themselves
Browse files Browse the repository at this point in the history
Not allowed.
  • Loading branch information
Carl Masak committed Jul 12, 2012
1 parent 38a7ce0 commit 71900d3
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions bin/crypt
Expand Up @@ -331,6 +331,14 @@ class X::Adventure::CannotPutInNonContainer is X::Adventure {
} }
} }


class X::Adventure::YoDawg is X::Adventure {
has $.in;

method message {
"Yo dawg, I know you like a $.in so I put a $.in in your $.in"
}
}

class Adventure::Engine { class Adventure::Engine {
my @possible_directions = < my @possible_directions = <
north south east west north south east west
Expand Down Expand Up @@ -462,6 +470,9 @@ class Adventure::Engine {
die X::Adventure::CannotPutInNonContainer.new(:$in) die X::Adventure::CannotPutInNonContainer.new(:$in)
unless %!containers{$in}; unless %!containers{$in};


die X::Adventure::YoDawg.new(:$in)
if $thing eq $in;

my @events; my @events;


if %!openable_things{$in} && !%!open_things{$in} { if %!openable_things{$in} && !%!open_things{$in} {
Expand Down Expand Up @@ -1089,6 +1100,24 @@ multi MAIN('test') {
'putting a thing inside another (+) container was closed'; 'putting a thing inside another (+) container was closed';
} }


{
my $engine = Adventure::Engine.new();

$engine.place_thing('box', 'street');
$engine.make_thing_a_container('box');
$engine.place_player('street');
throws_exception
{ $engine.put_thing_in('box', 'box') },
X::Adventure::YoDawg,
'putting a thing inside another (-) but it is the same thing',
{
is .in, 'box', '.in attribute';
is .message,
"Yo dawg, I know you like a box so I put a box in your box",
'.message attribute';
};
}

done; done;
} }


Expand Down

0 comments on commit 71900d3

Please sign in to comment.