Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[bin/crypt] putting things in themselves

Not allowed.
  • Loading branch information...
commit 71900d3fe6283d37abdd63661840fcc8578bb9a0 1 parent 38a7ce0
Carl Mäsak authored
Showing with 29 additions and 0 deletions.
  1. +29 −0 bin/crypt
29 bin/crypt
View
@@ -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 {
my @possible_directions = <
north south east west
@@ -462,6 +470,9 @@ class Adventure::Engine {
die X::Adventure::CannotPutInNonContainer.new(:$in)
unless %!containers{$in};
+ die X::Adventure::YoDawg.new(:$in)
+ if $thing eq $in;
+
my @events;
if %!openable_things{$in} && !%!open_things{$in} {
@@ -1089,6 +1100,24 @@ multi MAIN('test') {
'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;
}
Please sign in to comment.
Something went wrong with that request. Please try again.