Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[bin/crypt] can drop things

  • Loading branch information...
commit a0b45bb49c6dab13cbe1302c021950ba92f88277 1 parent f03f3ca
@masak authored
Showing with 23 additions and 0 deletions.
  1. +23 −0 bin/crypt
View
23 bin/crypt
@@ -311,6 +311,10 @@ class Adventure::ThingMadeCarryable does Event {
has $.thing;
}
+class Adventure::PlayerDropped does Event {
+ has $.thing;
+}
+
class X::Adventure is Exception {
}
@@ -652,6 +656,11 @@ class Adventure::Engine {
self!apply_and_return: @events;
}
+ method drop($thing) {
+ my @events = Adventure::PlayerDropped.new(:$thing);
+ self!apply_and_return: @events;
+ }
+
method on_try_exit($room, $direction, &hook) {
%!try_exit_hooks{$room}{$direction} = &hook;
}
@@ -1543,6 +1552,20 @@ multi MAIN('test') {
};
}
+ {
+ my $engine = Adventure::Engine.new();
+
+ $engine.place_thing('cup', 'porch');
+ $engine.make_thing_carryable('cup');
+ $engine.place_player('porch');
+ $engine.take('cup');
+ is $engine.drop('cup'),
+ Adventure::PlayerDropped.new(
+ :thing<cup>,
+ ),
+ 'dropping a thing (+)';
+ }
+
done;
}
Please sign in to comment.
Something went wrong with that request. Please try again.